#ifndef ___HELPERS____ #define ___HELPERS____ #include "TString.h" #include "TList.h" #include "TIterator.h" #include #include #include #include using namespace std; class mapHolder { private: static map < TString , HOnlineMonHistAddon* >* currentMap; static mapHolder* holder; mapHolder() { holder = this; }; public: static mapHolder* getMapHolder(){ if(holder == 0) return new mapHolder; else return holder; } static void setMap(map < TString , HOnlineMonHistAddon* >& myMap){ currentMap = &myMap; } static map < TString , HOnlineMonHistAddon* >* getMap() { return currentMap; } static void resetHists(Int_t evtCt){ // do reset if needed for( map::iterator iter = currentMap->begin(); iter != currentMap->end(); ++iter ) { iter->second->reset(2,evtCt); // reset hists if needed (2 = if resetable and count%getRefreshRate() == 0) } } static void createHists(Int_t nHists,Text_t* hists[],TList& histpool){ map& mapL = *currentMap; HOnlineMonHistAddon* addon; // create hists and add them to the pool for(Int_t i=0; i < nHists; i++ ){ addon = new HOnlineMonHistAddon(hists[i]); if(addon->getActive() == 1){ HOnlineMonHistAddon* addon2 = addon->createHist(); if (!addon2) exit(2); histpool.Add(addon2); mapL[addon->GetName()] = (HOnlineMonHistAddon*) histpool.FindObject(addon->GetName()); delete addon; } else { mapL[addon->GetName()] = 0; } } } }; mapHolder* mapHolder::holder = 0; map < TString , HOnlineMonHistAddon* >* mapHolder::currentMap = 0; void printMap(map< TString, HOnlineMonHistAddon* >& mapL){ Int_t ct = 0; cout<<"------------------------------------------------------"<::iterator iter = mapL.begin(); iter != mapL.end(); ++iter ) { ct++; TString classname = "unused"; if((*iter).second ) classname = (*iter).second->ClassName(); cout <Next()) != 0) ) { cout<<" active " <getActive() <<" resetable "<getResetable() <<" refresh " <getRefreshRate() <<" name : " <GetName() <<" type : " <ClassName() <& mapL) // have to be called before map< TString, HOnlineMonHistAddon* >& mapL = *mapHolder::getMap(); map::iterator iter = mapL.find(name.Data()); if( iter != mapL.end() ) { return (*iter).second ;} else { printMap(mapL); cout<<"Error::get(), No matching histogram found for name = "<