Hi Andre, There are currently two ways to loop over a Tree - via TTree::Draw - via code/class generated by TTree::MakeClass/MakeSelector The second option is more general as it allows you to: - loop on more than one Tree at the same time - fill more than one histogram - use complex selections It would look natural for your application to use the second form. However, I can also propose an alternative solution that implies writing a minimal piece of code, ie using Tree Friends. In your first pass, you compute one or several new variables (in your case only a new variable "final_discriminant"). You fill a new tree with this single variable, eg Tree named "Final" in file "Final.root" In a second pass, you can do: data_events->AddFriend("Final","Final.root"); data_events->Draw("mass","final_discriminant>0.9"); Note that in this case, the second pass may be in a different ROOT session. Also, you can add as many friends as you like. Rene Brun Andre Holzner wrote: > > Hello rooters, > > I have some TTree of events. For each event, I'd like to perform > a complex calculation (e.g. calculate the value of a pdf based > on a variable in the event or combine multiple pdf values). > > I currently have a method in this calculation class to which > I can give a TTree and it plots the distribution of this value > (possibly after some cuts). > > However, I would find it much more convenient, if I could > use such a calculation directly in TTree::Draw (as a value, > as a cut would also be useful !). > > I'm thinking of the following example: > > TTree *signal_events, *background_events, *data_events; > ... > > MyCalculation *calc = new MyCalculation; > calc->calculate_pdfs_from_mc(signal_events,background_events); > calc->SetName("final_discriminant"); > ... > data_events->Draw("final_discriminant"); > data_events->Draw("mass","final_discriminant>0.9"); > > So here's my question: Is it possible in root > to have a class (which e.g. inherits from TTreeFormula ??) > which can be registered in some dictionary and then can be > used in TTree::Draw in an expression ? > > thanks for the advice, > > André > > > > -- > ------------------+---------------------------------- > Andre Holzner | +41 22 76 76750 > Bureau 32 2-C13 | Building 32 > CERN | Office 2-C13 > CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:00 MET