_HADES_CLASS_DESCRIPTION HLoop is a helper class to allow for fast looping of HADES dsts. The categories are maped directly from the Tree and allow partical reading to speed up. If Hades object exists, the current event structure will be replaced by the one defined by HLoop. If Hades not exists, it can be created by HLoop constructor. The Hades eventstructure is important if one wants to access the data via gHades->getCurrentEvent()->getCategory(cattype) or implicit by Classes like HParticleTrackSorter. See the example below for further explanation. HEventHeader* getEventHeader() // retrieve the pointer to the HADES HEventHeader TTree* getTree () // retrieve the pointer to the HADES tree TChain* getChain () // retrieve TChain pointer Long64_t getEntries () // get Number of events in the chain example: #include "hloop.h" #include "hcategory.h" #include "hzip.h" #include "heventheader.h" #include "hgeantmedia.h" #include "hparticlecand.h" #include "hparticletracksorter.h" #include "TIterator.h" #include <iostream> using namespace std; void myLoop() { //---------------LOOP CONFIG---------------------------------------------------------------- Bool_t createHades = kTRUE; // kTRUE = create HADES new HLoop* loop = new HLoop(createHades); // create HADES (needed if one wants to use gHades) loop.setTreeCacheSize(8000000);//8MB (default is 8MB, values <= 0 will disable the cache) //-------------------------------------------------------------------------------------------- loop->readSectorFileList("selection.list",kFALSE,kTRUE); // hldname_without_evtbuilder 1 1 1 1 1 1 // a map of all files to active sector is filled // see functions HLoop::getSectors(Int_t*), Bool_t HLoop::goodSector(Int_t sector),HSectorSelector& getSectorSelector() // for file format description see HSectorSelector // parmeters: default value for files not inside the list (kTRUE all sectors on, kFALSE all sectors off) // print the filelist during read // If no list is read, all sectors are on by default // reading the files list is optional // lines which uses the feature are marked ##SECTOR_SELECTION## in the following example //-------------------------------------------------------------------------------------------- // add files : Input sources may be combined loop->addFile ("myFile1.root"); loop->addFile ("myFile2.root"); // .... loop->addFilesList("list.txt"); // add all files in ascii file list. list contains 1 root file per line (including path) loop->addFiles("myFiles*.root"); // add all files matching this expression loop->addMultFiles("file1.root,file2.root,file3.root"); add files as comma separated list HZip::makeChain("all_files.zip",loop->getChain()); // add all root files contained in zip file (this file has to be produced by hzip) if(!loop->setInput("-*,+HParticleCand")) // global disable "-*" has to be first in the list { // read only one category from file (HEventHeader is allways on) exit(1); } loop->printCategories(); // print status from all categories in event //------------------------------------------------------------------------------------------ TIterator* iterCand = 0; if (loop->getCategory("HParticleCand")) iterCand = loop->getCategory("HParticleCand")->MakeIterator(); HEventHeader* header = loop->getEventHeader(); HGeantMedia* media = loop->getGeantMedia(); if(media){ // NULL for real data or if not in sim input media->print(); } //--------------------------CONFIGURATION--------------------------------------------------- //At begin of the program (outside the event loop) HParticleTrackSorter sorter; //sorter.setDebug(); // for debug //sorter.setPrintLevel(3); // max prints //sorter.setRICHMatching(HParticleTrackSorter::kUseRKRICHWindow,4.); // select matching RICH-MDC for selectLeptons() function //sorter.setUseYMatching(kTRUE); // use meta cell build in select functions //sorter.setMetaBoundary(3.); // match in 3 mm to meta cell //sorter.setUseBeta(kTRUE); // require beta >0 in build in select functions //sorter.setBetaLeptonCut(0.9); // lower beta cut for lepton select //sorter.setUseFakeRejection(kTRUE); // reject fakes in build in select functions (default kTRUE) //sorter.setIgnoreInnerMDC(); // do not reject Double_t inner MDC hits //sorter.setIgnoreOuterMDC(); // do not reject Double_t outer MDC hits //sorter.setIgnoreMETA(); // do not reject Double_t META hits //sorter.setIgnorePreviousIndex(); // do not reject indices from previous selctions sorter.init(); // get catgegory pointers etc... //-------------------------------------------------------------------------------------------- Int_t nFile = 0; //-------------------------------------------------------------------------------------------- ##SECTOR_SELECTION## Int_t sectors[6]; // array of active sector (1 active, 0 off) will be retrive inside loop for each event //-------------------------------------------------------------------------------------------- for (Int_t i = 0; i < 10; i++) { if(loop->nextEvent(i) <= 0) break; // get next event. categories will be cleared before // if 0 (entry not found) or -1 (Io error) is returned stop the loop //-------------------------------------------------------------------------------------------- ##SECTOR_SELECTION## loop->getSectors(sectors); // get active sectors for current event (somethime arrays are useful) //-------------------------------------------------------------------------------------------- cout<<i<<"----------------------------------- "<<endl; cout<<"sequence Nr = "<<header->getEventSeqNumber()<<endl; // retrieve full header infos TString filename; if(loop->isNewFile(filename)){ // new file opened from chain ? cout<<"new File found "<<filename.Data()<<endl; nFile++; } sorter.cleanUp(); sorter.resetFlags(kTRUE,kTRUE,kTRUE,kTRUE); // reset all flags for flags (0-28) ,reject,used,lepton Int_t nCandLep = sorter.fill(HParticleTrackSorter::selectLeptons); // fill only good leptons Int_t nCandLepBest = sorter.selectBest(HParticleTrackSorter::kIsBestRKRKMETA,HParticleTrackSorter::kIsLepton); Int_t nCandHad = sorter.fill(HParticleTrackSorter::selectHadrons); // fill only good hadrons (already marked good leptons will be skipped) Int_t nCandHadBest = sorter.selectBest(HParticleTrackSorter::kIsBestRKRKMETA,HParticleTrackSorter::kIsHadron); if(iterCand){ iterCand->Reset(); HParticleCand* cand; while ( (cand = (HParticleCand*)iterCand->Next()) != 0 ){ // do some work .... //-------------------------------------------------------------------------------------------- ##SECTOR_SELECTION## if(!loop->goodSector(cand->getSector())) continue; // skipp all candidates from inactive sectors //-------------------------------------------------------------------------------------------- } } } sorter.finalize(); // clean up stuff if(createHades) delete gHades; // delete Hades or call destructor of HLoop. } A second example running a task with hloop. The task can use parameter containers if HSpectrometer and parameterio are specified. The task will be executed inside nextEvent() function. void hloopDst() { Bool_t createHades=kTRUE; HLoop* loop = new HLoop(createHades); // kTRUE : create Hades (needed to work with standard eventstructure) loop.setTreeCacheSize(8000000);//8MB (default is 8MB, values <= 0 will disable the cache) TString asciiParFile = "/misc/kempter/projects/plot_dedx/param_31oct11.txt"; TString rootParFile = ""; Int_t mdcMods[6][4]={ {0,0,0,0}, {0,0,0,0}, {1,1,1,1}, {0,0,0,0}, {1,1,1,1}, {1,1,1,1} }; HDst::setupSpectrometer ("aug11_3sec",mdcMods,"rich,mdc,tof,rpc,shower,wall,tbox,start"); HDst::setupParameterSources("ascii,oracle",asciiParFile,rootParFile,"now"); loop->addFile("be1122719211201.hld_dst_aug11.root"); if(!loop->setInput("")) { exit(1); } // read all categories HEventHeader* header = loop->getEventHeader(); HGeantMedia* media = loop->getGeantMedia(); // NULL if not in input file () if(media){ // NULL if not in input file media->print(); } loop->printCategories(); loop->printChain(); HTaskSet *masterTaskSet = gHades->getTaskSet("real"); masterTaskSet->add(new HMdcPlotDeDx()); // some task derived from HReconstructor HCategory* catCand = HCategoryManager::getCategory(catParticleCand); if(!catCand) { exit(1); } Int_t entries=loop->getEntries(); for (Int_t i=0; i < entries; i++) { Int_t nbytes = loop->nextEvent(i); // get next event. categories will be cleared before if(nbytes <= 0) { cout<<nbytes<<endl; break; } // last event reached if(catCand){ HParticleCand* cand=0; for(Int_t j=0; j<catCand->getEntries();j++){ cand = HCategoryManager::getObject(cand,catCand,j); // do something .... } // end loop cand } //catCand }// end event loop if(gHades)gHades->finalizeTasks(); if(createHades) delete gHades; // delete Hades or call destructor of HLoop. }
HLoop(Bool_t createHades = kFALSE) | |
HLoop(const HLoop&) | |
virtual | ~HLoop() |
void | TObject::AbstractMethod(const char* method) const |
Bool_t | addFile(TString infile) |
Bool_t | addFiles(TString expression) |
Bool_t | addFilesList(TString filelist) |
Bool_t | addMultFiles(TString commaSeparatedList) |
virtual void | TObject::AppendPad(Option_t* option = "") |
virtual void | TObject::Browse(TBrowser* b) |
static TClass* | Class() |
virtual const char* | TObject::ClassName() const |
virtual void | TObject::Clear(Option_t* = "") |
void | clearCategories() |
virtual TObject* | TObject::Clone(const char* newname = "") const |
virtual Int_t | TObject::Compare(const TObject* obj) const |
virtual void | TObject::Copy(TObject& object) const |
virtual void | TObject::Delete(Option_t* option = "")MENU |
virtual Int_t | TObject::DistancetoPrimitive(Int_t px, Int_t py) |
virtual void | TObject::Draw(Option_t* option = "") |
virtual void | TObject::DrawClass() constMENU |
virtual TObject* | TObject::DrawClone(Option_t* option = "") constMENU |
virtual void | TObject::Dump() constMENU |
virtual void | TObject::Error(const char* method, const char* msgfmt) const |
virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
virtual void | TObject::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
virtual TObject* | TObject::FindObject(const char* name) const |
virtual TObject* | TObject::FindObject(const TObject* obj) const |
HCategory* | getCategory(TString catname, Bool_t silent = kFALSE) |
Bool_t | getCategoryStatus(TString catname, Bool_t silent = kFALSE) |
TChain* | getChain() |
virtual Option_t* | TObject::GetDrawOption() const |
static Long_t | TObject::GetDtorOnly() |
Long64_t | getEntries() |
HEventHeader* | getEventHeader() |
TObject* | getFromInputFile(TString name = "") |
HGeantHeader* | getGeantHeader(Bool_t silent = kFALSE) |
HGeantMedia* | getGeantMedia() |
virtual const char* | TObject::GetIconName() const |
virtual const char* | TObject::GetName() const |
virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
static Bool_t | TObject::GetObjectStat() |
virtual Option_t* | TObject::GetOption() const |
HPartialEvent* | getPartialEvent(TString catname, Bool_t silent = kFALSE) |
void | getSectors(Int_t* sectors) |
HSectorSelector& | getSectorSelector() |
virtual const char* | TObject::GetTitle() const |
TTree* | getTree() |
virtual UInt_t | TObject::GetUniqueID() const |
Bool_t | goodSector(Int_t sector) |
virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
virtual ULong_t | TObject::Hash() const |
virtual void | TObject::Info(const char* method, const char* msgfmt) const |
virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
virtual void | TObject::Inspect() constMENU |
void | TObject::InvertBit(UInt_t f) |
virtual TClass* | IsA() const |
virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
virtual Bool_t | TObject::IsFolder() const |
Bool_t | isNewFile(TString& name) |
Bool_t | TObject::IsOnHeap() const |
Bool_t | isSkippedEvent() |
virtual Bool_t | TObject::IsSortable() const |
Bool_t | TObject::IsZombie() const |
virtual void | TObject::ls(Option_t* option = "") const |
void | TObject::MayNotUse(const char* method) const |
Int_t | nextEvent(Int_t iev) |
virtual Bool_t | TObject::Notify() |
void | TObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const |
static void | TObject::operator delete(void* ptr) |
static void | TObject::operator delete(void* ptr, void* vp) |
static void | TObject::operator delete[](void* ptr) |
static void | TObject::operator delete[](void* ptr, void* vp) |
void* | TObject::operator new(size_t sz) |
void* | TObject::operator new(size_t sz, void* vp) |
void* | TObject::operator new[](size_t sz) |
void* | TObject::operator new[](size_t sz, void* vp) |
HLoop& | operator=(const HLoop&) |
virtual void | TObject::Paint(Option_t* option = "") |
virtual void | TObject::Pop() |
virtual void | TObject::Print(Option_t* option = "") const |
void | printBranchStatus() |
void | printCategories() |
void | printChain() |
virtual Int_t | TObject::Read(const char* name) |
Bool_t | readSectorFileList(TString filename, Bool_t defaultVal = kFALSE, Bool_t print = kFALSE) |
virtual void | TObject::RecursiveRemove(TObject* obj) |
void | TObject::ResetBit(UInt_t f) |
virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU |
virtual void | TObject::SavePrimitive(ostream& out, Option_t* option = "") |
void | TObject::SetBit(UInt_t f) |
void | TObject::SetBit(UInt_t f, Bool_t set) |
void | setCurrentLoop() |
virtual void | TObject::SetDrawOption(Option_t* option = "")MENU |
static void | TObject::SetDtorOnly(void* obj) |
Bool_t | setInput(TString readCategories = "") |
static void | TObject::SetObjectStat(Bool_t stat) |
void | setRefID(Int_t id) |
void | setTreeCacheSize(Long64_t cs = 8000000) |
virtual void | TObject::SetUniqueID(UInt_t uid) |
virtual void | ShowMembers(TMemberInspector&) |
virtual void | Streamer(TBuffer&) |
void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
Bool_t | TObject::TestBit(UInt_t f) const |
Int_t | TObject::TestBits(UInt_t f) const |
virtual void | TObject::UseCurrentStyle() |
virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
void | TObject::MakeZombie() |
enum TObject::EStatusBits { | kCanDelete | |
kMustCleanup | ||
kObjInCanvas | ||
kIsReferenced | ||
kHasUUID | ||
kCannotPick | ||
kNoContextMenu | ||
kInvalidObject | ||
}; | ||
enum TObject::[unnamed] { | kIsOnHeap | |
kNotDeleted | ||
kZombie | ||
kBitMask | ||
kSingleKey | ||
kOverwrite | ||
kWriteDelete | ||
}; |
TChain* | fChain | chain |
Long64_t | fCurrentEntry | current entry in chain |
TString | fCurrentName | current file name |
map<TString,HCategory*> | fEvent | map category name -> HCategory pointer |
TFile* | fFileCurrent | current file pointer |
Bool_t | fFirstEvent | true if first event called |
HGeantMedia* | fGeantMedia | pointer to HGEANT MEDIA (NULL if not avvailable!) |
Bool_t | fHasCreatedHades | remember if this class has created HADES |
HEventHeader* | fHead | pointer to HADES event header |
Bool_t | fIsCacheSet | kTRUE if user has set the the cache. |
Bool_t | fIsNewFile | == kTRUE for first entry after a new file is opened |
Bool_t | fIsSkipped | == kTRUE event was skipped by tasklist |
Long64_t | fMaxEntries | total number of entries in the chain |
map<TString,Short_t> | fNameToCat | map category name -> category number |
map<TString,HPartialEvent*> | fPartial | map partial event name -> HPartialEvent pointer |
map<TString,TString> | fPartialN | map category name -> partial event name |
HRecEvent* | fRecEvent | HADES event under reconstruction |
Int_t | fRefID | reference ID for init of params |
HSectorSelector | fSectorSelector | selection of sectors from filelist |
map<TString,Int_t> | fStatus | map category name -> status |
TTree* | fTree | current Tree of the chain |
Long64_t | fTreeCacheDefaultSize | default 8MB |
Long64_t | fTreeCacheSize | |
Bool_t | fUseTaskSet | == kTRUE if hades tasksets should be executed |
Int_t | fsectors[6] | array of sector status form filelist |
if createHades == kTRUE (default=kFALSE) Hades will be created and event structure set == kFALSE Hades will not be created, but if exists the event structure will be replaced by the one defined in HLoop if Hades does not exists and is not created new, the event structure will be available only via HLoop and not via gHades
Configure the read of the Root Tree: default is 8MB to minimize the seek/read on the file system values <= 0 will disable the cache (for comparison) THis function has to be called before setInput().
add a single root file to the chain. It will be checked if the file exists.
add all files in list filelist. The list should contain 1 root file per line (including path). empty lines and commented lines (starting with "#") will be ignored. Return kFALSE if list files does not exist or and error occured while reading the file
add multiple files as comma separated file list : "file1,file2,file3"
read in the given file structure. Categories can be disabled/enabled by the string readCategories. This string should contain a comma separated list. By default all categories are enabled. The format should be like (example 1) "-*,+HMdcCal1,+HParticleCand" (switch off all categories and enable just the to given ones. The global disable -* has to be the first in the list. Or (example 2) "-HMdcRaw,-HRichHit" (enable all categories, but not the give ones). For simulation or real data one has to use the correct corresponding names (expample : HParticleCandSim / HParticleCand)
return the pointer to given category. NULL if not found
return the status of a given category. kFALSE if not found
return the pointer to given partialevent. NULL if not found
return the pointer to HGeantHader (subheader of PartialEvent Simul). NULL if not found
set the status of a given category. return kFALSE if something went wrong. if catname="-*" or "+*" all categories of the event are disabled /enabled.
get next entry form tree. clears all active categories before. Returns number of read bytes (0 = entry not found , -1 = IO error) prints the current file name if a new file is entered in the chain
add agiven category number to the HADES event structure. this function has to be called after setInput() !!!!
returns an object from root input file return 0 if not existsing, file not opened or anything else strange.
{ fSectorSelector.setDefaultVal(defaultVal); return fSectorSelector.readInput(filename,print); }