I have a tree, with (at least) two branches Q2 and Q5, both Float_t, written on a file.
I need to correct theses branches this way:
mytree->Q2 = A*Q2+B
Is this possible, and how can I do this (without writing a new file)
Thanks in advance
I am not sure to understand what you want to do.
If you simply want to histogram Q2 multiplied by a coeeficient or
any other transformation, do
mytree.Draw(“Q2”); //to draw the original Q2
Please read the Users Guide and the tutorials relates to Trees.
Precisely, here’s my pseudo-code:
- read ascii file and fill a tree with different branches
- fit branch Q2 to find peak
- compute a correction coefficient A = f(peak)
- compute branch Q2’ = f(Q2, A)
- write my tree to a root file
But, as I have read somewhere else in the forum, it is impossible (or “not recommended at all”) to do something like Q2 = Q2*A
So, I need to find another way to do this, with as few steps as possible.
[quote]But, as I have read somewhere else in the forum, it is impossible (or “not recommended at all”) to do something like Q2 = Q2*A [/quote]It is possible but not recommended since the step to do so are not trivial.
[quote]So, I need to find another way to do this, with as few steps as possible. [/quote]Simply create a new tree, with just the branch Q2 and make this new tree a friend of the first tree (oldtree->AddFriend(…) ).
Alternatively, Clone the old tree and add a new branch (See $ROOTSYS/tutorials/copytree3.C)
yes, it is exactly what I did, and it works. Well, almost, as I explain in :
If you have any suggestion…