//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class DebugLogger // see DebugLogger.hh for details // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Sebastian Neubert TUM (original author) // // //----------------------------------------------------------- // Panda Headers ---------------------- // This Class' Header ------------------ #include "DebugLogger.h" // Collaborating Class Headers -------- #include "dbgstream.h" #include "TH1D.h" #include "TH2D.h" // C/C++ Headers ---------------------- #include #include #include using std::string; // Class Member definitions ----------- ClassImp(DebugLogger) DebugLogger* DebugLogger::finstance=NULL; DebugLogger* DebugLogger::Instance() { if(finstance==0){ finstance = new DebugLogger(); } return finstance; } DebugLogger::DebugLogger() : TNamed() { if(finstance!=NULL)throw; finstance=this; foutfile=new TFile("log.root","RECREATE"); } DebugLogger::~DebugLogger() { std::cerr<<"Destructing DebugLogger"<Close(); delete foutfile; } } // handling histos void DebugLogger::Histo(string name, double value, double x0, double x1, int bins){ if(fhistomap[name]==NULL){ fhistomap[name]=new TH1D(name.c_str(),name.c_str(),bins,x0,x1); } fhistomap[name]->Fill(value); return; } void DebugLogger::Histo2D(string name, double xvalue, double yvalue, double xmin, double xmax, int xbins, double ymin, double ymax, int ybins){ if(fhistomap2D[name]==NULL){ fhistomap2D[name]=new TH2D(name.c_str(),name.c_str(),xbins,xmin,xmax, ybins,ymin,ymax); } fhistomap2D[name]->Fill(xvalue,yvalue); return; } void DebugLogger::WriteFiles(){ foutfile->cd(); std::map::iterator it=fhistomap.begin(); while(it!=fhistomap.end()){ std::cout<<"DebugLogger::Writing histogram "<first<second!=NULL){ it->second->Write(); delete it->second; it->second=NULL; } ++it; } std::map::iterator it2=fhistomap2D.begin(); while(it2!=fhistomap2D.end()){ std::cout<<"DebugLogger::Writing histogram "<first<second!=NULL){ it2->second->Write(); delete it2->second; it2->second=NULL; } ++it2; } if(foutfile!=NULL){ foutfile->Close(); delete foutfile; } } // Streering the debug-stream void DebugLogger::addRule(abslogrule* rule){ dbgstrm.addrule(rule); //std::cout<<"number of rules="<