CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQM/HLTEvF/plugins/FourVectorHLTOnline.cc

Go to the documentation of this file.
00001 // $Id: FourVectorHLTOnline.cc,v 1.35 2010/08/26 16:45:51 rekovic Exp $
00002 // See header file for information. 
00003 #include "TMath.h"
00004 #include "DQM/HLTEvF/interface/FourVectorHLTOnline.h"
00005 #include "FWCore/Common/interface/TriggerNames.h"
00006 
00007 #include <map>
00008 #include <utility>
00009 
00010 
00011 using namespace edm;
00012 using namespace trigger;
00013 using namespace std;
00014 
00015 FourVectorHLTOnline::FourVectorHLTOnline(const edm::ParameterSet& iConfig):
00016   resetMe_(true),  currentRun_(-99)
00017 {
00018 
00019   LogDebug("FourVectorHLTOnline") << "constructor...." ;
00020 
00021   dbe_ = Service < DQMStore > ().operator->();
00022   if ( ! dbe_ ) {
00023     LogInfo("FourVectorHLTOnline") << "unabel to get DQMStore service?";
00024   }
00025   if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
00026     dbe_->setVerbose(0);
00027   }
00028   
00029   dirname_ = iConfig.getUntrackedParameter("dirname", std::string("HLT/FourVector/"));
00030   //dirname_ +=  iConfig.getParameter<std::string>("@module_label");
00031   
00032   if (dbe_ != 0 ) {
00033     dbe_->setCurrentFolder(dirname_);
00034   }
00035   
00036   processname_ = iConfig.getParameter<std::string>("processname");
00037   fCustomBXPath = iConfig.getUntrackedParameter<std::string>("customBXPath", std::string("HLT_MinBiasBSC"));
00038 
00039   referenceBX_ = iConfig.getUntrackedParameter<unsigned int>("referenceBX",51);
00040   Nbx_ = iConfig.getUntrackedParameter<unsigned int>("Nbx",3564);
00041 
00042   // plotting paramters
00043   ptMin_ = iConfig.getUntrackedParameter<double>("ptMin",0.);
00044   ptMax_ = iConfig.getUntrackedParameter<double>("ptMax",1000.);
00045   nBins_ = iConfig.getUntrackedParameter<unsigned int>("Nbins",20);
00046   nBinsOneOverEt_ = iConfig.getUntrackedParameter<unsigned int>("NbinsOneOverEt",10000);
00047   nLS_   = iConfig.getUntrackedParameter<unsigned int>("NLuminositySegments",10);
00048 
00049   
00050   plotAll_ = iConfig.getUntrackedParameter<bool>("plotAll", false);
00051      // this is the list of paths to look at.
00052   std::vector<edm::ParameterSet> paths = 
00053   iConfig.getParameter<std::vector<edm::ParameterSet> >("paths");
00054 
00055   for(std::vector<edm::ParameterSet>::iterator pathconf = paths.begin() ; pathconf != paths.end(); pathconf++) {
00056 
00057     //std::pair<std::string, std::string> custompathnamepair;
00058     //custompathnamepair.first =pathconf->getParameter<std::string>("pathname"); 
00059     //custompathnamepair.second = pathconf->getParameter<std::string>("denompathname");   
00060     //custompathnamepairs_.push_back(custompathnamepair);
00061     custompathnamepairs_.push_back(
00062         make_pair(
00063           pathconf->getParameter<std::string>("pathname"),
00064           pathconf->getParameter<std::string>("denompathname")
00065         )
00066     );
00067 
00068   }
00069 
00070   if (hltPaths_.size() > 0)
00071   {
00072       // book a histogram of scalers
00073      scalersSelect = dbe_->book1D("selectedScalers","Selected Scalers", hltPaths_.size(), 0.0, (double)hltPaths_.size());
00074 
00075   }
00076 
00077   triggerSummaryLabel_ = iConfig.getParameter<edm::InputTag>("triggerSummaryLabel");
00078   triggerResultsLabel_ = iConfig.getParameter<edm::InputTag>("triggerResultsLabel");
00079   muonRecoCollectionName_ = iConfig.getUntrackedParameter("muonRecoCollectionName", std::string("muons"));
00080 
00081   electronEtaMax_ = iConfig.getUntrackedParameter<double>("electronEtaMax",2.5);
00082   electronEtMin_ = iConfig.getUntrackedParameter<double>("electronEtMin",3.0);
00083   electronDRMatch_  =iConfig.getUntrackedParameter<double>("electronDRMatch",0.3); 
00084 
00085   muonEtaMax_ = iConfig.getUntrackedParameter<double>("muonEtaMax",2.1);
00086   muonEtMin_ = iConfig.getUntrackedParameter<double>("muonEtMin",3.0);
00087   muonDRMatch_  =iConfig.getUntrackedParameter<double>("muonDRMatch",0.3); 
00088 
00089   tauEtaMax_ = iConfig.getUntrackedParameter<double>("tauEtaMax",2.5);
00090   tauEtMin_ = iConfig.getUntrackedParameter<double>("tauEtMin",3.0);
00091   tauDRMatch_  =iConfig.getUntrackedParameter<double>("tauDRMatch",0.3); 
00092 
00093   jetEtaMax_ = iConfig.getUntrackedParameter<double>("jetEtaMax",5.0);
00094   jetEtMin_ = iConfig.getUntrackedParameter<double>("jetEtMin",10.0);
00095   jetDRMatch_  =iConfig.getUntrackedParameter<double>("jetDRMatch",0.3); 
00096 
00097   bjetEtaMax_ = iConfig.getUntrackedParameter<double>("bjetEtaMax",2.5);
00098   bjetEtMin_ = iConfig.getUntrackedParameter<double>("bjetEtMin",10.0);
00099   bjetDRMatch_  =iConfig.getUntrackedParameter<double>("bjetDRMatch",0.3); 
00100 
00101   photonEtaMax_ = iConfig.getUntrackedParameter<double>("photonEtaMax",2.5);
00102   photonEtMin_ = iConfig.getUntrackedParameter<double>("photonEtMin",3.0);
00103   photonDRMatch_  =iConfig.getUntrackedParameter<double>("photonDRMatch",0.3); 
00104 
00105   trackEtaMax_ = iConfig.getUntrackedParameter<double>("trackEtaMax",2.5);
00106   trackEtMin_ = iConfig.getUntrackedParameter<double>("trackEtMin",3.0);
00107   trackDRMatch_  =iConfig.getUntrackedParameter<double>("trackDRMatch",0.3); 
00108 
00109   metEtaMax_ = iConfig.getUntrackedParameter<double>("metEtaMax",5);
00110   metMin_ = iConfig.getUntrackedParameter<double>("metMin",10.0);
00111   metDRMatch_  =iConfig.getUntrackedParameter<double>("metDRMatch",0.5); 
00112 
00113   htEtaMax_ = iConfig.getUntrackedParameter<double>("htEtaMax",5);
00114   htMin_ = iConfig.getUntrackedParameter<double>("htMin",10.0);
00115   htDRMatch_  =iConfig.getUntrackedParameter<double>("htDRMatch",0.5); 
00116 
00117   sumEtMin_ = iConfig.getUntrackedParameter<double>("sumEtMin",10.0);
00118 
00119   specialPaths_ = iConfig.getParameter<std::vector<std::string > >("SpecialPaths");
00120 
00121   pathsSummaryFolder_ = iConfig.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/FourVector/PathsSummary/"));
00122   pathsSummaryHLTCorrelationsFolder_ = iConfig.getUntrackedParameter ("hltCorrelationsFolder",std::string("HLT/FourVector/PathsSummary/HLT Correlations/"));
00123   pathsSummaryFilterCountsFolder_ = iConfig.getUntrackedParameter ("filterCountsFolder",std::string("HLT/FourVector/PathsSummary/Filters Counts/"));
00124 
00125   pathsSummaryHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("individualPathsPerLSFolder",std::string("HLT/FourVector/PathsSummary/HLT LS/"));
00126   pathsIndividualHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("individualPathsPerLSFolder",std::string("HLT/FourVector/PathsSummary/HLT LS/Paths/"));
00127   pathsSummaryHLTPathsPerBXFolder_ = iConfig.getUntrackedParameter ("individualPathsPerBXFolder",std::string("HLT/FourVector/PathsSummary/HLT BX/"));
00128 
00129   fLumiFlag = true;
00130   ME_HLTAll_LS_ = NULL;
00131   ME_HLT_BX_ = NULL;
00132   ME_HLT_CUSTOM_BX_ = NULL;
00133   
00134 }
00135 
00136 
00137 FourVectorHLTOnline::~FourVectorHLTOnline()
00138 {
00139  
00140    // do anything here that needs to be done at desctruction time
00141    // (e.g. close files, deallocate resources etc.)
00142 
00143 }
00144 
00145 
00146 //
00147 // member functions
00148 //
00149 
00150 // ------------ method called to for each event  ------------
00151 void
00152 FourVectorHLTOnline::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00153 {
00154 
00155   //if(! fLumiFlag ) return;
00156 
00157   using namespace edm;
00158   using namespace trigger;
00159   ++nev_;
00160   LogDebug("FourVectorHLTOnline")<< " analyze...." ;
00161 
00162 
00163   
00164   /*
00165   Handle<GenParticleCollection> genParticles;
00166   iEvent.getByLabel("genParticles", genParticles);
00167   if(!genParticles.isValid()) { 
00168     edm::LogInfo("FourVectorHLTOnline") << "genParticles not found, "
00169       "skipping event"; 
00170     return;
00171   }
00172 
00173   Handle<GenJetCollection> genJets;
00174   iEvent.getByLabel("iterativeCone5GenJets",genJets);
00175   if(!genJets.isValid()) { 
00176     edm::LogInfo("FourVectorHLTOnline") << "genJets not found, "
00177       "skipping event"; 
00178     return;
00179   }
00180 
00181   Handle<GenMETCollection> genMets;
00182   iEvent.getByLabel("genMetTrue",genMets);
00183   if(!genMets.isValid()) { 
00184     edm::LogInfo("FourVectorHLTOnline") << "genMets not found, "
00185       "skipping event"; 
00186     return;
00187   }
00188   */
00189 
00190   edm::Handle<TriggerResults> triggerResults;
00191   iEvent.getByLabel(triggerResultsLabel_,triggerResults);
00192   if(!triggerResults.isValid()) {
00193     edm::InputTag triggerResultsLabelFU(triggerResultsLabel_.label(),triggerResultsLabel_.instance(), "FU");
00194    iEvent.getByLabel(triggerResultsLabelFU,triggerResults);
00195   if(!triggerResults.isValid()) {
00196     edm::LogInfo("FourVectorHLTOnline") << "TriggerResults not found, "
00197       "skipping event"; 
00198     return;
00199    }
00200   }
00201   triggerResults_ = triggerResults;
00202   const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
00203   int npath = triggerResults->size();
00204 
00205   iEvent.getByLabel(triggerSummaryLabel_,fTriggerObj); 
00206   if(!fTriggerObj.isValid()) {
00207 
00208     edm::InputTag triggerSummaryLabelFU(triggerSummaryLabel_.label(),triggerSummaryLabel_.instance(), "FU");
00209     iEvent.getByLabel(triggerSummaryLabelFU,fTriggerObj);
00210 
00211     if(!fTriggerObj.isValid()) {
00212 
00213       edm::LogInfo("FourVectorHLTOnline") << "TriggerEvent not found, " "skipping event"; 
00214       return;
00215 
00216     }
00217 
00218   }
00219 
00220   edm::Handle<TriggerResults> muonHandle;
00221   iEvent.getByLabel(muonRecoCollectionName_,muonHandle);
00222   if(!muonHandle.isValid()) { 
00223 
00224     edm::LogInfo("FourVectorHLTOnline") << "muonHandle not found, ";
00225     //  "skipping event"; 
00226     //  return;
00227 
00228   }
00229 
00230 
00231   edm::Handle<TriggerResults> gsfElectrons;
00232   iEvent.getByLabel("gsfElectrons",gsfElectrons); 
00233   if(!gsfElectrons.isValid()) 
00234     edm::LogInfo("FourVectorHLTOnline") << "gsfElectrons not found, ";
00235 
00236   edm::Handle<TriggerResults> tauHandle;
00237   iEvent.getByLabel("caloRecoTauProducer",tauHandle);
00238   if(!tauHandle.isValid()) 
00239     edm::LogInfo("FourVectorHLTOnline") << "tauHandle not found, ";
00240 
00241   edm::Handle<TriggerResults> jetHandle;
00242   iEvent.getByLabel("iterativeCone5CaloJets",jetHandle);
00243   if(!jetHandle.isValid()) 
00244     edm::LogInfo("FourVectorHLTOnline") << "jetHandle not found, ";
00245  
00246    // Get b tag information
00247  edm::Handle<TriggerResults> bTagIPHandle;
00248  iEvent.getByLabel("jetProbabilityBJetTags", bTagIPHandle);
00249  if (!bTagIPHandle.isValid()) 
00250     edm::LogInfo("FourVectorHLTOnline") << "mTagIPHandle trackCountingHighEffJetTags not found, ";
00251 
00252    // Get b tag information
00253  edm::Handle<TriggerResults> bTagMuHandle;
00254  iEvent.getByLabel("softMuonBJetTags", bTagMuHandle);
00255  if (!bTagMuHandle.isValid()) 
00256     edm::LogInfo("FourVectorHLTOnline") << "bTagMuHandle  not found, ";
00257 
00258   edm::Handle<TriggerResults> metHandle;
00259   iEvent.getByLabel("met",metHandle);
00260   if(!metHandle.isValid()) 
00261     edm::LogInfo("FourVectorHLTOnline") << "metHandle not found, ";
00262 
00263   edm::Handle<TriggerResults> photonHandle;
00264   iEvent.getByLabel("photons",photonHandle);
00265   if(!photonHandle.isValid()) 
00266     edm::LogInfo("FourVectorHLTOnline") << "photonHandle not found, ";
00267 
00268   edm::Handle<TriggerResults> trackHandle;
00269   iEvent.getByLabel("pixelTracks",trackHandle);
00270   if(!trackHandle.isValid()) 
00271     edm::LogInfo("FourVectorHLTOnline") << "trackHandle not found, ";
00272 
00273   // ---------------------
00274   // Monitors
00275   // ---------------------
00276 
00277   // electron Monitor
00278   objMonData<TriggerResults> eleMon;
00279   eleMon.setReco(gsfElectrons);
00280   eleMon.setLimits(electronEtaMax_, electronEtMin_, electronDRMatch_);
00281   
00282   eleMon.pushTriggerType(TriggerElectron);
00283   eleMon.pushTriggerType(TriggerL1NoIsoEG);
00284   eleMon.pushTriggerType(TriggerL1IsoEG);
00285 
00286   eleMon.pushL1TriggerType(TriggerL1NoIsoEG);
00287   eleMon.pushL1TriggerType(TriggerL1IsoEG);
00288 
00289   // muon Monitor
00290   objMonData<TriggerResults>  muoMon;
00291   muoMon.setReco(muonHandle);
00292   muoMon.setLimits(muonEtaMax_, muonEtMin_, muonDRMatch_);
00293   
00294   muoMon.pushTriggerType(TriggerMuon);
00295   muoMon.pushTriggerType(TriggerL1Mu);
00296 
00297   muoMon.pushL1TriggerType(TriggerL1Mu);
00298   
00299   // tau Monitor
00300   objMonData<TriggerResults>  tauMon;
00301   tauMon.setReco(tauHandle);
00302   tauMon.setLimits(tauEtaMax_, tauEtMin_, tauDRMatch_);
00303   
00304   tauMon.pushTriggerType(TriggerTau);
00305   tauMon.pushTriggerType(TriggerL1TauJet);
00306 
00307   tauMon.pushL1TriggerType(TriggerL1TauJet);
00308   tauMon.pushL1TriggerType(TriggerL1ForJet);
00309   
00310   // photon Monitor
00311   objMonData<TriggerResults> phoMon;
00312   phoMon.setReco(photonHandle);
00313   phoMon.setLimits(photonEtaMax_, photonEtMin_, photonDRMatch_);
00314   
00315   phoMon.pushTriggerType(TriggerPhoton);
00316 
00317   phoMon.pushL1TriggerType(TriggerL1NoIsoEG);
00318   phoMon.pushL1TriggerType(TriggerL1IsoEG);
00319 
00320   // jet Monitor - NOTICE: we use genJets for MC
00321   objMonData<TriggerResults> jetMon;
00322   jetMon.setReco(jetHandle);
00323   jetMon.setLimits(jetEtaMax_, jetEtMin_, jetDRMatch_);
00324 
00325   jetMon.pushTriggerType(TriggerJet);
00326   jetMon.pushTriggerType(TriggerL1CenJet);
00327   jetMon.pushTriggerType(TriggerL1ForJet);
00328   
00329   jetMon.pushL1TriggerType(TriggerL1CenJet);
00330   jetMon.pushL1TriggerType(TriggerL1ForJet);
00331   jetMon.pushL1TriggerType(TriggerL1TauJet);
00332 
00333   // bjet Monitor - NOTICE: we use genJets for MC
00334   objMonData<TriggerResults> btagIPMon; // CaloJet will not be used, this is only place holder
00335   //btagIPMon.setReco(jetHandle);
00336   btagIPMon.setBJetsFlag(true);
00337   btagIPMon.setLimits(bjetEtaMax_, bjetEtMin_, bjetDRMatch_);
00338 
00339   btagIPMon.pushTriggerType(TriggerBJet);
00340   btagIPMon.pushTriggerType(TriggerJet);
00341 
00342   btagIPMon.pushL1TriggerType(TriggerL1CenJet);
00343   btagIPMon.pushL1TriggerType(TriggerL1ForJet);
00344   btagIPMon.pushL1TriggerType(TriggerL1TauJet);
00345 
00346   objMonData<TriggerResults> btagMuMon; // CaloJet will not be used, this is only place holder
00347   //btagMuMon.setReco(jetHandle);
00348   btagMuMon.setBJetsFlag(true);
00349   btagMuMon.setLimits(bjetEtaMax_, bjetEtMin_, bjetDRMatch_);
00350 
00351   btagMuMon.pushTriggerType(TriggerBJet);
00352   btagMuMon.pushTriggerType(TriggerJet);
00353 
00354   btagMuMon.pushL1TriggerType(TriggerL1CenJet);
00355   btagMuMon.pushL1TriggerType(TriggerL1ForJet);
00356   btagMuMon.pushL1TriggerType(TriggerL1TauJet);
00357 
00358 
00359   objMonData<TriggerResults> btagMon; // Generic btagMon
00360  
00361   // met Monitor
00362   objMonData<TriggerResults> metMon;
00363   metMon.setReco(metHandle);
00364   metMon.setLimits(metEtaMax_, metMin_, metDRMatch_);
00365   
00366   metMon.pushTriggerType(TriggerMET);
00367 
00368   metMon.pushL1TriggerType(TriggerL1ETM);
00369 
00370   // tet Monitor
00371   objMonData<TriggerResults> tetMon;
00372   tetMon.setReco(metHandle);
00373   //tetMon.setLimits(tetEtaMax_=999., tetEtMin_=10, tetDRMatch_=999);
00374   tetMon.setLimits(999., 10., 999.);
00375   
00376   tetMon.pushTriggerType(TriggerTET);
00377 
00378   tetMon.pushL1TriggerType(TriggerL1ETT);
00379 
00380   // default Monitor
00381   //objMonData<trigger::TriggerEvent> defMon;
00382   objMonData<TriggerResults> defMon;
00383   defMon.setLimits(999., 3., 999.);
00384 
00385   // vector to hold monitors 
00386   // interface is through virtual class BaseMonitor
00387   std::vector<BaseMonitor*> monitors;
00388 
00389   //monitors.push_back(&jetMon);
00390 
00391   monitors.push_back(&muoMon);
00392   monitors.push_back(&eleMon);
00393   monitors.push_back(&tauMon);
00394   monitors.push_back(&phoMon);
00395   monitors.push_back(&jetMon);
00396   monitors.push_back(&btagMon);
00397   monitors.push_back(&metMon);
00398   monitors.push_back(&tetMon);
00399 
00400   int bx = iEvent.bunchCrossing();
00401   /*
00402   // Fill HLTPassed_Correlation Matrix bin (i,j) = (Any,Any)
00403   // --------------------------------------------------------
00404   int anyBinNumber = ME_HLTPassPass_->getTH2F()->GetXaxis()->FindBin("HLT_Any");      
00405   // any triger accepted
00406   if(triggerResults->accept()){
00407 
00408     ME_HLTPassPass_->Fill(anyBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
00409 
00410   }
00411   */
00412 
00413   fillHltMatrix(triggerNames);
00414 
00415 
00416   // Loop over paths
00417   // --------------------
00418   for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) { 
00419 
00420     LogTrace("FourVectorHLTOnline") << " unique path " << v->getPath() << std::endl;
00421 
00422     unsigned int pathByIndex = triggerNames.triggerIndex(v->getPath());
00423 
00424     // path must be in the menu
00425     if(pathByIndex >= triggerResults_->size() ) continue;
00426 
00427   
00428     // Fill HLTPassed Matrix and HLTPassFail Matrix
00429     // --------------------------------------------------------
00430 
00431     if(triggerResults->accept(pathByIndex)){
00432   
00433       int pathBinNumber = ME_HLT_BX_->getTH2F()->GetYaxis()->FindBin(v->getPath().c_str());      
00434       ME_HLT_BX_->Fill(bx,pathBinNumber-1);
00435 
00436       if(hasHLTPassed(fCustomBXPath,triggerNames)) {
00437 
00438         ME_HLT_CUSTOM_BX_->Fill(bx,pathBinNumber-1);
00439 
00440       }
00441 
00442     } // end if accept
00443   
00444     // Fill histogram of filter ocupancy for each HLT path
00445     // ---------------------------------
00446     unsigned int lastModule = triggerResults->index(pathByIndex);
00447 
00448     //check if hlt passed
00449     bool hltPathPassed = triggerResults->accept(pathByIndex);
00450   
00451     //go through the list of filters
00452     for(unsigned int filt = 0; filt < v->filtersAndIndices.size(); filt++){
00453       
00454       int binNumber = v->getFiltersHisto()->getTH1()->GetXaxis()->FindBin(v->filtersAndIndices[filt].first.c_str());      
00455       
00456       // if hlt path passed, then all the modules passed
00457       // otherwise the module that issued the decision is the first fail
00458       // this means that all modules before it passed
00459       if(hltPathPassed) {
00460 
00461         v->getFiltersHisto()->Fill(binNumber-1);//binNumber1 = 0 = first filter
00462       }
00463       else if(v->filtersAndIndices[filt].second < lastModule){
00464         v->getFiltersHisto()->Fill(binNumber-1);//binNumber1 = 0 = first filter
00465       }
00466   
00467     } // end for filt
00468 
00469   } // end for diag paths
00470 
00471 
00472   // Main loop over paths
00473   // --------------------
00474   for(PathInfoCollection::iterator v = hltPaths_.begin(); v!= hltPaths_.end(); ++v ) { 
00475 
00476     LogTrace("FourVectorHLTOnline") << " path " << v->getPath() << std::endl;
00477 
00478     if (v->getPath().find("BTagIP") != std::string::npos ) btagMon = btagIPMon;
00479     else btagMon = btagMuMon;
00480 
00481     //if(*v != "HLT_L1Jet6U") continue;
00482 
00483     unsigned int pathByIndex = triggerNames.triggerIndex(v->getPath());
00484 
00485     if(pathByIndex >= triggerResults_->size() ) continue;
00486   
00487     // did we pass the denomPath?
00488     bool denompassed = false;  
00489 
00490     for(int i = 0; i < npath; ++i) {
00491 
00492      if (triggerNames.triggerName(i).find(v->getDenomPath()) != std::string::npos && triggerResults->accept(i))
00493      { 
00494         denompassed = true;
00495         break;
00496      }
00497    }
00498 
00499    if (denompassed)
00500    {  
00501 
00502      //LogTrace("FourVectorHLTOnline") << " denominator path " << v->getPath() << std::endl;
00503 
00504 
00505      // Get the righe monitor for this path
00506      // -----------------------------------
00507      BaseMonitor* mon = NULL;
00508 
00509      for(std::vector<BaseMonitor*>::iterator mit = monitors.begin(); mit!= monitors.end(); ++mit ) {
00510        
00511        if((*mit)->isTriggerType(v->getObjectType())) {
00512 
00513          mon = *mit;
00514          break;
00515 
00516        }
00517 
00518      }
00519 
00520      // if cannot find moniotor for the path, go to next path
00521      //if(!mon) continue;
00522 
00523      // if cannot find moniotor for the path, assign the default
00524      if(!mon) mon = &defMon;
00525 
00526      // attach this path to mon
00527      mon->setPath(v);
00528 
00529      // clear sets of matched objects
00530      mon->clearSets();
00531 
00532      int triggertype = 0;     
00533      triggertype = v->getObjectType();
00534 
00535      // monitor L1 (only if L1 passed and can find GTSeed)
00537      bool l1accept = false;
00538      edm::InputTag l1testTag(v->getl1Path(),"",processname_);
00539      const int l1Index = fTriggerObj->filterIndex(l1testTag);
00540      
00541      if ( l1Index >= fTriggerObj->sizeFilters() ) {
00542 
00543        LogTrace("FourVectorHLTOnline") << "Cannot find L1GTSeed of the path " << v->getPath() << std::endl;
00544        LogTrace("FourVectorHLTOnline") << "\t L1GTSeed name = " << v->getl1Path() << std::endl;
00545        LogTrace("FourVectorHLTOnline") <<  "\t tried with tag " << l1testTag << std::endl;
00546        LogTrace("FourVectorHLTOnline") <<"\t module index = "<< l1Index << std::endl;
00547 
00548      } 
00549 
00550            // monitor L1 object
00551            mon->monitorL1(l1Index, this);
00552         
00553     // monitor Online (only if HLT passed)
00555           bool numpassed = false;
00556 
00557     // did we pass the numerator path, i.e. HLT path?
00558     for(int i = 0; i < npath; ++i) {
00559 
00560       if (triggerNames.triggerName(i) == v->getPath() && triggerResults->accept(i)) numpassed = true;
00561 
00562     }
00563 
00564     if (!numpassed) continue;
00565 
00566     if (!l1accept) {
00567 
00568           LogDebug("FourVectorHLTOnline") 
00569             << "This should not happen.  HLT passed, but L1 Seed not passed for hlt path "<< std::endl 
00570             << "HLT path: " << v->getPath() << "\t HLTLevel1GTSeed: " << v->getl1Path();
00571 
00572     }
00573 
00574     // fill scaler histograms
00575     edm::InputTag filterTag = v->getTag();
00576 
00577     // loop through indices and see if the filter is 
00578     // on the list of filters used by this path
00579     //----------------------------------------------
00580     if (v->getLabel() == "dummy"){
00581     const std::vector<std::string> filterLabels = hltConfig_.moduleLabels(v->getPath());
00582 
00583     //loop over labels
00584     for (std::vector<std::string>::const_iterator labelIter= filterLabels.begin(); labelIter!=filterLabels.end(); labelIter++) {
00585 
00586       edm::InputTag testTag(*labelIter,"",processname_);
00587 
00588       int testindex = fTriggerObj->filterIndex(testTag);
00589 
00590       // last match wins...
00591       if ( !(testindex >= fTriggerObj->sizeFilters()) ) {
00592 
00593         filterTag = testTag; 
00594         v->setLabel(*labelIter);}
00595 
00596       }
00597 
00598     } // end for
00599   
00600     const int hltIndex = fTriggerObj->filterIndex(filterTag);
00601     if ( hltIndex >= fTriggerObj->sizeFilters() ) {
00602 
00603       LogTrace("FourVectorHLTOnline") << "WTF no index "<< index << " of that name " << filterTag << std::endl;
00604       continue; // not in this event
00605 
00606     }
00607 
00608     mon->monitorOnline(hltIndex, l1Index, this);
00609 
00610     mon->fillOnlineMatch(l1Index, this);
00611 
00612    } //denompassed
00613 
00614 
00615  } //pathinfo loop
00616 
00617 }
00618 
00619 
00620 
00621 // -- method called once each job just before starting event loop  --------
00622 void 
00623 FourVectorHLTOnline::beginJob()
00624 {
00625   nev_ = 0;
00626   DQMStore *dbe = 0;
00627   dbe = Service<DQMStore>().operator->();
00628   
00629   if (dbe) {
00630     dbe->setCurrentFolder(dirname_);
00631     dbe->rmdir(dirname_);
00632   }
00633   
00634   
00635   if (dbe) {
00636     dbe->setCurrentFolder(dirname_);
00637     }  
00638 }
00639 
00640 // - method called once each job just after ending the event loop  ------------
00641 void 
00642 FourVectorHLTOnline::endJob() 
00643 {
00644    LogInfo("FourVectorHLTOnline") << "analyzed " << nev_ << " events";
00645    return;
00646 }
00647 
00648 
00649 // BeginRun
00650 void FourVectorHLTOnline::beginRun(const edm::Run& run, const edm::EventSetup& c)
00651 {
00652 
00653   LogDebug("FourVectorHLTOnline") << "beginRun, run " << run.id();
00654   
00655   // HLT config does not change within runs!
00656   bool changed=false;
00657  
00658   if (!hltConfig_.init(run, c, processname_, changed)) {
00659 
00660     processname_ = "FU";
00661 
00662     if (!hltConfig_.init(run, c, processname_, changed)){
00663 
00664       LogDebug("FourVectorHLTOnline") << "HLTConfigProvider failed to initialize.";
00665 
00666     }
00667 
00668     // check if trigger name in (new) config
00669     //  std::cout << "Available TriggerNames are: " << std::endl;
00670     //  hltConfig_.dump("Triggers");
00671   }
00672 
00673   if (1) {
00674 
00675     DQMStore *dbe = 0;
00676     dbe = Service<DQMStore>().operator->();
00677   
00678     if (dbe) {
00679       dbe->setCurrentFolder(dirname_);
00680     }
00681 
00682     const unsigned int n(hltConfig_.size());
00683     if (plotAll_){
00684 
00685       for (unsigned int j=0; j!=n; ++j) {
00686   
00687         std::string pathname = hltConfig_.triggerName(j);  
00688 
00689         std::string l1pathname = getL1ConditionModuleName(pathname);
00690       
00691         int objectType =  getTriggerTypeParsePathName(pathname);
00692   
00693         for (unsigned int i=0; i!=n; ++i) {
00694   
00695           std::string denompathname = hltConfig_.triggerName(i);  
00696           int denomobjectType =  getTriggerTypeParsePathName(denompathname);
00697 
00698       
00699          
00700           std::string filtername("dummy");
00701           float ptMin = 0.0;
00702           float ptMax = 100.0;
00703           if (plotAll_ && denomobjectType == objectType && objectType != 0)
00704           
00705             hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00706 
00707         }
00708       }
00709 
00710     } // end if plotAll
00711     else {
00712 
00713       // plot all diagonal combinations plus any other specified pairs
00714       for (unsigned int i=0; i!=n; ++i) {
00715 
00716          std::string denompathname = "";  
00717          std::string pathname = hltConfig_.triggerName(i);  
00718          //parse pathname to guess object type
00719          int objectType =  getTriggerTypeParsePathName(pathname);
00720 
00721         std::string l1pathname = getL1ConditionModuleName(pathname);
00722   
00723         std::string filtername("dummy");
00724         float ptMin = 0.0;
00725         float ptMax = 100.0;
00726 
00727         if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00728         if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00729         if (objectType == trigger::TriggerMuon) ptMax = 150.0;
00730         if (objectType == trigger::TriggerTau) ptMax = 100.0;
00731         if (objectType == trigger::TriggerJet) ptMax = 300.0;
00732         if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00733         if (objectType == trigger::TriggerMET) ptMax = 300.0;
00734         if (objectType == trigger::TriggerTET) ptMax = 300.0;
00735         if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00736     
00737         // keep track of all paths, except for FinalPath
00738         if (objectType != -1 && pathname.find("FinalPath") == std::string::npos){
00739   
00740           hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00741 
00742           hltPathsDiagonal_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00743   
00744         }
00745 
00746       } // end for i
00747 
00748         
00749       // now loop over denom/num path pairs specified in cfg, 
00750       // recording the off-diagonal ones
00751       for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair) {
00752             
00753         std::string numpathname = custompathnamepair->first;  
00754         std::string denompathname = custompathnamepair->second;  
00755   
00756         if (numpathname != denompathname) {
00757   
00758           // check that denominator exists
00759           bool founddenominator = false;
00760           for (unsigned int k=0; k!=n; ++k) {
00761 
00762             std::string n_pathname = hltConfig_.triggerName(k);
00763 
00764             if (n_pathname.find(denompathname) != std::string::npos) {
00765               
00766               LogDebug("FourVectorHLTOnline") << "denompathname is selected to be = " << n_pathname << std::endl;;
00767               founddenominator = true;
00768 
00769               break;
00770 
00771             }
00772           }
00773 
00774           if (!founddenominator) {
00775   
00776             edm::LogInfo("FourVectorHLTOnline") << "denompathname not found, go to the next pair numearator-denominator" << std::endl;
00777             
00778             // go to the next pair
00779             continue;
00780   
00781           }
00782 
00783           // check that numerator exists
00784           bool foundnumerator = false;
00785           for (unsigned int j=0; j!=n; ++j) {
00786 
00787             std::string pathname = hltConfig_.triggerName(j);
00788 
00789             LogDebug("FourVectorHLTOnline") << "check if path " << pathname << " is numpathname = " << numpathname << std::endl;
00790             if (hltConfig_.triggerName(j).find(numpathname)!= std::string::npos) {
00791               
00792               LogDebug("FourVectorHLTOnline") << "pathname is selected to be = " << denompathname << std::endl;;
00793               foundnumerator = true;
00794 
00795             }
00796   
00797   
00798             if (!foundnumerator) {
00799     
00800               edm::LogInfo("FourVectorHLTOnline") << "pathname not found, ignoring " << pathname;
00801               continue;
00802   
00803             }
00804   
00805   
00806             std::string l1pathname = getL1ConditionModuleName(pathname);
00807             int objectType =  getTriggerTypeParsePathName(pathname);
00808   
00809           std::string filtername("dummy");
00810           float ptMin = 0.0;
00811           float ptMax = 100.0;
00812           if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00813           if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00814           if (objectType == trigger::TriggerMuon) ptMax = 150.0;
00815           if (objectType == trigger::TriggerTau) ptMax = 100.0;
00816           if (objectType == trigger::TriggerJet) ptMax = 300.0;
00817           if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00818           if (objectType == trigger::TriggerMET) ptMax = 300.0;
00819           if (objectType == trigger::TriggerTET) ptMax = 300.0;
00820           if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00821   
00822           // monitor regardless of the objectType of the path
00823           if (objectType != 0)
00824             hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00825       
00826         } // end for j, loop over paths
00827 
00828        }  // end if not same num and denominator 
00829   
00830       } // end for pair
00831 
00832     } // end else
00833 
00834 
00835     std::vector<std::string> muonPaths;
00836     std::vector<std::string> egammaPaths;
00837     std::vector<std::string> tauPaths;
00838     std::vector<std::string> jetmetPaths;
00839     std::vector<std::string> restPaths;
00840     std::vector<std::string> allPaths;
00841     // fill vectors of Muon, Egamma, JetMet, Rest, and Special paths
00842     for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
00843 
00844       std::string pathName = v->getPath();
00845       int objectType = v->getObjectType();
00846 
00847       std::vector<int> tempCount(5,0);
00848 
00849       fPathTempCountPair.push_back(make_pair(pathName,0));
00850       fPathBxTempCountPair.push_back(make_pair(pathName,tempCount));
00851 
00852       allPaths.push_back(pathName);
00853 
00854       switch (objectType) {
00855         case trigger::TriggerMuon :
00856           muonPaths.push_back(pathName);
00857           break;
00858 
00859         case trigger::TriggerElectron :
00860         case trigger::TriggerPhoton :
00861           egammaPaths.push_back(pathName);
00862           break;
00863 
00864         case trigger::TriggerTau :
00865           tauPaths.push_back(pathName);
00866           break;
00867 
00868         case trigger::TriggerJet :
00869         case trigger::TriggerMET :
00870           jetmetPaths.push_back(pathName);
00871           break;
00872 
00873         default:
00874           restPaths.push_back(pathName);
00875       }
00876 
00877     }
00878 
00879     fPathTempCountPair.push_back(make_pair("HLT_Any",0));
00880 
00881     fGroupName.push_back("All");
00882     fGroupName.push_back("Muon");
00883     fGroupName.push_back("Egamma");
00884     fGroupName.push_back("Tau");
00885     fGroupName.push_back("JetMet");
00886     fGroupName.push_back("Rest");
00887     fGroupName.push_back("Special");
00888 
00889     for(unsigned int g=0; g<fGroupName.size(); g++) {
00890 
00891       //fGroupTempCountPair.push_back(make_pair(fGroupName[g],0));
00892       //fGroupL1TempCountPair.push_back(make_pair(fGroupName[g],0));
00893 
00894     }
00895   
00896     dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
00897 
00898 
00899 
00900     fGroupNamePathsPair.push_back(make_pair("All",allPaths));
00901 
00902     fGroupNamePathsPair.push_back(make_pair("Muon",muonPaths));
00903 
00904     fGroupNamePathsPair.push_back(make_pair("Egamma",egammaPaths));
00905 
00906     fGroupNamePathsPair.push_back(make_pair("Tau",tauPaths));
00907 
00908     fGroupNamePathsPair.push_back(make_pair("JetMet",jetmetPaths));
00909 
00910     fGroupNamePathsPair.push_back(make_pair("Rest",restPaths));
00911 
00912     fGroupNamePathsPair.push_back(make_pair("Special",specialPaths_));
00913 
00915     std::vector<std::string> datasetNames =  hltConfig_.datasetNames() ;
00916     for (unsigned int i=0;i<datasetNames.size();i++) {
00917 
00918       std::vector<std::string> datasetPaths = hltConfig_.datasetContent(datasetNames[i]);
00919       fGroupNamePathsPair.push_back(make_pair(datasetNames[i],datasetPaths));
00920       //setupHltMatrix(datasetNames[i],datasetPaths);
00921 
00922     }
00923 
00924     /*
00925     setupHltMatrix("All", allPaths);
00926     setupHltMatrix("Muon", muonPaths);
00927     setupHltMatrix("Egamma", egammaPaths);
00928     setupHltMatrix("Tau", tauPaths);
00929     setupHltMatrix("JetMET", jetmetPaths);
00930     setupHltMatrix("Rest", restPaths);
00931     setupHltMatrix("Special", specialPaths_);
00932     */
00933 
00934     for (unsigned int g=0;g<fGroupNamePathsPair.size();g++) {
00935 
00936       fGroupTempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
00937       fGroupL1TempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
00938       setupHltMatrix(fGroupNamePathsPair[g].first,fGroupNamePathsPair[g].second);
00939 
00940     }
00941     /*
00942     */
00943 
00944     setupHltLsPlots();
00945 
00946     setupHltBxPlots();
00947 
00948 
00949     for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
00950 
00951        // -------------------------
00952        //
00953        //  Filters for each path
00954        //
00955        // -------------------------
00956        
00957        // get all modules in this HLT path
00958        std::vector<std::string> moduleNames = hltConfig_.moduleLabels( v->getPath() ); 
00959        
00960        int numModule = 0;
00961        std::string moduleName, moduleType;
00962        unsigned int moduleIndex;
00963        
00964        //print module name
00965        std::vector<std::string>::const_iterator iDumpModName;
00966        for (iDumpModName = moduleNames.begin();iDumpModName != moduleNames.end();iDumpModName++) {
00967 
00968          moduleName = *iDumpModName;
00969          moduleType = hltConfig_.moduleType(moduleName);
00970          moduleIndex = hltConfig_.moduleIndex(v->getPath(), moduleName);
00971 
00972          LogTrace ("FourVectorHLTOnline") << "Module "      << numModule
00973              << " is called " << moduleName
00974              << " , type = "  << moduleType
00975              << " , index = " << moduleIndex
00976              << std::endl;
00977 
00978          numModule++;
00979 
00980          if((moduleType.find("Filter") != std::string::npos && moduleType.find("HLTTriggerTypeFilter") == std::string::npos ) || 
00981             (moduleType.find("Associator") != std::string::npos) || 
00982             (moduleType.find("HLTLevel1GTSeed") != std::string::npos) || 
00983             (moduleType.find("HLTGlobalSumsCaloMET") != std::string::npos) ||
00984             (moduleType.find("HLTPrescaler") != std::string::npos) ) {
00985 
00986            //std::pair<std::string, int> filterIndexPair;
00987            //filterIndexPair.first   = moduleName;
00988            //filterIndexPair.second  = moduleIndex;
00989            //v->filtersAndIndices.push_back(filterIndexPair);
00990            v->filtersAndIndices.push_back(make_pair(moduleName,moduleIndex));
00991 
00992          }
00993 
00994 
00995        }//end for modulesName
00996 
00997        dbe_->setCurrentFolder(pathsSummaryFilterCountsFolder_.c_str()); 
00998 
00999        //int nbin_sub = 5;
01000        int nbin_sub = v->filtersAndIndices.size()+2;
01001     
01002        // count plots for subfilter
01003        MonitorElement* filters = dbe_->book1D("Filters_" + v->getPath(), 
01004                               "Filters_" + v->getPath(),
01005                               nbin_sub+1, -0.5, 0.5+(double)nbin_sub);
01006        
01007        for(unsigned int filt = 0; filt < v->filtersAndIndices.size(); filt++){
01008 
01009          filters->setBinLabel(filt+1, (v->filtersAndIndices[filt]).first);
01010 
01011        }
01012 
01013        // book Count vs LS
01014        dbe_->setCurrentFolder(pathsIndividualHLTPathsPerLSFolder_.c_str());
01015        MonitorElement* tempME = dbe_->book1D(v->getPath() + "_count_per_LS", 
01016                               v->getPath() + " count per LS",
01017                               nLS_, 0,nLS_);
01018        tempME->setAxisTitle("Luminosity Section");
01019 
01020        v->setFilterHistos(filters);
01021 
01022     } // end for paths
01023 
01024     // now set up all of the histos for each path-denom
01025     for(PathInfoCollection::iterator v = hltPaths_.begin(); v!= hltPaths_.end(); ++v ) {
01026 
01027       MonitorElement *NOn, *onEtOn, *onOneOverEtOn, *onEtavsonPhiOn=0;
01028       MonitorElement *NOff, *offEtOff, *offEtavsoffPhiOff=0;
01029       MonitorElement *NL1, *l1EtL1, *l1Etavsl1PhiL1=0;
01030       MonitorElement *NL1On, *l1EtL1On, *l1Etavsl1PhiL1On=0;
01031       MonitorElement *NL1Off, *offEtL1Off, *offEtavsoffPhiL1Off=0;
01032       MonitorElement *NOnOff, *offEtOnOff, *offEtavsoffPhiOnOff=0;
01033       MonitorElement *NL1OnUM, *l1EtL1OnUM, *l1Etavsl1PhiL1OnUM=0;
01034       MonitorElement *NL1OffUM, *offEtL1OffUM, *offEtavsoffPhiL1OffUM=0;
01035       MonitorElement *NOnOffUM, *offEtOnOffUM, *offEtavsoffPhiOnOffUM=0;
01036       MonitorElement *offDRL1Off, *offDROnOff, *l1DRL1On=0;
01037       
01038 
01039       std::string labelname("dummy");
01040       labelname = v->getPath() + "_wrt_" + v->getDenomPath();
01041       std::string histoname(labelname+"_NOn");
01042       std::string title(labelname+" N online");
01043       double histEtaMax = 2.5;
01044 
01045       if (v->getObjectType() == trigger::TriggerMuon || v->getObjectType() == trigger::TriggerL1Mu) {
01046 
01047         histEtaMax = muonEtaMax_;
01048 
01049       }
01050       else if (v->getObjectType() == trigger::TriggerElectron || v->getObjectType() == trigger::TriggerL1NoIsoEG || v->getObjectType() == trigger::TriggerL1IsoEG )
01051       {
01052         histEtaMax = electronEtaMax_;
01053       }
01054         else if (v->getObjectType() == trigger::TriggerTau || v->getObjectType() == trigger::TriggerL1TauJet )
01055       {
01056         histEtaMax = tauEtaMax_;
01057       }
01058       else if (v->getObjectType() == trigger::TriggerJet || v->getObjectType() == trigger::TriggerL1CenJet || v->getObjectType() == trigger::TriggerL1ForJet )
01059       {
01060         histEtaMax = jetEtaMax_; 
01061       }
01062         else if (v->getObjectType() == trigger::TriggerBJet)
01063       {
01064         histEtaMax = bjetEtaMax_;
01065       }
01066       else if (v->getObjectType() == trigger::TriggerMET || v->getObjectType() == trigger::TriggerL1ETM )
01067       {
01068         histEtaMax = metEtaMax_; 
01069       }
01070         else if (v->getObjectType() == trigger::TriggerPhoton)
01071       {
01072         histEtaMax = photonEtaMax_; 
01073       }
01074       else if (v->getObjectType() == trigger::TriggerTrack)
01075       {
01076         histEtaMax = trackEtaMax_; 
01077       }
01078 
01079       TString pathfolder = dirname_ + TString("/") + v->getPath();
01080       dbe_->setCurrentFolder(pathfolder.Data());
01081 
01082       NOn =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01083 
01084 
01085        histoname = labelname+"_NOff";
01086        title = labelname+" N Off";
01087        NOff =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01088        
01089        histoname = labelname+"_NL1";
01090        title = labelname+" N L1";
01091        NL1 =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01092        
01093        histoname = labelname+"_NL1On";
01094        title = labelname+" N L1On";
01095        NL1On =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01096        
01097        histoname = labelname+"_NL1Off";
01098        title = labelname+" N L1Off";
01099        NL1Off =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01100        
01101        histoname = labelname+"_NOnOff";
01102        title = labelname+" N OnOff";
01103        NOnOff =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01104        
01105        
01106        histoname = labelname+"_NL1OnUM";
01107        title = labelname+" N L1OnUM";
01108        NL1OnUM =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01109        
01110        histoname = labelname+"_NL1OffUM";
01111        title = labelname+" N L1OffUM";
01112        NL1OffUM =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01113        
01114        histoname = labelname+"_NOnOffUM";
01115        title = labelname+" N OnOffUM";
01116        NOnOffUM =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01117        
01118        
01119        histoname = labelname+"_onEtOn";
01120        title = labelname+" onE_t online";
01121        onEtOn =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01122        
01123        histoname = labelname+"_onOneOverEtOn";
01124        title = labelname+" 1 / onE_t online";
01125        onOneOverEtOn =  dbe->book1D(histoname.c_str(), title.c_str(),nBinsOneOverEt_, 0, 1);
01126        onOneOverEtOn->setAxisTitle("HLT 1/Et [1/GeV]");
01127        
01128        histoname = labelname+"_offEtOff";
01129        title = labelname+" offE_t offline";
01130        offEtOff =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01131        
01132        histoname = labelname+"_l1EtL1";
01133        title = labelname+" l1E_t L1";
01134        l1EtL1 =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01135        
01136        int nBins2D = 10;
01137        
01138        
01139        histoname = labelname+"_onEtaonPhiOn";
01140        title = labelname+" on#eta vs on#phi online";
01141        onEtavsonPhiOn =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
01142        
01143        histoname = labelname+"_offEtaoffPhiOff";
01144        title = labelname+" off#eta vs off#phi offline";
01145        offEtavsoffPhiOff =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
01146        
01147        histoname = labelname+"_l1Etal1PhiL1";
01148        title = labelname+" l1#eta vs l1#phi L1";
01149        l1Etavsl1PhiL1 =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
01150        
01151        histoname = labelname+"_l1EtL1On";
01152        title = labelname+" l1E_t L1+online";
01153        l1EtL1On =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01154        
01155        histoname = labelname+"_offEtL1Off";
01156        title = labelname+" offE_t L1+offline";
01157        offEtL1Off =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01158        
01159        histoname = labelname+"_offEtOnOff";
01160        title = labelname+" offE_t online+offline";
01161        offEtOnOff =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01162        
01163        histoname = labelname+"_l1Etal1PhiL1On";
01164        title = labelname+" l1#eta vs l1#phi L1+online";
01165        l1Etavsl1PhiL1On =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
01166        
01167        histoname = labelname+"_offEtaoffPhiL1Off";
01168        title = labelname+" off#eta vs off#phi L1+offline";
01169        offEtavsoffPhiL1Off =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
01170        
01171        histoname = labelname+"_offEtaoffPhiOnOff";
01172        title = labelname+" off#eta vs off#phi online+offline";
01173        offEtavsoffPhiOnOff =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
01174        
01175        histoname = labelname+"_l1EtL1OnUM";
01176        title = labelname+" l1E_t L1+onlineUM";
01177        l1EtL1OnUM =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01178        
01179        histoname = labelname+"_offEtL1OffUM";
01180        title = labelname+" offE_t L1+offlineUM";
01181        offEtL1OffUM =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01182        
01183        histoname = labelname+"_offEtOnOffUM";
01184        title = labelname+" offE_t online+offlineUM";
01185        offEtOnOffUM =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01186        
01187        histoname = labelname+"_l1Etal1PhiL1OnUM";
01188        title = labelname+" l1#eta vs l1#phi L1+onlineUM";
01189        l1Etavsl1PhiL1OnUM =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
01190        
01191        histoname = labelname+"_offEtaoffPhiL1OffUM";
01192        title = labelname+" off#eta vs off#phi L1+offlineUM";
01193        offEtavsoffPhiL1OffUM =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
01194        
01195        histoname = labelname+"_offEtaoffPhiOnOffUM";
01196        title = labelname+" off#eta vs off#phi online+offlineUM";
01197        offEtavsoffPhiOnOffUM =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
01198        
01199        
01200        
01201        
01202        histoname = labelname+"_l1DRL1On";
01203        title = labelname+" l1DR L1+online";
01204        l1DRL1On =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, 0, 1.); 
01205        
01206        histoname = labelname+"_offDRL1Off";
01207        title = labelname+" offDR L1+offline";
01208        offDRL1Off =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, 0, 1.);
01209        
01210        histoname = labelname+"_offDROnOff";
01211        title = labelname+" offDR online+offline";
01212        offDROnOff =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, 0, 1.); 
01213 
01214 
01215        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 
01216 );
01217 
01218 
01219     }  // end for hltPath
01220 
01221     // HLT_Any
01222     // book Count vs LS
01223     dbe_->setCurrentFolder(pathsIndividualHLTPathsPerLSFolder_.c_str());
01224     MonitorElement* tempME = dbe_->book1D("HLT_Any_count_per_LS", 
01225                            "HLT_Any count per LS",
01226                            nLS_, 0,nLS_);
01227     tempME->setAxisTitle("Luminosity Section");
01228 
01229   } // end if(1) dummy
01230 
01231  return;
01232 
01233 }
01234 
01236 void FourVectorHLTOnline::endRun(const edm::Run& run, const edm::EventSetup& c)
01237 {
01238 
01239   LogDebug("FourVectorHLTOnline") << "endRun, run " << run.id();
01240 
01241 }
01242 
01244 void FourVectorHLTOnline::cleanDRMatchSet(mmset& tempSet)
01245 {
01246 
01247   LogDebug("FourVectorHLTOnline") << "cleanDRMatchSet(mmset& tempSet) " << "size of the set (before CLEANING) = " << tempSet.size() << " maps." << std::endl;
01248 
01249   if(tempSet.size() < 2) return;
01250 
01251   if(tempSet.size() > 10) {
01252 
01253     LogDebug("FourVectorHLTOnline") << "size of the set is too large.  It will be truncated to 10." << std::endl;
01254     mmset::iterator it = tempSet.begin();
01255     for (int i=0;i<10;i++) {    it++; }
01256     tempSet.erase( it, tempSet.end());
01257     LogDebug("FourVectorHLTOnline") << "size of the set is now = " << tempSet.size() << " maps." << std::endl;
01258 
01259   }
01260  
01261   bool cleanedOneMap = false;
01262  
01263   // cleaning needed if the set has at least two maps
01264 
01265   while(! cleanedOneMap && tempSet.size() > 1) {
01266 
01267     cleanedOneMap=false;
01268 
01269     //LogTrace("FourVectorHLTOnline") << "cleaning: size of the set  = " << tempSet.size() << " maps." << std::endl;
01270 
01271     int imap = 0;
01272     for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) {
01273 
01274       fimmap tempMap_j = *setIter_i;
01275 
01276       //LogTrace("FourVectorHLTOnline") << " map " << imap << std::endl;
01277       //LogTrace("FourVectorHLTOnline") << " --------" << std::endl;
01278 
01279       for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it) {
01280 
01281         //LogTrace("FourVectorHLTOnline") << " " <<   (*it).first << " :  " << (*it).second << std::endl;
01282 
01283       }
01284 
01285       imap++;
01286 
01287     }
01288 
01289     // loop i
01290     for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) {
01291      
01292       fimmap tempMap_i = *setIter_i;
01293       fimmap::iterator it = tempMap_i.begin();
01294       int topValue = (*it).second;
01295       //LogTrace("FourVectorHLTOnline") << " topValue = " << topValue << std::endl;
01296   
01297       
01298       mmset::iterator tempIter_i = setIter_i;
01299   
01300       // from all the other maps, clean entries that have mapped value "topValue"
01301       // loop j
01302       for ( mmset::iterator setIter_j = ++tempIter_i; setIter_j != tempSet.end( ); setIter_j++ ) {
01303   
01304         fimmap tempMap_j = *setIter_j;
01305         //LogTrace("FourVectorHLTOnline") << "  size of the map  = " << tempMap_j.size() << std::endl;
01306   
01307         for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it)
01308         {
01309   
01310           if(topValue == (*it).second) {
01311             
01312             //LogTrace("FourVectorHLTOnline") << "   Ridding map of a doubly-matched object." << std::endl;
01313             tempMap_j.erase(it);
01314             cleanedOneMap = true;
01315   
01316           }
01317   
01318         } //end for
01319   
01320         if(cleanedOneMap) {
01321           
01322           //remove the old map from the set
01323           tempSet.erase(setIter_j);
01324   
01325           // insert in the set the new map if it is not an empty map
01326           if(! tempMap_j.empty()) tempSet.insert(tempMap_j);
01327   
01328           break; // break from loop j
01329   
01330        } // end if
01331   
01332       }// end loop j 
01333   
01334       if(cleanedOneMap) break; // break from loop i
01335 
01336     } // end loop i
01337 
01338     if(cleanedOneMap) { 
01339 
01340       // continue cleaning (in while loop)
01341       // but reset flag first
01342       cleanedOneMap=false;
01343       continue; 
01344 
01345     }
01346     else {
01347 
01348       // finished cleaing (break from while loop)
01349       break; 
01350 
01351     }
01352 
01353   } // end while
01354 
01355   //LogTrace("FourVectorHLTOnline") << "cleaned: size of the set  = " << tempSet.size() << " maps." << std::endl;
01356   int jmap = 0;
01357 
01358   for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) 
01359   {
01360 
01361     fimmap tempMap_j = *setIter_i;
01362 
01363     //LogTrace("FourVectorHLTOnline") << " map " << jmap << std::endl;
01364     //LogTrace("FourVectorHLTOnline") << " --------" << std::endl;
01365 
01366     for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it) {
01367 
01368         //LogTrace("FourVectorHLTOnline") << " " <<   (*it).first << " :  " << (*it).second << std::endl;
01369       
01370     }
01371 
01372     jmap++;
01373 
01374   } // end for
01375 
01376   return;
01377 
01378 }
01379 
01380 void FourVectorHLTOnline::setupHltMatrix(std::string label, std::vector<std::string> paths) {
01381 
01382     //string groupLabelAny = "HLT_"+label+"_Any";
01383     //paths.push_back(groupLabelAny.c_str());
01384     paths.push_back("HLT_"+label+"_L1_Any");
01385     paths.push_back("HLT_"+label+"_Any");
01386     paths.push_back("HLT_Any");
01387 
01388     std::string h_name; 
01389     std::string h_title; 
01390 
01391     dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
01392 
01393     h_name= "HLT_"+label+"_PassPass";
01394     h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass)";
01395     MonitorElement* ME = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01396                            paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01397 
01398     h_name= "HLT_"+label+"_Pass_Any";
01399     h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
01400     MonitorElement* ME_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01401                            paths.size(), -0.5, paths.size()-0.5);
01402 
01403     dbe_->setCurrentFolder(pathsSummaryHLTCorrelationsFolder_.c_str());
01404     h_name= "HLT_"+label+"_PassPass_Normalized";
01405     h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass) normalized to xBin=Pass";
01406     MonitorElement* ME_Normalized = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01407                            paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01408     h_name= "HLT_"+label+"_Pass_Normalized_Any";
01409     h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
01410     MonitorElement* ME_Normalized_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01411                            paths.size(), -0.5, paths.size()-0.5);
01412 
01413     dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_.c_str());
01414     h_name= "HLT_"+label+"_Total_LS";
01415     h_title = label+" HLT paths total count combined per LS ";
01416     MonitorElement* ME_Total_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
01417     ME_Total_LS->setAxisTitle("LS");
01418 
01419     h_name= "HLT_"+label+"_LS";
01420     h_title = label+" HLT paths count per LS ";
01421     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);
01422     ME_Group_LS->setAxisTitle("LS");
01424     v_ME_HLTAll_LS_.push_back(ME_Group_LS);
01425 
01426     h_name= "HLT_"+label+"_L1_Total_LS";
01427     h_title = label+" HLT paths total count combined per LS ";
01428     MonitorElement* ME_Total_L1_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
01429     ME_Total_L1_LS->setAxisTitle("LS");
01430 
01431     h_name= "HLT_"+label+"_L1_LS";
01432     h_title = label+" HLT L1s count per LS ";
01433     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);
01434     ME_Group_L1_LS->setAxisTitle("LS");
01435 
01436     dbe_->setCurrentFolder(pathsSummaryHLTPathsPerBXFolder_.c_str());
01437     h_name= "HLT_"+label+"_BX_LS";
01438     h_title = label+" HLT paths total count combined per BX ";
01439     MonitorElement* ME_Total_BX = dbe_->book2D(h_name.c_str(), h_title.c_str(),  nLS_, 0, nLS_, 5, -2.5, 2.5);
01440     ME_Total_BX->setAxisTitle("LS",1);
01441 
01442     for(unsigned int i = 0; i < paths.size(); i++){
01443 
01444       ME->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01445       ME->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01446       ME_Group_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01447 
01448       ME_Normalized->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01449       ME_Normalized->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01450       ME_Normalized_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01451       ME_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01452 
01453     }
01454     
01455 }
01456 
01457 void FourVectorHLTOnline::fillHltMatrix(const edm::TriggerNames & triggerNames) {
01458 
01459  std::string fullPathToME; 
01460 
01461  //for (unsigned int mi=0;mi<fGroupName.size();mi++) {
01462   for (unsigned int mi=0;mi<fGroupNamePathsPair.size();mi++) {
01463 
01464 
01465   fullPathToME = "HLT/FourVector/PathsSummary/HLT_"+fGroupNamePathsPair[mi].first+"_PassPass";
01466   MonitorElement* ME_2d = dbe_->get(fullPathToME);
01467   fullPathToME = "HLT/FourVector/PathsSummary/HLT_"+fGroupNamePathsPair[mi].first+"_Pass_Any";
01468   MonitorElement* ME_1d = dbe_->get(fullPathToME);
01469   if(!ME_2d || !ME_1d) {  
01470 
01471     LogTrace("FourVectorHLTOnline") << " ME not valid although I gave full path" << std::endl;
01472     continue;
01473 
01474   }
01475 
01476   TH2F * hist_2d = ME_2d->getTH2F();
01477   TH1F * hist_1d = ME_1d->getTH1F();
01478 
01479   // Fill HLTPassed Matrix bin (i,j) = (Any,Any)
01480   // --------------------------------------------------------
01481   int anyBinNumber = hist_2d->GetXaxis()->FindBin("HLT_Any");      
01482   // any triger accepted
01483   if(triggerResults_->accept()){
01484 
01485     hist_2d->Fill(anyBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
01486     hist_1d->Fill(anyBinNumber-1);//binNumber1 = 0 = first filter
01487 
01488   }
01489 
01490   bool groupPassed = false;
01491   bool groupL1Passed = false;
01492 
01493   // Main loop over paths
01494   // --------------------
01495 
01496   for (int i=1; i< hist_2d->GetNbinsX();i++) { 
01497 
01498   std::string hltpathname =  hist_2d->GetXaxis()->GetBinLabel(i);
01499 
01500 
01501     // check if this is hlt path name
01502     unsigned int pathByIndex = triggerNames.triggerIndex(hltpathname);
01503     if(pathByIndex >= triggerResults_->size() ) continue;
01504 
01505     // check if its L1 passed
01506     if(hasL1Passed(hltpathname,triggerNames)) groupL1Passed = true;
01507 
01508     // Fill HLTPassed Matrix and HLTPassFail Matrix
01509     // --------------------------------------------------------
01510 
01511     if(triggerResults_->accept(pathByIndex)){
01512 
01513       groupPassed = true;
01514       //groupL1Passed = true;
01515 
01516       if(groupPassed && !groupL1Passed) 
01517   
01518       hist_2d->Fill(i-1,anyBinNumber-1);//binNumber1 = 0 = first filter
01519       hist_2d->Fill(anyBinNumber-1,i-1);//binNumber1 = 0 = first filter
01520 
01521       hist_1d->Fill(i-1);//binNumber1 = 0 = first filter
01522 
01523       for (int j=1; j< hist_2d->GetNbinsY();j++) {
01524   
01525         unsigned int crosspathByIndex = triggerNames.triggerIndex(hist_2d->GetXaxis()->GetBinLabel(j));
01526         if(crosspathByIndex >= triggerResults_->size() ) continue;
01527   
01528         if(triggerResults_->accept(crosspathByIndex)){
01529   
01530           hist_2d->Fill(i-1,j-1);//binNumber1 = 0 = first filter
01531   
01532         } // end if j path passed
01533   
01534       } // end for j 
01535   
01536     } // end if i passed
01537     
01538 
01539   } // end for i
01540 
01541   std::string groupBinLabel = "HLT_"+fGroupNamePathsPair[mi].first+"_Any";
01542   int groupBinNumber = hist_2d->GetXaxis()->FindBin(groupBinLabel.c_str());      
01543   if(groupPassed) hist_1d->Fill(groupBinNumber-1);//binNumber1 = 0 = first filter
01544 
01545   std::string groupL1BinLabel = "HLT_"+fGroupNamePathsPair[mi].first+"_L1_Any";
01546   int groupL1BinNumber = hist_2d->GetXaxis()->FindBin(groupL1BinLabel.c_str());      
01547 
01548   if(groupL1Passed) hist_1d->Fill(groupL1BinNumber-1);//binNumber1 = 0 = first filter
01549  } // end for mi
01550 
01551 }
01552 
01553 void FourVectorHLTOnline::setupHltBxPlots()
01554 {
01555 
01556   //pathsSummaryFolder_ = TString("HLT/FourVector/PathsSummary/");
01557   //dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
01558   dbe_->setCurrentFolder(pathsSummaryFolder_);
01559 
01560   // setup HLT bx plot
01561   unsigned int npaths = hltPathsDiagonal_.size();
01562 
01563   ME_HLT_BX_ = dbe_->book2D("HLT_bx",
01564                          "HLT counts vs Event bx",
01565                          Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
01566   ME_HLT_CUSTOM_BX_ = dbe_->book2D("HLT_Custom_bx",
01567                          "HLT counts vs Event bx",
01568                          Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
01569   ME_HLT_BX_->setAxisTitle("Bunch Crossing");
01570   ME_HLT_CUSTOM_BX_->setAxisTitle("Bunch Crossing");
01571 
01572 
01573   // Set up bin labels on Y axis continuing to cover all npaths
01574   for(unsigned int i = 0; i < npaths; i++){
01575 
01576     ME_HLT_BX_->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01577     ME_HLT_CUSTOM_BX_->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01578 
01579   }
01580 
01581 
01582 }
01583 
01584 void FourVectorHLTOnline::setupHltLsPlots()
01585 {
01586  
01587   unsigned int npaths = hltPathsDiagonal_.size();
01588 
01589   //pathsSummaryHLTPathsPerLSFolder_ = TString("HLT/FourVector/PathsSummary/HLT LS/");
01590   //dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_.c_str());
01591   dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_);
01592 
01593   ME_HLTAll_LS_  = dbe_->book2D("All_count_LS",
01594                     "All paths per LS ",
01595                          nLS_, 0, nLS_, npaths+1, -0.5, npaths+1-0.5);
01596   ME_HLTAll_LS_->setAxisTitle("Luminosity Section");
01597 
01598   // Set up bin labels on Y axis continuing to cover all npaths
01599   for(unsigned int i = 0; i < npaths; i++){
01600 
01601     ME_HLTAll_LS_->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01602 
01603   }
01604 
01605   unsigned int i = npaths;
01606   ME_HLTAll_LS_->getTH2F()->GetYaxis()->SetBinLabel(i+1, "HLT_Any");
01607 
01608   int nBinsPerLSHisto = 20;
01609   int nLSHistos = npaths/nBinsPerLSHisto;
01610   for (int nh=0;nh<nLSHistos+1;nh++) {
01611 
01612     char name[200];
01613     char title[200];
01614 
01615     sprintf(name, "Group_%d_paths_count_LS",nLSHistos-nh);
01616     sprintf(title, "Group %d,  paths count per LS",nLSHistos-nh);
01617 
01618     MonitorElement* tempME  = dbe_->book2D(name,title,
01619                     nLS_, 0, nLS_, nBinsPerLSHisto+3, -0.5, nBinsPerLSHisto+3-0.5);
01620 
01621     tempME->setAxisTitle("LS");
01622 
01623     // Set up bin labels on Y axis continuing to cover all npaths
01624     for(int i = nh*nBinsPerLSHisto; i < (nh+1)*nBinsPerLSHisto; i++){
01625 
01626       if (i == int(npaths)) break;
01627 
01628       int bin;
01629       if(nh == 0){
01630 
01631        bin = i;
01632 
01633       }
01634       else {
01635 
01636        bin = i % nBinsPerLSHisto;
01637 
01638       }
01639 
01640       tempME->setBinLabel(bin+1, hltPathsDiagonal_[i].getPath().c_str(), 2);
01641 
01642     }
01643 
01644     tempME->setBinLabel(nBinsPerLSHisto+3, "HLT_Any", 2);
01645     tempME->setBinLabel(nBinsPerLSHisto+2, "HLT_PhysicsDeclared", 2);
01646 
01647     v_ME_HLTAll_LS_.push_back(tempME);
01648 
01649   }
01650 
01651 
01652 }
01653 
01654 
01655 void FourVectorHLTOnline::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c){   
01656 
01657    //int lumi = int(lumiSeg.id().luminosityBlock());
01658    //if(lumi < 74 || lumi > 77) fLumiFlag = false;
01659    //else fLumiFlag = true;
01660 
01661 }
01662 
01663 void FourVectorHLTOnline::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c)
01664 {
01665 
01666    int lumi = int(lumiSeg.id().luminosityBlock());
01667    LogTrace("FourVectorHLTOnline") << " end lumiSection number " << lumi << std::endl;
01668 
01669   countHLTPathHitsEndLumiBlock(lumi);
01670   countHLTGroupHitsEndLumiBlock(lumi);
01671   countHLTGroupL1HitsEndLumiBlock(lumi);
01672 
01673   countHLTGroupBXHitsEndLumiBlock(lumi);
01674 
01675 }
01676 
01677 void FourVectorHLTOnline::countHLTGroupBXHitsEndLumiBlock(const int& lumi)
01678 {
01679 
01680  LogTrace("FourVectorHLTOnline") << " countHLTGroupBXHitsEndLumiBlock() lumiSection number " << lumi << std::endl;
01681 
01682    TH2F * hist_2d_bx = ME_HLT_BX_->getTH2F();
01683 
01684    for (std::vector<std::pair<std::string, std::vector<int> > >::iterator ip = fPathBxTempCountPair.begin(); ip != fPathBxTempCountPair.end(); ++ip) {
01685   
01686     // get the path and its previous count
01687     std::string pathname = ip->first;  
01688     std::vector<int> prevCount = ip->second;  
01689 
01690     // vector of 5 zeros
01691     std::vector<int> currCount (5,0);
01692     std::vector<int> diffCount (5,0);
01693     
01694     // get the current count of path up to now
01695     int pathBin = hist_2d_bx->GetYaxis()->FindBin(pathname.c_str());      
01696 
01697     if(pathBin > hist_2d_bx->GetNbinsY()) {
01698       
01699       LogTrace("FourVectorHLTOnline") << " Cannot find the bin for path " << pathname << std::endl;
01700       continue;
01701 
01702     }
01703 
01704     for (unsigned int j =0;j<currCount.size();j++) { 
01705 
01706       int bxOffset = j-2;
01707       int bunch = referenceBX_+bxOffset;
01708       if(bunch < 1) bunch += Nbx_ ;
01709       int bxBin = bunch +1; // add one to get the right bin
01710 
01711       
01712       currCount[j] = int(hist_2d_bx->GetBinContent(bxBin, pathBin));  // add one to get the right bin
01713 
01714       LogTrace("FourVectorHLTOnline") << "currCount = " << currCount[j] << std::endl;
01715 
01716       // count due to prev lumi sec is a difference bw current and previous
01717       diffCount[j] = currCount[j] - prevCount[j];
01718 
01719       LogTrace("FourVectorHLTOnline") << " lumi = " << lumi << "  path " << pathname << "bxOffset = " << bxOffset << "  count = " << diffCount[j] <<  std::endl;
01720 
01721       // set the counter in the pair to current count
01722       ip->second = currCount;  
01723 
01724     } // end for bx j
01725 
01727    // fill the 2D Group paths'  BX count per LS
01729    LogTrace("FourVectorHLTOnline")  << "Find " << pathname << std::endl;
01730    for(unsigned int i=0; i<fGroupName.size(); i++){
01731 
01732     bool isMember = false;
01733     //check if the path is in this group
01734     for (unsigned int j=0;j<fGroupNamePathsPair.size();j++) { 
01735 
01736       LogTrace("FourVectorHLTOnline")  << " ---- Group " << fGroupNamePathsPair[j].first << std::endl;
01737       if(fGroupNamePathsPair[j].first != fGroupName[i]) continue;
01738 
01739       for (unsigned int k = 0; k<(fGroupNamePathsPair[j].second).size();k++) {
01740 
01741         LogTrace("FourVectorHLTOnline")  << " comparing to " <<  fGroupNamePathsPair[j].second[k] << std::endl; 
01742 
01743         if(fGroupNamePathsPair[j].second[k] == pathname) {
01744 
01745           isMember = true;
01746           break;
01747 
01748         }
01749 
01750       } // end for k
01751     } // end for j
01752 
01753 
01754     if(!isMember) {
01755       
01756       LogTrace("FourVectorHLTOnline")  << "Could not find a group to which the path belongs, path = " << pathname << "    group = " << fGroupName[i] << std::endl;
01757       continue;
01758 
01759     }
01760 
01761     std::string fullPathToME = pathsSummaryHLTPathsPerBXFolder_ + "HLT_"+fGroupName[i] + "_BX_LS";
01762     MonitorElement* ME_2d = dbe_->get(fullPathToME);
01763 
01764     if ( ME_2d) {
01765 
01766       TH2F* hist_All = ME_2d->getTH2F();
01767 
01768       for (unsigned int j = 0; j<diffCount.size();j++) {
01769 
01770         // find the bin
01771         int binNumber = j+1; // add one to get right bin
01772 
01773         // update  the bin content  (must do that since events don't ncessarily come in the order
01774         int currentLumiCount = int(hist_All->GetBinContent(lumi+1,binNumber));
01775         int updatedLumiCount = currentLumiCount + diffCount[j];
01776         hist_All->SetBinContent(lumi+1,binNumber,updatedLumiCount);
01777       } // end for bx j
01778     
01779     }
01780     else {
01781 
01782       LogDebug("FourVectorHLTOnline") << " cannot find ME_2d" << ME_2d->getName() <<  std::endl;
01783 
01784     }
01785     
01786 
01787    } // end for group i
01788 
01789   } // end for ip
01790 
01791 }
01792 
01793 void FourVectorHLTOnline::countHLTGroupL1HitsEndLumiBlock(const int& lumi)
01794 {
01795 
01796  LogTrace("FourVectorHLTOnline") << " countHLTGroupL1HitsEndLumiBlock() lumiSection number " << lumi << std::endl;
01797 
01798  //for(unsigned int i=0; i<fGroupName.size(); i++){
01799  for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
01800 
01801    // get the count of path up to now
01802    std::string fullPathToME = "HLT/FourVector/PathsSummary/HLT_" + fGroupNamePathsPair[i].first+ "_Pass_Any";
01803    MonitorElement* ME_1d = dbe_->get(fullPathToME);
01804 
01805    if(! ME_1d) {
01806 
01807      LogTrace("FourVectorHLTOnline") << " could not find 1d matrix " << fullPathToME << std::endl;
01808 
01809      continue;
01810 
01811    }
01812 
01813    LogTrace("FourVectorHLTOnline") << " Looking in histogram "  << fullPathToME << std::endl;
01814 
01815    TH1F * hist_1d = ME_1d->getTH1F();
01816 
01817    for (std::vector<std::pair<std::string, int> >::iterator ip = fGroupL1TempCountPair.begin(); ip != fGroupL1TempCountPair.end(); ++ip) {
01818   
01819     // get the path and its previous count
01820     std::string pathname = ip->first;  
01821     int prevCount = ip->second;  
01822 
01823     std::string binLabel = "HLT_"+pathname+"_L1_Any";
01824     
01825     LogTrace("FourVectorHLTOnline") << " Looking for binLabel = " << binLabel <<  std::endl;
01826     // get the current count of path up to now
01827     int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());      
01828 
01829     LogTrace("FourVectorHLTOnline") << " pathBin = " << pathBin <<  "  out of histogram total number of bins " << hist_1d->GetNbinsX() <<  std::endl;
01830     if(pathBin == -1) {
01831       
01832       LogTrace("FourVectorHLTOnline") << " Cannot find the bin for path " << pathname << std::endl;
01833       continue;
01834 
01835     }
01836 
01837     int currCount = int(hist_1d->GetBinContent(pathBin));
01838 
01839     // count due to prev lumi sec is a difference bw current and previous
01840     int diffCount = currCount - prevCount;
01841 
01842     LogTrace("FourVectorHLTOnline") << " lumi = " << lumi << "  path " << pathname << "  count " << diffCount <<  std::endl;
01843 
01844     // set the counter in the pair to current count
01845     ip->second = currCount;  
01846 
01847 
01849     // fill the 1D individual path count per LS
01851     std::string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_L1_Total_LS";
01852     MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
01853     if ( ME_1d) { 
01854 
01855       // update  the bin content  (must do that since events don't ncessarily come in the order
01856       int currentLumiCount = int(ME_1d->getTH1()->GetBinContent(lumi+1));
01857       int updatedLumiCount = currentLumiCount + diffCount;
01858       ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
01859 
01860     }
01861     else {
01862 
01863       LogDebug("FourVectorHLTOnline") << " cannot find ME " << fullPathToME_count  <<  std::endl;
01864 
01865     }
01866 
01867    } // end for ip
01868 
01869  } // end for i
01870 
01871 }
01872 
01873 
01874 void FourVectorHLTOnline::countHLTGroupHitsEndLumiBlock(const int& lumi)
01875 {
01876 
01877  LogTrace("FourVectorHLTOnline") << " countHLTGroupHitsEndLumiBlock() lumiSection number " << lumi << std::endl;
01878  //for(unsigned int i=0; i<fGroupName.size(); i++){
01879  for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
01880 
01881     // get the count of path up to now
01882    //string fullPathToME = "HLT/FourVector/PathsSummary/HLT_" + fGroupName[i] + "_Pass_Any";
01883    std::string fullPathToME = "HLT/FourVector/PathsSummary/HLT_" + fGroupNamePathsPair[i].first + "_Pass_Any";
01884    MonitorElement* ME_1d = dbe_->get(fullPathToME);
01885 
01886    if(! ME_1d) {
01887 
01888      LogTrace("FourVectorHLTOnline") << " could not find 1d matrix " << fullPathToME << std::endl;
01889 
01890      continue;
01891 
01892    }
01893 
01894    LogTrace("FourVectorHLTOnline") << " Looking in histogram "  << fullPathToME << std::endl;
01895 
01896    TH1F * hist_1d = ME_1d->getTH1F();
01897 
01898    for (std::vector<std::pair<std::string, int> >::iterator ip = fGroupTempCountPair.begin(); ip != fGroupTempCountPair.end(); ++ip) {
01899   
01900     // get the path and its previous count
01901     std::string pathname = ip->first;  
01902     int prevCount = ip->second;  
01903 
01904     std::string binLabel = "HLT_"+pathname+"_Any";
01905     
01906     LogTrace("FourVectorHLTOnline") << " Looking for binLabel = " << binLabel <<  std::endl;
01907     // get the current count of path up to now
01908     int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());      
01909 
01910     LogTrace("FourVectorHLTOnline") << " pathBin = " << pathBin <<  "  out of histogram total number of bins " << hist_1d->GetNbinsX() <<  std::endl;
01911     if(pathBin == -1) {
01912       
01913       LogTrace("FourVectorHLTOnline") << " Cannot find the bin for path " << pathname << std::endl;
01914       continue;
01915 
01916     }
01917 
01918     int currCount = int(hist_1d->GetBinContent(pathBin));
01919 
01920     // count due to prev lumi sec is a difference bw current and previous
01921     int diffCount = currCount - prevCount;
01922 
01923     LogTrace("FourVectorHLTOnline") << " lumi = " << lumi << "  path " << pathname << "  count " << diffCount <<  std::endl;
01924 
01925     // set the counter in the pair to current count
01926     ip->second = currCount;  
01927 
01928 
01930     // fill the 1D individual path count per LS
01932     std::string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_Total_LS";
01933     MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
01934     if ( ME_1d) { 
01935 
01936       // update  the bin content  (must do that since events don't ncessarily come in the order
01937       int currentLumiCount = int(ME_1d->getTH1()->GetBinContent(lumi+1));
01938       int updatedLumiCount = currentLumiCount + diffCount;
01939       ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
01940 
01941     }
01942     else {
01943 
01944       LogDebug("FourVectorHLTOnline") << " cannot find ME " << fullPathToME_count  <<  std::endl;
01945 
01946     }
01947 
01948    } // end for ip
01949 
01950  } // end for i
01951 
01952 }
01953 
01954 
01955 void FourVectorHLTOnline::countHLTPathHitsEndLumiBlock(const int& lumi)
01956 {
01957 
01958    LogTrace("FourVectorHLTOnline") << " countHLTPathHitsEndLumiBlock() lumiSection number " << lumi << std::endl;
01959     // get the count of path up to now
01960    std::string fullPathToME = "HLT/FourVector/PathsSummary/HLT_All_PassPass";
01961    MonitorElement* ME_2d = dbe_->get(fullPathToME);
01962 
01963    if(! ME_2d) {
01964 
01965      LogTrace("FourVectorHLTOnline") << " could not fine 2d matrix " << fullPathToME << std::endl;
01966 
01967      return;
01968 
01969    }
01970 
01971    TH2F * hist_2d = ME_2d->getTH2F();
01972 
01973    for (std::vector<std::pair<std::string, int> >::iterator ip = fPathTempCountPair.begin(); ip != fPathTempCountPair.end(); ++ip) {
01974   
01975     // get the path and its previous count
01976     std::string pathname = ip->first;  
01977     int prevCount = ip->second;  
01978     
01979     // get the current count of path up to now
01980     int pathBin = hist_2d->GetXaxis()->FindBin(pathname.c_str());      
01981 
01982     if(pathBin > hist_2d->GetNbinsX()) {
01983       
01984       LogTrace("FourVectorHLTOnline") << " Cannot find the bin for path " << pathname << std::endl;
01985       continue;
01986 
01987     }
01988 
01989     int currCount = int(hist_2d->GetBinContent(pathBin, pathBin));
01990 
01991     // count due to prev lumi sec is a difference bw current and previous
01992     int diffCount = currCount - prevCount;
01993 
01994     LogTrace("FourVectorHLTOnline") << " lumi = " << lumi << "  path " << pathname << "  count " << diffCount <<  std::endl;
01995 
01996     // set the counter in the pair to current count
01997     ip->second = currCount;  
01998 
02000     // fill the 2D All paths' count per LS
02002     if ( ME_HLTAll_LS_) {
02003 
02004       TH2F* hist_All = ME_HLTAll_LS_->getTH2F();
02005 
02006       // find the bin
02007       int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
02008       
02009       // update  the bin content  (must do that since events don't ncessarily come in the order
02010       int currentLumiCount = int(hist_All->GetBinContent(lumi+1,pathBinNumber));
02011       int updatedLumiCount = currentLumiCount + diffCount;
02012       hist_All->SetBinContent(lumi+1,pathBinNumber,updatedLumiCount);
02013     
02014     }
02015     else {
02016 
02017       LogDebug("FourVectorHLTOnline") << " cannot find ME_HLTAll_LS_" <<  std::endl;
02018 
02019     }
02020     
02021     for (unsigned int i=0 ; i< v_ME_HLTAll_LS_.size(); i++) {  
02022       
02023       MonitorElement* tempME = v_ME_HLTAll_LS_[i];
02024 
02025       if ( tempME ) {
02026   
02027         TH2F* hist_All = tempME->getTH2F();
02028   
02029         // find the bin
02030         int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
02031         // update  the bin content  (must do that since events don't ncessarily come in the order
02032         int currentLumiCount = int(hist_All->GetBinContent(lumi+1,pathBinNumber));
02033         int updatedLumiCount = currentLumiCount + diffCount;
02034         hist_All->SetBinContent(lumi+1,pathBinNumber,updatedLumiCount);
02035       
02036       }
02037       else {
02038   
02039         LogDebug("FourVectorHLTOnline") << " cannot find tempME " <<  std::endl;
02040   
02041       }
02042 
02043     }
02044 
02045 
02047     // fill the 1D individual path count per LS
02049     std::string fullPathToME_count = pathsIndividualHLTPathsPerLSFolder_ + pathname + "_count_per_LS";
02050     MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
02051     if ( ME_1d) { 
02052 
02053       // update  the bin content  (must do that since events don't ncessarily come in the order
02054       int currentLumiCount = int(ME_1d->getTH1()->GetBinContent(lumi+1));
02055       int updatedLumiCount = currentLumiCount + diffCount;
02056       ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
02057 
02058     }
02059     else {
02060 
02061       LogDebug("FourVectorHLTOnline") << " cannot find ME " << fullPathToME_count  <<  std::endl;
02062 
02063     }
02064 
02065   } // end for ip
02066 
02067 }
02068 
02069 int FourVectorHLTOnline::getTriggerTypeParsePathName(const std::string& pathname)
02070 {
02071 
02072    int objectType = 0;
02073 
02074          if (pathname.find("MET") != std::string::npos) 
02075            objectType = trigger::TriggerMET;    
02076          if (pathname.find("SumET") != std::string::npos) 
02077            objectType = trigger::TriggerTET;    
02078          if (pathname.find("HT") != std::string::npos) 
02079            objectType = trigger::TriggerTET;    
02080          if (pathname.find("Jet") != std::string::npos) 
02081            objectType = trigger::TriggerJet;    
02082          if (pathname.find("Mu") != std::string::npos)
02083            objectType = trigger::TriggerMuon;    
02084          if (pathname.find("Ele") != std::string::npos) 
02085            objectType = trigger::TriggerElectron;    
02086          if (pathname.find("Photon") != std::string::npos) 
02087            objectType = trigger::TriggerPhoton;    
02088          if (pathname.find("Tau") != std::string::npos) 
02089            objectType = trigger::TriggerTau;    
02090          if (pathname.find("IsoTrack") != std::string::npos) 
02091            objectType = trigger::TriggerTrack;    
02092          if (pathname.find("BTag") != std::string::npos) 
02093            objectType = trigger::TriggerBJet;    
02094 
02095    return objectType;
02096 }
02097 
02098 const std::string FourVectorHLTOnline::getL1ConditionModuleName(const std::string& pathname)
02099 {
02100 
02101   // find L1 condition for numpath with numpath objecttype 
02102   // find PSet for L1 global seed for numpath, 
02103   // list module labels for numpath
02104   std::string l1pathname = "dummy";
02105 
02106   std::vector<std::string> numpathmodules = hltConfig_.moduleLabels(pathname);
02107 
02108   for(std::vector<std::string>::iterator numpathmodule = numpathmodules.begin();
02109   numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
02110 
02111     if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed") {
02112 
02113      l1pathname = *numpathmodule;
02114      break; 
02115 
02116     }
02117 
02118   } // end for
02119 
02120   return l1pathname;
02121 
02122 }
02123 
02124 
02125 bool FourVectorHLTOnline::hasL1Passed(const std::string& pathname, const edm::TriggerNames & triggerNames)
02126 {
02127   
02128   bool rc = false;
02129 
02130   std::string l1ModuleName = getL1ConditionModuleName(pathname);
02131   int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1ModuleName);
02132 
02133   unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
02134   if(pathByIndex >= triggerResults_->size() ) return rc; // path is not in the menu
02135 
02136   // get index of the last module that issued the decision
02137   int lastModule = triggerResults_->index(pathByIndex);
02138 
02139   // if L1 passed, then it must not be the module that 
02140   // issued the last decision
02141   rc = (l1ModuleIndex < lastModule);
02142 
02143   return rc;
02144 
02145 }
02146 
02147 bool FourVectorHLTOnline::hasHLTPassed(const std::string& pathname, const edm::TriggerNames & triggerNames)
02148 {
02149   
02150   bool rc = false;
02151 
02152   unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
02153   if(pathByIndex >= triggerResults_->size() ) return rc; // path is not in the menu
02154 
02155   rc  = triggerResults_->accept(pathByIndex);
02156 
02157   return rc;
02158 
02159 }