Previous      Directory 

Folder: GENERAL From: enagy@mard05.in2p3.fr Subject: How to use ROOT in the D0 framework Date: 06-SEP-2001 01:57 Expires: 21-SEP-2001 01:57
This note contains the basics to include ROOT routines ===================== into C++ and in particular into the D0 framework. ====================== All informations cited here come from Philippe Canal: pcanal@fnal.gov 630-840-2545 A realization can be found in my class chprt_reco in the pmcs_chprt package. I would like to share with you what I have learned from Philippe, hoping it will spare considerable time for you. Elemer Nagy 1. Compilation: =============== in the classname.hpp file add: ------------- // include ROOT header files #include "TFile.h" #include "TROOT.h" #include "TH3.h" last line before ending class ClassDef(name::classname, 1) where name is the namespace in which the headerfile is imbedded in the classname.cpp file add: ------------- namespace name{ ClassImp(name::classname) } in the most general case if namespace name is used (this replaces using namespace name) In addition in the same directory where classname.cpp can be found add a file classname_linkdef.h ------------------- which contains in the most general case the following lines (when namespace name1, name2, ... are used): #include "pkg_name/classname.hpp" #ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ namespace name1; #pragma link C++ namespace name2; #pragma link C++ class name1::classname; #endif 2. Link: ======== In the pkgname/LIBDEPS on has to include all library packages which is used by ROOT. An example (containing presumably many superfluous packages) can be found in pmcs_chprt/LIBDEPS. Most probably the minimum needed are: HepTuple CLHEP z cern root stdhep 3. ROOT Files ============= Opening ROOT input-output files should be done using HepRootFileManager. It provides means to open any number of files this way independently of the order. Initialization of the ROOT system will be done only once. In the classname.hpp file a forward declaration: class HepRootFileManager; and in the classname.cpp file: #include "HepTuple/HepRootFileManager.h" HepRootFileManager::initialiseRoot(); HepRootFileManager *_hepMgr; _hepMgr = new HepRootFileManager(FileName); TFile *file = _hepMgr->file(); Having done this *file can be used in a usual way to retrieve histograms on it. E.g.: TH3F *my3dh = (TH3F*)file->Get("ValAccept"); Note that Filename has to be std character string.

[ Active News || Post a New Message || Search || Archived News || Help ]

[ Choose Folders || List Unseen News ]