Hi Miro,
You should use TTree::MakeClass (or better MakeSelector) to generate a skeleton
code for your analysis.
In the Loop function (if using MakeClass), you are free to use directly
the class members directly in C++ with as many expressions as you like. In this
way you read the entries only once and for each entry you can
select what to read (via TBranch::SetBranchStatus) or calling TBranch::GetEntry
directly.
I suggest to have a look at $ROOTSYS/tutorials/h1analysis.C tutorial
with the corresponding explanations in the Users Guide.
Rene Brun
@mail.desy.de wrote:
>
> Hi all,
>
> I have the following problem:
>
> For the purpose of my analysis I have root trees with Branches containing
> many leafs (all are simple floats/integers).
>
> In order to get the cross-sections a number of (combinations of
> ) variables have to be extracted for different selections. These variables
> and cuts are passed to the class as character strings.
>
> e.g. I need to evaluate
>
> cos(Thetah), cos(mc_Thetah),(Q2+0.59)^2.2/(Q2+1.02)^0.2,
> goodevent&&BoxCut, Q2>2&&Q2<5&&t<1 etc...
>
> There is a way to get it
> tree->Draw("cos(Thetah):cos(mc_Thetah)",cut1)
> double* var1 = tree->GetV1() // contains cos(Thetah)
> double* var2 = tree->GetV2() // contains cos(mc_Thetah)
>
> However for more than 3 variables and few cuts one has to loop MANY times
> over the tree to get it. The I/O is the slowest operation and this is the
> main limit on the speed of my calculations. For this reason I would like
> to know if there is other way to do this
>
> if there would be a method like double TTree::Eval(const char*
> variable) or something more efficient so that one doesn't have to parse
> the string by every call.
>
> This would mean that after
> tree->GetEntry(10)
> var = tree->Eval("cos(Thetah)")
> the var would contain the value of cos(Thetah) for entry 10
>
> This way I could do all my calculation in one loop through the data.
>
> Well, there is a way to do it if the variable is just a simple Leaf but is
> there anything I could use to evaluate more complicated strings?
>
> I think it must be already implemented somehow since the TTree::Draw()
> uses it extensively but I couldn't find it anywhere and many people around
> would be interested in this feature.
>
> Best regards,
>
> Miro
>
> Version 3.05/05 5 June 2003 for linuxsuse6
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET