Hi Christian, On Fri, 17 Aug 2001 15:56:17 +0200 (CEST) Christian Doerr <cdoerr@physi.uni-heidelberg.de> wrote concerning "[ROOT] TCuts as argument": > Hello roottalk, > > I've taken a close look at the roottalk digest, but didn't really find a > solution to my problem. > Is there a way of passing a TCut expression as argument, for example > something like: > > void getSelection(TCut cut) > { > select events if "cut" is true > } You should use a const reference rather than a value class gradStudAna : public TObject { private: TFile* fFile; TTree* fTree; TEventList* fEvents; public: gradStudAna(const Char_t* fileName) { fFile = new TFile(fileName, "READ"); if (!fFile) { MakeZombie(); return; } fTree = (TTree*)fFile->Get("T"); if (!fTree) { MakeZombie(); return; } } void getSelection(const TCut& cut) { // Read the selection into a TEventList. See the Users guide. ... } void plotSelection(); ... }; > Certainly I could just use plain C++ syntax to get some selection, but my > aim is to create some environment for undergraduates to enable them to > do a simple physics analysis without any C++ knowledge, giving them some > easy to use tools for things like fitting, plotting etc... So it would be > nice if there was a way of passing cuts as an argument to a function so > that the students can define their own cuts without having to implement > root macros. I guess something like Root> gradStudAna myAna("course1.root"); Root> TCut myCut("pt > 5 && pid == 411"); Root> myAna.getSelection(myCut); Root> myAna.plotSelection(); is what you want. Hope this helps. Yours, Christian Holm Christensen ------------------------------------------- Address: Sankt Hansgade 23, 1. th. Phone: (+45) 35 35 96 91 DK-2200 Copenhagen N Cell: (+45) 28 82 16 23 Denmark Office: (+45) 353 25 305 Email: cholm@nbi.dk Web: www.nbi.dk/~cholm
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:58 MET