Re: 2 Tree Questions

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon May 17 1999 - 16:52:37 MEST


Hi Olivier,
In the following, I assume that you are selecting a small subsample
of your original tree and that your tree contains many branches.
I have modified your code below to
  - read only the branches required to perform your selection.
  - for events passing the 4 selection criteria read the full event

You could optimize this logic further by calling branch->getEvent
only when it is really required.

from your code, I have the feeling that you are filling possibly many
times your sub_tree for a given input event !

Concerning the error;

  Warning in <TBranch::GetBasket>: Estimated keylen too small=14465

It is likely that you have created the sub_tree in the same file
(may be read only) than the original_tree. I need the full listing
to understand this problem. Do you get this error when you read
the sub_tree in a separate session?

Rene Brun


        b=original_tree->GetBranch("EventBranch"); //b is a TBranch
        evt= new Event(); //my event class
        b->SetAddress(&evt);
        if(sub_tree!=0) delete sub_tree;
        sub_tree=original_tree->CloneTree(0);
//        Int_t kTime,kAmplitude,kPileUp,kChannel; //flags for selection
        TBranch *bTime      = original_tree->GetBranch("Time");
        TBranch *bAmplitude = original_tree->GetBranch("Amplitude");
        TBranch *bPileUp    = original_tree->GetBranch("PileUp");
        TBranch *bChannel   = original_tree->GetBranch("Channel");
        Int_t i;
        for(i=0;i < o_nentries ; i++)  { 
            bChannel->GetEvent(i);
            bAmplitude->GetEvent(i);
            bPileUp->GetEvent(i);
            bTime->GetEvent(i);

           if (event_is_rejected) continue;  //your set of tests
           original_tree->GetEvent(i);
           sub_tree->Fill();      
        }


Olivier Meplan wrote:
> 
> Hi rooters!
> 
> I have 2 questions about trees (certainly very stupid...)
> 
> 1) I have a tree with a single branch; the number of entries is of the
> order of 50 000 000. I want to make a sub tree of that tree with some
> conditions; for that I use the following code
> 
>         b=original_tree->GetBranch("EventBranch"); //b is a TBranch
>         evt= new Event(); //my event class
>         b->SetAddress(&evt);
>         if(sub_tree!=0) delete sub_tree;
>         sub_tree=original_tree->CloneTree(0);
>         Int_t kTime,kAmplitude,kPileUp,kChannel; //flags for selection
>         Int_t i;
>         for(i=0;i < o_nentries ; i++) //o_entries=
>                                       //original_tree->GetEvent()
>         {
>                 b->GetEvent(i);
>                 kChannel=0; //evt_sel contains my selections
>                 for (Int_t k=0;k<evt_sel->GetNChannel();k++)
>                 {
>                         if(evt->GetChannel()==evt_sel->GetChannel(k))                                   kChannel=1;
>                         if(evt_sel->Tmax>evt_sel->Tmin)
>                                 kTime=(evt->GetTime()>=evt_sel->Tmin &&
> evt->GetTime()<=evt_sel->Tmax);
>                         else kTime=1;
>                         if(evt_sel->Amax>evt_sel->Amin)
>                                 kAmplitude=(evt->GetAmplitude()>=
>                                 evt_sel->Amin &&
>                                 evt->GetAmplitude()<=evt_sel->Amax);
>                         else kAmplitude=1;
>                         if(evt_sel->PileUpBit!=2)
>                                 kPileUp=(evt->GetPileUpBit()==
>                                         evt_sel->PileUpBit);
>                         else kPileUp=1;
>                         if(kTime && kAmplitude && kPileUp  && kChannel)
> sub_tree->Fill();
>                 }
>         }
>         sub_tree->SetName("Sub_E");
> 
> With that code it took a very long time to make the sub tree!
> (Up o 5 min); What can I do to increased the speed?
> 
> 2) question 2.
> 
> In my interface I have 3 tree pointers: one for the original_tree, one
> for the sub_tree and one named cuurent_tree wich take the value of
> original_tree or of the sub_tree depending of the user choice.
> There is no pb when I try to draw a given selection of the original_tree
> but when I do the same thing for the sub_tree I have the following error
> message:
> 
> Warning in <TBranch::GetBasket>: Estimated keylen too small=14465
> Fatal in <operator new>: storage exhausted
> 
> which of course I don't understand...
> Thanks for your help
> Olivier Meplan



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:33 MET