//----------------------------------------------------------- // 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" // C/C++ Headers ---------------------- #include #include using std::string; // Class Member definitions ----------- ClassImp(DebugLogger) DebugLogger* DebugLogger::_instance=NULL; DebugLogger* DebugLogger::Instance() { if(_instance==0){ _instance = new DebugLogger(); } return _instance; } DebugLogger::DebugLogger() : TNamed() { if(_instance!=NULL)throw; _instance=this; _outfile=new TFile("log.root","RECREATE"); } DebugLogger::~DebugLogger() { std::cout<<"Destructing DebugLogger"<Close(); delete _outfile; } } // handling histos void DebugLogger::Histo(string name, double value, double x0, double x1, int bins){ if(_histomap[name]==NULL){ _histomap[name]=new TH1D(name.c_str(),name.c_str(),bins,x0,x1); } _histomap[name]->Fill(value); return; } void DebugLogger::WriteFiles(){ std::map::iterator it=_histomap.begin(); _outfile->cd(); while(it!=_histomap.end()){ std::cout<<"DebugLogger::Writing histogram "<first<second->Write(); delete it->second; ++it; } if(_outfile!=NULL){ _outfile->Close(); delete _outfile; } } // Streering the debug-stream void DebugLogger::addRule(abslogrule* rule){ dbgstrm.addrule(rule); //std::cout<<"number of rules="<