> Is it possible for you to write a example code for me since I am a > beginner of Root and C++ or tell me where I can find a similar example? For a good source of informations have a look at : - ROOT User's Guide on http://root.cern.ch/root/RootDoc.html see chapters : "Trees" -> "Using Trees in Analysis" -> ("More Complex Analysis using TTree::MakeClass" and "Anaylysis using Selectors") and "Example Analysis" - ROOT Tutorials on http://root.cern.ch/root/Tutorials.html see "Example of analysis class for the H1 data" The User's Guide contains also an "Introduction", "Getting Started", "A Little C++" and "CINT the C++ Interpreter" chapters (see also "The Tutorials and Tests" chapter). If, in the "More Complex Analysis using TTree::MakeClass" chapter, you replace 'T->MakeClass("MyClass")' by (an older way) 'T->MakeCode("MyCode.C")' you will get a file MyCode.C. Another good example can be built using ROOT Tutorials. Just go to the $ROOTSYS/tutorials (or copy them into your private area) and do the following : > root > root [0] .x hsimple.C > root [1] .q This should build an example "ntuple" in a file "hsimple.root". Then do : > root > root [0] TFile *f = new TFile("hsimple.root"); > root [1] f->ls() > root [2] ntuple->MakeSelector("ntupleSelector") (you will get ntupleSelector.h and ntupleSelector.C) > root [3] ntuple->MakeClass("ntupleClass") (you will get ntupleClass.h and ntupleClass.C) > root [4] ntuple->MakeCode("ntupleCode.C") (you will get ntupleCode.C) > root [5] .q Then have a look into all these files. For your convenience I attached these files that I just generated using root version 3.00/06 (with some modifications - I added a small printf in all of them and I had to edit the ntupleCode.C and change the local variable "i" in the event loop, which name was generated by the MakeCode, into "j", as one of the "ntuple" variables is also called "i"). Let's take the ntupleCode.C, for example, In the event loop after "ntuple->GetEntry(j)" in variables "px", "py", "pz", "random" and "i" you simply get values for the current ntuple entry ("j"). A similar situation exists in ntupleClass.C and ntupleSelector.C files. Just try : > root > root [0] .x ntupleCode.C > root [1] .q or : > root > root [0] .L ntupleClass.C > root [1] ntupleClass t > root [2] t.Loop() > root [3] .q or : > root > root [0] TFile *f = new TFile("hsimple.root") > root [1] TTree *n = (TTree*)gDirectory->Get("ntuple") > root [2] n.Process("ntupleSelector.C") > root [3] .q Hope this helps, Jacek.
This archive was generated by hypermail 2b29 : Fri Jun 08 2001 - 11:51:22 MEST