/////////////////////////////////////////////////////////////////////////////// // Feb 2002 P.Murat: split source and include files /////////////////////////////////////////////////////////////////////////////// #include "TH1.h" #include "TProfile.h" #include "TSQLResult.h" #include "TObjArray.h" #include "TCanvas.h" #include "TString.h" #include #include "Stntuple/base/TUsedSet.hh" #include "Stntuple/base/TTriggerConditions.hh" #include "Stntuple/base/TBeamConditions.hh" #include "TCdfOracle.hh" #include "Stntuple/obj/TStnRunSummary.hh" #include "Stntuple/obj/TStnTrigger.hh" #include "Stntuple/obj/TStnTriggerTable.hh" TH1F* h_dtmin[2] = {0,0}; TProfile* h_uprate = 0; TProfile* h_rate = 0; TProfile* h_upcr = 0; TProfile* h_cr = 0; //_____________________________________________________________________________ void TCdfOracle::PlotTriggerRate(const char* TriggerName, Int_t Level, Int_t Run1, Int_t Run2, Int_t Mode) { TObjArray* list_of_runs = new TObjArray(100); TObjArray* trig_cond = new TObjArray(100); TObjArray* beam_cond = new TObjArray(100); int tc_ft, bc_ft, dt, dt_min; TBeamConditions *bc, *best_bc; TTriggerConditions *tc; // process default values if (Run2 == -1) Run2 = Run1; GetListOfGoodRuns(list_of_runs,Run1,Run2); int nr = list_of_runs->GetEntriesFast(); int last_bc, first_found, nbins; float t0, x, lum, lum0, uprate, rate, upcr, cr; float last_uprate, last_rate, last_upcr, last_cr; //----------------------------------------------------------------------------- // book the histograms //----------------------------------------------------------------------------- if (h_dtmin[0]) { delete h_dtmin[0]; delete h_dtmin[1]; delete h_uprate; delete h_rate; delete h_upcr; delete h_cr; } h_dtmin[0] = new TH1F(Form("%s_dtmin_0_%i",TriggerName,Run1), "dtmin 0" ,400,-1000,1000); h_dtmin[1] = new TH1F(Form("%s_dtmin_1_%i",TriggerName,Run1), "dtmin 1" ,400,-1000,1000); if (Mode == 1) nbins = (Run2-Run1+1)*10; else if (Mode == 2) nbins = Run2-Run1+1; h_uprate = new TProfile(Form("%s_uprate_%i" ,TriggerName,Run1), Form("%s: Unprescaled rate",TriggerName), nbins,Run1,Run2+1,0,1e5); h_rate = new TProfile(Form("%s_rate_%i" ,TriggerName,Run1), Form("%s: rate" ,TriggerName), nbins,Run1,Run2+1,0,1e5); h_upcr = new TProfile(Form("%s_upcr_%i" ,TriggerName,Run1), Form("%s: Unprescaled cross section",TriggerName), nbins,Run1,Run2+1,0,1e5); h_cr = new TProfile(Form("%s_cr_%i", TriggerName,Run1), Form("%s: cross section",TriggerName), nbins,Run1,Run2+1,0,1e5); //----------------------------------------------------------------------------- // loop over the runs and fill the histograms //----------------------------------------------------------------------------- for (int ir=0; irAt(ir); int run = rs->RunNumber(); GetTriggerConditions(TriggerName,Level,trig_cond,run,run); GetBeamConditions (beam_cond,run,run); //----------------------------------------------------------------------------- // for each trigger rate measurement go to the beam conditions list to // extract the closest value of instantaneous luminosity //----------------------------------------------------------------------------- int nbc = beam_cond->GetEntriesFast(); int ntc = trig_cond->GetEntriesFast(); last_bc = 0; first_found = 0; for (int itc=0; itcAt(itc); tc_ft = tc->FrontendTime(); // loop over the beam conditions and // figure the right beam measurement dt_min = 10000000; best_bc = NULL; for (int ibc=last_bc; ibcAt(ibc); bc_ft = bc->FrontendTime(); dt = tc_ft-bc_ft; if (TMath::Abs(dt) < TMath::Abs(dt_min)) { best_bc = bc; dt_min = dt; } } // time to do histogramming h_dtmin[0]->Fill(dt_min); // calculate trigger rates if (TMath::Abs(dt_min) < 60) { //----------------------------------------------------------------------------- // right match found //----------------------------------------------------------------------------- h_dtmin[1]->Fill(dt_min); if (best_bc) lum = best_bc->B0IntegratedLiveLumi(); else printf(" run: %7i : best_bc = NULL\n",run); // luminosity is integrated from // the beginning of the store if (! first_found) { first_found = 1; lum0 = lum; t0 = tc_ft; } float atime = tc_ft-t0; rate = -1.; uprate = -1.; if (atime) { uprate = tc->Unprescaled()/atime; rate = tc->Prescaled ()/atime; last_uprate = uprate; last_rate = rate; } upcr = -1; cr = -1; if (lum-lum0 > 0.01) { upcr = tc->Unprescaled()/(lum-lum0); cr = tc->Prescaled ()/(lum-lum0); last_upcr = upcr; last_cr = cr; } // if (rate < 0) { // printf(" run, tc->Prescaled(), lum: %10i %10i , %10.3f \n", // run,tc->Prescaled(),lum); // } x = tc->RunNumber()+itc/(ntc+0.); if (Mode == 1) { if (rate > 0) { h_uprate->Fill(x,uprate); h_rate->Fill (x,rate); } if (lum > lum0) { h_upcr->Fill(x,upcr); h_cr->Fill(x,cr); } } } } if (Mode == 2) { // one histogram entry per run h_uprate->Fill(run,last_uprate); h_rate->Fill (run,last_rate); h_upcr->Fill (run,last_upcr); h_cr->Fill (run,last_cr); } } //----------------------------------------------------------------------------- // plot the histograms //----------------------------------------------------------------------------- TCanvas* c = new TCanvas(Form("Runs_%6i-%6i.%s",Run1,Run2,TriggerName), Form("Runs %6i-%6i: %s",Run1,Run2,TriggerName), 0,0,600,800); c->Divide(2,3); c->cd(1); h_uprate->Draw(); c->cd(2); h_rate->Draw(); c->cd(3); h_upcr->Draw(); c->cd(4); h_cr->Draw(); c->cd(5); h_dtmin[0]->Draw(); h_dtmin[1]->Draw("same"); delete list_of_runs; trig_cond->Delete(); delete trig_cond; beam_cond->Delete(); delete beam_cond; }