#include "UserAlg.h" #include "RunStatisticsAlg.h" #include #include #include #include #include "TROOT.h" #include "TStyle.h" #include "TH1F.h" #include "TCanvas.h" using std::cout; using std::endl; using std::map; using std::vector; UserAlg::UserAlg(Event* event, Geometry* geo, Headers* runHeader):SystemAlg( event,geo,runHeader){ m_event = event; m_geo = geo; m_runHeader = runHeader; // create the new System Alg Objects m_occupancy = new OccupancyAlg(m_event, m_geo, m_runHeader); RunStatisticsAlg* m_runstatistics = new RunStatisticsAlg(m_event, m_geo, m_runHeader); vector algVector; algVector.push_back(m_occupancy); algVector.push_back(m_runstatistics); SystemAlg::setAlgs(algVector); } // initialize any variables here bool UserAlg::initialize(){ SystemAlg::initialize(); //do NOT remove this line // hec // needed in case the ntuple data is in ADC m_occupancy->hecCalibrationFileName("/afs/cern.ch/user/h/hectbmon/public/tb/aug02/dig/coeff_hec_aug02_020903.dat"); // enable the occupancy computation m_occupancy->hecEnable(); // use default noise file name // set print level m_occupancy->hecPrintLevel(1); // emec // needed in case the ntuple data is in ADC m_occupancy->emecCalibrationFileName("/afs/cern.ch/user/h/hectbmon/public/tb/aug02/dig/coeff_emec_high_aug02_020903.dat"); // enable the occupancy computation m_occupancy->emecEnable(); // use default noise file name // set print level m_occupancy->emecPrintLevel(1); return true; } // put any code you want executed per event here bool UserAlg::execute(){ SystemAlg::execute(); //do NOT remove this line return true; } //put any code here that you want executed after all the events have been processed. bool UserAlg::finalize(){ SystemAlg::finalize();//do NOT remove this line string cRun = "run "; std::ostringstream os; os << m_runHeader->global()->getRunNo(); cRun = cRun + os.str(); map hecOccMap = m_occupancy->hecOccupancyMap(); string hecHTitle = "hec " + cRun; TH1F* hecOccH = new TH1F("hecOccH", hecHTitle.c_str(), 200, 0., 1.); for (map::iterator it = hecOccMap.begin(); it != hecOccMap.end(); ++it) { hecOccH->Fill(it->second); } map emecOccMap = m_occupancy->emecOccupancyMap(); string emecHTitle = "emec " + cRun; TH1F* emecOccH = new TH1F("emecOccH", emecHTitle.c_str(), 200, 0., 1.); for (map::iterator it = emecOccMap.begin(); it != emecOccMap.end(); ++it) { emecOccH->Fill(it->second); } // draw gROOT->SetStyle("Plain"); gStyle->SetOptStat(1110); gStyle->SetStatW(0.25); // statistics box (% of pad width?) TCanvas* C = new TCanvas("C", "occupancy", 10, 10, 1000, 774); // letter proportions C->Divide(1, 2); C->cd(1); gPad->SetLogx(); hecOccH->GetXaxis()->SetTitle("occupancy"); hecOccH->Draw(); C->cd(2); gPad->SetLogx(); emecOccH->GetXaxis()->SetTitle("occupancy"); emecOccH->Draw(); C->Update(); // string t = "occupancy " + cRun; m_geo->draw2DHecDetail(m_occupancy->hecOccupancyMap(), 0, false, 0, 0, t); m_geo->draw2DEmecDetail(m_occupancy->emecOccupancyMap(), 0, false, 0, 0, t); return true; }