CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/DQM/HLTEvF/plugins/TrigResRateMon.cc

Go to the documentation of this file.
00001 // $Id: TrigResRateMon.cc,v 1.26 2012/02/21 10:32:34 slaunwhj Exp $
00002 // See header file for information. 
00003 #include "TMath.h"
00004 #include "TString.h"
00005 #include "DQM/HLTEvF/interface/TrigResRateMon.h"
00006 #include "FWCore/Common/interface/TriggerNames.h"
00007 #include "DataFormats/Scalers/interface/LumiScalers.h"
00008 
00009 #include <map>
00010 #include <utility>
00011 
00012 
00013 using namespace edm;
00014 using namespace trigger;
00015 using namespace std;
00016 
00017 TrigResRateMon::TrigResRateMon(const edm::ParameterSet& iConfig): currentRun_(-99)
00018 {
00019 
00020   LogDebug("TrigResRateMon") << "constructor...." ;
00021 
00022   fIsSetup = false;
00023 
00024   dbe_ = Service < DQMStore > ().operator->();
00025   if ( ! dbe_ ) {
00026     LogInfo("TrigResRateMon") << "unabel to get DQMStore service?";
00027   }
00028   if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
00029     dbe_->setVerbose(0);
00030   }
00031   
00032   dirname_ = iConfig.getUntrackedParameter("dirname", std::string("HLT/TrigResults/"));
00033   //dirname_ +=  iConfig.getParameter<std::string>("@module_label");
00034   
00035   if (dbe_ != 0 ) {
00036     dbe_->setCurrentFolder(dirname_);
00037   }
00038 
00039   doCombineRuns_ = iConfig.getUntrackedParameter<bool>("doCombineRuns", false);
00040   doVBTFMuon_ = iConfig.getUntrackedParameter<bool>("doVBTFMuon", true);
00041   
00042   processname_ = iConfig.getParameter<std::string>("processname");
00043   fCustomBXPath = iConfig.getUntrackedParameter<std::string>("customBXPath", std::string("HLT_MinBiasBSC"));
00044 
00045   referenceBX_ = iConfig.getUntrackedParameter<unsigned int>("referenceBX",51);
00046   Nbx_ = iConfig.getUntrackedParameter<unsigned int>("Nbx",3564);
00047 
00048   // plotting paramters
00049   ptMin_ = iConfig.getUntrackedParameter<double>("ptMin",0.);
00050   ptMax_ = iConfig.getUntrackedParameter<double>("ptMax",1000.);
00051   nBins_ = iConfig.getUntrackedParameter<unsigned int>("Nbins",20);
00052   nBins2D_ = iConfig.getUntrackedParameter<unsigned int>("Nbins2D",40);
00053   dRMax_ = iConfig.getUntrackedParameter<double>("dRMax",1.0);
00054   dRMaxElectronMuon_ = iConfig.getUntrackedParameter<double>("dRMaxElectronMuon",0.3);
00055   nBinsDR_ = iConfig.getUntrackedParameter<unsigned int>("NbinsDR",10);
00056   nBinsOneOverEt_ = iConfig.getUntrackedParameter<unsigned int>("NbinsOneOverEt",10000);
00057   nLS_   = iConfig.getUntrackedParameter<unsigned int>("NLuminositySegments",10);
00058   LSsize_   = iConfig.getUntrackedParameter<double>("LuminositySegmentSize",23);
00059   thresholdFactor_ = iConfig.getUntrackedParameter<double>("thresholdFactor",1.0);
00060 
00061   
00062   plotAll_ = iConfig.getUntrackedParameter<bool>("plotAll", false);
00063      // this is the list of paths to look at.
00064   std::vector<edm::ParameterSet> paths = 
00065   iConfig.getParameter<std::vector<edm::ParameterSet> >("paths");
00066 
00067   for(std::vector<edm::ParameterSet>::iterator pathconf = paths.begin() ; pathconf != paths.end(); pathconf++) {
00068 
00069     custompathnamepairs_.push_back(
00070         make_pair(
00071           pathconf->getParameter<std::string>("pathname"),
00072           pathconf->getParameter<std::string>("denompathname")
00073         )
00074     );
00075 
00076   }
00077 
00078   if (hltPaths_.size() > 0)
00079   {
00080       // book a histogram of scalers
00081      scalersSelect = dbe_->book1D("selectedScalers","Selected Scalers", hltPaths_.size(), 0.0, (double)hltPaths_.size());
00082 
00083   }
00084 
00085   triggerSummaryLabel_ = iConfig.getParameter<edm::InputTag>("triggerSummaryLabel");
00086   triggerResultsLabel_ = iConfig.getParameter<edm::InputTag>("triggerResultsLabel");
00087 
00088 
00089   /*
00090   muonRecoCollectionName_ = iConfig.getUntrackedParameter("muonRecoCollectionName", std::string("muons"));
00091 
00092   electronEtaMax_ = iConfig.getUntrackedParameter<double>("electronEtaMax",2.5);
00093   electronEtMin_ = iConfig.getUntrackedParameter<double>("electronEtMin",3.0);
00094   electronDRMatch_  =iConfig.getUntrackedParameter<double>("electronDRMatch",0.3); 
00095   electronL1DRMatch_  =iConfig.getUntrackedParameter<double>("electronL1DRMatch",0.3); 
00096 
00097   muonEtaMax_ = iConfig.getUntrackedParameter<double>("muonEtaMax",2.1);
00098   muonEtMin_ = iConfig.getUntrackedParameter<double>("muonEtMin",0.0);
00099   muonDRMatch_  =iConfig.getUntrackedParameter<double>("muonDRMatch",0.3); 
00100   muonL1DRMatch_  =iConfig.getUntrackedParameter<double>("muonL1DRMatch",0.3); 
00101 
00102   tauEtaMax_ = iConfig.getUntrackedParameter<double>("tauEtaMax",2.5);
00103   tauEtMin_ = iConfig.getUntrackedParameter<double>("tauEtMin",3.0);
00104   tauDRMatch_  =iConfig.getUntrackedParameter<double>("tauDRMatch",0.3); 
00105   tauL1DRMatch_  =iConfig.getUntrackedParameter<double>("tauL1DRMatch",0.5); 
00106 
00107   jetEtaMax_ = iConfig.getUntrackedParameter<double>("jetEtaMax",5.0);
00108   jetEtMin_ = iConfig.getUntrackedParameter<double>("jetEtMin",10.0);
00109   jetDRMatch_  =iConfig.getUntrackedParameter<double>("jetDRMatch",0.3); 
00110   jetL1DRMatch_  =iConfig.getUntrackedParameter<double>("jetL1DRMatch",0.5); 
00111 
00112   bjetEtaMax_ = iConfig.getUntrackedParameter<double>("bjetEtaMax",2.5);
00113   bjetEtMin_ = iConfig.getUntrackedParameter<double>("bjetEtMin",10.0);
00114   bjetDRMatch_  =iConfig.getUntrackedParameter<double>("bjetDRMatch",0.3); 
00115   bjetL1DRMatch_  =iConfig.getUntrackedParameter<double>("bjetL1DRMatch",0.3); 
00116 
00117   photonEtaMax_ = iConfig.getUntrackedParameter<double>("photonEtaMax",2.5);
00118   photonEtMin_ = iConfig.getUntrackedParameter<double>("photonEtMin",3.0);
00119   photonDRMatch_  =iConfig.getUntrackedParameter<double>("photonDRMatch",0.3); 
00120   photonL1DRMatch_  =iConfig.getUntrackedParameter<double>("photonL1DRMatch",0.3); 
00121 
00122   trackEtaMax_ = iConfig.getUntrackedParameter<double>("trackEtaMax",2.5);
00123   trackEtMin_ = iConfig.getUntrackedParameter<double>("trackEtMin",3.0);
00124   trackDRMatch_  =iConfig.getUntrackedParameter<double>("trackDRMatch",0.3); 
00125   trackL1DRMatch_  =iConfig.getUntrackedParameter<double>("trackL1DRMatch",0.3); 
00126 
00127   metEtaMax_ = iConfig.getUntrackedParameter<double>("metEtaMax",5);
00128   metMin_ = iConfig.getUntrackedParameter<double>("metMin",10.0);
00129   metDRMatch_  =iConfig.getUntrackedParameter<double>("metDRMatch",0.5); 
00130   metL1DRMatch_  =iConfig.getUntrackedParameter<double>("metL1DRMatch",0.5); 
00131 
00132   htEtaMax_ = iConfig.getUntrackedParameter<double>("htEtaMax",5);
00133   htMin_ = iConfig.getUntrackedParameter<double>("htMin",10.0);
00134   htDRMatch_  =iConfig.getUntrackedParameter<double>("htDRMatch",0.5); 
00135   htL1DRMatch_  =iConfig.getUntrackedParameter<double>("htL1DRMatch",0.5); 
00136   */
00137 
00138   sumEtMin_ = iConfig.getUntrackedParameter<double>("sumEtMin",10.0);
00139 
00140       // Muon quality cuts
00141       dxyCut_ = iConfig.getUntrackedParameter<double>("DxyCut", 0.2);   // dxy < 0.2 cm 
00142       normalizedChi2Cut_ = iConfig.getUntrackedParameter<double>("NormalizedChi2Cut", 10.); // chi2/ndof (of global fit) <10.0
00143       trackerHitsCut_ = iConfig.getUntrackedParameter<int>("TrackerHitsCut", 11);  // Tracker Hits >10 
00144       pixelHitsCut_ = iConfig.getUntrackedParameter<int>("PixelHitsCut", 1); // Pixel Hits >0
00145       muonHitsCut_ = iConfig.getUntrackedParameter<int>("MuonHitsCut", 1);  // Valid Muon Hits >0 
00146       isAlsoTrackerMuon_ = iConfig.getUntrackedParameter<bool>("IsAlsoTrackerMuon", true);
00147       nMatchesCut_ = iConfig.getUntrackedParameter<int>("NMatchesCut", 2); // At least 2 Chambers with matches 
00148 
00149   specialPaths_ = iConfig.getParameter<std::vector<std::string > >("SpecialPaths");
00150 
00151   testPathsFolder_ = iConfig.getUntrackedParameter ("testPathsFolder",std::string("HLT/TrigResults/testPaths/"));
00152   pathsSummaryFolder_ = iConfig.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/TrigResults/PathsSummary/HLT Counts/"));
00153   pathsSummaryStreamsFolder_ = iConfig.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/TrigResults/PathsSummary/"));
00154   //pathsSummaryStreamsFolder_ = iConfig.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/TrigResults/PathsSummary/Streams/"));
00155   pathsSummaryHLTCorrelationsFolder_ = iConfig.getUntrackedParameter ("hltCorrelationsFolder",std::string("HLT/TrigResults/PathsSummary/HLT Correlations/"));
00156   pathsSummaryFilterCountsFolder_ = iConfig.getUntrackedParameter ("filterCountsFolder",std::string("HLT/TrigResults/PathsSummary/Filters Counts/"));
00157 
00158   pathsSummaryHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("individualPathsPerLSFolder",std::string("HLT/TrigResults/PathsSummary/HLT LS/"));
00159   pathsIndividualHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("individualPathsPerLSFolder",std::string("HLT/TrigResults/PathsSummary/HLT LS/Paths/"));
00160   pathsSummaryHLTPathsPerBXFolder_ = iConfig.getUntrackedParameter ("individualPathsPerBXFolder",std::string("HLT/TrigResults/PathsSummary/HLT BX/"));
00161 
00162 
00163   // mask off some of the paths so that they don't appear in the plots
00164 
00165   maskedPaths_ = iConfig.getParameter<std::vector<std::string > >("MaskedPaths");
00166 
00167   referenceTrigInput_ = iConfig.getParameter<std::string> ("ReferenceTrigger");
00168   foundReferenceTrigger_ = false;
00169 
00170   //Robin
00171   testPaths_ = iConfig.getParameter<std::vector<std::string > >("testPaths");
00172   
00173   fLumiFlag = true;
00174   ME_HLTAll_LS = NULL;
00175   ME_HLT_BX = NULL;
00176   ME_HLT_CUSTOM_BX = NULL;
00177 
00178   //jetID = new reco::helper::JetIDHelper(iConfig.getParameter<ParameterSet>("JetIDParams"));
00179 
00180     recHitsEBTag_ = iConfig.getUntrackedParameter<edm::InputTag>("RecHitsEBTag",edm::InputTag("reducedEcalRecHitsEB"));
00181       recHitsEETag_ = iConfig.getUntrackedParameter<edm::InputTag>("RecHitsEETag",edm::InputTag("reducedEcalRecHitsEE"));
00182 
00183 
00184       jmsDebug = false;
00185       jmsFakeZBCounts = false;
00186       found_zbIndex = false;
00187       if (jmsDebug ) std::cout << "Printing extra info " << std::endl;
00188       
00189 }
00190 
00191 
00192 TrigResRateMon::~TrigResRateMon()
00193 {
00194  
00195   // do anything here that needs to be done at desctruction time
00196   // (e.g. close files, deallocate resources etc.)
00197 
00198 }
00199 
00200 
00201 //
00202 // member functions
00203 //
00204 
00205 // ------------ method called to for each event  ------------
00206 void
00207 TrigResRateMon::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00208 {
00209 
00210   //if(! fLumiFlag ) return;
00211 
00212   using namespace edm;
00213   using namespace trigger;
00214   ++nev_;
00215   LogDebug("TrigResRateMon")<< " analyze...." ;
00216 
00217 
00218   edm::Handle<TriggerResults> triggerResults;
00219   iEvent.getByLabel(triggerResultsLabel_,triggerResults);
00220   if(!triggerResults.isValid()) {
00221     edm::InputTag triggerResultsLabelFU(triggerResultsLabel_.label(),triggerResultsLabel_.instance(), "FU");
00222     iEvent.getByLabel(triggerResultsLabelFU,triggerResults);
00223     if(!triggerResults.isValid()) {
00224       edm::LogInfo("TrigResRateMon") << "TriggerResults not found, "
00225         "skipping event"; 
00226       return;
00227     }
00228   }
00229   triggerResults_ = triggerResults;
00230   const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
00231 
00232   //Robin---
00233   nStream_++;
00234   passAny = false ;
00235 
00236   // Find which index is zero bias for this run
00237   
00238 // //   if(!found_zbIndex){
00239 // //     // set default to something that is out-of-bounds
00240 // //     zbIndex = triggerNames.size() +2;
00241 // //     for (unsigned int i = 0; i < triggerNames.size(); i ++){
00242 // //       std::string thisName = triggerNames.triggerName(i);
00243 // //       TString checkName(thisName.c_str());
00244 // //       if (checkName.Contains("HLT_ZeroBias_v")){
00245 // //         zbIndex = i;
00246 // //         found_zbIndex = true;
00247 // //         if(jmsDebug) std::cout << "Found the ZeroBias index!!!!!!!! It is   " << zbIndex <<std::endl;
00248 // //       }
00249 // //     }
00250 // //   }
00251 
00252   // int bx = iEvent.bunchCrossing();
00253   /*
00254   // Fill HLTPassed_Correlation Matrix bin (i,j) = (Any,Any)
00255   // --------------------------------------------------------
00256   int anyBinNumber = ME_HLTPassPass->getTH2F()->GetXaxis()->FindBin("HLT_Any");      
00257   // any triger accepted
00258   if(triggerResults->accept()){
00259 
00260     ME_HLTPassPass->Fill(anyBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
00261 
00262   }
00263   */
00264 
00265 
00266   
00267   fillHltMatrix(triggerNames, iEvent, iSetup);
00268 
00269 
00270 
00271 
00273   //
00274   //  Experimental Testing Area
00275   //  Try to get the lumi information for these events 
00276   //
00278 
00279   edm::Handle<LumiScalersCollection> lumiScalers;
00280   bool lumiHandleOK = iEvent.getByLabel(InputTag("hltScalersRawToDigi","",""), lumiScalers);
00281 
00282   if (jmsDebug) std::cout << "Tried to get lumi handle result = " << lumiHandleOK << std::endl;
00283   
00284   if (lumiHandleOK) {
00285     if (jmsDebug) std::cout << "LumiScalers size is:  " << lumiScalers->size()  << std::endl;
00286 
00287     if (lumiScalers->size()) {
00288       LumiScalersCollection::const_iterator it3 = lumiScalers->begin();
00289       unsigned int lumisection = it3->sectionNumber();
00290       if(lumisection){
00291 
00292         if (jmsDebug) std::cout << "Instanteous Lumi is " << it3->instantLumi() << std::endl;
00293         if (jmsDebug) std::cout << "Instanteous Lumi Error is " <<it3->instantLumiErr() << std::endl;
00294         if (jmsDebug) std::cout << "Lumi Fill is " <<it3->lumiFill() << std::endl;
00295         if (jmsDebug) std::cout << "Lumi Fill is " <<it3->lumiRun() << std::endl;
00296         if (jmsDebug) std::cout << "Live Lumi Fill is " <<it3->liveLumiFill() << std::endl;
00297         if (jmsDebug) std::cout << "Live Lumi Run is " <<it3->liveLumiRun() << std::endl;
00298 
00299         addLumiToAverage(it3->instantLumi());
00300         
00301         
00302       } // end
00303     }// end if lumi scalers exist
00304     
00305   }// end if lumi handle ok
00306 
00307   
00308   fillCountsPerPath(iEvent, iSetup);
00309 
00310   if (passAny) nPass_ ++ ;
00311   
00312   return;
00313 
00314 }
00315 
00316 
00317 
00318 // -- method called once each job just before starting event loop  --------
00319 void 
00320 TrigResRateMon::beginJob()
00321 {
00322   nev_ = 0;
00323   DQMStore *dbe = 0;
00324   dbe = Service<DQMStore>().operator->();
00325   
00326   if (dbe) {
00327     dbe->setCurrentFolder(dirname_);
00328   }
00329   
00330   
00331   MonitorElement* reportSummaryME = dbe->book1D("reportSummaryMap","report Summary Map",2,0,2);
00332   if(reportSummaryME) reportSummaryME->Fill(1);
00333 
00334 
00335 }
00336 
00337 // - method called once each job just after ending the event loop  ------------
00338 void 
00339 TrigResRateMon::endJob() 
00340 {
00341    LogInfo("TrigResRateMon") << "analyzed " << nev_ << " events";
00342    return;
00343 }
00344 
00345 
00346 // BeginRun
00347 void TrigResRateMon::beginRun(const edm::Run& run, const edm::EventSetup& c)
00348 {
00349 
00350   LogDebug("TrigResRateMon") << "beginRun, run " << run.id();
00351 
00352   if(fIsSetup) return;
00353   
00354   // HLT config does not change within runs!
00355   bool changed=false;
00356  
00357   if (!hltConfig_.init(run, c, processname_, changed)) {
00358 
00359     processname_ = "FU";
00360 
00361     
00362     if (!hltConfig_.init(run, c, processname_, changed)){
00363 
00364       if (jmsDebug) std::cout << "HLTConfigProvider failed to initialize.";
00365 
00366     } else {
00367       if (jmsDebug) std::cout << "Initialized HLTConfigProvider with name FU " << std::endl;
00368     }
00369 
00370     // check if trigger name in (new) config
00371     //  cout << "Available TriggerNames are: " << endl;
00372     //  hltConfig_.dump("Triggers");
00373   } else {
00374     if (jmsDebug) std::cout << "Initialized HLTConfigProvider with name HLT " << std::endl;
00375   }
00376 
00377   if (1) {
00378 
00379     DQMStore *dbe = 0;
00380     dbe = Service<DQMStore>().operator->();
00381   
00382     if (dbe) {
00383       dbe->setCurrentFolder(dirname_);
00384     }
00385 
00386 
00387     //    const unsigned int n(hltConfig_.size());
00388 
00389     TotalDroppedCounts = 0;
00390     //Robin-------Diagnostic plots--------
00391     meDiagnostic = dbe->book1D("DroppedCounts Diagnose", "LSs vs Status;Status;LSs", 3, -0.5,2.5 );
00392     meCountsDroppedPerLS = dbe->book1D("CountsDroppedVsLS", "Counts vs LumiSec;LS;Dropped Stream Counts", nLS_, 0.5, nLS_+0.5);
00393     meCountsPassPerLS = dbe->book1D("CountsPassVsLS", "Counts vs LumiSec;LS;Passed Stream Counts", nLS_, 0.5, nLS_+0.5);
00394     meCountsStreamPerLS = dbe->book1D("CountsStreamVsLS", "Counts vs LumiSec;LS;Stream Counts", nLS_, 0.5, nLS_+0.5);
00395     meXsecStreamPerLS = dbe->book1D("XsecStreamVsLS", "Xsec vs LumiSec;LS;Stream Xsec", nLS_, 0.5, nLS_+0.5);
00396 
00397 //     meXsecPerLS = dbe->book1D("XsecVsLS", "Xsec vs LumiSec;LS;Xsec", nLS_, 0.5, nLS_+0.5);
00398 //     meXsec = dbe->book1D("Xsec", "histo for Xsec ", 20, 0.01, 0.06);
00399 //     //    meXsecPerIL = dbe->book2D("XsecVsIL", "Xsec vs Inst Lumi;#mub^{-1}*s^{-1}; Xsec", 200, 700, 900, 100, 0.01, 0.1);
00400 //     TProfile tempProfile("XsecVsIL", "Xsec vs Inst Lumi;#mub^{-1}*s^{-1}; Xsec", 40, 600, 3000);
00401 //     meXsecPerIL = dbe_->bookProfile("XsecVsIL", &tempProfile);
00402 
00403     bookTestHisto(); //Robin
00404     dbe->setCurrentFolder(dirname_); //Robin
00405 
00406     // JMS fill the counts per path
00407     bookCountsPerPath();
00408     clearLumiAverage();
00409     averageInstLumi3LS = 0 ;
00410     findReferenceTriggerIndex();
00411     meAverageLumiPerLS = dbe->book1D("InstLumiVsLS", "Instantaneous Luminosity vs LumiSec;LS;#mub^{-1}*s^{-1}", nLS_, 0.5, nLS_+0.5);
00412 // //     if (plotAll_){
00413 
00414 // //       for (unsigned int j=0; j!=n; ++j) {
00415   
00416 // //         std::string pathname = hltConfig_.triggerName(j);  
00417 
00418 // //         string l1pathname = getL1ConditionModuleName(pathname);
00419 
00420 // //         int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1pathname);
00421       
00422 // //         int objectType =  getTriggerTypeParsePathName(pathname);
00423   
00424 // //         for (unsigned int i=0; i!=n; ++i) {
00425   
00426 // //           std::string denompathname = hltConfig_.triggerName(i);  
00427 // //           int denomobjectType =  getTriggerTypeParsePathName(denompathname);
00428 
00429       
00430          
00431 // //           std::string filtername("dummy");
00432 // //           float ptMin = 0.0;
00433 // //           float ptMax = 100.0;
00434 // //           if (plotAll_ && denomobjectType == objectType && objectType != 0) {
00435           
00436 // //             int hltThreshold = getThresholdFromName(pathname);
00437 // //             int l1Threshold = getThresholdFromName(l1pathname);
00438 // //             hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00439 
00440 // //           }
00441 
00442 // //         }
00443 // //       }
00444 
00445 // //     } // end if plotAll
00446 // //     else {
00447 
00448       // plot all diagonal combinations plus any other specified pairs
00449 // //       for (unsigned int i=0; i!=n; ++i) {
00450 
00451 // //          std::string denompathname = "";  
00452 // //          std::string pathname = hltConfig_.triggerName(i);  
00453 // //          //parse pathname to guess object type
00454 // //          int objectType =  getTriggerTypeParsePathName(pathname);
00455 
00456 // //         string l1pathname = getL1ConditionModuleName(pathname);
00457 // //         int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1pathname);
00458   
00459 // //         std::string filtername("dummy");
00460 // //         float ptMin = 0.0;
00461 // //         float ptMax = 100.0;
00462 
00463 // //         if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00464 // //         if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00465 // //         if (objectType == trigger::TriggerMuon) ptMax = 150.0;
00466 // //         if (objectType == trigger::TriggerTau) ptMax = 100.0;
00467 // //         if (objectType == trigger::TriggerJet) ptMax = 300.0;
00468 // //         if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00469 // //         if (objectType == trigger::TriggerMET) ptMax = 300.0;
00470 // //         if (objectType == trigger::TriggerTET) ptMax = 300.0;
00471 // //         if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00472     
00473 // //         // keep track of all paths, except for FinalPath
00474 // //         if (objectType != -1 && pathname.find("FinalPath") == std::string::npos){
00475 
00476 // //           int hltThreshold = getThresholdFromName(pathname);
00477 // //           int l1Threshold = getThresholdFromName(l1pathname);
00478   
00479 // //           hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00480 
00481 // //           hltPathsDiagonal_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00482   
00483 // //         }
00484 
00485 // //       } // end for i
00486 
00487         
00488       // now loop over denom/num path pairs specified in cfg, 
00489       // recording the off-diagonal ones
00490 // //       for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair) {
00491             
00492 // //         std::string numpathname = custompathnamepair->first;  
00493 // //         std::string denompathname = custompathnamepair->second;  
00494   
00495 // //         if (numpathname != denompathname) {
00496   
00497 // //           // check that denominator exists
00498 // //           bool founddenominator = false;
00499 // //           for (unsigned int k=0; k!=n; ++k) {
00500 
00501 // //             string n_pathname = hltConfig_.triggerName(k);
00502 
00503 // //             if (n_pathname.find(denompathname) != std::string::npos) {
00504               
00505 // //               LogDebug("TrigResRateMon") << "denompathname is selected to be = " << n_pathname << endl;;
00506 // //               founddenominator = true;
00507 
00508 // //               break;
00509 
00510 // //             }
00511 // //           }
00512 
00513 // //           if (!founddenominator) {
00514   
00515 // //             edm::LogInfo("TrigResRateMon") << "denompathname not found, go to the next pair numearator-denominator" << endl;
00516             
00517 // //             // go to the next pair
00518 // //             continue;
00519   
00520 // //           }
00521 
00522 // //           // check that numerator exists
00523 // //           bool foundnumerator = false;
00524 // //           for (unsigned int j=0; j!=n; ++j) {
00525 
00526 // //             string pathname = hltConfig_.triggerName(j);
00527 
00528 // //             LogDebug("TrigResRateMon") << "check if path " << pathname << " is numpathname = " << numpathname << endl;
00529 // //             if (hltConfig_.triggerName(j).find(numpathname)!= std::string::npos) {
00530               
00531 // //               LogDebug("TrigResRateMon") << "pathname is selected to be = " << denompathname << endl;;
00532 // //               foundnumerator = true;
00533 
00534 // //             }
00535   
00536   
00537 // //             if (!foundnumerator) {
00538     
00539 // //               edm::LogInfo("TrigResRateMon") << "pathname not found, ignoring " << pathname;
00540 // //               continue;
00541   
00542 // //             }
00543   
00544   
00545 // //             string l1pathname = getL1ConditionModuleName(pathname);
00546 // //             int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1pathname);
00547 // //             int objectType =  getTriggerTypeParsePathName(pathname);
00548   
00549 // //           std::string filtername("dummy");
00550 // //           float ptMin = 0.0;
00551 // //           float ptMax = 100.0;
00552 // //           if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00553 // //           if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00554 // //           if (objectType == trigger::TriggerMuon) ptMax = 150.0;
00555 // //           if (objectType == trigger::TriggerTau) ptMax = 100.0;
00556 // //           if (objectType == trigger::TriggerJet) ptMax = 300.0;
00557 // //           if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00558 // //           if (objectType == trigger::TriggerMET) ptMax = 300.0;
00559 // //           if (objectType == trigger::TriggerTET) ptMax = 300.0;
00560 // //           if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00561   
00562 // //           // monitor regardless of the objectType of the path
00563 // //           if (objectType != 0) {
00564 // //             int hltThreshold = getThresholdFromName(pathname);
00565 // //             int l1Threshold = getThresholdFromName(l1pathname);
00566 // //             hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00567 
00568 // //           }
00569       
00570 // //         } // end for j, loop over paths
00571 
00572 // //        }  // end if not same num and denominator 
00573   
00574 // //       }
00575 //       // end for pair
00576 
00577 //     }
00578   // end else
00579 
00580 
00581     /*
00582     vector<string> muonPaths;
00583     vector<string> egammaPaths;
00584     vector<string> tauPaths;
00585     vector<string> jetmetPaths;
00586     vector<string> restPaths;
00587     */
00588     vector<string> allPaths;
00589 
00590     // fill vectors of Muon, Egamma, JetMET, Rest, and Special paths
00591     for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
00592 
00593       std::string pathName = v->getPath();
00594       //int objectType = v->getObjectType();
00595 
00596       vector<int> tempCount(5,0);
00597 
00598       fPathTempCountPair.push_back(make_pair(pathName,0));
00599       fPathBxTempCountPair.push_back(make_pair(pathName,tempCount));
00600 
00601       allPaths.push_back(pathName);
00602 
00603       /*
00604       switch (objectType) {
00605         case trigger::TriggerMuon :
00606           muonPaths.push_back(pathName);
00607           break;
00608 
00609         case trigger::TriggerElectron :
00610         case trigger::TriggerPhoton :
00611           egammaPaths.push_back(pathName);
00612           break;
00613 
00614         case trigger::TriggerTau :
00615           tauPaths.push_back(pathName);
00616           break;
00617 
00618         case trigger::TriggerJet :
00619         case trigger::TriggerMET :
00620           jetmetPaths.push_back(pathName);
00621           break;
00622 
00623         default:
00624           restPaths.push_back(pathName);
00625       }
00626       */
00627 
00628     }
00629 
00630     fPathTempCountPair.push_back(make_pair("HLT_Any",0));
00631 
00632     fGroupName.push_back("AllSelectedPaths");
00633     /*
00634     fGroupName.push_back("Muon");
00635     fGroupName.push_back("Egamma");
00636     fGroupName.push_back("Tau");
00637     fGroupName.push_back("JetMET");
00638     fGroupName.push_back("Rest");
00639     fGroupName.push_back("Special");
00640     */
00641 
00642     for(unsigned int g=0; g<fGroupName.size(); g++) {
00643 
00644       //fGroupTempCountPair.push_back(make_pair(fGroupName[g],0));
00645       //fGroupL1TempCountPair.push_back(make_pair(fGroupName[g],0));
00646 
00647     }
00648   
00649     dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
00650 
00651 
00652 
00653 //     fGroupNamePathsPair.push_back(make_pair("AllSelectedPaths",allPaths));
00654 
00655     /*
00656     fGroupNamePathsPair.push_back(make_pair("Muon",muonPaths));
00657 
00658     fGroupNamePathsPair.push_back(make_pair("Egamma",egammaPaths));
00659 
00660     fGroupNamePathsPair.push_back(make_pair("Tau",tauPaths));
00661 
00662     fGroupNamePathsPair.push_back(make_pair("JetMET",jetmetPaths));
00663 
00664     fGroupNamePathsPair.push_back(make_pair("Rest",restPaths));
00665 
00666     fGroupNamePathsPair.push_back(make_pair("Special",specialPaths_));
00667     */
00668 
00670     //vector<string> datasetNames =  hltConfig_.datasetNames() ;
00671     vector<string> datasetNames =  hltConfig_.streamContent("A") ;
00672     for (unsigned int i=0;i<datasetNames.size();i++) {
00673 
00674       vector<string> datasetPaths = hltConfig_.datasetContent(datasetNames[i]);
00675       fGroupNamePathsPair.push_back(make_pair(datasetNames[i],datasetPaths));
00676 
00677       DatasetInfo tempDS;
00678       tempDS.datasetName = datasetNames[i];
00679       tempDS.setPaths(datasetPaths);
00680       tempDS.countsPerPathME_Name = pathsSummaryFolder_ + "HLT_" + datasetNames[i] + "_Pass_Any";
00681       tempDS.xsecPerPathME_Name = pathsSummaryFolder_ + "HLT_" + datasetNames[i] + "_Xsec";
00682       tempDS.rawCountsPerPathME_Name = pathsSummaryFolder_ + "HLT_" + datasetNames[i] + "_RawCounts";
00683       tempDS.scaledXsecPerPathME_Name = pathsSummaryFolder_ + "HLT_" + datasetNames[i] + "_XsecScaled";
00684       tempDS.ratePerLSME_Name = pathsSummaryFolder_ + "HLT_" + datasetNames[i] + "_Rate"; //Robin
00685       tempDS.setMaskedPaths(maskedPaths_);
00686       if (jmsDebug) tempDS.printMaskedPaths();
00687       primaryDataSetInformation.push_back(tempDS);
00688 
00689       rawCountsPerPD.push_back(0);  //Robin
00690     }
00691 
00692     // push stream A and its PDs
00693     fGroupNamePathsPair.push_back(make_pair("A",datasetNames));
00694 
00695 
00696     for (unsigned int g=0;g<fGroupNamePathsPair.size();g++) {
00697 
00698       fGroupTempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
00699       fGroupL1TempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
00700       setupHltMatrix(fGroupNamePathsPair[g].first,fGroupNamePathsPair[g].second);
00701 
00702     }
00703 
00704 /*
00705     // HLT matrices from Streams
00706     const std::vector<std::string> streamNames = hltConfig_.streamNames();
00707 
00708     for (unsigned int s=0;s<streamNames.size();s++) {
00709 
00711       vector<string> hltConfig =  streamDatasetNames_.streamContent(streamNames[s]) ;
00712       if(streamNames[s] == "A") setupStreamMatrix(streamNames[s],streamDatasetNames);
00713 
00714     }
00715 */
00716 
00717 // //     setupHltLsPlots();
00718 
00719 // //     setupHltBxPlots();
00720 
00721 
00722 //     for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
00723 
00724 //        // -------------------------
00725 //        //
00726 //        //  Filters for each path
00727 //        //
00728 //        // -------------------------
00729        
00730 //        // get all modules in this HLT path
00731 //        vector<string> moduleNames = hltConfig_.moduleLabels( v->getPath() ); 
00732        
00733 //        int numModule = 0;
00734 //        string moduleName, moduleType;
00735 //        unsigned int moduleIndex;
00736        
00737 //        //print module name
00738 //        vector<string>::const_iterator iDumpModName;
00739 //        for (iDumpModName = moduleNames.begin();iDumpModName != moduleNames.end();iDumpModName++) {
00740 
00741 //          moduleName = *iDumpModName;
00742 //          moduleType = hltConfig_.moduleType(moduleName);
00743 //          moduleIndex = hltConfig_.moduleIndex(v->getPath(), moduleName);
00744 
00745 //          LogTrace ("TrigResRateMon") << "Module "      << numModule
00746 //              << " is called " << moduleName
00747 //              << " , type = "  << moduleType
00748 //              << " , index = " << moduleIndex
00749 //              << endl;
00750 
00751 //          numModule++;
00752 
00753 //          if((moduleType.find("Filter") != string::npos && moduleType.find("HLTTriggerTypeFilter") == string::npos ) || 
00754 //             (moduleType.find("Associator") != string::npos) || 
00755 //             (moduleType.find("HLTLevel1GTSeed") != string::npos) || 
00756 //             (moduleType.find("HLTGlobalSumsCaloMET") != string::npos) ||
00757 //             (moduleType.find("HLTPrescaler") != string::npos) ) {
00758 
00759 //            //std::pair<std::string, int> filterIndexPair;
00760 //            //filterIndexPair.first   = moduleName;
00761 //            //filterIndexPair.second  = moduleIndex;
00762 //            //v->filtersAndIndices.push_back(filterIndexPair);
00763 //            v->filtersAndIndices.push_back(make_pair(moduleName,moduleIndex));
00764 
00765 //          }
00766 
00767 
00768 //        }//end for modulesName
00769 
00770 //        // dbe_->setCurrentFolder(pathsSummaryFilterCountsFolder_.c_str()); 
00771 
00772 // //        //int nbin_sub = 5;
00773 // //        int nbin_sub = v->filtersAndIndices.size()+2;
00774     
00775 // //        // count plots for subfilter
00776 // //        MonitorElement* filters = dbe_->book1D("Filters_" + v->getPath(), 
00777 // //                               "Filters_" + v->getPath(),
00778 // //                               nbin_sub+1, -0.5, 0.5+(double)nbin_sub);
00779        
00780 // //        for(unsigned int filt = 0; filt < v->filtersAndIndices.size(); filt++){
00781 
00782 // //          filters->setBinLabel(filt+1, (v->filtersAndIndices[filt]).first);
00783 
00784 // //        }
00785 
00786 //        // book Count vs LS
00787 //        dbe_->setCurrentFolder(pathsIndividualHLTPathsPerLSFolder_.c_str());
00788 //        MonitorElement* tempME = dbe_->book1D(v->getPath() + "_count_per_LS", 
00789 //                               v->getPath() + " rate [Hz]",
00790 //                               nLS_, 0,nLS_);
00791 //        tempME->setAxisTitle("Luminosity Section");
00792 
00793 //        //v->setFilterHistos(filters);
00794 
00795 //     }
00796     // end for paths
00797 
00798     // now set up all of the histos for each path-denom
00799 //    for(PathInfoCollection::iterator v = hltPaths_.begin(); v!= hltPaths_.end(); ++v ) {
00800 
00801       /*
00802       MonitorElement *NOn, *onEtOn, *onOneOverEtOn, *onEtavsonPhiOn=0;
00803       MonitorElement *NOff, *offEtOff, *offEtavsoffPhiOff=0;
00804       MonitorElement *NL1, *l1EtL1, *l1Etavsl1PhiL1=0;
00805       MonitorElement *NL1On, *l1EtL1On, *l1Etavsl1PhiL1On=0;
00806       MonitorElement *NL1Off, *offEtL1Off, *offEtavsoffPhiL1Off=0;
00807       MonitorElement *NOnOff, *offEtOnOff, *offEtavsoffPhiOnOff=0;
00808       MonitorElement *NL1OnUM, *l1EtL1OnUM, *l1Etavsl1PhiL1OnUM=0;
00809       MonitorElement *NL1OffUM, *offEtL1OffUM, *offEtavsoffPhiL1OffUM=0;
00810       MonitorElement *NOnOffUM, *offEtOnOffUM, *offEtavsoffPhiOnOffUM=0;
00811       MonitorElement *offDRL1Off, *offDROnOff, *l1DRL1On=0;
00812       */
00813       
00814 
00815 //       std::string labelname("dummy");
00816 //       labelname = v->getPath() + "_wrt_" + v->getDenomPath();
00817 //       std::string histoname(labelname+"_NOn");
00818 //       std::string title(labelname+" N online");
00819 //       double histEtaMax = 2.5;
00820 
00821 //       if (v->getObjectType() == trigger::TriggerMuon || v->getObjectType() == trigger::TriggerL1Mu) {
00822 
00823 //         histEtaMax = muonEtaMax_;
00824 
00825 //       }
00826 //       else if (v->getObjectType() == trigger::TriggerElectron || v->getObjectType() == trigger::TriggerL1NoIsoEG || v->getObjectType() == trigger::TriggerL1IsoEG )
00827 //       {
00828 //         histEtaMax = electronEtaMax_;
00829 //       }
00830 //         else if (v->getObjectType() == trigger::TriggerTau || v->getObjectType() == trigger::TriggerL1TauJet )
00831 //       {
00832 //         histEtaMax = tauEtaMax_;
00833 //       }
00834 //       else if (v->getObjectType() == trigger::TriggerJet || v->getObjectType() == trigger::TriggerL1CenJet || v->getObjectType() == trigger::TriggerL1ForJet )
00835 //       {
00836 //         histEtaMax = jetEtaMax_; 
00837 //       }
00838 //         else if (v->getObjectType() == trigger::TriggerBJet)
00839 //       {
00840 //         histEtaMax = bjetEtaMax_;
00841 //       }
00842 //       else if (v->getObjectType() == trigger::TriggerMET || v->getObjectType() == trigger::TriggerL1ETM )
00843 //       {
00844 //         histEtaMax = metEtaMax_; 
00845 //       }
00846 //         else if (v->getObjectType() == trigger::TriggerPhoton)
00847 //       {
00848 //         histEtaMax = photonEtaMax_; 
00849 //       }
00850 //       else if (v->getObjectType() == trigger::TriggerTrack)
00851 //       {
00852 //         histEtaMax = trackEtaMax_; 
00853 //       }
00854 
00855 //       TString pathfolder = dirname_ + TString("/FourVector/") + v->getPath();
00856       /*
00857       dbe_->setCurrentFolder(pathfolder.Data());
00858 
00859       NOn =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
00860 
00861 
00862        histoname = labelname+"_NOff";
00863        title = labelname+" N Off";
00864        NOff =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
00865        
00866        histoname = labelname+"_NL1";
00867        title = labelname+" N L1";
00868        NL1 =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
00869        
00870        histoname = labelname+"_NL1On";
00871        title = labelname+" N L1On";
00872        NL1On =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
00873        
00874        histoname = labelname+"_NL1Off";
00875        title = labelname+" N L1Off";
00876        NL1Off =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
00877        
00878        histoname = labelname+"_NOnOff";
00879        title = labelname+" N OnOff";
00880        NOnOff =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
00881        
00882        
00883        histoname = labelname+"_NL1OnUM";
00884        title = labelname+" N L1OnUM";
00885        NL1OnUM =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
00886        
00887        histoname = labelname+"_NL1OffUM";
00888        title = labelname+" N L1OffUM";
00889        NL1OffUM =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
00890        
00891        histoname = labelname+"_NOnOffUM";
00892        title = labelname+" N OnOffUM";
00893        NOnOffUM =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
00894        
00895        
00896        histoname = labelname+"_onEtOn";
00897        title = labelname+" onE_t online";
00898        onEtOn =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
00899        
00900        histoname = labelname+"_onOneOverEtOn";
00901        title = labelname+" 1 / onE_t online";
00902        onOneOverEtOn =  dbe->book1D(histoname.c_str(), title.c_str(),nBinsOneOverEt_, 0, 1);
00903        onOneOverEtOn->setAxisTitle("HLT 1/Et [1/GeV]");
00904        
00905        histoname = labelname+"_offEtOff";
00906        title = labelname+" offE_t offline";
00907        offEtOff =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
00908        
00909        histoname = labelname+"_l1EtL1";
00910        title = labelname+" l1E_t L1";
00911        l1EtL1 =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
00912        
00913        
00914        histoname = labelname+"_onEtaonPhiOn";
00915        title = labelname+" on#eta vs on#phi online";
00916        onEtavsonPhiOn =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
00917        
00918        histoname = labelname+"_offEtaoffPhiOff";
00919        title = labelname+" off#eta vs off#phi offline";
00920        offEtavsoffPhiOff =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
00921        
00922        histoname = labelname+"_l1Etal1PhiL1";
00923        title = labelname+" l1#eta vs l1#phi L1";
00924        l1Etavsl1PhiL1 =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
00925        
00926        histoname = labelname+"_l1EtL1On";
00927        title = labelname+" l1E_t L1+online";
00928        l1EtL1On =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
00929        
00930        histoname = labelname+"_offEtL1Off";
00931        title = labelname+" offE_t L1+offline";
00932        offEtL1Off =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
00933        
00934        histoname = labelname+"_offEtOnOff";
00935        title = labelname+" offE_t online+offline";
00936        offEtOnOff =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
00937        
00938        histoname = labelname+"_l1Etal1PhiL1On";
00939        title = labelname+" l1#eta vs l1#phi L1+online";
00940        l1Etavsl1PhiL1On =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
00941        
00942        histoname = labelname+"_offEtaoffPhiL1Off";
00943        title = labelname+" off#eta vs off#phi L1+offline";
00944        offEtavsoffPhiL1Off =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
00945        
00946        histoname = labelname+"_offEtaoffPhiOnOff";
00947        title = labelname+" off#eta vs off#phi online+offline";
00948        offEtavsoffPhiOnOff =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
00949        
00950        histoname = labelname+"_l1EtL1OnUM";
00951        title = labelname+" l1E_t L1+onlineUM";
00952        l1EtL1OnUM =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
00953        
00954        histoname = labelname+"_offEtL1OffUM";
00955        title = labelname+" offE_t L1+offlineUM";
00956        offEtL1OffUM =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
00957        
00958        histoname = labelname+"_offEtOnOffUM";
00959        title = labelname+" offE_t online+offlineUM";
00960        offEtOnOffUM =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
00961        
00962        histoname = labelname+"_l1Etal1PhiL1OnUM";
00963        title = labelname+" l1#eta vs l1#phi L1+onlineUM";
00964        l1Etavsl1PhiL1OnUM =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
00965        
00966        histoname = labelname+"_offEtaoffPhiL1OffUM";
00967        title = labelname+" off#eta vs off#phi L1+offlineUM";
00968        offEtavsoffPhiL1OffUM =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
00969        
00970        histoname = labelname+"_offEtaoffPhiOnOffUM";
00971        title = labelname+" off#eta vs off#phi online+offlineUM";
00972        offEtavsoffPhiOnOffUM =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
00973        
00974        
00975        
00976        
00977        histoname = labelname+"_l1DRL1On";
00978        title = labelname+" l1DR L1+online";
00979        l1DRL1On =  dbe->book1D(histoname.c_str(), title.c_str(),nBinsDR_, 0, dRMax_); 
00980        
00981        histoname = labelname+"_offDRL1Off";
00982        title = labelname+" offDR L1+offline";
00983        offDRL1Off =  dbe->book1D(histoname.c_str(), title.c_str(),nBinsDR_, 0, dRMax_);
00984        
00985        histoname = labelname+"_offDROnOff";
00986        title = labelname+" offDR online+offline";
00987        offDROnOff =  dbe->book1D(histoname.c_str(), title.c_str(),nBinsDR_, 0, dRMax_); 
00988        */
00989 
00990 
00991        //v->setHistos( NOn, onEtOn, onOneOverEtOn, onEtavsonPhiOn, NOff, offEtOff, offEtavsoffPhiOff, NL1, l1EtL1, l1Etavsl1PhiL1, NL1On, l1EtL1On, l1Etavsl1PhiL1On, NL1Off, offEtL1Off, offEtavsoffPhiL1Off, NOnOff, offEtOnOff, offEtavsoffPhiOnOff, NL1OnUM, l1EtL1OnUM, l1Etavsl1PhiL1OnUM, NL1OffUM, offEtL1OffUM, offEtavsoffPhiL1OffUM, NOnOffUM, offEtOnOffUM, offEtavsoffPhiOnOffUM, offDRL1Off, offDROnOff, l1DRL1On );
00992 
00993 
00994 //    }  // end for hltPath 
00995 
00996     // HLT_Any
00997     // book Count vs LS
00998 // //     dbe_->setCurrentFolder(pathsIndividualHLTPathsPerLSFolder_.c_str());
00999 // //     MonitorElement* tempME = dbe_->book1D("HLT_Any_count_per_LS", 
01000 // //                            "HLT_Any rate [Hz]",
01001 // //                            nLS_, 0,nLS_);
01002 // //     tempME->setAxisTitle("Luminosity Section");
01003 
01004   } // end if(1) dummy
01005 
01006 
01007   
01008   
01009   
01010  if(doCombineRuns_) fIsSetup = true;
01011 
01012  return;
01013 
01014 }
01015 
01017 void TrigResRateMon::endRun(const edm::Run& run, const edm::EventSetup& c)
01018 {
01019 
01020   LogDebug("TrigResRateMon") << "endRun, run " << run.id();
01021 
01022 }
01023 
01024 
01025 void TrigResRateMon::setupHltMatrix(const std::string& label, vector<std::string>& paths) {
01026 
01027     //string groupLabelAny = "HLT_"+label+"_Any";
01028     //paths.push_back(groupLabelAny.c_str());
01029     //paths.push_back("HLT_"+label+"_L1_Any");
01030     paths.push_back("");
01031     paths.push_back("Total "+label);
01032     //paths.push_back("HLT_Any");
01033 
01034     string h_name; 
01035     string h_title; 
01036 
01037     dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
01038 
01039 // //     h_name= "HLT_"+label+"_PassPass";
01040 // //     h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass);;; ";
01041 // //     MonitorElement* ME = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01042 // //                            paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01043 
01044     // This is counts per path per for a specific PD
01045     // it will be corrected for prescales
01046     h_name= "HLT_"+label+"_Pass_Any";
01047     h_title = "HLT_"+label+"_Pass -- Prescale*Counts Per Path;Path;PS*Counts";
01048     MonitorElement* ME_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01049                            paths.size(), -0.5, paths.size()-0.5);
01050 
01051     // This is RAW counts per path per for a specific PD
01052     // it will be corrected for
01053     h_name= "HLT_"+label+"_RawCounts";
01054     h_title = "HLT_"+label+"_Pass (x=Pass, An) normalized to HLT_Any Pass;;Counts";
01055     MonitorElement* ME_RawCounts = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01056                            paths.size(), -0.5, paths.size()-0.5);
01057 
01058 
01059     // Make a similar histogram that is xsec per path for a specific PD
01060     // this is actually a profile of the average xsec per path 
01061     h_name= "HLT_"+label+"_Xsec";
01062     h_title = "HLT_"+label+"_Xsec -- Profile shows Average Xsec per path;;#sigma (#mu b)";
01063 
01064     TProfile tempProfile(h_name.c_str(), h_title.c_str(),
01065                          paths.size(), -0.5, paths.size()-0.5);
01066     MonitorElement* ME_Xsec = dbe_->bookProfile(h_name.c_str(), &tempProfile);
01067 
01068 
01069     // Make a similar histogram that is xsec per path for a specific PD
01070     // this is actually a profile of the average xsec per path
01071     // this histogram is scaled to the cross section of a reference path
01072     h_name= "HLT_"+label+"_XsecScaled";
01073     h_title = "HLT_"+label+"_Xsec -- Profile shows Average Xsec per path Scaled to Reference;;Ratio (#sigma/#sigma_{ref}";
01074 
01075     TProfile tempProfileScaled(h_name.c_str(), h_title.c_str(),
01076                          paths.size(), -0.5, paths.size()-0.5);
01077     MonitorElement* ME_XsecScaled = dbe_->bookProfile(h_name.c_str(), &tempProfileScaled);
01078 
01080     h_name= "HLT_"+label+"_Rate";
01081     h_title = "HLT_"+label+"_Rate -- histogram shows Average Rate per LS;LS;Rate [Hz]";
01082 
01083     // MonitorElement* ME_Rate = dbe_->book1D(h_name.c_str(), h_title.c_str(),nLS_, 0, nLS_);
01084 
01085 
01086 //     dbe_->setCurrentFolder(pathsSummaryHLTCorrelationsFolder_.c_str());
01087 //     h_name= "HLT_"+label+"_PassPass_Normalized";
01088 //     h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass) normalized to xBin=Pass";
01089 //     MonitorElement* ME_Normalized = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01090 //                            paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01091 //     h_name= "HLT_"+label+"_Pass_Normalized_Any";
01092 //     h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
01093 //     MonitorElement* ME_Normalized_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01094 //                            paths.size(), -0.5, paths.size()-0.5);
01095 
01096 //     dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_.c_str());
01097 //     h_name= "HLT_"+label+"_Total_LS";
01098 //     h_title = label+" HLT paths total combined rate [Hz]";
01099 //     MonitorElement* ME_Total_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
01100 //     ME_Total_LS->setAxisTitle("LS");
01101 
01102 //     h_name= "HLT_"+label+"_LS";
01103 //     h_title = label+" HLT paths rate [Hz]";
01104 //     MonitorElement* ME_Group_LS = dbe_->book2D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_, paths.size(), -0.5, paths.size()-0.5);
01105 //     ME_Group_LS->setAxisTitle("LS");
01106 //     /// add this path to the vector of 2D LS paths
01107 //     v_ME_HLTAll_LS.push_back(ME_Group_LS);
01108 
01109     /*
01110     h_name= "HLT_"+label+"_L1_Total_LS";
01111     h_title = label+" HLT paths total combined rate [Hz]";
01112     MonitorElement* ME_Total_L1_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
01113     ME_Total_L1_LS->setAxisTitle("LS");
01114 
01115     h_name= "HLT_"+label+"_L1_LS";
01116     h_title = label+" HLT L1s rate [Hz]";
01117     MonitorElement* ME_Group_L1_LS = dbe_->book2D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_, paths.size(), -0.5, paths.size()-0.5);
01118     ME_Group_L1_LS->setAxisTitle("LS");
01119 
01120     dbe_->setCurrentFolder(pathsSummaryHLTPathsPerBXFolder_.c_str());
01121     h_name= "HLT_"+label+"_BX_LS";
01122     h_title = label+" HLT paths total count combined per BX ";
01123     MonitorElement* ME_Total_BX = dbe_->book2D(h_name.c_str(), h_title.c_str(),  nLS_, 0, nLS_, 5, -2.5, 2.5);
01124     ME_Total_BX->setAxisTitle("LS",1);
01125     v_ME_Total_BX.push_back(ME_Total_BX);
01126 
01127     h_name= "HLT_"+label+"_BX_LS_Norm";
01128     h_title = label+" HLT paths total count combined per BX Normalized to LS";
01129     MonitorElement* ME_Total_BX_Norm = dbe_->book2D(h_name.c_str(), h_title.c_str(),  nLS_, 0, nLS_, 5, -2.5, 2.5);
01130     ME_Total_BX_Norm->setAxisTitle("LS",1);
01131     v_ME_Total_BX_Norm.push_back(ME_Total_BX_Norm);
01132     */
01133 
01134     for(unsigned int i = 0; i < paths.size(); i++){
01135 
01136 // //       ME->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01137 // //       ME->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01138 //       ME_Group_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01139 
01140 //       ME_Normalized->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01141 //       ME_Normalized->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01142 //       ME_Normalized_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01143       ME_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01144       ME_Xsec->getTProfile()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01145       ME_XsecScaled->getTProfile()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01146       ME_RawCounts->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01147     }
01148     
01149 }
01150 
01151 
01152 void TrigResRateMon::setupStreamMatrix(const std::string& label, vector<std::string>& paths) {
01153 
01154 
01155     paths.push_back("");
01156     paths.push_back("HLT_"+label+"_Any");
01157 
01158     string h_name; 
01159     string h_title; 
01160 
01161     dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
01162 
01163     h_name= "HLT_"+label+"_PassPass";
01164     h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass)";
01165     MonitorElement* ME = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01166                            paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01167 
01168     h_name= "HLT_"+label+"_Pass_Any";
01169     h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
01170     MonitorElement* ME_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01171                            paths.size(), -0.5, paths.size()-0.5);
01172 
01173     dbe_->setCurrentFolder(pathsSummaryHLTCorrelationsFolder_.c_str());
01174     h_name= "HLT_"+label+"_PassPass_Normalized";
01175     h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass) normalized to xBin=Pass";
01176     MonitorElement* ME_Normalized = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01177                            paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01178     h_name= "HLT_"+label+"_Pass_Normalized_Any";
01179     h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
01180     MonitorElement* ME_Normalized_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01181                            paths.size(), -0.5, paths.size()-0.5);
01182 
01183     for(unsigned int i = 0; i < paths.size(); i++){
01184 
01185       ME->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01186       ME->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01187 
01188       ME_Normalized->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01189       ME_Normalized->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01190 
01191       ME_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01192       ME_Normalized_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01193 
01194     }
01195 
01196 }
01197 
01198 void TrigResRateMon::fillHltMatrix(const edm::TriggerNames & triggerNames, const edm::Event& iEvent, const edm::EventSetup& iSetup) {
01199 
01200  string fullPathToME; 
01201  std::vector <std::pair<std::string, bool> > groupAcceptPair;
01202 
01203  // This will store the prescale values
01204  std::pair<int,int>  psValueCombo;
01205 
01206   // For each dataset
01207  for (unsigned int mi=0;mi<fGroupNamePathsPair.size()-1;mi++) {  
01208 
01209 
01210 // //   fullPathToME = pathsSummaryFolder_ + "HLT_"+fGroupNamePathsPair[mi].first+"_PassPass";
01211 // //   MonitorElement* ME_2d = dbe_->get(fullPathToME);
01212   fullPathToME = pathsSummaryFolder_ + "HLT_"+fGroupNamePathsPair[mi].first+"_Pass_Any";
01213   MonitorElement* ME_1d = dbe_->get(fullPathToME);
01214 //   // if(!ME_2d || !ME_1d) {  
01215   if(!ME_1d) { 
01216     LogTrace("TrigResRateMon") << " ME not valid although I gave full path" << endl;
01217     continue;
01218 
01219   }
01220 
01221 // //   TH2F * hist_2d = ME_2d->getTH2F();
01222   TH1F * hist_1d = ME_1d->getTH1F();
01223 
01224   // Fill HLTPassed Matrix bin (i,j) = (Any,Any)
01225   // --------------------------------------------------------
01226 // //   int anyBinNumber = hist_2d->GetXaxis()->FindBin("HLT_Any");   
01227 
01228   //string groupBinLabel = "HLT_"+fGroupNamePathsPair[mi].first+"_Any";
01229 // //   string groupBinLabel = "Total "+fGroupNamePathsPair[mi].first;
01230 // //   int groupBinNumber = hist_2d->GetXaxis()->FindBin(groupBinLabel.c_str()); 
01231 
01232   // any triger accepted
01233   //   if(triggerResults_->accept()){
01234   
01235   //     hist_2d->Fill(anyBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
01236   
01237   
01238   
01239   //     hist_1d->Fill(anyBinNumber-1);//binNumber1 = 0 = first filter
01240   
01241   //   }
01242 
01243     
01244  
01245 
01246   //if (jmsDebug) std::cout << "Setting histograms to HLT_ZeroBias index " << zbIndex << std::endl;
01247 
01248 // //   if (zbIndex < triggerResults_->size() ) {
01249 // //     if (triggerResults_->accept(zbIndex) || jmsFakeZBCounts) {
01250 // //       if (jmsDebug) std::cout << "Filling bin " << (groupBinNumber-1)
01251 // //                               << " (out of " << hist_1d->GetNbinsX()
01252 // //                               << ")  with ZB counts in histo "
01253 // //                               << hist_1d->GetName() << std::endl;
01254       
01255 // //       hist_1d->Fill(groupBinNumber-1, 50000);
01256 // //       hist_2d->Fill(groupBinNumber-1,groupBinNumber-1, 10000);//binNumber1 = 0 = first filter
01257 // //    }
01258 // //  }
01259   
01260   
01261   bool groupPassed = false;
01262   //bool groupL1Passed = false;
01263 
01264   // Main loop over paths
01265   // --------------------
01266 
01267   //for (int i=1; i< hist_2d->GetNbinsX();i++) 
01268   for (unsigned int i=0; i< fGroupNamePathsPair[mi].second.size(); i++)
01269   { 
01270 
01271     //string hltPathName =  hist_2d->GetXaxis()->GetBinLabel(i);
01272     string hltPathName =  fGroupNamePathsPair[mi].second[i];
01273 
01274     // check if this is hlt path name
01275     //unsigned int pathByIndex = triggerNames.triggerIndex(hltPathName);
01276     unsigned int pathByIndex = triggerNames.triggerIndex(fGroupNamePathsPair[mi].second[i]);
01277     if(pathByIndex >= triggerResults_->size() ) continue;
01278 
01279     // check if its L1 passed
01280     // comment out below but set groupL1Passed to true always
01281     //if(hasL1Passed(hltPathName,triggerNames)) groupL1Passed = true;
01282     //groupL1Passed = true;
01283 
01284     // Fill HLTPassed Matrix and HLTPassFail Matrix
01285     // --------------------------------------------------------
01286 
01287     if(triggerResults_->accept(pathByIndex)){
01288 
01289       groupPassed = true;
01290       //groupL1Passed = true;
01291 
01292 // //       hist_2d->Fill(i,anyBinNumber-1);//binNumber1 = 0 = first filter
01293 // //       hist_2d->Fill(anyBinNumber-1,i);//binNumber1 = 0 = first filter
01294 
01295 // //       hist_2d->Fill(i,groupBinNumber-1);//binNumber1 = 0 = first filter
01296 // //       hist_2d->Fill(groupBinNumber-1,i);//binNumber1 = 0 = first filter
01297 
01298       if (jmsDebug) std::cout << "Trying to get prescales... " << std::endl;
01299   
01300       psValueCombo =  hltConfig_.prescaleValues(iEvent, iSetup, hltPathName);
01301 
01302       if (jmsDebug) std::cout << "Path " << hltPathName
01303                               << "  L1 PS " << psValueCombo.first
01304                               << " and hlt ps " << psValueCombo.second << std::endl;
01305       
01306       if ( (psValueCombo.first > 0) && (psValueCombo.second > 0) ){
01307         hist_1d->Fill(i, psValueCombo.first * psValueCombo.second );//binNumber1 = 0 = first filter
01308       } else {
01309         hist_1d->Fill(i);
01310       }
01311 
01312       //for (int j=1; j< hist_2d->GetNbinsY();j++) 
01313 //*       for (unsigned int j=0; j< fGroupNamePathsPair[mi].second.size(); j++)
01314 //*       { 
01315   
01316 //*         string crossHltPathName =  fGroupNamePathsPair[mi].second[j];
01317   
01318 //*         //unsigned int crosspathByIndex = triggerNames.triggerIndex(hist_2d->GetXaxis()->GetBinLabel(j));
01319 //*         //unsigned int crosspathByIndex = triggerNames.triggerIndex(crossHltPathName);
01320 //*         unsigned int crosspathByIndex = triggerNames.triggerIndex(fGroupNamePathsPair[mi].second[j]);
01321   
01322 //*         if(crosspathByIndex >= triggerResults_->size() ) continue;
01323   
01324 //*         if(triggerResults_->accept(crosspathByIndex)){
01325   
01326 //*           hist_2d->Fill(i,j);//binNumber1 = 0 = first filter
01327   
01328 //*         } // end if j path passed
01329   
01330 //*       } // end for j 
01331   
01332     } // end if i passed
01333     
01334 
01335   } // end for i
01336 
01337   if(groupPassed) {
01338   
01339     rawCountsPerPD[mi]++ ;
01340     //hist_1d->Fill(groupBinNumber-1);//binNumber1 = 0 = first filter
01341     //hist_2d->Fill(groupBinNumber-1,groupBinNumber-1);//binNumber1 = 0 = first filter
01342     //hist_2d->Fill(anyBinNumber-1,groupBinNumber-1);//binNumber1 = 0 = first filter
01343     //hist_2d->Fill(groupBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
01344 
01345   }
01346 
01347   // if the group belongs to stream A
01348   // store groupName and Bool if it has passed 
01349   bool isGroupFromStreamA = false;
01350 
01351   vector<string> streamDatasetNames =  hltConfig_.streamContent("A") ;
01352   for (unsigned int g=0;g<streamDatasetNames.size();g++) {
01353 
01354     if(streamDatasetNames[g] == fGroupNamePathsPair[mi].first) 
01355     {
01356 
01357       isGroupFromStreamA = true;
01358       break;
01359 
01360     }
01361   }
01362 
01363   if(isGroupFromStreamA) groupAcceptPair.push_back(make_pair(fGroupNamePathsPair[mi].first,groupPassed));
01364 
01365 
01366   // L1 groups  - not used anymore
01367 //   string groupL1BinLabel = "HLT_"+fGroupNamePathsPair[mi].first+"_L1_Any";
01368 // //   int groupL1BinNumber = hist_2d->GetXaxis()->FindBin(groupL1BinLabel.c_str());      
01369 
01370 // //  if(groupL1Passed) hist_1d->Fill(groupL1BinNumber-1);//binNumber1 = 0 = first filter
01371 
01372  } // end for mi
01373 
01374 // //   fullPathToME = pathsSummaryFolder_ + "HLT_A_PassPass";
01375 // //   MonitorElement* ME_2d_Stream = dbe_->get(fullPathToME);
01376   fullPathToME = pathsSummaryFolder_ + "HLT_A_Pass_Any";
01377   MonitorElement* ME_1d_Stream = dbe_->get(fullPathToME);
01378 // //  if(!ME_2d_Stream || !ME_1d_Stream) {  
01379   if(!ME_1d_Stream) {  
01380 
01381     LogTrace("TrigResRateMon") << " ME not valid although I gave full path" << endl;
01382     return;
01383 
01384   }
01385   else {
01386 
01387 // //     TH2F * hist_2d_Stream = ME_2d_Stream->getTH2F();
01388     TH1F * hist_1d_Stream = ME_1d_Stream->getTH1F();
01389     
01390     int streamBinNumber = hist_1d_Stream->GetXaxis()->GetLast();
01391 
01392     bool acceptedStreamA = false;
01393     
01394     // loop over groups
01395     for (unsigned int i=0;i<groupAcceptPair.size();i++) {
01396 
01397      if(groupAcceptPair[i].second) {
01398 
01399        acceptedStreamA = true;
01400 
01401 // //        int groupBinNumber_i = hist_2d_Stream->GetXaxis()->FindBin(groupAcceptPair[i].first.c_str()); 
01402        int groupBinNumber_i = hist_1d_Stream->GetXaxis()->FindBin(groupAcceptPair[i].first.c_str()); 
01403        //LogTrace("TrigResRateMon")  << "Accepted group X " << groupAcceptPair[i].first.c_str() << "    bin number " << groupBinNumber_i << endl;
01404        // Robin what about prescale for this one?
01405        hist_1d_Stream->Fill(groupBinNumber_i-1);//binNumber1 = 0 = first filter
01406 // //        hist_2d_Stream->Fill(groupBinNumber_i-1,streamBinNumber-1);//binNumber1 = 0 = first filter
01407 // //        hist_2d_Stream->Fill(streamBinNumber-1,groupBinNumber_i-1);//binNumber1 = 0 = first filter
01408     
01409 // //        for (unsigned int j=0;j<groupAcceptPair.size();j++) {
01410     
01411 
01412 // //         if(groupAcceptPair[j].second) {
01413     
01414 // //           int groupBinNumber_j = hist_2d_Stream->GetXaxis()->FindBin(groupAcceptPair[j].first.c_str()); 
01415 // //           //LogTrace("TrigResRateMon") << "Accepted group Y " << groupAcceptPair[j].first.c_str() << "    bin number " << groupBinNumber_j << endl;
01416 
01417 // //           // fill StreamMatrix(i,j)
01418 // //           hist_2d_Stream->Fill(groupBinNumber_i-1,groupBinNumber_j-1);//binNumber1 = 0 = first filter
01419 
01420 // //         } // end if j-th group accepted
01421     
01422 // //      } // end for j
01423     
01424      } // end if i-th group accepted
01425     
01426     } // end for i
01427 
01428     if(acceptedStreamA) {
01429       
01430 //       hist_2d_Stream->Fill(streamBinNumber-1,streamBinNumber-1);//binNumber1 = 0 = first filter
01431       hist_1d_Stream->Fill(streamBinNumber-1);//binNumber1 = 0 = first filter
01432       
01433       passAny = true ;       //Robin
01434 
01435     }
01436 
01437  } // end else
01438 
01439 }
01440 
01441 
01442 
01443 void TrigResRateMon::fillCountsPerPath(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
01444 
01445 
01446   if (jmsDebug) std::cout << "Filling counts per path" << std::endl;
01447   
01448   if (!triggerResults_.isValid()) {
01449     if (jmsDebug) std::cout << "Trigger Results not valid, sorry" << std::endl;
01450     return;
01451   }
01452   
01453   for (unsigned iName = 0; iName < hltConfig_.size(); iName++) {
01454     if ( triggerResults_ -> accept ( iName ) ){
01455       rawCountsPerPath[iName]++;
01456 
01457       //---Robin
01458       std::string thisName = hltConfig_.triggerName(iName);
01459    
01460       std::pair<int,int> psValueCombo =  hltConfig_.prescaleValues(iEvent, iSetup, thisName);
01461       // if ps OK, 
01462       if ( (psValueCombo.first > 0) && (psValueCombo.second > 0) ){
01463         finalCountsPerPath[iName] += psValueCombo.first * psValueCombo.second;
01464       } else {
01465         finalCountsPerPath[iName]++;
01466       }
01467       //-----------
01468 
01469       if ( (iName == referenceTrigIndex_) && (foundReferenceTrigger_) ) {
01470         // the get the prescales, and increment the PS*counts
01471         std::pair<int,int> psValueCombo =  hltConfig_.prescaleValues(iEvent, iSetup, referenceTrigName_);
01472         // if ps OK, 
01473         if ( (psValueCombo.first > 0) && (psValueCombo.second > 0) ){
01474           referenceTrigCountsPS_ += psValueCombo.first * psValueCombo.second;
01475         } else {
01476           referenceTrigCountsPS_++;
01477         }
01478 
01479       }// end if this is reference
01480     
01481       //Robin
01482       //     std::string thisName = hltConfig_.triggerName(iName);
01483 //       TString checkName(thisName.c_str());
01484 //       if (checkName.Contains("HLT_IsoMu24_v")){
01485 
01486 //         std::pair<int,int> psValueCombo =  hltConfig_.prescaleValues(iEvent, iSetup, thisName);
01487 //         // if ps OK, 
01488 //         if ( (psValueCombo.first > 0) && (psValueCombo.second > 0) ){
01489 //           testTrigCountsPS_ += psValueCombo.first * psValueCombo.second;
01490 //         } else {
01491 //           testTrigCountsPS_++;
01492 //         }
01493 
01494 //       }
01495 
01496     } // end if trig fired         
01497   }// end loop over paths
01498 
01499   // loop over all pds
01500   for (std::vector<DatasetInfo>::iterator iDS = primaryDataSetInformation.begin();
01501        iDS != primaryDataSetInformation.end();
01502        iDS++) {
01503 
01504     // now loop over all paths in the PD
01505     
01506     for (std::vector<std::string>::iterator iPath = iDS->pathNames.begin();
01507          iPath != iDS->pathNames.end();
01508          iPath++){
01509       
01510       unsigned trigIndex = hltConfig_.triggerIndex(*iPath);
01511       // did you pass the trigger?
01512       if ( triggerResults_ -> accept ( trigIndex ) ){
01513 
01514         // ok, you passed, increment the raw counts plot
01515         MonitorElement * thisRawCountsPlot = dbe_->get(iDS->rawCountsPerPathME_Name);
01516         if (thisRawCountsPlot){
01517           iDS->fillRawCountsForPath(thisRawCountsPlot, *iPath);
01518         } else {
01519           if (jmsDebug) std::cout << "sorry but couldn't find this raw counts plot"<< iDS->datasetName << std::endl;
01520         }
01521         
01522 
01523 
01524         // the get the prescales, and increment the PS*counts
01525         std::pair<int,int> psValueCombo =  hltConfig_.prescaleValues(iEvent, iSetup, *iPath);
01526 
01527         // if ps OK, 
01528         if ( (psValueCombo.first > 0) && (psValueCombo.second > 0) ){
01529           iDS->incrementCountsForPath(*iPath, psValueCombo.first*psValueCombo.second);
01530         } else {
01531           iDS->incrementCountsForPath(*iPath);
01532         }
01533         
01534       } 
01535     }// end for each path
01536       
01537   }// end for each pd
01538 
01539   
01540 
01541   
01542 }
01543 
01544 void TrigResRateMon::bookCountsPerPath() {
01545 
01546   
01547   for (unsigned iName = 0; iName < hltConfig_.size(); iName++) {
01548     
01549     rawCountsPerPath.push_back(0);
01550     finalCountsPerPath.push_back(0);  //Robin
01551     
01552   }  
01553 
01554   
01555 }
01556 
01557 
01558 void TrigResRateMon::findReferenceTriggerIndex() {
01559 
01560   if (jmsDebug) std::cout << "Looking for reference trigger " << referenceTrigInput_ << std::endl;
01561   for (unsigned iName = 0; iName < hltConfig_.size(); iName++) {
01562     
01563     std::string thisName = hltConfig_.triggerName(iName);
01564     TString tempThisName(thisName.c_str());
01565     if (tempThisName.Contains(referenceTrigInput_)){
01566       referenceTrigName_ = thisName;
01567       if (jmsDebug) std::cout << "Using Reference trigger " << referenceTrigName_ << std::endl;
01568       referenceTrigIndex_ = iName;
01569       foundReferenceTrigger_ = true;
01570       referenceTrigCountsPS_ = 0;
01571       break;
01572     }// end if name contains substring
01573   }  
01574 
01575   if (!foundReferenceTrigger_) {
01576     std::cout << "Sorry, we couldn't find a trigger like " << referenceTrigInput_ << std::endl;
01577   }
01578   
01579 }
01580 
01581 
01582 void TrigResRateMon::printCountsPerPathThisLumi() {
01583 
01584   std::cout << "===> COUNTS THIS LUMI <===" << std::endl;
01585   
01586   for (unsigned iName = 0; iName < hltConfig_.size() ; iName++) {
01587     std::cout << hltConfig_.triggerName(iName)
01588               << "  =  " << rawCountsPerPath[iName]
01589               << "finalCounts  =  " << finalCountsPerPath[iName]  //Robin
01590               << std::endl;        
01591   }
01592 
01593   std::cout << "+++ Reference trigger " << referenceTrigName_ << " index " << referenceTrigIndex_ << " counts " << referenceTrigCountsPS_ << std::endl;
01594 
01595     // loop over all pds
01596   for (std::vector<DatasetInfo>::const_iterator iDS = primaryDataSetInformation.begin();
01597        iDS != primaryDataSetInformation.end();
01598        iDS++) {
01599 
01600     iDS->printCountsPerPath();
01601 
01602   }
01603 
01604   
01605 }
01606 
01607 void TrigResRateMon::clearCountsPerPath() {
01608 
01609   
01610 //   for (unsigned iName = 0; iName < hltConfig_.size() ; iName++) {
01611     
01612 //     rawCountsPerPath[iName] = 0;
01613 //     finalCountsPerPath[iName] = 0;  //Robin
01614     
01615 //   }
01616 
01617   referenceTrigCountsPS_ = 0 ;
01618   //  testTrigCountsPS_ = 0 ; //Robin
01619   
01620   for (std::vector<DatasetInfo>::iterator iDS = primaryDataSetInformation.begin();
01621        iDS != primaryDataSetInformation.end();
01622        iDS++) {
01623     iDS->clearCountsPerPath();
01624   }
01625 
01626   
01627 }
01628 
01629 void TrigResRateMon::clearLumiAverage() {
01630 
01631   averageInstLumi = 0;
01632     
01633 }
01634 
01635 void TrigResRateMon::addLumiToAverage(double lumi) {
01636 
01637   if (averageInstLumi == 0) {
01638     averageInstLumi = lumi;
01639   } else {
01640     averageInstLumi = (averageInstLumi + lumi) / 2;
01641   }
01642     
01643 }
01644 
01645 void TrigResRateMon::fillXsecPerDataset(const int& lumi) {
01646 
01647   // calculate the reference cross section
01648 
01649   double refTrigXSec = referenceTrigCountsPS_ / ( averageInstLumi * LSsize_);
01650 
01651   //  string fullpath = pathsSummaryFolder_ + "HLT_A_Pass_Any";
01652   //  MonitorElement * meStreamA = dbe_->get(fullpath);
01653   //  if (!meStreamA )  std::cout << "sorry but couldn't get the stream A ME" << std::endl;
01654 
01655   int iPD = 0;
01656 
01657   for (std::vector<DatasetInfo>::iterator iDS = primaryDataSetInformation.begin();
01658        iDS != primaryDataSetInformation.end();
01659        iDS++) {
01660     MonitorElement * thisXsecPlot = dbe_->get(iDS->xsecPerPathME_Name);
01661     MonitorElement * scaledXsecPlot = dbe_->get(iDS->scaledXsecPerPathME_Name);
01662     if (thisXsecPlot){
01663       iDS->fillXsecPlot(thisXsecPlot, averageInstLumi, LSsize_);
01664     } else {
01665       if (jmsDebug) std::cout << "sorry but couldn't find this xsec plot"<< iDS->datasetName << std::endl;
01666     }
01667 
01668     if (scaledXsecPlot){
01669       iDS->fillXsecPlot(scaledXsecPlot, averageInstLumi, LSsize_, refTrigXSec);
01670     } else {
01671       if (jmsDebug) std::cout << "sorry but couldn't find this scaled xsec plot"<< iDS->datasetName << std::endl;
01672     }
01673 
01675     MonitorElement * thisRatePlot = dbe_->get(iDS->ratePerLSME_Name);
01676     if (thisRatePlot) {
01677 
01678       double rate = rawCountsPerPD[iPD] / LSsize_ ;
01679       
01680       TH1F* rateHist = thisRatePlot->getTH1F();
01681       rateHist->SetBinContent(lumi, rate);
01682     }
01683     else {
01684       if (jmsDebug) std::cout << "sorry but couldn't find this rate plot"<< iDS->datasetName << std::endl;
01685     }
01686   
01687     rawCountsPerPD[iPD] = 0 ;
01688     iPD++;
01689   }
01690   
01691 }
01692 
01693 
01694 void TrigResRateMon::setupHltBxPlots()
01695 {
01696 
01697   //pathsSummaryFolder_ = TString("HLT/TrigResults/PathsSummary/");
01698   //dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
01699   dbe_->setCurrentFolder(pathsSummaryFolder_);
01700 
01701   // setup HLT bx plot
01702   unsigned int npaths = hltPathsDiagonal_.size();
01703 
01704   ME_HLT_BX = dbe_->book2D("HLT_bx",
01705                          "HLT counts vs Event bx",
01706                          Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
01707   ME_HLT_CUSTOM_BX = dbe_->book2D("HLT_Custom_bx",
01708                          "HLT counts vs Event bx",
01709                          Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
01710   ME_HLT_BX->setAxisTitle("Bunch Crossing");
01711   ME_HLT_CUSTOM_BX->setAxisTitle("Bunch Crossing");
01712 
01713 
01714   // Set up bin labels on Y axis continuing to cover all npaths
01715   for(unsigned int i = 0; i < npaths; i++){
01716 
01717     ME_HLT_BX->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01718     ME_HLT_CUSTOM_BX->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01719 
01720   }
01721 
01722 
01723 }
01724 
01725 void TrigResRateMon::setupHltLsPlots()
01726 {
01727  
01728   unsigned int npaths = hltPathsDiagonal_.size();
01729 
01730   //pathsSummaryHLTPathsPerLSFolder_ = TString("HLT/TrigResults/PathsSummary/HLT LS/");
01731   //dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_.c_str());
01732   dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_);
01733 
01734   ME_HLTAll_LS  = dbe_->book2D("AllSelectedPaths_count_LS",
01735                     "AllSelectedPaths paths rate [Hz]",
01736                          nLS_, 0, nLS_, npaths+1, -0.5, npaths+1-0.5);
01737   ME_HLTAll_LS->setAxisTitle("Luminosity Section");
01738 
01739   // Set up bin labels on Y axis continuing to cover all npaths
01740   for(unsigned int i = 0; i < npaths; i++){
01741 
01742     ME_HLTAll_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01743 
01744   }
01745 
01746   unsigned int i = npaths;
01747   ME_HLTAll_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, "HLT_Any");
01748 
01749   int nBinsPerLSHisto = 20;
01750   int nLSHistos = npaths/nBinsPerLSHisto;
01751   for (int nh=0;nh<nLSHistos+1;nh++) {
01752 
01753     char name[200];
01754     char title[200];
01755 
01756     sprintf(name, "Group_%d_paths_count_LS",nLSHistos-nh);
01757     sprintf(title, "Group %d, paths rate [Hz]",nLSHistos-nh);
01758 
01759     MonitorElement* tempME  = dbe_->book2D(name,title,
01760                     nLS_, 0, nLS_, nBinsPerLSHisto+3, -0.5, nBinsPerLSHisto+3-0.5);
01761 
01762     tempME->setAxisTitle("LS");
01763 
01764     // Set up bin labels on Y axis continuing to cover all npaths
01765     for(int i = nh*nBinsPerLSHisto; i < (nh+1)*nBinsPerLSHisto; i++){
01766 
01767       if (i == int(npaths)) break;
01768 
01769       int bin;
01770       if(nh == 0){
01771 
01772        bin = i;
01773 
01774       }
01775       else {
01776 
01777        bin = i % nBinsPerLSHisto;
01778 
01779       }
01780 
01781       tempME->setBinLabel(bin+1, hltPathsDiagonal_[i].getPath().c_str(), 2);
01782 
01783     }
01784 
01785     tempME->setBinLabel(nBinsPerLSHisto+3, "HLT_Any", 2);
01786     tempME->setBinLabel(nBinsPerLSHisto+2, "HLT_PhysicsDeclared", 2);
01787 
01788     v_ME_HLTAll_LS.push_back(tempME);
01789 
01790   }
01791 
01792 
01793 }
01794 
01795 //Robin
01796 void TrigResRateMon::bookTestHisto()
01797 {
01798  
01799   unsigned int npaths = testPaths_.size();
01800 
01801   //pathsSummaryHLTPathsPerLSFolder_ = TString("HLT/TrigResults/PathsSummary/HLT LS/");
01802   //dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_.c_str());
01803   //dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_);
01804   dbe_->setCurrentFolder(testPathsFolder_);
01805 
01806   TProfile tempProfile("XsecVsTestPath", "Xsec vs Test Path;;Xsec #mub", npaths, 0.5, npaths+0.5);
01807   meXsecPerTestPath = dbe_->bookProfile("XsecVsTestPath", &tempProfile);
01808 
01809 
01810   for(unsigned int i = 0; i < npaths; i++){
01811     const char* pname = testPaths_[i].c_str() ;
01812     TString pathname = testPaths_[i].c_str() ;
01813     meXsecPerTestPath->getTProfile()->GetXaxis()->SetBinLabel(i+1, pathname );
01814     
01816     char name[200];
01817     char title[200];
01818 
01819     sprintf(name, "path_%s_XsecVsLS",  pname);
01820     sprintf(title, "path_%s_XsecVsLS;LS;Xsec #mub", pname);
01821 
01822     MonitorElement* tempME  = dbe_->book1D(name,title, nLS_, 0, nLS_ );
01823 
01824     tempME->setAxisTitle("LS");
01825 
01826     v_ME_XsecPerLS.push_back(tempME); 
01827 
01828     char name2[200];
01829     char title2[200];
01830 
01831     sprintf(name2, "path_%s_countsVsLS",  pname);
01832     sprintf(title2, "path_%s_countsVsLS;LS;Counts", pname);
01833 
01834     MonitorElement* tempME2  = dbe_->book1D(name2, title2, nLS_, 0, nLS_ );
01835 
01836     tempME2->setAxisTitle("LS");
01837 
01838     v_ME_CountsPerLS.push_back(tempME2); 
01839 
01840   }
01841 
01842   MonitorElement* meXsec1 = dbe_->book1D("Xsec_HLT_IsoMu30_eta2p1", "HLT_IsoMu30_eta2p1 Xsec;Xsec #mub;number of LS", 10, 0.008, 0.012);
01843   MonitorElement* meXsec2 = dbe_->book1D("Xsec_HLT_Ele65_CaloIdVT_TrkIdT", "HLT_Ele65_CaloIdVT_TrkIdT Xsec;Xsec #mub;number of LS", 10, 0.002, 0.0025);
01844   MonitorElement* meXsec3 = dbe_->book1D("Xsec_HLT_MET200", "HLT_MET200 Xsec;Xsec #mub;number of LS", 10, 0.0004, 0.0008);
01845   MonitorElement* meXsec4 = dbe_->book1D("Xsec_HLT_Jet370", "HLT_Jet370 Xsec;Xsec #mub;number of LS", 10, 0.0006, 0.0008);
01846   MonitorElement* meXsec5 = dbe_->book1D("Xsec_HLT_HT600", "HLT_HT600 Xsec;Xsec #mub;number of LS", 10, 0.004, 0.005);
01847   MonitorElement* meXsec6 = dbe_->book1D("Xsec_HLT_Photon26_R9Id_Photon18_R9Id", "HLT_Photon26_R9Id_Photon18_R9Id Xsec;Xsec #mub;number of LS", 10, 0.002, 0.004);
01848   MonitorElement* meXsec7 = dbe_->book1D("Xsec_HLT_IsoMu15_eta2p1_LooseIsoPFTau20", "HLT_IsoMu15_eta2p1_LooseIsoPFTau20 Xsec;Xsec #mub;number of LS", 10, 0.0022, 0.003);
01849   MonitorElement* meXsec8 = dbe_->book1D("Xsec_HLT_PFMHT150", "HLT_PFMHT150 Xsec;Xsec #mub;number of LS", 10, 0.0005, 0.001);
01850   MonitorElement* meXsec9 = dbe_->book1D("Xsec_HLT_Photon90_CaloIdVL_IsoL", "HLT_Photon90_CaloIdVL_IsoL Xsec;Xsec #mub;number of LS", 10, 0.0015, 0.0025);
01851 
01852 
01853   v_ME_Xsec.push_back(meXsec1); 
01854   v_ME_Xsec.push_back(meXsec2); 
01855   v_ME_Xsec.push_back(meXsec3); 
01856   v_ME_Xsec.push_back(meXsec4); 
01857   v_ME_Xsec.push_back(meXsec5); 
01858   v_ME_Xsec.push_back(meXsec6); 
01859   v_ME_Xsec.push_back(meXsec7); 
01860   v_ME_Xsec.push_back(meXsec8); 
01861   v_ME_Xsec.push_back(meXsec9); 
01862 
01863 
01864 }
01865 
01866 void TrigResRateMon::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c){   
01867 
01868    //int lumi = int(lumiSeg.id().luminosityBlock());
01869    //if(lumi < 74 || lumi > 77) fLumiFlag = false;
01870    //else fLumiFlag = true;
01871 
01872   if (jmsDebug) std::cout << "Inside begin lumi block" << std::endl;
01873   
01874   clearCountsPerPath();
01875   clearLumiAverage();
01876   nStream_ = 0 ;
01877   nPass_ = 0 ;
01878 
01879 }
01880 
01881 void TrigResRateMon::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c)
01882 {
01883 
01884    int lumi = int(lumiSeg.id().luminosityBlock());
01885    LogTrace("TrigResRateMon") << " end lumiSection number " << lumi << endl;
01886 
01887 //   countHLTPathHitsEndLumiBlock(lumi);
01888 //   countHLTGroupHitsEndLumiBlock(lumi);
01889   //countHLTGroupL1HitsEndLumiBlock(lumi);
01890   //countHLTGroupBXHitsEndLumiBlock(lumi);
01891 
01892 //   normalizeHLTMatrix();
01893 
01894   //if (jmsDebug) printCountsPerPathThisLumi();
01895   if (jmsDebug) printCountsPerPathThisLumi();
01896   if (jmsDebug) std::cout << "Average lumi is " << averageInstLumi << std::endl;
01897 
01898   if (averageInstLumi > 500) {
01899 //     MonitorElement* reportSumME = dbe_->get("Info/EventInfo/reportSummaryMap" );
01900 //       TH2F * reportSum = reportSumME->getTH2F();
01901 //       float physDecl = reportSum->GetBinContent(lumi,26);
01902       
01903         fillXsecPerDataset(lumi);
01904         
01905         filltestHisto(lumi);  //Robin
01906   }
01907   //Robin-------Diagnostic plots--------
01908 //   TH1F* tempXsecPerLS = meXsecPerLS->getTH1F();
01909 //   double xsec = 1.0;
01910    
01911 //   //  std::cout << "counts for HLT_IsoMu15* is " << testTrigCountsPS_ << std::endl;
01912   
01913 //   if (averageInstLumi > 0) {
01914 //     xsec = testTrigCountsPS_ / (averageInstLumi*LSsize_);
01915 //   }    
01916 //   //  std::cout << "LS is " << lumi << " ; xsec is "<< xsec << std::endl;
01917 //   tempXsecPerLS->SetBinContent(lumi, xsec);
01918   
01919 
01920 //   TH1F* tempXsec = meXsec->getTH1F();
01921 //   tempXsec->Fill(xsec);
01922 
01923 //   TProfile* tempXsecPerIL = meXsecPerIL->getTProfile();
01924 //   tempXsecPerIL->Fill(averageInstLumi,xsec);
01925 
01926   //--------- stream counts and xsec
01927   TH1F* tempCountsStreamPerLS = meCountsStreamPerLS->getTH1F();
01928   //  std::cout << "number of stream counts is " << nStream_ << std::endl;
01929   tempCountsStreamPerLS->SetBinContent(lumi, nStream_);
01930 
01931   // dropped events
01932   MonitorElement* tempDroppedEvents = dbe_->get("SM_SMPS_Stats/droppedEventsCount_HLTTrigerResults DQM Consumer" );
01933   if (tempDroppedEvents) {
01934     TH1F* tempDiagnostic = meDiagnostic->getTH1F();
01935     if (tempDroppedEvents->kind() == MonitorElement::DQM_KIND_INT){
01936       tempDiagnostic->Fill(2);
01937       int64_t tempDroppedCounts =  tempDroppedEvents->getIntValue();
01938       int64_t currentDroppedCounts = tempDroppedCounts - TotalDroppedCounts;
01939       TotalDroppedCounts = tempDroppedCounts ;
01940       TH1F* tempCountsDroppedPerLS = meCountsDroppedPerLS->getTH1F();
01941       tempCountsDroppedPerLS->SetBinContent(lumi, currentDroppedCounts);
01942     }
01943     else     tempDiagnostic->Fill(1);
01944   }
01945   else {
01946     TH1F* tempDiagnostic = meDiagnostic->getTH1F();
01947     tempDiagnostic->Fill(0);
01948   }
01949 
01950   TH1F* tempXsecStreamPerLS = meXsecStreamPerLS->getTH1F();
01951   double xsecStream = 1.0 ;
01952   if (averageInstLumi > 0){
01953     xsecStream = nStream_ / (averageInstLumi*LSsize_);
01954     tempXsecStreamPerLS->SetBinContent(lumi, xsecStream);
01955   }
01956 
01957   TH1F* tempCountsPassPerLS = meCountsPassPerLS->getTH1F();
01958   //  std::cout << "number of passed stream counts is " << nPass_ << std::endl;
01959   tempCountsPassPerLS->SetBinContent(lumi, nPass_);
01960 
01961   //-----------
01962 
01963   // keep track of what you thought the lumi was
01964   // assign an error of 6%
01965   TH1F* tempLumiPerLS = meAverageLumiPerLS->getTH1F();
01966   tempLumiPerLS->SetBinContent(lumi, averageInstLumi);
01967   tempLumiPerLS->SetBinError(lumi, averageInstLumi*0.06);
01968   
01969 
01970 }
01971 
01972 //Robin----
01973 void TrigResRateMon::filltestHisto(const int& lumi) {
01974 
01975   averageInstLumi3LS += averageInstLumi;
01976 
01977   if (lumi%3 == 0){
01978     unsigned int npaths = testPaths_.size();
01979     for(unsigned int i = 0; i < npaths; i++){
01980       TString pathname = testPaths_[i].c_str() ;
01981       pathname += "_v" ;
01982       
01983       int index = 0 ;
01984       int rawCount = 0 ;
01985       int finalCount = 0;
01986       double xsec = 0 ;
01987 
01988       
01989       //find the index for this test trigger path
01990       for (unsigned iName = 0; iName < hltConfig_.size(); iName++) {
01991         
01992         std::string thisName = hltConfig_.triggerName(iName);
01993         TString checkName(thisName.c_str());
01994         if (checkName.Contains(pathname)){
01995           index = iName ;
01996           //    std::cout << "==>test path name is " << checkName << std::endl;
01997           break ;
01998         }
01999       }
02000       
02001       MonitorElement* testME_XsecPerLS = v_ME_XsecPerLS[i];
02002       MonitorElement* testME_rawCountsPerLS = v_ME_CountsPerLS[i];
02003       MonitorElement* testME_Xsec = v_ME_Xsec[i];
02004       //    TProfile tempProfile("XsecVsTestPath", "Xsec vs Test Path", npaths, 0.5, npaths+0.5);
02005       
02006       rawCount = rawCountsPerPath[index];
02007       finalCount = finalCountsPerPath[index];
02008       
02009       testME_rawCountsPerLS->getTH1F()->SetBinContent(lumi, rawCount);
02010       
02011       if (averageInstLumi > 0 ) {
02012         xsec = finalCount/ (averageInstLumi3LS*LSsize_); //averageInstLumi ???
02013         
02014         testME_XsecPerLS->getTH1F()->SetBinContent(lumi, xsec); 
02015         //      testME_rawCountsPerLS->getTH1F()->SetBinContent(lumi, rawCount);
02016         testME_Xsec->getTH1F()->Fill(xsec);    
02017         
02018         meXsecPerTestPath->getTProfile()->Fill(i+1,xsec);    
02019       }
02020     }
02021     
02022     for (unsigned iName = 0; iName < hltConfig_.size() ; iName++) {
02023       
02024       rawCountsPerPath[iName] = 0;
02025       finalCountsPerPath[iName] = 0;  //Robin
02026     }
02027     averageInstLumi3LS = 0 ;
02028 
02029   } // end if 3xLS
02030 
02031 }
02032 //----------
02033 
02034 void TrigResRateMon::countHLTGroupBXHitsEndLumiBlock(const int& lumi)
02035 {
02036 
02037  LogTrace("TrigResRateMon") << " countHLTGroupBXHitsEndLumiBlock() lumiSection number " << lumi << endl;
02038 
02039    if(! ME_HLT_BX) return;
02040 
02041    TH2F * hist_2d_bx = ME_HLT_BX->getTH2F();
02042 
02043    for (std::vector<std::pair<std::string, vector<int> > >::iterator ip = fPathBxTempCountPair.begin(); ip != fPathBxTempCountPair.end(); ++ip) {
02044   
02045     // get the path and its previous count
02046     std::string pathname = ip->first;  
02047     vector<int> prevCount = ip->second;  
02048 
02049     // vector of 5 zeros
02050     vector<int> currCount (5,0);
02051     vector<int> diffCount (5,0);
02052     
02053     // get the current count of path up to now
02054     int pathBin = hist_2d_bx->GetYaxis()->FindBin(pathname.c_str());      
02055 
02056     if(pathBin > hist_2d_bx->GetNbinsY()) {
02057       
02058       LogTrace("TrigResRateMon") << " Cannot find the bin for path " << pathname << endl;
02059       continue;
02060 
02061     }
02062 
02063     for (unsigned int b =0;b<currCount.size();b++) { 
02064 
02065       int bxOffset = b-2;
02066       int bunch = referenceBX_+bxOffset;
02067       if(bunch < 1) bunch += Nbx_ ;
02068       int bxBin = bunch +1; // add one to get the right bin
02069 
02070       
02071       currCount[b] = int(hist_2d_bx->GetBinContent(bxBin, pathBin));  // add one to get the right bin
02072 
02073       LogTrace("TrigResRateMon") << "currCount = " << currCount[b] << endl;
02074 
02075       // count due to prev lumi sec is a difference bw current and previous
02076       diffCount[b] = currCount[b] - prevCount[b];
02077 
02078       LogTrace("TrigResRateMon") << " lumi = " << lumi << "  path " << pathname << "bxOffset = " << bxOffset << "  count = " << diffCount[b] <<  endl;
02079 
02080     } // end for bx b
02081 
02082     // set the counter in the pair to current count
02083     ip->second = currCount;  
02084 
02086    // fill the 2D Group paths' BX count per LS, using currCount
02088    LogTrace("TrigResRateMon")  << "Find " << pathname << endl;
02089 
02090    //check if the path is in this group
02091    //for (unsigned int j=0;j<fGroupNamePathsPair.size();j++) 
02092    for (unsigned int j=0;j<v_ME_Total_BX.size();j++) 
02093    { 
02094 
02095       bool isMember = false;
02096 
02097       LogTrace("TrigResRateMon")  << " ---- Group " << fGroupNamePathsPair[j].first << endl;
02098 
02099       // decide if pathname is member of this group
02100       for (unsigned int k = 0; k<(fGroupNamePathsPair[j].second).size();k++) {
02101 
02102         LogTrace("TrigResRateMon")  << " comparing to " <<  fGroupNamePathsPair[j].second[k] << endl; 
02103 
02104         if(fGroupNamePathsPair[j].second[k] == pathname) {
02105 
02106           isMember = true;
02107           break;
02108 
02109         }
02110 
02111       } // end for k
02112 
02113       if(!isMember) {
02114       
02115       LogTrace("TrigResRateMon")  << "Could not find a group to which the path belongs, path = " << pathname << "    group = " << fGroupNamePathsPair[j].first << endl;
02116       continue;
02117 
02118       }
02119 
02120       MonitorElement* ME_2d = v_ME_Total_BX[j];
02121 
02122       if (! ME_2d) {
02123 
02124         LogDebug("TrigResRateMon") << " cannot find ME_2d for group " << fGroupNamePathsPair[j].first  <<  endl;
02125         continue;
02126 
02127       }
02128 
02129       vector<int> updatedLumiCount(5,0);
02130 
02131       float entireBXWindowUpdatedLumiCount = 0;
02132       
02133       TH2F* hist_All = ME_2d->getTH2F();
02134 
02135       for (unsigned int b = 0; b<diffCount.size();b++) {
02136 
02137         // find the bin
02138         int binNumber = b+1; // add one to get right bin
02139 
02140         // update  the bin content  (must do that since events don't ncessarily come in the order
02141         int currentLumiCount = int(hist_All->GetBinContent(lumi+1,binNumber));
02142         updatedLumiCount[b] = currentLumiCount + diffCount[b];
02143         hist_All->SetBinContent(lumi+1,binNumber,updatedLumiCount[b]);
02144 
02145         entireBXWindowUpdatedLumiCount += updatedLumiCount[b];
02146         
02147       } // end for bx b
02148 
02149       MonitorElement* ME_2d_Norm = v_ME_Total_BX_Norm[j];
02150 
02151       if (! ME_2d_Norm) {
02152 
02153         LogDebug("TrigResRateMon") << " cannot find ME_2d_Norm for group " << fGroupNamePathsPair[j].first  <<  endl;
02154         continue;
02155 
02156       }
02157 
02158       TH2F* hist_All_Norm = ME_2d_Norm->getTH2F();
02159 
02160       for (unsigned int b = 0; b<diffCount.size();b++) {
02161 
02162         // find the bin
02163         int binNumber = b+1; // add one to get right bin
02164 
02165         // update  the bin content  but normalized to the whole columb (BX windw +/- 2)
02166         hist_All_Norm->SetBinContent(lumi+1,binNumber,float(updatedLumiCount[b])/entireBXWindowUpdatedLumiCount);
02167 
02168       } // end for bx b
02169     
02170     } // end for group j
02171     
02172   } // end for ip
02173 
02174 }
02175 
02176 void TrigResRateMon::countHLTGroupL1HitsEndLumiBlock(const int& lumi)
02177 {
02178 
02179  LogTrace("TrigResRateMon") << " countHLTGroupL1HitsEndLumiBlock() lumiSection number " << lumi << endl;
02180 
02181  for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
02182 
02183    // get the count of path up to now
02184    string fullPathToME = pathsSummaryFolder_ +  "HLT_" + fGroupNamePathsPair[i].first+ "_Pass_Any";
02185    MonitorElement* ME_1d = dbe_->get(fullPathToME);
02186 
02187    if(! ME_1d) {
02188 
02189      LogTrace("TrigResRateMon") << " could not find 1d matrix " << fullPathToME << endl;
02190 
02191      continue;
02192 
02193    }
02194 
02195    LogTrace("TrigResRateMon") << " Looking in histogram "  << fullPathToME << endl;
02196 
02197    TH1F * hist_1d = ME_1d->getTH1F();
02198 
02199    for (std::vector<std::pair<std::string, float> >::iterator ip = fGroupL1TempCountPair.begin(); ip != fGroupL1TempCountPair.end(); ++ip) {
02200   
02201     // get the path and its previous count
02202     string pathname = ip->first;  
02203     float prevCount = ip->second;  
02204 
02205     string binLabel = "HLT_"+pathname+"_L1_Any";
02206     
02207     LogTrace("TrigResRateMon") << " Looking for binLabel = " << binLabel <<  endl;
02208     // get the current count of path up to now
02209     int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());      
02210 
02211     LogTrace("TrigResRateMon") << " pathBin = " << pathBin <<  "  out of histogram total number of bins " << hist_1d->GetNbinsX() <<  endl;
02212     if(pathBin == -1) {
02213       
02214       LogTrace("TrigResRateMon") << " Cannot find the bin for path " << pathname << endl;
02215       continue;
02216 
02217     }
02218 
02219     float currCount = hist_1d->GetBinContent(pathBin)/LSsize_;
02220 
02221     // count due to prev lumi sec is a difference bw current and previous
02222     float diffCount = currCount - prevCount;
02223 
02224     LogTrace("TrigResRateMon") << " lumi = " << lumi << "  path " << pathname << "  count " << diffCount <<  endl;
02225 
02226     // set the counter in the pair to current count
02227     ip->second = currCount;  
02228 
02229 
02231     // fill the 1D individual path count per LS
02233     string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_L1_Total_LS";
02234     MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
02235     if ( ME_1d) { 
02236 
02237       // update  the bin content  (must do that since events don't ncessarily come in the order
02238       float currentLumiCount = ME_1d->getTH1()->GetBinContent(lumi+1);
02239       float updatedLumiCount = currentLumiCount + diffCount;
02240       ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
02241 
02242     }
02243     else {
02244 
02245       LogDebug("TrigResRateMon") << " cannot find ME " << fullPathToME_count  <<  endl;
02246 
02247     }
02248 
02249    } // end for ip
02250 
02251  } // end for i
02252 
02253 }
02254 
02255 
02256 void TrigResRateMon::countHLTGroupHitsEndLumiBlock(const int& lumi)
02257 {
02258 
02259  LogTrace("TrigResRateMon") << " countHLTGroupHitsEndLumiBlock() lumiSection number " << lumi << endl;
02260  for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
02261 
02262    // get the count of path up to now
02263    string fullPathToME = pathsSummaryFolder_ + "HLT_" + fGroupNamePathsPair[i].first + "_Pass_Any";
02264    MonitorElement* ME_1d = dbe_->get(fullPathToME);
02265 
02266    if(! ME_1d) {
02267 
02268      LogTrace("TrigResRateMon") << " could not find 1d matrix " << fullPathToME << endl;
02269 
02270      continue;
02271 
02272    }
02273 
02274    LogTrace("TrigResRateMon") << " Looking in histogram "  << fullPathToME << endl;
02275 
02276    TH1F * hist_1d = ME_1d->getTH1F();
02277 
02278    for (std::vector<std::pair<std::string, float> >::iterator ip = fGroupTempCountPair.begin(); ip != fGroupTempCountPair.end(); ++ip) {
02279   
02280     // get the path and its previous count
02281     string pathname = ip->first;  
02282     float prevCount = ip->second;  
02283 
02284     string binLabel = "Total "+pathname;
02285     
02286     LogTrace("TrigResRateMon") << " Looking for binLabel = " << binLabel <<  endl;
02287 
02288     // get the current count of path up to now
02289     int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());      
02290 
02291     LogTrace("TrigResRateMon") << " pathBin = " << pathBin <<  "  out of histogram total number of bins " << hist_1d->GetNbinsX() <<  endl;
02292     if(pathBin == -1) {
02293       
02294       binLabel = pathname;
02295       int alternativePathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());      
02296 
02297       if(alternativePathBin == -1) {
02298 
02299         LogTrace("TrigResRateMon") << " Cannot find the bin for path " << pathname << endl;
02300 
02301         continue;
02302 
02303       }
02304       else {
02305 
02306         pathBin = alternativePathBin;
02307 
02308       }
02309 
02310     }
02311 
02312     float currCount = hist_1d->GetBinContent(pathBin)/LSsize_;
02313 
02314     // count due to prev lumi sec is a difference bw current and previous
02315     float diffCount = currCount - prevCount;
02316 
02317     LogTrace("TrigResRateMon") << " lumi = " << lumi << "  path " << pathname << "  diffCount " << diffCount <<  endl;
02318 
02319     // set the counter in the pair to current count
02320     ip->second = currCount;  
02321 
02323     // fill the 1D and 2D gruop and 2d_Stream_A count per LS
02325     string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_Total_LS";
02326     MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
02327 
02328     string fullPathToME_2D_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_LS";
02329     MonitorElement* ME_2d = dbe_->get(fullPathToME_2D_count);
02330 
02331     string fullPathToME_Stream_A_2D_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_A_LS";
02332     MonitorElement* ME_Stream_A_2d = dbe_->get(fullPathToME_Stream_A_2D_count);
02333 
02334     if ( ME_1d && ME_2d && ME_Stream_A_2d) { 
02335 
02336       // update  the bin content  (must do that since events don't ncessarily come in the order
02337 
02338       float currentLumiCount = ME_1d->getTH1()->GetBinContent(lumi+1);
02339       float updatedLumiCount = currentLumiCount + diffCount;
02340       ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
02341 
02342       string groupBinLabel = "Total " + fGroupNamePathsPair[i].first;
02343       int groupBin = ME_2d->getTH2F()->GetYaxis()->FindBin(groupBinLabel.c_str());      
02344       if(groupBin != -1) ME_2d->getTH2F()->SetBinContent(lumi+1,groupBin,updatedLumiCount);
02345       
02346       // this is to deal with Stream A and bins with names of PDs
02347       groupBinLabel = fGroupNamePathsPair[i].first;
02348       groupBin = ME_Stream_A_2d->getTH2F()->GetYaxis()->FindBin(groupBinLabel.c_str());      
02349       if(groupBin != -1) ME_Stream_A_2d->getTH2F()->SetBinContent(lumi+1,groupBin,updatedLumiCount);
02350 
02351     }
02352     else {
02353 
02354       LogDebug("TrigResRateMon") << " cannot find ME " << fullPathToME_count  <<  endl;
02355 
02356     }
02357 
02358    } // end for ip
02359 
02360  } // end for i
02361 
02362 }
02363 
02364 
02365 void TrigResRateMon::countHLTPathHitsEndLumiBlock(const int& lumi)
02366 {
02367 
02368    LogTrace("TrigResRateMon") << " countHLTPathHitsEndLumiBlock() lumiSection number " << lumi << endl;
02369     // get the count of path up to now
02370    string fullPathToME = pathsSummaryFolder_ + "HLT_AllSelectedPaths_PassPass";
02371    MonitorElement* ME_2d = dbe_->get(fullPathToME);
02372 
02373    if(! ME_2d) {
02374 
02375      LogTrace("TrigResRateMon") << " could not fine 2d matrix " << fullPathToME << endl;
02376 
02377      return;
02378 
02379    }
02380 
02381    TH2F * hist_2d = ME_2d->getTH2F();
02382 
02383    for (std::vector<std::pair<std::string, float> >::iterator ip = fPathTempCountPair.begin(); ip != fPathTempCountPair.end(); ++ip) {
02384   
02385     // get the path and its previous count
02386     std::string pathname = ip->first;  
02387     float prevCount = ip->second;  
02388     
02389     // get the current count of path up to now
02390     float pathBin = hist_2d->GetXaxis()->FindBin(pathname.c_str());      
02391 
02392     if(pathBin > hist_2d->GetNbinsX()) {
02393       
02394       LogTrace("TrigResRateMon") << " Cannot find the bin for path " << pathname << endl;
02395       continue;
02396 
02397     }
02398 
02399     float currCount = hist_2d->GetBinContent(pathBin, pathBin)/LSsize_;
02400 
02401     // count due to prev lumi sec is a difference bw current and previous
02402     float diffCount = currCount - prevCount;
02403 
02404     LogTrace("TrigResRateMon") << " lumi = " << lumi << "  path " << pathname << "  count " << diffCount <<  endl;
02405 
02406     // set the counter in the pair to current count
02407     ip->second = currCount;  
02408 
02410     // fill the 2D All paths' count per LS
02412     if ( ME_HLTAll_LS) {
02413 
02414       TH2F* hist_All = ME_HLTAll_LS->getTH2F();
02415 
02416       // find the bin
02417       int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
02418       
02419       // update  the bin content  (must do that since events don't ncessarily come in the order
02420       float currentLumiCount = hist_All->GetBinContent(lumi+1,pathBinNumber);
02421       float updatedLumiCount = currentLumiCount + diffCount;
02422       hist_All->SetBinContent(lumi+1,pathBinNumber,updatedLumiCount);
02423     
02424     }
02425     else {
02426 
02427       LogDebug("TrigResRateMon") << " cannot find ME_HLTAll_LS" <<  endl;
02428 
02429     }
02430     
02431     for (unsigned int i=0 ; i< v_ME_HLTAll_LS.size(); i++) {  
02432       
02433       MonitorElement* tempME = v_ME_HLTAll_LS[i];
02434 
02435       if ( tempME ) {
02436   
02437         TH2F* hist_All = tempME->getTH2F();
02438   
02439         // find the bin
02440         int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
02441         // update  the bin content  (must do that since events don't ncessarily come in the order
02442         float currentLumiCount = hist_All->GetBinContent(lumi+1,pathBinNumber);
02443         float updatedLumiCount = currentLumiCount + diffCount;
02444         hist_All->SetBinContent(lumi+1,pathBinNumber,updatedLumiCount);
02445       
02446       }
02447       else {
02448   
02449         LogDebug("TrigResRateMon") << " cannot find tempME " <<  endl;
02450   
02451       }
02452 
02453     }
02454 
02455 
02457     // fill the 1D individual path count per LS
02459     string fullPathToME_count = pathsIndividualHLTPathsPerLSFolder_ + pathname + "_count_per_LS";
02460     MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
02461     if ( ME_1d) { 
02462 
02463       // update  the bin content  (must do that since events don't ncessarily come in the order
02464       float currentLumiCount = ME_1d->getTH1()->GetBinContent(lumi+1);
02465       float updatedLumiCount = currentLumiCount + diffCount;
02466       ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
02467 
02468     }
02469     else {
02470 
02471       LogDebug("TrigResRateMon") << " cannot find ME " << fullPathToME_count  <<  endl;
02472 
02473     }
02474 
02475   } // end for ip
02476 
02477 }
02478 
02479 int TrigResRateMon::getTriggerTypeParsePathName(const string& pathname)
02480 {
02481 
02482    int objectType = 0;
02483 
02484          if (pathname.find("MET") != std::string::npos) 
02485            objectType = trigger::TriggerMET;    
02486          if (pathname.find("SumET") != std::string::npos) 
02487            objectType = trigger::TriggerTET;    
02488          if (pathname.find("HT") != std::string::npos) 
02489            objectType = trigger::TriggerTET;    
02490          if (pathname.find("Jet") != std::string::npos) 
02491            objectType = trigger::TriggerJet;    
02492          if (pathname.find("Mu") != std::string::npos)
02493            objectType = trigger::TriggerMuon;    
02494          if (pathname.find("Ele") != std::string::npos) 
02495            objectType = trigger::TriggerElectron;    
02496          if (pathname.find("Photon") != std::string::npos) 
02497            objectType = trigger::TriggerPhoton;    
02498          if (pathname.find("EG") != std::string::npos) 
02499            objectType = trigger::TriggerPhoton;    
02500          if (pathname.find("Tau") != std::string::npos) 
02501            objectType = trigger::TriggerTau;    
02502          if (pathname.find("IsoTrack") != std::string::npos) 
02503            objectType = trigger::TriggerTrack;    
02504          if (pathname.find("BTag") != std::string::npos) 
02505            objectType = trigger::TriggerBJet;    
02506 
02507    return objectType;
02508 }
02509 
02510 const string TrigResRateMon::getL1ConditionModuleName(const string& pathname)
02511 {
02512 
02513   // find L1 condition for numpath with numpath objecttype 
02514   // find PSet for L1 global seed for numpath, 
02515   // list module labels for numpath
02516   string l1pathname = "dummy";
02517 
02518   vector<string> numpathmodules = hltConfig_.moduleLabels(pathname);
02519 
02520   for(vector<string>::iterator numpathmodule = numpathmodules.begin();
02521   numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
02522 
02523     if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed") {
02524 
02525      l1pathname = *numpathmodule;
02526      break; 
02527 
02528     }
02529 
02530   } // end for
02531 
02532   return l1pathname;
02533 
02534 }
02535 
02536 
02537 bool TrigResRateMon::hasL1Passed(const string& pathname, const edm::TriggerNames & triggerNames)
02538 {
02539   
02540   bool rc = false;
02541   int l1ModuleIndex = 999;
02542   // --------------------
02543   for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) { 
02544 
02545     if(v->getPath() == pathname ) l1ModuleIndex = v->getL1ModuleIndex();
02546 
02547   }
02548 
02549   unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
02550   if(pathByIndex >= triggerResults_->size() ) return rc; // path is not in the menu
02551 
02552   // get index of the last module that issued the decision
02553   int lastModule = triggerResults_->index(pathByIndex);
02554 
02555   // if L1 passed, then it must not be the module that 
02556   // issued the last decision
02557   rc = (l1ModuleIndex < lastModule);
02558 
02559   return rc;
02560 
02561 }
02562 
02563 bool TrigResRateMon::hasHLTPassed(const string& pathname, const edm::TriggerNames & triggerNames)
02564 {
02565   
02566   bool rc = false;
02567 
02568   unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
02569   if(pathByIndex >= triggerResults_->size() ) return rc; // path is not in the menu
02570 
02571   rc  = triggerResults_->accept(pathByIndex);
02572   return rc;
02573 
02574 }
02575 
02576 
02577 int TrigResRateMon::getThresholdFromName(const string & name)
02578 {
02579   
02580   std::string pathname = name;
02581   //cout << "----------------------------------------------" << endl;
02582   //cout << pathname << endl;
02583 
02584   //remove "L1" substr
02585   if(pathname.find("L1") != std::string::npos) pathname.replace(pathname.find("L1"),2,"");
02586   //remove "L2" substr
02587   if(pathname.find("L2") != std::string::npos) pathname.replace(pathname.find("L2"),2,"");
02588   //remove "8E29" substr
02589   if(pathname.find("8E29") != std::string::npos) pathname.replace(pathname.find("8E29"),4,"");
02590 
02591   int digitLocation=0;
02592   for (unsigned int i=0; i < pathname.length(); i++)
02593   {
02594      if (isdigit(pathname.at(i))) {
02595 
02596        digitLocation = i;
02597        break;
02598 
02599      }
02600   }
02601 
02602   // get the string from the location of the first digit to the end
02603   string hltThresholdString = pathname.substr(digitLocation);
02604 
02605   int hltThreshold = 0;
02606 
02607   // get intiger at the begining of the string
02608   sscanf (hltThresholdString.c_str(),"%d%*s",&hltThreshold);
02609   //printf ("%s -> %s -> %d\n",pathname.c_str(), hltThresholdString.c_str(), hltThreshold);
02610 
02611   return hltThreshold;
02612 
02613 }
02614 
02615 void TrigResRateMon::normalizeHLTMatrix() {
02616 
02617   string fullPathToME; 
02618 
02619   // again, get hold of dataset names 
02620   //vector<string> datasetNames =  hltConfig_.datasetNames() ;
02621   vector<string> datasetNames =  hltConfig_.streamContent("A") ;
02622 
02623   // fill vectors of MEs needed in  normalization
02624   for (unsigned int i=0;i<datasetNames.size();i++) {
02625 
02626     fullPathToME = pathsSummaryFolder_ +"HLT_"+datasetNames[i]+"_PassPass";
02627     v_ME_HLTPassPass.push_back( dbe_->get(fullPathToME));
02628 
02629     fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_"+datasetNames[i]+"_PassPass_Normalized";
02630     v_ME_HLTPassPass_Normalized.push_back( dbe_->get(fullPathToME));
02631 
02632     fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_"+datasetNames[i]+"_Pass_Normalized_Any";
02633     v_ME_HLTPass_Normalized_Any.push_back( dbe_->get(fullPathToME));
02634 
02635   }
02636 
02637   // add stream MEs
02638   fullPathToME = pathsSummaryFolder_ +"HLT_A_PassPass";
02639   v_ME_HLTPassPass.push_back( dbe_->get(fullPathToME));
02640 
02641   fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_A_PassPass_Normalized";
02642   v_ME_HLTPassPass_Normalized.push_back( dbe_->get(fullPathToME));
02643 
02644   fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_A_Pass_Normalized_Any";
02645   v_ME_HLTPass_Normalized_Any.push_back( dbe_->get(fullPathToME));
02646 
02647   for (unsigned int i =0;i<v_ME_HLTPassPass.size();i++) {
02648 
02649     MonitorElement* ME_HLTPassPass = v_ME_HLTPassPass[i]; 
02650     MonitorElement* ME_HLTPassPass_Normalized = v_ME_HLTPassPass_Normalized[i]; 
02651     MonitorElement* ME_HLTPass_Normalized_Any = v_ME_HLTPass_Normalized_Any[i]; 
02652 
02653     if(!ME_HLTPassPass || !ME_HLTPassPass_Normalized || !ME_HLTPass_Normalized_Any) return;
02654 
02655     float passCount = 0;
02656     unsigned int nBinsX = ME_HLTPassPass->getTH2F()->GetNbinsX();
02657     unsigned int nBinsY = ME_HLTPassPass->getTH2F()->GetNbinsY();
02658 
02659     for(unsigned int binX = 0; binX < nBinsX+1; binX++) {
02660        
02661       passCount = ME_HLTPassPass->getTH2F()->GetBinContent(binX,binX);
02662 
02663 
02664       for(unsigned int binY = 0; binY < nBinsY+1; binY++) {
02665 
02666         if(passCount != 0) {
02667 
02668           // normalize each bin to number of passCount
02669           float normalizedBinContentPassPass = (ME_HLTPassPass->getTH2F()->GetBinContent(binX,binY))/passCount;
02670           //float normalizedBinContentPassFail = (ME_HLTPassFail_->getTH2F()->GetBinContent(binX,binY))/passCount;
02671 
02672           ME_HLTPassPass_Normalized->getTH2F()->SetBinContent(binX,binY,normalizedBinContentPassPass);
02673           //ME_HLTPassFail_Normalized_->getTH2F()->SetBinContent(binX,binY,normalizedBinContentPassFail);
02674 
02675           if(binX == nBinsX) {
02676 
02677             ME_HLTPass_Normalized_Any->getTH1F()->SetBinContent(binY,normalizedBinContentPassPass);
02678 
02679           }
02680 
02681         }
02682         else {
02683 
02684           ME_HLTPassPass_Normalized->getTH2F()->SetBinContent(binX,binY,0);
02685           //ME_HLTPassFail_Normalized_->getTH2F()->SetBinContent(binX,binY,0);
02686 
02687         } // end if else
02688      
02689       } // end for binY
02690 
02691     } // end for binX
02692   
02693   } // end for i
02694 
02695 }