CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DQM/TrigXMonitor/src/L1TScalersSCAL.cc

Go to the documentation of this file.
00001 // Class:      L1TScalersSCAL
00002 // user include files
00003 
00004 #include <sstream>
00005 #include <vector>
00006 
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009 
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 
00013 #include "DataFormats/Scalers/interface/Level1TriggerScalers.h"
00014 #include "DataFormats/Scalers/interface/Level1TriggerRates.h"
00015 #include "DataFormats/Scalers/interface/LumiScalers.h"
00016 #include "DataFormats/Scalers/interface/L1AcceptBunchCrossing.h"
00017 #include "DataFormats/Scalers/interface/ScalersRaw.h"
00018 #include "DataFormats/Scalers/interface/TimeSpec.h"
00019 
00020 #include "DQM/TrigXMonitor/interface/L1TScalersSCAL.h"
00021 #include "DataFormats/Common/interface/Handle.h"
00022 #include "DQMServices/Core/interface/DQMStore.h"
00023 
00024 
00025 const double SECS_PER_LUMI = 23.31040958083832;
00026 
00027 
00028 using namespace edm;
00029 using namespace std;
00030 
00031 
00032 L1TScalersSCAL::L1TScalersSCAL(const edm::ParameterSet& ps):
00033   dbe_(0),
00034   scalersSource_( ps.getParameter< edm::InputTag >("scalersResults")),
00035   verbose_(ps.getUntrackedParameter <bool> ("verbose", false)),
00036   denomIsTech_(ps.getUntrackedParameter <bool> ("denomIsTech", true)),
00037   denomBit_(ps.getUntrackedParameter <unsigned int> ("denomBit", 40)),
00038   muonBit_(ps.getUntrackedParameter <unsigned int> ("muonBit", 55)),
00039   egammaBit_(ps.getUntrackedParameter <unsigned int> ("egammaBit", 46)),
00040   jetBit_(ps.getUntrackedParameter <unsigned int> ("jetBit", 15))
00041 {
00042   LogDebug("Status") << "constructor" ;
00043 
00044   for ( int i=0; i<Level1TriggerScalers::nLevel1Triggers; i++) 
00045     { bufferAlgoRates_.push_back(0); algorithmRates_.push_back(0); integral_algo_.push_back(0.);}
00046   for ( int i=0; i<Level1TriggerScalers::nLevel1TestTriggers; i++) 
00047     { bufferTechRates_.push_back(0); technicalRates_.push_back(0); integral_tech_.push_back(0.);}
00048 
00049   buffertime_ = 0;
00050   reftime_ = 0;
00051   nev_ = 0;
00052   integral_tech_42_OR_43_ = 0;
00053   bufferLumi_ = 0;
00054 
00055   int maxNbins = 2001;
00056 
00057   dbe_ = Service<DQMStore>().operator->();
00058   if(dbe_) {
00059     dbe_->setVerbose(0);
00060         
00061     dbe_->setCurrentFolder("L1T/L1TScalersSCAL/Level1TriggerScalers");
00062         
00063     //orbitNum = dbe_->book1D("Orbit_Number","Orbit_Number", 1000,0,10E8);
00064     orbitNum = dbe_->book1D("Orbit_Number","Orbit_Number", maxNbins,-0.5,double(maxNbins)-0.5);
00065 
00066     trigNum = dbe_->book1D("Number_of_Triggers","Number_of_Triggers",1000,0,4E4);
00067     trigNum->setAxisTitle("Time [sec]", 1);
00068 
00069     //eventNum = dbe_->book1D("Number_of_Events","Number_of_Events", 1000,0,1E7);
00070     eventNum = dbe_->book1D("Number_of_Events","Number_of_Events", maxNbins,-0.5,double(maxNbins)-0.5);
00071 
00072     physTrig = dbe_->book1D("Physics_Triggers","Physics_Triggers", maxNbins,-0.5,double(maxNbins)-0.5);
00073     physTrig->setAxisTitle("Lumi Section", 1);
00074 
00075     randTrig = dbe_->book1D("Random_Triggers","Random_Triggers", maxNbins,-0.5,double(maxNbins)-0.5);
00076     randTrig->setAxisTitle("Lumi Section", 1);
00077 
00078     //numberResets = dbe_->book1D("Number_Resets","Number_Resets", 1000,0,1000);
00079     numberResets = dbe_->book1D("Number_Resets","Number_Resets", maxNbins,-0.5,double(maxNbins)-0.5);
00080    
00081     //deadTime = dbe_->book1D("DeadTime","DeadTime", 1000,0,1E9);
00082     deadTime = dbe_->book1D("DeadTime","DeadTime", maxNbins,-0.5,double(maxNbins)-0.5);
00083     
00084     //lostFinalTriggers = dbe_->book1D("Lost_Final_Trigger","Lost_Final_Trigger", 1000,0,1E6);
00085     lostFinalTriggers = dbe_->book1D("Lost_Final_Trigger","Lost_Final_Trigger", maxNbins,-0.5,double(maxNbins)-0.5);
00086    
00087     dbe_->setCurrentFolder("L1T/L1TScalersSCAL/Level1TriggerRates");
00088 
00089     physRate = dbe_->book1D("Physics_Trigger_Rate","Physics_Trigger_Rate", 
00090                             maxNbins,-0.5,double(maxNbins)-0.5);
00091     //physRate->setAxisTitle("Lumi Section", 1);
00092 
00093     randRate = dbe_->book1D("Random_Trigger_Rate","Random_Trigger_Rate", 
00094                             maxNbins,-0.5,double(maxNbins)-0.5);
00095     //randRate->setAxisTitle("Lumi Section", 1);
00096 
00097     deadTimePercent = dbe_->book1D("Deadtime_Percent","Deadtime_Percent", 
00098                                    maxNbins,-0.5,double(maxNbins)-0.5);
00099     //deadTimePercent->setAxisTitle("Lumi Section", 1);
00100 
00101     lostPhysRate = dbe_->book1D("Lost_Physics_Trigger_Rate","Lost_Physics_Trigger_Rate", 
00102                                 maxNbins,-0.5,double(maxNbins)-0.5);
00103     //lostPhysRate->setAxisTitle("Lumi Section", 1);
00104 
00105     lostPhysRateBeamActive = dbe_->book1D("Lost_Physics_Trigger_Rate_Beam_Active",
00106                                           "Lost_Physics_Trigger_Rate_Beam_Active", 
00107                                           maxNbins,-0.5,double(maxNbins)-0.5);
00108     //lostPhysRateBeamActive->setAxisTitle("Lumi Section", 1);
00109 
00110     
00111     instTrigRate = dbe_->book1D("instTrigRate","instTrigRate",1000,0,4E4);
00112     instTrigRate->setAxisTitle("Time [sec]", 1);
00113 
00114     instEventRate = dbe_->book1D("instEventRate","instEventRate",1000,0,4E4);
00115     instEventRate->setAxisTitle("Time [sec]", 1);
00116 
00117     char hname[40];//histo name
00118     char mename[40];//ME name
00119 
00120     dbe_->setCurrentFolder("L1T/L1TScalersSCAL/Level1TriggerRates/AlgorithmRates");
00121 
00122     for(int i=0; i<Level1TriggerScalers::nLevel1Triggers; i++) {
00123       sprintf(hname, "Rate_AlgoBit_%03d", i);
00124       sprintf(mename, "Rate_AlgoBit _%03d", i);
00125 
00126       algoRate[i] = dbe_->book1D(hname, mename,maxNbins,-0.5,double(maxNbins)-0.5);
00127       algoRate[i]->setAxisTitle("Lumi Section" ,1);
00128     }    
00129                                      
00130     dbe_->setCurrentFolder("L1T/L1TScalersSCAL/Level1TriggerRates/AlgorithmRates/Integrated");
00131 
00132     for(int i=0; i<Level1TriggerScalers::nLevel1Triggers; i++) {
00133       sprintf(hname, "Integral_AlgoBit_%03d", i);
00134       sprintf(mename, "Integral_AlgoBit _%03d", i);
00135 
00136       integralAlgo[i] = dbe_->book1D(hname, mename,maxNbins,-0.5,double(maxNbins)-0.5);
00137       integralAlgo[i]->setAxisTitle("Lumi Section" ,1);
00138     }                                        
00139 
00140     dbe_->setCurrentFolder("L1T/L1TScalersSCAL/Level1TriggerRates/TechnicalRates");
00141 
00142     for(int i=0; i<Level1TriggerScalers::nLevel1TestTriggers; i++) {
00143       sprintf(hname, "Rate_TechBit_%03d", i);
00144       sprintf(mename, "Rate_TechBit _%03d", i);
00145 
00146       techRate[i] = dbe_->book1D(hname, mename,maxNbins,-0.5,double(maxNbins)-0.5);
00147       techRate[i]->setAxisTitle("Lumi Section" ,1);
00148     }
00149 
00150     dbe_->setCurrentFolder("L1T/L1TScalersSCAL/Level1TriggerRates/TechnicalRates/Integrated");
00151 
00152     for(int i=0; i<Level1TriggerScalers::nLevel1TestTriggers; i++) {
00153       sprintf(hname, "Integral_TechBit_%03d", i);
00154       sprintf(mename, "Integral_TechBit _%03d", i);
00155 
00156       integralTech[i] = dbe_->book1D(hname, mename,maxNbins,-0.5,double(maxNbins)-0.5);
00157       integralTech[i]->setAxisTitle("Lumi Section" ,1);
00158     }                                        
00159     integralTech_42_OR_43 = dbe_->book1D("Integral_TechBit_042_OR_043","Integral_TechBit _042_OR_043",maxNbins,-0.5,double(maxNbins)-0.5);
00160     integralTech_42_OR_43->setAxisTitle("Lumi Section" ,1);
00161 
00162 
00163     dbe_->setCurrentFolder("L1T/L1TScalersSCAL/Level1TriggerRates/Ratios");
00164 
00165     std::stringstream smu,seg,sjet,sdenom;
00166     //denominator string
00167     if(denomIsTech_) sdenom << "_TechBit_";
00168     else sdenom << "_AlgoBit_";
00169     sdenom << denomBit_;
00170     //Muon ratio
00171     smu << muonBit_;
00172     rateRatio_mu = dbe_->book1D("Rate_Ratio_mu_PhysBit_"+ smu.str()+sdenom.str(), "Rate_Ratio_mu_PhysBit_" + smu.str()+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00173     //rateRatio_mu->setAxisTitle("Lumi Section" , 1);
00174     //Egamma ratio
00175     seg << egammaBit_;
00176     rateRatio_egamma = dbe_->book1D("Rate_Ratio_egamma_PhysBit_"+ seg.str()+sdenom.str(), "Rate_Ratio_egamma_PhysBit_" + seg.str()+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00177     //rateRatio_egamma->setAxisTitle("Lumi Section" , 1);
00178     //Jet ratio
00179     sjet << jetBit_;
00180     rateRatio_jet = dbe_->book1D("Rate_Ratio_jet_PhysBit_" + sjet.str()+sdenom.str(), "Rate_Ratio_jet_PhysBit_" + sjet.str()+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00181     //rateRatio_jet->setAxisTitle("Lumi Section" , 1);
00182 
00183     //HF bit ratios
00184     techRateRatio_8 = dbe_->book1D("Rate_Ratio_TechBit_8"+sdenom.str(), "Rate_Ratio_TechBit_8"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00185     //techRateRatio_8->setAxisTitle("Lumi Section" ,1);
00186     techRateRatio_9 = dbe_->book1D("Rate_Ratio_TechBit_9"+sdenom.str(), "Rate_Ratio_TechBit_9"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00187     //techRateRatio_9->setAxisTitle("Lumi Section" ,1);
00188     techRateRatio_10 = dbe_->book1D("Rate_Ratio_TechBit_10"+sdenom.str(), "Rate_Ratio_TechBit_10"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00189     //techRateRatio_10->setAxisTitle("Lumi Section" ,1);
00190 
00191     //Other tech bit ratios
00192     techRateRatio_33_over_32 = dbe_->book1D("Rate_Ratio_TechBits_33_over_32", "Rate_Ratio_TechBits_33_over_32",maxNbins,-0.5,double(maxNbins)-0.5);
00193     techRateRatio_36 = dbe_->book1D("Rate_Ratio_TechBit_36"+sdenom.str(), "Rate_Ratio_TechBit_36"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00194     techRateRatio_37 = dbe_->book1D("Rate_Ratio_TechBit_37"+sdenom.str(), "Rate_Ratio_TechBit_37"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00195     techRateRatio_38 = dbe_->book1D("Rate_Ratio_TechBit_38"+sdenom.str(), "Rate_Ratio_TechBit_38"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00196     techRateRatio_39 = dbe_->book1D("Rate_Ratio_TechBit_39"+sdenom.str(), "Rate_Ratio_TechBit_39"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00197     techRateRatio_40 = dbe_->book1D("Rate_Ratio_TechBit_40"+sdenom.str(), "Rate_Ratio_TechBit_40"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00198     techRateRatio_41 = dbe_->book1D("Rate_Ratio_TechBit_41"+sdenom.str(), "Rate_Ratio_TechBit_41"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00199     techRateRatio_42 = dbe_->book1D("Rate_Ratio_TechBit_42"+sdenom.str(), "Rate_Ratio_TechBit_42"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00200     techRateRatio_43 = dbe_->book1D("Rate_Ratio_TechBit_43"+sdenom.str(), "Rate_Ratio_TechBit_43"+sdenom.str(),maxNbins,-0.5,double(maxNbins)-0.5);
00201 
00202                                 
00203     dbe_->setCurrentFolder("L1T/L1TScalersSCAL/LumiScalers");
00204     //instLumi = dbe_->book1D("Instant Lumi","Instant Lumi",100,0,100);
00205     instLumi = dbe_->book1D("Instant_Lumi","Instant_Lumi", maxNbins,-0.5,double(maxNbins)-0.5);
00206     //instLumiErr = dbe_->book1D("Instant Lumi Err","Instant Lumi Err",100,
00207     //                         0,100);
00208     instLumiErr = dbe_->book1D("Instant_Lumi_Err","Instant_Lumi_Err",maxNbins,-0.5,double(maxNbins)-0.5);
00209     //instLumiQlty = dbe_->book1D("Instant Lumi Qlty","Instant Lumi Qlty",100,
00210     //                          0,100);
00211     instLumiQlty = dbe_->book1D("Instant_Lumi_Qlty","Instant_Lumi_Qlty",maxNbins,-0.5,double(maxNbins)-0.5);
00212     //instEtLumi = dbe_->book1D("Instant Et Lumi","Instant Et Lumi",100,0,100);
00213     instEtLumi = dbe_->book1D("Instant_Et_Lumi","Instant_Et_Lumi",maxNbins,-0.5,double(maxNbins)-0.5);
00214     //instEtLumiErr = dbe_->book1D("Instant Et Lumi Err","Instant Et Lumi Err",
00215     //                           100,0,100);
00216     instEtLumiErr = dbe_->book1D("Instant_Et_Lumi_Err","Instant_Et_Lumi_Err",maxNbins,-0.5,double(maxNbins)-0.5);
00217     //instEtLumiQlty = dbe_->book1D("Instant Et Lumi Qlty",
00218     //                            "Instant Et Lumi Qlty",100,0,100);
00219     instEtLumiQlty = dbe_->book1D("Instant_Et_Lumi_Qlty",
00220                                   "Instant_Et_Lumi_Qlty",maxNbins,-0.5,double(maxNbins)-0.5);
00221     //sectionNum = dbe_->book1D("Section Number","Section Number",100,0,100);
00222     //startOrbit = dbe_->book1D("Start Orbit","Start Orbit",100,0,100);
00223     startOrbit = dbe_->book1D("Start_Orbit","Start_Orbit", maxNbins,-0.5,double(maxNbins)-0.5);
00224     //numOrbits = dbe_->book1D("Num Orbits","Num Orbits",100,0,100);
00225     numOrbits = dbe_->book1D("Num_Orbits","Num_Orbits", maxNbins,-0.5,double(maxNbins)-0.5);
00226         
00227     
00228     dbe_->setCurrentFolder("L1T/L1TScalersSCAL/L1AcceptBunchCrossing");
00229        
00230     for(int i=0; i<4; i++){
00231 
00232       sprintf(hname, "OrbitNumber_L1A_%d", i+1);
00233       sprintf(mename, "OrbitNumber_L1A_%d", i+1);
00234       orbitNumL1A[i] = dbe_->book1D(hname,mename,200,0,10E8);          
00235 
00236       sprintf(hname, "Bunch_Crossing_L1A_%d", i+1);
00237       sprintf(mename, "Bunch_Crossing_L1A_%d", i+1);
00238       bunchCrossingL1A[i]= dbe_->book1D(hname, mename, 3564, -0.5, 3563.5);
00239     }
00240     orbitNumL1A[0]->setAxisTitle("Current BX",1);
00241     orbitNumL1A[1]->setAxisTitle("Previous BX",1);
00242     orbitNumL1A[2]->setAxisTitle("Second Previous BX",1);
00243     orbitNumL1A[3]->setAxisTitle("Third Previous BX",1);
00244 
00245     bunchCrossingL1A[0]->setAxisTitle("Current BX",1);
00246     bunchCrossingL1A[1]->setAxisTitle("Previous BX",1);
00247     bunchCrossingL1A[2]->setAxisTitle("Second Previous BX",1);
00248     bunchCrossingL1A[3]->setAxisTitle("Third Previous BX",1);
00249 
00250 
00251     for(int j=0; j<3; j++) {
00252       sprintf(hname, "BX_Correlation_%d", j+1);
00253       sprintf(mename, "BX_Correlation_%d", j+1);
00254 
00255       bunchCrossingCorr[j] = dbe_->book2D(hname, mename, 99,-0.5,3563.5, 99,-0.5,3563.5);
00256       bunchCrossingCorr[j]->setAxisTitle("Current Event", 1);
00257 
00258       sprintf(hname, "Bunch_Crossing_Diff_%d", j+1);
00259       sprintf(mename, "Bunch_Crossing_Diff_%d", j+1);
00260       
00261       bunchCrossingDiff[j] = dbe_->book1D(hname, mename, 1000,0,1E6);
00262 
00263       sprintf(hname, "Bunch_Crossing_Diff_small_%d", j+1);
00264       sprintf(mename, "Bunch_Crossing_Diff_small_%d", j+1);
00265       
00266       bunchCrossingDiff_small[j] = dbe_->book1D(hname, mename, 1000,0,1000);
00267 
00268     }                                        
00269     bunchCrossingCorr[0]->setAxisTitle("Previous Event" , 2);
00270     bunchCrossingCorr[1]->setAxisTitle("Second Previous Event" , 2);
00271     bunchCrossingCorr[2]->setAxisTitle("Third Previous Event" , 2);
00272 
00273     bunchCrossingDiff[0]->setAxisTitle("BX_Current - BX_Previous" , 1);
00274     bunchCrossingDiff[1]->setAxisTitle("BX_Current - BX_SecondPrevious" , 1);
00275     bunchCrossingDiff[2]->setAxisTitle("BX_Current - BX_ThirdPrevious" , 1);
00276 
00277     bunchCrossingDiff_small[0]->setAxisTitle("BX_Current - BX_Previous" , 1);
00278     bunchCrossingDiff_small[1]->setAxisTitle("BX_Current - BX_SecondPrevious" , 1);
00279     bunchCrossingDiff_small[2]->setAxisTitle("BX_Current - BX_ThirdPrevious" , 1);
00280 
00281   }    
00282 
00283 }
00284 
00285 
00286 L1TScalersSCAL::~L1TScalersSCAL()
00287 {
00288    // do anything here that needs to be done at destruction time
00289    // (e.g. close files, deallocate resources etc.)
00290 }
00291 
00292 
00293 //
00294 // member functions
00295 //
00296 
00297 // ------------ method called to for each event  ------------
00298 void
00299 L1TScalersSCAL::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00300 {
00301   nev_++;
00302 
00303   //access SCAL info
00304   edm::Handle<Level1TriggerScalersCollection> triggerScalers;
00305   bool a = iEvent.getByLabel(scalersSource_, triggerScalers);
00306   //edm::Handle<L1TriggerRatesCollection> triggerRates;
00307   //edm::Handle<Level1TriggerRatesCollection> triggerRates;
00308   //bool b = iEvent.getByLabel(scalersSource_, triggerRates);
00309   edm::Handle<LumiScalersCollection> lumiScalers;
00310   bool c = iEvent.getByLabel(scalersSource_, lumiScalers);
00311   edm::Handle<L1AcceptBunchCrossingCollection> bunchCrossings;
00312   bool d = iEvent.getByLabel(scalersSource_, bunchCrossings);
00313   
00314   double evtLumi = iEvent.luminosityBlock();
00315   int run = iEvent.id().run();
00316 
00317 
00318   if ( ! (a && c && d) ) {
00319     LogInfo("Status") << "getByLabel failed with label " 
00320                       << scalersSource_;
00321   }
00322                                 
00323   else { // we have the data 
00324     
00325     Level1TriggerScalersCollection::const_iterator it = triggerScalers->begin();
00326     if(triggerScalers->size()){ 
00327 
00328       //for(L1TriggerScalersCollection::const_iterator it = triggerScalers->begin();
00329       //it != triggerScalers->end();
00330       //++it){
00331        
00332       unsigned int lumisection = it->lumiSegmentNr();
00333       struct timespec thetime = it->collectionTime();
00334       long currenttime;
00335       //cout << "lumisection = " << lumisection << endl;
00336       if(nev_ == 1) reftime_ = thetime.tv_sec; 
00337       //cout << "reftime = " << reftime_ << endl;
00338       if(lumisection){
00339 
00340         //orbitNum->Fill(it->orbitNr());
00341         orbitNum->setBinContent(lumisection+1,it->orbitNr());
00342 
00343         //trigNum ->Fill(it->gtTriggers());
00344         //trigNum->setBinContent(lumisection+1, it->gtTriggers()); 
00345 
00346         //eventNum->Fill(it->gtEvents());
00347         eventNum->setBinContent(lumisection+1,it->gtEvents());
00348 
00349         //physTrig ->Fill(it->l1AsPhysics());
00350         physTrig->setBinContent(lumisection+1, it->l1AsPhysics()); 
00351 
00352         //randTrig ->Fill(it->l1AsRandom());
00353         randTrig->setBinContent(lumisection+1, it->l1AsRandom()); 
00354 
00355         //numberResets ->Fill(it->gtResets());   
00356         numberResets->setBinContent(lumisection+1, it->gtResets());      
00357 
00358         //deadTime ->Fill(it->deadtime());
00359         deadTime->setBinContent(lumisection+1, it->deadtime());
00360 
00361         //lostFinalTriggers ->Fill(it->triggersPhysicsLost());                       
00362         lostFinalTriggers->setBinContent(lumisection+1, it->triggersPhysicsLost());
00363          
00364         //cout << "lumisection = " << lumisection << " , orbitNum = " 
00365         //     << it->orbitNr() << ", lumiSegmentOrbits = " << it->lumiSegmentOrbits() 
00366         //     << ", l1AsPhys = " << it->l1AsPhysics() << endl;
00367         //cout << "gtTriggersRate = " << it->gtTriggersRate() << endl;
00368 
00369         if(buffertime_ < thetime.tv_sec){
00370           buffertime_ = thetime.tv_sec;
00371           currenttime = thetime.tv_sec - reftime_ ;
00372           int timebin = (int)(currenttime/30) + 1;
00373           //cout << "time bin = " << timebin << endl;
00374           trigNum->setBinContent((int)timebin ,it->gtTriggers());
00375           instTrigRate->setBinContent((int)timebin ,it->gtTriggersRate());
00376           instEventRate->setBinContent((int)timebin ,it->gtEventsRate());
00377         }
00378         
00379         //cout << "tv_sec = " << thetime.tv_sec << endl;
00380 
00381         //std::vector<unsigned int> algoBits = it->gtAlgoCounts();
00382         //std::vector<unsigned int> techBits = it->gtTechCounts();
00383         /*         
00384                    int length = algoBits.size() / 4;
00385                    char line[128];
00386                    for ( int i=0; i<length; i++)
00387                    {
00388                    sprintf(line," %3.3d: %10u    %3.3d: %10u    %3.3d: %10u    %3.3d: %10u",
00389                    i,              algoBits[i], 
00390                    (i+length),     algoBits[i+length], 
00391                    (i+(length*2)), algoBits[i+(length*2)], 
00392                    (i+(length*3)), algoBits[i+(length*3)]);
00393                    std::cout << line << std::endl;
00394                    }
00395         */
00396         //sprintf(line,
00397         //        " LuminositySection: %15d  BunchCrossingErrors:      %15d",
00398         //        it->luminositySection(), it->bunchCrossingErrors());
00399         //std::cout << line << std::endl;
00400          
00401         //Level1TriggerRatesCollection::const_iterator it2 = triggerRates->begin();
00402 
00403         Level1TriggerRates trigRates(*it,run);
00404         Level1TriggerRates *triggerRates = &trigRates;
00405         if(triggerRates){
00406           algorithmRates_ = triggerRates->gtAlgoCountsRate();
00407           technicalRates_ = triggerRates->gtTechCountsRate();
00408           
00409           if( ((bufferLumi_!=lumisection) && (bufferLumi_<lumisection) && (evtLumi>1 || evtLumi==lumisection+1)) ){
00410             bufferLumi_ = lumisection;
00411  
00412             if(bufferAlgoRates_ != algorithmRates_){ 
00413               bufferAlgoRates_ = algorithmRates_;
00414               for (unsigned int i=0; i< algorithmRates_.size(); i++){ 
00415                 integral_algo_[i]+=(algorithmRates_[i]*SECS_PER_LUMI);
00416                 algoRate[i]->setBinContent(lumisection+1, algorithmRates_[i]); 
00417                 integralAlgo[i]->setBinContent(lumisection+1,integral_algo_[i]); 
00418               }            
00419             }
00420             if(bufferTechRates_ != technicalRates_){ 
00421               bufferTechRates_ = technicalRates_;
00422               for (unsigned int i=0; i< technicalRates_.size(); i++){ 
00423                 integral_tech_[i]+=(technicalRates_[i]*SECS_PER_LUMI);
00424                 techRate[i]->setBinContent(lumisection+1, technicalRates_[i]); 
00425                 integralTech[i]->setBinContent(lumisection+1, integral_tech_[i]); 
00426                 if( (i==42 || i==43) ) integral_tech_42_OR_43_+=(technicalRates_[i]*SECS_PER_LUMI);
00427               } 
00428 
00429               //fill rate ratio plots
00430               if(denomIsTech_){
00431                 if( denomBit_ < technicalRates_.size() ){
00432                   if(technicalRates_[denomBit_]){
00433 
00434                     if( muonBit_ < algorithmRates_.size() )
00435                       rateRatio_mu->setBinContent(lumisection+1, algorithmRates_[muonBit_]/technicalRates_[denomBit_]);
00436                     if( egammaBit_ < algorithmRates_.size() )
00437                       rateRatio_egamma->setBinContent(lumisection+1, algorithmRates_[egammaBit_]/technicalRates_[denomBit_]);
00438                     if( jetBit_ < algorithmRates_.size() )
00439                       rateRatio_jet->setBinContent(lumisection+1, algorithmRates_[jetBit_]/technicalRates_[denomBit_]);
00440 
00441                     techRateRatio_8->setBinContent(lumisection+1, technicalRates_[8]/technicalRates_[denomBit_]);
00442                     techRateRatio_9->setBinContent(lumisection+1, technicalRates_[9]/technicalRates_[denomBit_]);
00443                     techRateRatio_10->setBinContent(lumisection+1, technicalRates_[10]/technicalRates_[denomBit_]);
00444 
00445                     techRateRatio_36->setBinContent(lumisection+1, technicalRates_[36]/technicalRates_[denomBit_]);
00446                     techRateRatio_37->setBinContent(lumisection+1, technicalRates_[37]/technicalRates_[denomBit_]);
00447                     techRateRatio_38->setBinContent(lumisection+1, technicalRates_[38]/technicalRates_[denomBit_]);
00448                     techRateRatio_39->setBinContent(lumisection+1, technicalRates_[39]/technicalRates_[denomBit_]);
00449                     techRateRatio_40->setBinContent(lumisection+1, technicalRates_[40]/technicalRates_[denomBit_]);
00450                     techRateRatio_41->setBinContent(lumisection+1, technicalRates_[41]/technicalRates_[denomBit_]);
00451                     techRateRatio_42->setBinContent(lumisection+1, technicalRates_[42]/technicalRates_[denomBit_]);
00452                     techRateRatio_43->setBinContent(lumisection+1, technicalRates_[43]/technicalRates_[denomBit_]);
00453                   }
00454                 }
00455               }
00456               if( technicalRates_[32]!=0 ) techRateRatio_33_over_32->setBinContent(lumisection+1, technicalRates_[33]/technicalRates_[32]);
00457               integralTech_42_OR_43->setBinContent(lumisection+1, integral_tech_42_OR_43_);        
00458 
00459             }
00460 
00461             physRate->setBinContent(lumisection+1, 
00462                                     triggerRates->l1AsPhysicsRate()); 
00463             randRate->setBinContent(lumisection+1, 
00464                                     triggerRates->l1AsRandomRate());
00465             lostPhysRate->setBinContent(lumisection+1, 
00466                                         triggerRates->triggersPhysicsLostRate()); 
00467             lostPhysRateBeamActive->setBinContent(lumisection+1, 
00468                                                   triggerRates->triggersPhysicsLostBeamActiveRate()); 
00469             deadTimePercent->setBinContent(lumisection+1, 
00470                                            triggerRates->deadtimePercent()); 
00471            
00472           }//bufferLumi test
00473         }//triggerRates  
00474       }//lumisection
00475     }//triggerScalers->size()
00476 
00477      
00478     LumiScalersCollection::const_iterator it3 = lumiScalers->begin();
00479     if(lumiScalers->size()){ 
00480     
00481       //for(LumiScalersCollection::const_iterator it3 = lumiScalers->begin();
00482       //it3 != lumiScalers->end();
00483       //++it3){
00484       unsigned int lumisection = it3->sectionNumber();
00485       if(lumisection){
00486        
00487         instLumi->setBinContent(lumisection+1, it3->instantLumi());
00488         instLumiErr->setBinContent(lumisection+1, it3->instantLumiErr()); 
00489         instLumiQlty->setBinContent(lumisection+1, it3->instantLumiQlty()); 
00490         instEtLumi->setBinContent(lumisection+1, it3->instantETLumi()); 
00491         instEtLumiErr->setBinContent(lumisection+1, it3->instantETLumiErr()); 
00492         instEtLumiQlty->setBinContent(lumisection+1, it3->instantETLumiQlty()); 
00493         //sectionNum->Fill(it3->sectionNumber()); 
00494         startOrbit->setBinContent(lumisection+1, it3->startOrbit()); 
00495         numOrbits->setBinContent(lumisection+1, it3->numOrbits()); 
00496 
00497       }       
00498       /*
00499         char line2[128];
00500         sprintf(line2," InstantLumi:       %e  Err: %e  Qlty: %d",
00501         it3->instantLumi(), it3->instantLumiErr(), it3->instantLumiQlty());
00502         std::cout << line2 << std::endl;
00503 
00504         sprintf(line2," SectionNumber: %10d   StartOrbit: %10d  NumOrbits: %10d",
00505         it3->sectionNumber(), it3->startOrbit(), it3->numOrbits());
00506         std::cout << line2 << std::endl;
00507       */
00508     }
00509 
00510     //     L1AcceptBunchCrossingCollection::const_iterator it4 = bunchCrossings->begin();
00511     //if(bunchCrossings->size()){
00512     //int counttest=0;
00513     int l1accept; 
00514     unsigned int bx_current = 0, orbitnumber_current = 0, bxdiff = 0;
00515 
00516     for(L1AcceptBunchCrossingCollection::const_iterator it4 = bunchCrossings->begin();
00517         it4 != bunchCrossings->end();
00518         ++it4){
00519       //counttest++;
00520       //cout << "counttest = " << counttest << endl;
00521       //cout << "bunchCrossing = "  << it4->bunchCrossing() << endl;
00522       //cout << "l1AcceptOffset = " << it4->l1AcceptOffset() << endl;
00523 
00524       l1accept = std::abs(it4->l1AcceptOffset());   
00525 
00526       //cout << "l1a orbit number (before if)= " << it4->orbitNumber() << endl;
00527       //cout << "l1a bunch crossing = " << it4->bunchCrossing() << endl;
00528 
00529       if(l1accept == 0){
00530         orbitnumber_current = it4->orbitNumber();
00531         orbitNumL1A[l1accept]->Fill(orbitnumber_current);
00532 
00533         bx_current = it4->bunchCrossing();
00534         bunchCrossingL1A[l1accept]->Fill(bx_current);
00535 
00536       }
00537       else if (l1accept==1 || l1accept==2 || l1accept==3){
00538         orbitNumL1A[l1accept]->Fill(it4->orbitNumber());
00539         bunchCrossingL1A[l1accept]->Fill(it4->bunchCrossing());
00540         //cout << "l1accept = " << l1accept << ", bx_current = " << bx_current << ", it4->bunchCrossing() = " << it4->bunchCrossing() << endl;
00541         bunchCrossingCorr[l1accept-1]->Fill(bx_current, it4->bunchCrossing());
00542         bxdiff = 3564*(orbitnumber_current-it4->orbitNumber()) + bx_current - it4->bunchCrossing();
00543         bunchCrossingDiff[l1accept-1]->Fill(bxdiff);
00544         bunchCrossingDiff_small[l1accept-1]->Fill(bxdiff);
00545       }
00546 
00547     }
00548    
00549   } // getByLabel succeeds for scalers
00550        
00551 
00552 
00553 }
00554 
00555 
00556 // ------------ method called once each job just before starting event loop  ------------
00557 void 
00558 L1TScalersSCAL::beginJob(void)
00559 {
00560 
00561 }
00562 
00563 // ------------ method called once each job just after ending the event loop  ------------
00564 void 
00565 L1TScalersSCAL::endJob() {
00566 }
00567 
00568 
00569 void L1TScalersSCAL::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00570                                    const edm::EventSetup& iSetup)
00571 {                                   
00572 }                   
00574 void L1TScalersSCAL::beginRun(const edm::Run& run, const edm::EventSetup& iSetup)
00575 {
00576 }
00577                                     
00579 void L1TScalersSCAL::endRun(const edm::Run& run, const edm::EventSetup& iSetup)
00580 {
00581 }
00582