Re: [ROOT] Query's

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Nov 14 2002 - 18:45:31 MET


Hi Nuno,

I assume that you know that you can do directly:

for(Int_t i=0; i< nentries; i++){
   mytree->GetEvent(i);
   if(event->bx <180 && event->evt < 1000 &&event->ottmean<180){
     tree->Fill();
   }
}

If you want to do it "a la TTree::Draw", you can use the 
TTreeFormula class, eg

char* expression="event->bx <180 && event->evt < 1000
&&event->ottmean<180";
TTreeFormula *for = new TTreeFormula("for",expression,tree);

for(Int_t i=0; i< nentries; i++){
   mytree->GetEvent(i);
   if(for->EvalInstance(0) != 0) [
     tree->Fill();
   }
}

Rene Brun

On Thu, 14 Nov 2002, Nuno Almeida wrote:

> Hi all,
> 
> I have the following doubt:
> 
> How ROOT evaluate expression like "bx>100 && fNtracks <50" passed by
> argument to a function like TTree:Draw()?
> Because the expression is a char* .
> 
> I have the following situation:
> 
> char* expression="event->bx <180 && event->evt < 1000 &&event->ottmean<180";
> 
> for(Int_t i=0; i< nentries; i++){
>       mytree->GetEvent(i);
>       if(expression){
> 	tree->Fill();
>       }
>   }
> 
> ROOT has any function that allow me to do that ?
> 
> Best Regards
> 
> Nuno Almeida
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:17 MET