CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQMOffline/Trigger/src/FourVectorHLTOffline.cc

Go to the documentation of this file.
00001 // $Id: FourVectorHLTOffline.cc,v 1.106 2012/02/01 14:27:45 muzaffar Exp $
00002 // See header file for information. 
00003 #include "TMath.h"
00004 #include "DQMOffline/Trigger/interface/FourVectorHLTOffline.h"
00005 #include "FWCore/Common/interface/TriggerNames.h"
00006 
00007 #include <map>
00008 #include <utility>
00009 
00010 using namespace edm;
00011 using namespace trigger;
00012 using namespace std;
00013 using namespace muon;
00014 
00015 FourVectorHLTOffline::FourVectorHLTOffline(const edm::ParameterSet& iConfig): currentRun_(-99)
00016 {
00017 
00018   LogDebug("FourVectorHLTOffline") << "constructor...." ;
00019 
00020   useUM = false;
00021   fIsSetup = false;
00022   fSelectedMuons = new reco::MuonCollection;
00023   fSelectedElectrons = new reco::GsfElectronCollection;
00024   fSelectedPhotons = new reco::PhotonCollection;
00025   fSelectedJets = new reco::CaloJetCollection;
00026   fSelectedMet = new reco::CaloMETCollection;
00027   //fSelectedTaus = new reco::CaloTauCollection;
00028   fSelectedTaus = new reco::PFTauCollection;
00029 
00030   dbe_ = Service < DQMStore > ().operator->();
00031   if ( ! dbe_ ) {
00032     LogInfo("FourVectorHLTOffline") << "unabel to get DQMStore service?";
00033   }
00034   if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
00035     dbe_->setVerbose(0);
00036   }
00037   
00038   dirname_ = iConfig.getUntrackedParameter("dirname", std::string("HLT/FourVector/"));
00039   //dirname_ +=  iConfig.getParameter<std::string>("@module_label");
00040    
00041   if (dbe_ != 0 ) {
00042     dbe_->setCurrentFolder(dirname_);
00043   }
00044 
00045 
00046   doCombineRuns_ = iConfig.getUntrackedParameter<bool>("doCombineRuns", false);
00047   
00048   processname_ = iConfig.getParameter<std::string>("processname");
00049   fCustomBXPath = iConfig.getUntrackedParameter<std::string>("customBXPath", std::string("HLT_MinBiasBSC"));
00050 
00051   referenceBX_ = iConfig.getUntrackedParameter<unsigned int>("referenceBX",51);
00052   Nbx_ = iConfig.getUntrackedParameter<unsigned int>("Nbx",3564);
00053 
00054   // plotting paramters
00055   ptMin_ = iConfig.getUntrackedParameter<double>("ptMin",0.);
00056   ptMax_ = iConfig.getUntrackedParameter<double>("ptMax",1000.);
00057   nBins_ = iConfig.getUntrackedParameter<unsigned int>("Nbins",20);
00058   nBins2D_ = iConfig.getUntrackedParameter<unsigned int>("Nbins2D",40);
00059   dRMax_ = iConfig.getUntrackedParameter<double>("dRMax",1.0);
00060   nBinsDR_ = iConfig.getUntrackedParameter<unsigned int>("NbinsDR",10);
00061   nBinsOneOverEt_ = iConfig.getUntrackedParameter<unsigned int>("NbinsOneOverEt",10000);
00062   nLS_   = iConfig.getUntrackedParameter<unsigned int>("NLuminositySegments",10);
00063   LSsize_   = iConfig.getUntrackedParameter<double>("LuminositySegmentSize",23);
00064   thresholdFactor_ = iConfig.getUntrackedParameter<double>("thresholdFactor",1.5);
00065 
00066   
00067   plotAll_ = iConfig.getUntrackedParameter<bool>("plotAll", false);
00068      // this is the list of paths to look at.
00069   std::vector<edm::ParameterSet> paths = 
00070   iConfig.getParameter<std::vector<edm::ParameterSet> >("paths");
00071 
00072   for(std::vector<edm::ParameterSet>::iterator pathconf = paths.begin() ; pathconf != paths.end(); pathconf++) {
00073 
00074     //std::pair<std::string, std::string> custompathnamepair;
00075     //custompathnamepair.first =pathconf->getParameter<std::string>("pathname"); 
00076     //custompathnamepair.second = pathconf->getParameter<std::string>("denompathname");   
00077     //custompathnamepairs_.push_back(custompathnamepair);
00078     custompathnamepairs_.push_back(
00079         make_pair(
00080           pathconf->getParameter<std::string>("pathname"),
00081           pathconf->getParameter<std::string>("denompathname")
00082         )
00083     );
00084 
00085   }
00086 
00087   if (hltPaths_.size() > 0)
00088   {
00089       // book a histogram of scalers
00090      scalersSelect = dbe_->book1D("selectedScalers","Selected Scalers", hltPaths_.size(), 0.0, (double)hltPaths_.size());
00091 
00092   }
00093 
00094   triggerSummaryLabel_ = iConfig.getParameter<edm::InputTag>("triggerSummaryLabel");
00095   triggerResultsLabel_ = iConfig.getParameter<edm::InputTag>("triggerResultsLabel");
00096   muonRecoCollectionName_ = iConfig.getUntrackedParameter("muonRecoCollectionName", std::string("muons"));
00097 
00098   electronEtaMax_ = iConfig.getUntrackedParameter<double>("electronEtaMax",2.5);
00099   electronEtMin_ = iConfig.getUntrackedParameter<double>("electronEtMin",3.0);
00100   electronDRMatch_  =iConfig.getUntrackedParameter<double>("electronDRMatch",0.3); 
00101   electronL1DRMatch_  =iConfig.getUntrackedParameter<double>("electronL1DRMatch",0.3); 
00102 
00103   muonEtaMax_ = iConfig.getUntrackedParameter<double>("muonEtaMax",2.1);
00104   muonEtMin_ = iConfig.getUntrackedParameter<double>("muonEtMin",3.0);
00105   muonDRMatch_  =iConfig.getUntrackedParameter<double>("muonDRMatch",0.3); 
00106   muonL1DRMatch_  =iConfig.getUntrackedParameter<double>("muonL1DRMatch",0.3); 
00107 
00108   tauEtaMax_ = iConfig.getUntrackedParameter<double>("tauEtaMax",2.5);
00109   tauEtMin_ = iConfig.getUntrackedParameter<double>("tauEtMin",3.0);
00110   tauDRMatch_  =iConfig.getUntrackedParameter<double>("tauDRMatch",0.3); 
00111   tauL1DRMatch_  =iConfig.getUntrackedParameter<double>("tauL1DRMatch",0.5); 
00112 
00113   jetEtaMax_ = iConfig.getUntrackedParameter<double>("jetEtaMax",5.0);
00114   jetEtMin_ = iConfig.getUntrackedParameter<double>("jetEtMin",10.0);
00115   jetDRMatch_  =iConfig.getUntrackedParameter<double>("jetDRMatch",0.3); 
00116   jetL1DRMatch_  =iConfig.getUntrackedParameter<double>("jetL1DRMatch",0.5); 
00117 
00118   bjetEtaMax_ = iConfig.getUntrackedParameter<double>("bjetEtaMax",2.5);
00119   bjetEtMin_ = iConfig.getUntrackedParameter<double>("bjetEtMin",10.0);
00120   bjetDRMatch_  =iConfig.getUntrackedParameter<double>("bjetDRMatch",0.3); 
00121   bjetL1DRMatch_  =iConfig.getUntrackedParameter<double>("bjetL1DRMatch",0.3); 
00122 
00123   photonEtaMax_ = iConfig.getUntrackedParameter<double>("photonEtaMax",2.5);
00124   photonEtMin_ = iConfig.getUntrackedParameter<double>("photonEtMin",3.0);
00125   photonDRMatch_  =iConfig.getUntrackedParameter<double>("photonDRMatch",0.3); 
00126   photonL1DRMatch_  =iConfig.getUntrackedParameter<double>("photonL1DRMatch",0.3); 
00127 
00128   trackEtaMax_ = iConfig.getUntrackedParameter<double>("trackEtaMax",2.5);
00129   trackEtMin_ = iConfig.getUntrackedParameter<double>("trackEtMin",3.0);
00130   trackDRMatch_  =iConfig.getUntrackedParameter<double>("trackDRMatch",0.3); 
00131   trackL1DRMatch_  =iConfig.getUntrackedParameter<double>("trackL1DRMatch",0.3); 
00132 
00133   metEtaMax_ = iConfig.getUntrackedParameter<double>("metEtaMax",5);
00134   metMin_ = iConfig.getUntrackedParameter<double>("metMin",10.0);
00135   metDRMatch_  =iConfig.getUntrackedParameter<double>("metDRMatch",0.5); 
00136   metL1DRMatch_  =iConfig.getUntrackedParameter<double>("metL1DRMatch",0.5); 
00137 
00138   htEtaMax_ = iConfig.getUntrackedParameter<double>("htEtaMax",5);
00139   htMin_ = iConfig.getUntrackedParameter<double>("htMin",10.0);
00140   htDRMatch_  =iConfig.getUntrackedParameter<double>("htDRMatch",0.5); 
00141   htL1DRMatch_  =iConfig.getUntrackedParameter<double>("htL1DRMatch",0.5); 
00142 
00143   sumEtMin_ = iConfig.getUntrackedParameter<double>("sumEtMin",10.0);
00144 
00145   // Muon quality cuts
00147   dxyCut_ = iConfig.getUntrackedParameter<double>("DxyCut", 0.2);   // dxy < 0.2 cm 
00148   normalizedChi2Cut_ = iConfig.getUntrackedParameter<double>("NormalizedChi2Cut", 10.); // chi2/ndof (of global fit) <10.0
00149   trackerHitsCut_ = iConfig.getUntrackedParameter<int>("TrackerHitsCut", 11);  // Tracker Hits >10 
00150   pixelHitsCut_ = iConfig.getUntrackedParameter<int>("PixelHitsCut", 1); // Pixel Hits >0
00151   muonHitsCut_ = iConfig.getUntrackedParameter<int>("MuonHitsCut", 1);  // Valid Muon Hits >0 
00152   isAlsoTrackerMuon_ = iConfig.getUntrackedParameter<bool>("IsAlsoTrackerMuon", true);
00153   nMatchesCut_ = iConfig.getUntrackedParameter<int>("NMatchesCut", 2); // At least 2 Chambers with matches 
00154 
00155   // Electron quality cuts
00157         eleMaxOver3x3_  =  iConfig.getUntrackedParameter<double>("eleMaxOver3x3", 0.9);
00158   // Ecal Barrel
00159   dr03TkSumPtEB_ =  iConfig.getUntrackedParameter<double>("dr03TkSumPtEB", 3.0);
00160         dr04EcalRecHitSumEtEB_ = iConfig.getUntrackedParameter<double>("dr04EcalRecHitSumEtEB", 4.0);
00161         dr04HcalTowerSumEtEB_ =  iConfig.getUntrackedParameter<double>("dr04HcalTowerSumEtEB", 5.0);
00162         hadronicOverEmEB_ =    iConfig.getUntrackedParameter<double>("hadronicOverEmEB", 0.05);
00163         deltaPhiSuperClusterTrackAtVtxEB_ = iConfig.getUntrackedParameter<double>("deltaPhiSuperClusterTrackAtVtxEB", 0.2);
00164         deltaEtaSuperClusterTrackAtVtxEB_ = iConfig.getUntrackedParameter<double>("deltaEtaSuperClusterTrackAtVtxEB", 0.006);
00165         sigmaIetaIetaEB_ = iConfig.getUntrackedParameter<double>("sigmaIetaIetaEB", 0.01);
00166   //spikes
00167         sigmaIetaIetaSpikesEB_ = iConfig.getUntrackedParameter<double>("sigmaIetaIetaSpikesEB", 0.002);
00168 
00169   // Ecal Endcap
00170         dr03TkSumPtEC_ =  iConfig.getUntrackedParameter<double>("dr03TkSumPtEC", 1.5);
00171         dr04EcalRecHitSumEtEC_ = iConfig.getUntrackedParameter<double>("dr04EcalRecHitSumEtEC", 2.5);
00172         dr04HcalTowerSumEtEC_ =  iConfig.getUntrackedParameter<double>("dr04HcalTowerSumEtEC", 0.7);
00173         hadronicOverEmEC_ =  iConfig.getUntrackedParameter<double>("hadronicOverEmEC", 0.025);
00174         deltaPhiSuperClusterTrackAtVtxEC_ = iConfig.getUntrackedParameter<double>("deltaPhiSuperClusterTrackAtVtxEC", 0.2);
00175         deltaEtaSuperClusterTrackAtVtxEC_ = iConfig.getUntrackedParameter<double>("deltaEtaSuperClusterTrackAtVtxEC", 0.006);
00176         sigmaIetaIetaEC_ = iConfig.getUntrackedParameter<double>("sigmaIetaIetaEC", 0.03);
00177   //spikes
00178         sigmaIetaIetaSpikesEC_ = iConfig.getUntrackedParameter<double>("sigmaIetaIetaSpikesEC", 0.002);
00179 
00180   // Jet ID cuts
00182   emEnergyFractionJet_ = iConfig.getUntrackedParameter<double>("emEnergyFractionJet",0.01);
00183   fHPDJet_ = iConfig.getUntrackedParameter<double>("fHPDJet",0.98);
00184   n90Jet_ = iConfig.getUntrackedParameter<int>("n90Jet",2);
00185 
00186   // Tau discriminators
00188   tauDscrmtrLabel1_ = iConfig.getUntrackedParameter("tauDscrmtrLabel1", std::string("shrinkingConePFTauDiscriminationByLeadingTrackFinding"));
00189   tauDscrmtrLabel2_ = iConfig.getUntrackedParameter("tauDscrmtrLabel2", std::string("shrinkingConePFTauDiscriminationByLeadingTrackPtCut"));
00190   tauDscrmtrLabel3_ = iConfig.getUntrackedParameter("tauDscrmtrLabel3", std::string("shrinkingConePFTauDiscriminationByIsolation"));
00191 
00192   specialPaths_ = iConfig.getParameter<std::vector<std::string > >("SpecialPaths");
00193 
00194   pathsSummaryFolder_ = iConfig.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/FourVector/PathsSummary/"));
00195   pathsSummaryHLTCorrelationsFolder_ = iConfig.getUntrackedParameter ("hltCorrelationsFolder",std::string("HLT/FourVector/PathsSummary/HLT Correlations/"));
00196   pathsSummaryFilterCountsFolder_ = iConfig.getUntrackedParameter ("filterCountsFolder",std::string("HLT/FourVector/PathsSummary/Filters Counts/"));
00197 
00198   pathsSummaryHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("pathsPerLSFolder",std::string("HLT/FourVector/PathsSummary/HLT LS/"));
00199   //  pathsIndividualHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("individualPathsPerLSFolder",std::string("HLT/FourVector/PathsSummary/HLT LS/Paths/"));
00200   //  pathsSummaryHLTPathsPerBXFolder_ = iConfig.getUntrackedParameter ("individualPathsPerBXFolder",std::string("HLT/FourVector/PathsSummary/HLT BX/"));
00201 
00202   fLumiFlag = true;
00203   ME_HLTAll_LS = NULL;
00204   ME_HLT_BX = NULL;
00205   ME_HLT_CUSTOM_BX = NULL;
00206 
00207   jetID = new reco::helper::JetIDHelper(iConfig.getParameter<ParameterSet>("JetIDParams"));
00208 
00209     recHitsEBTag_ = iConfig.getUntrackedParameter<edm::InputTag>("RecHitsEBTag",edm::InputTag("reducedEcalRecHitsEB"));
00210       recHitsEETag_ = iConfig.getUntrackedParameter<edm::InputTag>("RecHitsEETag",edm::InputTag("reducedEcalRecHitsEE"));
00211 
00212   
00213 }
00214 
00215 
00216 FourVectorHLTOffline::~FourVectorHLTOffline()
00217 {
00218  
00219   // do anything here that needs to be done at desctruction time
00220   // (e.g. close files, deallocate resources etc.)
00221   delete fSelectedMuons;
00222   delete fSelectedElectrons;
00223   delete fSelectedPhotons;
00224   delete fSelectedJets;
00225   delete fSelectedMet;
00226   delete fSelectedTaus;
00227 
00228 }
00229 
00230 
00231 //
00232 // member functions
00233 //
00234 
00235 // ------------ method called to for each event  ------------
00236 void
00237 FourVectorHLTOffline::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00238 {
00239 
00240   //if(! fLumiFlag ) return;
00241 
00242   using namespace edm;
00243   using namespace trigger;
00244   ++nev_;
00245   LogDebug("FourVectorHLTOffline")<< " analyze...." ;
00246 
00247 
00248   
00249   /*
00250   Handle<GenParticleCollection> genParticles;
00251   iEvent.getByLabel("genParticles", genParticles);
00252   if(!genParticles.isValid()) { 
00253     edm::LogInfo("FourVectorHLTOffline") << "genParticles not found, "
00254       "skipping event"; 
00255     return;
00256   }
00257 
00258   Handle<GenJetCollection> genJets;
00259   iEvent.getByLabel("iterativeCone5GenJets",genJets);
00260   if(!genJets.isValid()) { 
00261     edm::LogInfo("FourVectorHLTOffline") << "genJets not found, "
00262       "skipping event"; 
00263     return;
00264   }
00265 
00266   Handle<GenMETCollection> genMets;
00267   iEvent.getByLabel("genMetTrue",genMets);
00268   if(!genMets.isValid()) { 
00269     edm::LogInfo("FourVectorHLTOffline") << "genMets not found, "
00270       "skipping event"; 
00271     return;
00272   }
00273   */
00274 
00275   edm::Handle<TriggerResults> triggerResults;
00276   iEvent.getByLabel(triggerResultsLabel_,triggerResults);
00277   if(!triggerResults.isValid()) {
00278     edm::InputTag triggerResultsLabelFU(triggerResultsLabel_.label(),triggerResultsLabel_.instance(), "FU");
00279    iEvent.getByLabel(triggerResultsLabelFU,triggerResults);
00280   if(!triggerResults.isValid()) {
00281     edm::LogInfo("FourVectorHLTOffline") << "TriggerResults not found, "
00282       "skipping event"; 
00283     return;
00284    }
00285   }
00286   fTriggerResults = triggerResults;
00287   const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
00288   int npath = triggerResults->size();
00289 
00290   iEvent.getByLabel(triggerSummaryLabel_,fTriggerObj); 
00291   if(!fTriggerObj.isValid()) {
00292 
00293     edm::InputTag triggerSummaryLabelFU(triggerSummaryLabel_.label(),triggerSummaryLabel_.instance(), "FU");
00294     iEvent.getByLabel(triggerSummaryLabelFU,fTriggerObj);
00295 
00296     if(!fTriggerObj.isValid()) {
00297 
00298       edm::LogInfo("FourVectorHLTOffline") << "TriggerEvent not found, " "skipping event"; 
00299       return;
00300 
00301     }
00302 
00303   }
00304 
00305   // Beam spot
00306   if (!iEvent.getByLabel(InputTag("offlineBeamSpot"), fBeamSpotHandle)) {
00307         edm::LogInfo("") << ">>> No beam spot found !!!";
00308   }
00309 
00310   edm::Handle<reco::MuonCollection> muonHandle;
00311   iEvent.getByLabel(muonRecoCollectionName_,muonHandle);
00312   if(!muonHandle.isValid())  
00313     edm::LogInfo("FourVectorHLTOffline") << "muonHandle not found, ";
00314   selectMuons(muonHandle);
00315 
00316   edm::Handle<reco::GsfElectronCollection> gsfElectrons;
00317   iEvent.getByLabel("gsfElectrons",gsfElectrons); 
00318   if(!gsfElectrons.isValid()) 
00319     edm::LogInfo("FourVectorHLTOffline") << "gsfElectrons not found, ";
00320   selectElectrons(iEvent, iSetup, gsfElectrons);
00321 
00322   //edm::Handle<reco::CaloTauCollection> tauHandle;
00323   edm::Handle<reco::PFTauCollection> tauHandle;
00324   iEvent.getByLabel("caloRecoTauProducer",tauHandle);
00325   if(!tauHandle.isValid()) 
00326     edm::LogInfo("FourVectorHLTOffline") << "tauHandle not found, ";
00327   //selectTaus(tauHandle);
00328   selectTaus(iEvent);
00329 
00330   edm::Handle<reco::CaloJetCollection> jetHandle;
00331   iEvent.getByLabel("iterativeCone5CaloJets",jetHandle);
00332   if(!jetHandle.isValid()) 
00333     edm::LogInfo("FourVectorHLTOffline") << "jetHandle not found, ";
00334   selectJets(iEvent,jetHandle);
00335 
00336    // Get b tag information
00337  edm::Handle<reco::JetTagCollection> bTagIPHandle;
00338  iEvent.getByLabel("jetProbabilityBJetTags", bTagIPHandle);
00339  if (!bTagIPHandle.isValid()) 
00340     edm::LogInfo("FourVectorHLTOffline") << "mTagIPHandle trackCountingHighEffJetTags not found, ";
00341 
00342    // Get b tag information
00343  edm::Handle<reco::JetTagCollection> bTagMuHandle;
00344  iEvent.getByLabel("softMuonBJetTags", bTagMuHandle);
00345  if (!bTagMuHandle.isValid()) 
00346     edm::LogInfo("FourVectorHLTOffline") << "bTagMuHandle  not found, ";
00347 
00348   edm::Handle<reco::CaloMETCollection> metHandle;
00349   iEvent.getByLabel("met",metHandle);
00350   if(!metHandle.isValid()) 
00351     edm::LogInfo("FourVectorHLTOffline") << "metHandle not found, ";
00352   selectMet(metHandle);
00353 
00354   edm::Handle<reco::PhotonCollection> photonHandle;
00355   iEvent.getByLabel("photons",photonHandle);
00356   if(!photonHandle.isValid()) 
00357     edm::LogInfo("FourVectorHLTOffline") << "photonHandle not found, ";
00358   selectPhotons(photonHandle);
00359 
00360   edm::Handle<reco::TrackCollection> trackHandle;
00361   iEvent.getByLabel("pixelTracks",trackHandle);
00362   if(!trackHandle.isValid()) 
00363     edm::LogInfo("FourVectorHLTOffline") << "trackHandle not found, ";
00364 
00365 
00366   // ---------------------
00367   // Monitors
00368   // ---------------------
00369 
00370   // electron Monitor
00371   objMonData<reco::GsfElectronCollection> eleMon;
00372   //eleMon.setReco(gsfElectrons);
00373   eleMon.setReco(fSelElectronsHandle);
00374   eleMon.setRecoEle(fSelElectronsHandle);
00375   eleMon.setLimits(electronEtaMax_, electronEtMin_, electronDRMatch_, electronL1DRMatch_, dRMax_, thresholdFactor_);
00376   
00377   eleMon.pushTriggerType(TriggerElectron);
00378   eleMon.pushTriggerType(TriggerL1NoIsoEG);
00379   eleMon.pushTriggerType(TriggerL1IsoEG);
00380 
00381   eleMon.pushL1TriggerType(TriggerL1NoIsoEG);
00382   eleMon.pushL1TriggerType(TriggerL1IsoEG);
00383 
00384   // muon Monitor
00385   objMonData<reco::MuonCollection>  muoMon;
00386   //muoMon.setReco(muonHandle);
00387   muoMon.setReco(fSelMuonsHandle);
00388   muoMon.setRecoMu(fSelMuonsHandle);
00389   muoMon.setLimits(muonEtaMax_, muonEtMin_, muonDRMatch_, muonL1DRMatch_, dRMax_, thresholdFactor_);
00390   
00391   muoMon.pushTriggerType(TriggerMuon);
00392   muoMon.pushTriggerType(TriggerL1Mu);
00393 
00394   muoMon.pushL1TriggerType(TriggerL1Mu);
00395   
00396   // tau Monitor
00397   //objMonData<reco::CaloTauCollection>  tauMon;
00398   objMonData<reco::PFTauCollection>  tauMon;
00399   //tauMon.setReco(tauHandle);
00400   tauMon.setReco(fSelTausHandle);
00401   tauMon.setLimits(tauEtaMax_, tauEtMin_, tauDRMatch_, tauL1DRMatch_, dRMax_, thresholdFactor_);
00402   
00403   tauMon.pushTriggerType(TriggerTau);
00404   tauMon.pushTriggerType(TriggerL1TauJet);
00405 
00406   tauMon.pushL1TriggerType(TriggerL1TauJet);
00407   tauMon.pushL1TriggerType(TriggerL1ForJet);
00408   
00409   // photon Monitor
00410   //objMonData<reco::PhotonCollection> phoMon;
00411   //phoMon.setReco(photonHandle);
00412   //phoMon.setReco(fSelPhotonsHandle);
00413   // -----------------------------------------------
00414   // Use RECO Electrons instead of RECO Photons 
00415   // to measure HLT_Photon efficiency
00416   // -----------------------------------------------
00417   objMonData<reco::GsfElectronCollection> phoMon;
00418   phoMon.setReco(fSelElectronsHandle);
00419   phoMon.setRecoEle(fSelElectronsHandle);
00420   
00421 
00422   phoMon.setLimits(photonEtaMax_, photonEtMin_, photonDRMatch_, photonL1DRMatch_, dRMax_, thresholdFactor_);
00423   
00424   phoMon.pushTriggerType(TriggerPhoton);
00425 
00426   phoMon.pushL1TriggerType(TriggerL1NoIsoEG);
00427   phoMon.pushL1TriggerType(TriggerL1IsoEG);
00428 
00429   // jet Monitor - NOTICE: we use genJets for MC
00430   objMonData<reco::CaloJetCollection> jetMon;
00431   //jetMon.setReco(jetHandle);
00432   jetMon.setReco(fSelJetsHandle);
00433   jetMon.setLimits(jetEtaMax_, jetEtMin_, jetDRMatch_, jetL1DRMatch_, dRMax_, thresholdFactor_);
00434 
00435   jetMon.pushTriggerType(TriggerJet);
00436   jetMon.pushTriggerType(TriggerL1CenJet);
00437   jetMon.pushTriggerType(TriggerL1ForJet);
00438   
00439   jetMon.pushL1TriggerType(TriggerL1CenJet);
00440   jetMon.pushL1TriggerType(TriggerL1ForJet);
00441   jetMon.pushL1TriggerType(TriggerL1TauJet);
00442 
00443   // bjet Monitor - NOTICE: we use genJets for MC
00444   objMonData<reco::CaloJetCollection> btagIPMon; // CaloJet will not be used, this is only place holder
00445   //btagIPMon.setReco(jetHandle);
00446   btagIPMon.setRecoB(bTagIPHandle);
00447   btagIPMon.setBJetsFlag(true);
00448   btagIPMon.setLimits(bjetEtaMax_, bjetEtMin_, bjetDRMatch_, bjetL1DRMatch_, dRMax_, thresholdFactor_);
00449 
00450   btagIPMon.pushTriggerType(TriggerBJet);
00451   btagIPMon.pushTriggerType(TriggerJet);
00452 
00453   btagIPMon.pushL1TriggerType(TriggerL1CenJet);
00454   btagIPMon.pushL1TriggerType(TriggerL1ForJet);
00455   btagIPMon.pushL1TriggerType(TriggerL1TauJet);
00456 
00457   objMonData<reco::CaloJetCollection> btagMuMon; // CaloJet will not be used, this is only place holder
00458   //btagMuMon.setReco(jetHandle);
00459   btagMuMon.setRecoB(bTagMuHandle);
00460   btagMuMon.setBJetsFlag(true);
00461   btagMuMon.setLimits(bjetEtaMax_, bjetEtMin_, bjetDRMatch_, bjetL1DRMatch_, dRMax_, thresholdFactor_);
00462 
00463   btagMuMon.pushTriggerType(TriggerBJet);
00464   btagMuMon.pushTriggerType(TriggerJet);
00465 
00466   btagMuMon.pushL1TriggerType(TriggerL1CenJet);
00467   btagMuMon.pushL1TriggerType(TriggerL1ForJet);
00468   btagMuMon.pushL1TriggerType(TriggerL1TauJet);
00469 
00470 
00471   objMonData<reco::CaloJetCollection> btagMon; // Generic btagMon
00472  
00473   // met Monitor
00474   objMonData<reco::CaloMETCollection> metMon;
00475   //metMon.setReco(metHandle);
00476   metMon.setReco(fSelMetHandle);
00477   metMon.setLimits(metEtaMax_, metMin_, metDRMatch_, metL1DRMatch_, dRMax_, thresholdFactor_);
00478   
00479   metMon.pushTriggerType(TriggerMET);
00480 
00481   metMon.pushL1TriggerType(TriggerL1ETM);
00482 
00483   // tet Monitor
00484   objMonData<reco::CaloMETCollection> tetMon;
00485   //tetMon.setReco(metHandle);
00486   tetMon.setReco(fSelMetHandle);
00487   //tetMon.setLimits(tetEtaMax_=999., tetEtMin_=10, tetDRMatch_=999);
00488   tetMon.setLimits(999., 10., 999., 999., dRMax_, thresholdFactor_);
00489   
00490   tetMon.pushTriggerType(TriggerTET);
00491 
00492   tetMon.pushL1TriggerType(TriggerL1ETT);
00493 
00494   // default Monitor
00495   //objMonData<trigger::TriggerEvent> defMon;
00496   objMonData<reco::CaloMETCollection> defMon;
00497   defMon.setLimits(999., 3., 999., 999., dRMax_, thresholdFactor_);
00498 
00499   // vector to hold monitors 
00500   // interface is through virtual class BaseMonitor
00501   std::vector<BaseMonitor*> monitors;
00502 
00503   //monitors.push_back(&jetMon);
00504 
00505   monitors.push_back(&muoMon);
00506   monitors.push_back(&eleMon);
00507   monitors.push_back(&tauMon);
00508   monitors.push_back(&phoMon);
00509   monitors.push_back(&jetMon);
00510   monitors.push_back(&btagMon);
00511   monitors.push_back(&metMon);
00512   monitors.push_back(&tetMon);
00513   /*
00514   */
00515 
00516   //  int bx = iEvent.bunchCrossing();
00517   /*
00518   // Fill HLTPassed_Correlation Matrix bin (i,j) = (Any,Any)
00519   // --------------------------------------------------------
00520   int anyBinNumber = ME_HLTPassPass_->getTH2F()->GetXaxis()->FindBin("HLT_Any");      
00521   // any triger accepted
00522   if(triggerResults->accept()){
00523 
00524     ME_HLTPassPass_->Fill(anyBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
00525 
00526   }
00527   */
00528 
00529   fillHltMatrix(triggerNames);
00530 
00531 
00532   // Loop over paths
00533   // --------------------
00534   for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) { 
00535 
00536     LogTrace("FourVectorHLTOffline") << " unique path " << v->getPath() << endl;
00537 
00538     unsigned int pathByIndex = triggerNames.triggerIndex(v->getPath());
00539 
00540     // path must be in the menu
00541     if(pathByIndex >= fTriggerResults->size() ) continue;
00542 
00543   
00544     // Fill HLTPassed Matrix and HLTPassFail Matrix
00545     // --------------------------------------------------------
00546 
00547 //     if(triggerResults->accept(pathByIndex)){
00548   
00549 //       int pathBinNumber = ME_HLT_BX->getTH2F()->GetYaxis()->FindBin(v->getPath().c_str());      
00550 //       ME_HLT_BX->Fill(bx,pathBinNumber-1);
00551 
00552 //       //if(hasHLTPassed(fCustomBXPath,triggerNames)) {
00553 
00554 //         //ME_HLT_CUSTOM_BX->Fill(bx,pathBinNumber-1);
00555 
00556 //       //}
00557 
00558 //     } // end if accept
00559   
00560     // Fill histogram of filter ocupancy for each HLT path
00561     // ---------------------------------
00562     unsigned int lastModule = triggerResults->index(pathByIndex);
00563 
00564     //check if hlt passed
00565     bool hltPathPassed = triggerResults->accept(pathByIndex);
00566   
00567     //go through the list of filters
00568     for(unsigned int filt = 0; filt < v->filtersAndIndices.size(); filt++){
00569       
00570       int binNumber = v->getFiltersHisto()->getTH1()->GetXaxis()->FindBin(v->filtersAndIndices[filt].first.c_str());      
00571       
00572       // if hlt path passed, then all the modules passed
00573       // otherwise the module that issued the decision is the first fail
00574       // this means that all modules before it passed
00575       if(hltPathPassed) {
00576 
00577         v->getFiltersHisto()->Fill(binNumber-1);//binNumber1 = 0 = first filter
00578       }
00579       else if(v->filtersAndIndices[filt].second < lastModule){
00580         v->getFiltersHisto()->Fill(binNumber-1);//binNumber1 = 0 = first filter
00581       }
00582   
00583     } // end for filt
00584 
00585   } // end for diag paths
00586 
00587   // Main loop over paths
00588   // --------------------
00589   for(PathInfoCollection::iterator v = hltPaths_.begin(); v!= hltPaths_.end(); ++v ) { 
00590 
00591     LogTrace("FourVectorHLTOffline") << " path " << v->getPath() << endl;
00592 
00593     if (v->getPath().find("BTagIP") != std::string::npos ) btagMon = btagIPMon;
00594     else btagMon = btagMuMon;
00595 
00596     // set flag for muon monitor if L2-muon or L1-muon type path
00597     if (v->getPath().find("L2Mu") != std::string::npos || v->getPath().find("L1Mu") != std::string::npos ) muoMon.setL2MuFlag(true);
00598     else muoMon.setL2MuFlag(false);
00599 
00600     //if (v->getPath().find("HLT_Jet15U") == std::string::npos ) continue;
00601     //if(*v != "HLT_L1Jet6U") continue;
00602 
00603     unsigned int pathByIndex = triggerNames.triggerIndex(v->getPath());
00604 
00605     if(pathByIndex >= fTriggerResults->size() ) continue;
00606   
00607     // did we pass the denomPath?
00608     bool denompassed = false;  
00609 
00610     for(int i = 0; i < npath; ++i) {
00611 
00612      if (triggerResults->accept(i) && triggerNames.triggerName(i).find(v->getDenomPath()) != std::string::npos && triggerNames.triggerName(i).find("HLT_Mult") == std::string::npos )
00613      { 
00614         denompassed = true;
00615         break;
00616      }
00617    }
00618 
00619    if (denompassed)
00620    {  
00621 
00622      //LogTrace("FourVectorHLTOffline") << " denominator path " << v->getPath() << endl;
00623 
00624 
00625      // Get the righe monitor for this path
00626      // -----------------------------------
00627      BaseMonitor* mon = NULL;
00628 
00629      for(std::vector<BaseMonitor*>::iterator mit = monitors.begin(); mit!= monitors.end(); ++mit ) {
00630        
00631        if((*mit)->isTriggerType(v->getObjectType())) {
00632 
00633          mon = *mit;
00634          break;
00635 
00636        }
00637 
00638      }
00639 
00640      // if cannot find moniotor for the path, go to next path
00641      //if(!mon) continue;
00642 
00643      // if cannot find moniotor for the path, assign the default
00644      if(!mon) mon = &defMon;
00645 
00646      // attach this path to mon
00647      mon->setPath(v);
00648 
00649      // clear sets of matched objects
00650      mon->clearSets();
00651 
00652      v->getObjectType();
00653 
00654      // monitor offline (RECO objects)
00656      mon->monitorOffline();
00657 
00658      // monitor L1 (only if L1 passed and can find GTSeed)
00660      bool l1accept = false;
00661      edm::InputTag l1testTag(v->getl1Path(),"",processname_);
00662      const int l1Index = fTriggerObj->filterIndex(l1testTag);
00663      
00664      if ( l1Index >= fTriggerObj->sizeFilters() ) {
00665 
00666        LogTrace("FourVectorHLTOffline") << "Cannot find L1GTSeed of the path " << v->getPath() << endl;
00667        LogTrace("FourVectorHLTOffline") << "\t L1GTSeed name = " << v->getl1Path() << endl;
00668        LogTrace("FourVectorHLTOffline") <<  "\t tried with tag " << l1testTag << endl;
00669        LogTrace("FourVectorHLTOffline") <<"\t module index = "<< l1Index << endl;
00670 
00671      } 
00672 
00673            // monitor L1 object
00674            mon->monitorL1(l1Index, this);
00675         
00676            // fill matching b/w Offline and L1 objects
00677            mon->fillL1Match(this);
00678         
00679     // monitor Online (only if HLT passed)
00681           bool numpassed = false;
00682 
00683     // did we pass the numerator path, i.e. HLT path?
00684     for(int i = 0; i < npath; ++i) {
00685 
00686       if ( triggerResults->accept(i) && triggerNames.triggerName(i) == v->getPath() ) numpassed = true;
00687 
00688     }
00689 
00690     if (!numpassed) continue;
00691 
00692     if (!l1accept) {
00693 
00694           LogDebug("FourVectorHLTOffline") 
00695             << "This should not happen.  HLT passed, but L1 Seed not passed for hlt path "<< endl 
00696             << "HLT path: " << v->getPath() << "\t HLTLevel1GTSeed: " << v->getl1Path();
00697 
00698     }
00699 
00700     // fill scaler histograms
00701     edm::InputTag filterTag = v->getTag();
00702 
00703     // loop through indices and see if the filter is 
00704     // on the list of filters used by this path
00705     //----------------------------------------------
00706     if (v->getLabel() == "dummy"){
00707     const vector<string> filterLabels = hltConfig_.moduleLabels(v->getPath());
00708 
00709     //loop over labels
00710     for (vector<string>::const_iterator labelIter= filterLabels.begin(); labelIter!=filterLabels.end(); labelIter++) {
00711 
00712       edm::InputTag testTag(*labelIter,"",processname_);
00713 
00714       int testindex = fTriggerObj->filterIndex(testTag);
00715 
00716       // last match wins...
00717       if ( !(testindex >= fTriggerObj->sizeFilters()) ) {
00718 
00719         filterTag = testTag; 
00720         v->setLabel(*labelIter);}
00721 
00722       }
00723 
00724     } // end for
00725   
00726     const int hltIndex = fTriggerObj->filterIndex(filterTag);
00727     if ( hltIndex >= fTriggerObj->sizeFilters() ) {
00728 
00729       LogTrace("FourVectorHLTOffline") << "WTF no index "<< hltIndex << " of that name " << filterTag << endl;
00730       continue; // not in this event
00731 
00732     }
00733 
00734     mon->monitorOnline(hltIndex, l1Index, this);
00735 
00736     mon->fillOnlineMatch(l1Index, this);
00737 
00738    } //denompassed
00739 
00740 
00741  } //pathinfo loop
00742 
00743 }
00744 
00745 
00746 
00747 // -- method called once each job just before starting event loop  --------
00748 void 
00749 FourVectorHLTOffline::beginJob()
00750 {
00751   nev_ = 0;
00752   DQMStore *dbe = 0;
00753   dbe = Service<DQMStore>().operator->();
00754   
00755   if (dbe) {
00756     dbe->setCurrentFolder(dirname_);
00757     dbe->rmdir(dirname_);
00758   }
00759   
00760   
00761   if (dbe) {
00762     dbe->setCurrentFolder(dirname_);
00763     }  
00764 }
00765 
00766 // - method called once each job just after ending the event loop  ------------
00767 void 
00768 FourVectorHLTOffline::endJob() 
00769 {
00770    LogInfo("FourVectorHLTOffline") << "analyzed " << nev_ << " events";
00771    return;
00772 }
00773 
00774 
00775 // BeginRun
00776 void FourVectorHLTOffline::beginRun(const edm::Run& run, const edm::EventSetup& c)
00777 {
00778 
00779   LogDebug("FourVectorHLTOffline") << "beginRun, run " << run.id();
00780 
00781   if(fIsSetup) return;
00782   
00783   // HLT config does not change within runs!
00784   bool changed=false;
00785  
00786   if (!hltConfig_.init(run, c, processname_, changed)) {
00787 
00788     processname_ = "FU";
00789 
00790     if (!hltConfig_.init(run, c, processname_, changed)){
00791 
00792       LogDebug("FourVectorHLTOffline") << "HLTConfigProvider failed to initialize.";
00793 
00794     }
00795 
00796     // check if trigger name in (new) config
00797     //  cout << "Available TriggerNames are: " << endl;
00798     //  hltConfig_.dump("Triggers");
00799   }
00800 
00801   if (1) {
00802 
00803     DQMStore *dbe = 0;
00804     dbe = Service<DQMStore>().operator->();
00805   
00806     if (dbe) {
00807       dbe->setCurrentFolder(dirname_);
00808     }
00809 
00810     const unsigned int n(hltConfig_.size());
00811 
00812     if (plotAll_){
00813 
00814       for (unsigned int j=0; j!=n; ++j) {
00815   
00816         std::string pathname = hltConfig_.triggerName(j);  
00817 
00818         string l1pathname = getL1ConditionModuleName(pathname);
00819 
00820         int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1pathname);
00821       
00822         int objectType =  getTriggerTypeParsePathName(pathname);
00823   
00824         for (unsigned int i=0; i!=n; ++i) {
00825   
00826           std::string denompathname = hltConfig_.triggerName(i);  
00827           int denomobjectType =  getTriggerTypeParsePathName(denompathname);
00828 
00829       
00830          
00831           std::string filtername("dummy");
00832           float ptMin = 0.0;
00833           float ptMax = 100.0;
00834           if (plotAll_ && denomobjectType == objectType && objectType != 0) {
00835           
00836             int hltThreshold = getHltThresholdFromName(pathname);
00837             int l1Threshold = getHltThresholdFromName(l1pathname);
00838             hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00839 
00840           }
00841 
00842         }
00843       }
00844 
00845     } // end if plotAll
00846     else {
00847 
00848       // plot all diagonal combinations plus any other specified pairs
00849       for (unsigned int i=0; i!=n; ++i) {
00850 
00851          std::string denompathname = "";  
00852          std::string pathname = hltConfig_.triggerName(i);  
00853          //parse pathname to guess object type
00854          int objectType =  getTriggerTypeParsePathName(pathname);
00855 
00856         string l1pathname = getL1ConditionModuleName(pathname);
00857         int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1pathname);
00858   
00859         std::string filtername("dummy");
00860         float ptMin = 0.0;
00861         float ptMax = 100.0;
00862 
00863         if (objectType == trigger::TriggerPhoton) ptMax = 400.0;
00864         if (objectType == trigger::TriggerElectron) ptMax = 300.0;
00865         if (objectType == trigger::TriggerMuon) ptMax = 300.0;
00866         if (objectType == trigger::TriggerTau) ptMax = 300.0;
00867         if (objectType == trigger::TriggerJet) ptMax = 700.0;
00868         if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00869         if (objectType == trigger::TriggerMET) ptMax = 500.0;
00870         if (objectType == trigger::TriggerTET) ptMax = 1000.0;
00871         if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00872     
00873         // keep track of all paths, except for FinalPath
00874         if (objectType != -1 && pathname.find("FinalPath") == std::string::npos){
00875 
00876           int hltThreshold = getHltThresholdFromName(pathname);
00877           int l1Threshold = getHltThresholdFromName(l1pathname);
00878   
00879           hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00880 
00881           hltPathsDiagonal_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00882   
00883         }
00884 
00885       } // end for i
00886 
00887       // now loop over denom/num path pairs specified in cfg, 
00888       // recording the off-diagonal ones
00889       for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair) {
00890             
00891         std::string numpathname = custompathnamepair->first;  
00892         std::string denompathname = custompathnamepair->second;  
00893   
00894         if (numpathname != denompathname) {
00895   
00896           // check that denominator exists
00897           bool founddenominator = false;
00898           for (unsigned int k=0; k!=n; ++k) {
00899 
00900             string n_pathname = hltConfig_.triggerName(k);
00901 
00902             if (n_pathname.find(denompathname) != std::string::npos) {
00903               
00904               LogDebug("FourVectorHLTOffline") << "denompathname is selected to be = " << n_pathname << endl;;
00905               founddenominator = true;
00906 
00907               break;
00908 
00909             }
00910           }
00911 
00912           if (!founddenominator) {
00913   
00914             edm::LogInfo("FourVectorHLTOffline") << "denompathname not found, go to the next pair numearator-denominator" << endl;
00915             
00916             // go to the next pair
00917             continue;
00918   
00919           }
00920 
00921           // check that numerator exists
00922           for (unsigned int j=0; j!=n; ++j) {
00923           bool foundnumerator = false;
00924 
00925             string pathname = hltConfig_.triggerName(j);
00926 
00927             LogDebug("FourVectorHLTOffline") << "check if path " << pathname << " is numpathname = " << numpathname << endl;
00928             if (hltConfig_.triggerName(j).find(numpathname)!= std::string::npos) {
00929               
00930               LogDebug("FourVectorHLTOffline") << "pathname is selected to be = " << denompathname << endl;;
00931               foundnumerator = true;
00932 
00933             }
00934   
00935   
00936             if (!foundnumerator) {
00937     
00938               edm::LogInfo("FourVectorHLTOffline") << "pathname not found, ignoring " << pathname;
00939               continue;
00940   
00941             }
00942   
00943             string l1pathname = getL1ConditionModuleName(pathname);
00944             int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1pathname);
00945             int objectType =  getTriggerTypeParsePathName(pathname);
00946   
00947           std::string filtername("dummy");
00948           float ptMin = 0.0;
00949           float ptMax = 100.0;
00950 
00951         if (objectType == trigger::TriggerPhoton) ptMax = 400.0;
00952         if (objectType == trigger::TriggerElectron) ptMax = 300.0;
00953         if (objectType == trigger::TriggerMuon) ptMax = 300.0;
00954         if (objectType == trigger::TriggerTau) ptMax = 300.0;
00955         if (objectType == trigger::TriggerJet) ptMax = 700.0;
00956         if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00957         if (objectType == trigger::TriggerMET) ptMax = 500.0;
00958         if (objectType == trigger::TriggerTET) ptMax = 1000.0;
00959         if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00960   
00961           // monitor regardless of the objectType of the path
00962           if (objectType != 0) {
00963             int hltThreshold = getHltThresholdFromName(pathname);
00964             int l1Threshold = getHltThresholdFromName(l1pathname);
00965             hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00966 
00967           }
00968       
00969         } // end for j, loop over paths
00970 
00971        }  // end if not same num and denominator 
00972   
00973       } // end for pair
00974 
00975     } // end else
00976 
00977 
00978     vector<string> allPaths;
00979     // fill vectors of Muon, Egamma, JetMet, Rest, and Special paths
00980 
00981     int vi = 0;
00982 
00983     for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
00984 
00985       std::string pathName = removeVersions(v->getPath());
00986       //int objectType = v->getObjectType();
00987 
00988       vector<int> tempCount(5,0);
00989 
00990       fPathTempCountPair.push_back(make_pair(pathName,0));
00991       fPathBxTempCountPair.push_back(make_pair(pathName,tempCount));
00992 
00993       allPaths.push_back(pathName);
00994 
00995     }
00996     
00997     fPathTempCountPair.push_back(make_pair("HLT_Any",0));
00998 
00999     fGroupName.push_back("All");
01000 
01001     for(unsigned int g=0; g<fGroupName.size(); g++) {
01002 
01003       //fGroupTempCountPair.push_back(make_pair(fGroupName[g],0));
01004       //fGroupL1TempCountPair.push_back(make_pair(fGroupName[g],0));
01005 
01006     }
01007   
01008     dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
01009 
01010     fGroupNamePathsPair.push_back(make_pair("All",allPaths));
01011 
01013     vector<string> datasetNames =  hltConfig_.datasetNames() ;
01014     for (unsigned int i=0;i<datasetNames.size();i++) {
01015 
01016       vector<string> datasetPaths = hltConfig_.datasetContent(datasetNames[i]);
01017       fGroupNamePathsPair.push_back(make_pair(datasetNames[i],datasetPaths));
01018 
01019     }
01020 
01021 
01022     for (unsigned int g=0;g<fGroupNamePathsPair.size();g++) {
01023 
01024       fGroupTempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
01025       fGroupL1TempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
01026       setupHltMatrix(fGroupNamePathsPair[g].first,fGroupNamePathsPair[g].second);
01027 
01028     }
01029 
01030     //    setupHltLsPlots();
01031     //    setupHltBxPlots();
01032 
01033     vi = 0;
01034 
01035     for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
01036       vi++;
01037 
01038        // -------------------------
01039        //
01040        //  Filters for each path
01041        //
01042        // -------------------------
01043        
01044        // get all modules in this HLT path
01045       std::string pathName = removeVersions(v->getPath());
01046       vector<string> moduleNames = hltConfig_.moduleLabels(v->getPath()); 
01047 
01048        int numModule = 0;
01049        string moduleName, moduleType, moduleEDMType;
01050        unsigned int moduleIndex;
01051        
01052        //print module name
01053        vector<string>::const_iterator iDumpModName;
01054        for (iDumpModName = moduleNames.begin();iDumpModName != moduleNames.end();iDumpModName++) {
01055 
01056          moduleName = *iDumpModName;
01057          moduleType = hltConfig_.moduleType(moduleName);
01058          moduleEDMType = hltConfig_.moduleEDMType(moduleName);
01059          moduleIndex = hltConfig_.moduleIndex(v->getPath(), moduleName);
01060 
01061          LogTrace ("FourVectorHLTOffline") << "Module "      << numModule
01062              << " is called " << moduleName
01063              << " , type = "  << moduleType
01064              << " , EDMtype = " << moduleEDMType 
01065              << " , index = " << moduleIndex
01066              << endl;
01067 
01068          numModule++;
01069 
01070          if((moduleType.find("Filter") != string::npos && moduleType.find("HLTTriggerTypeFilter") == string::npos ) || 
01071             (moduleType.find("Associator") != string::npos) || 
01072             (moduleType.find("HLTLevel1GTSeed") != string::npos) || 
01073             (moduleType.find("HLTGlobalSumsCaloMET") != string::npos) ||
01074             (moduleType.find("HLTPrescaler") != string::npos) || 
01075             (moduleEDMType.find("EDFilter") != string::npos) ) {
01076 
01077            //std::pair<std::string, int> filterIndexPair;
01078            //filterIndexPair.first   = moduleName;
01079            //filterIndexPair.second  = moduleIndex;
01080            //v->filtersAndIndices.push_back(filterIndexPair);
01081            v->filtersAndIndices.push_back(make_pair(moduleName,moduleIndex));
01082 
01083          }
01084 
01085 
01086        }//end for modulesName
01087 
01088        dbe_->setCurrentFolder(pathsSummaryFilterCountsFolder_.c_str()); 
01089 
01090        //int nbin_sub = 5;
01091        int nbin_sub = v->filtersAndIndices.size()+2;
01092     
01093 
01094        //TString thisPath = v->getPath();
01095 
01096        // count plots for subfilter
01097        MonitorElement* filters = dbe_->book1D("Filters_" + pathName, 
01098                                               "Filters_" + pathName,
01099                               nbin_sub+1, -0.5, 0.5+(double)nbin_sub);
01100        
01101        for(unsigned int filt = 0; filt < v->filtersAndIndices.size(); filt++){
01102 
01103          if (filters)
01104            filters->setBinLabel(filt+1, (v->filtersAndIndices[filt]).first);
01105 
01106        }
01107 
01108        // bjk here
01109 //        // book Count vs LS
01110 //        dbe_->setCurrentFolder(pathsIndividualHLTPathsPerLSFolder_.c_str());
01111 //        MonitorElement* tempME = dbe_->book1D(v->getPath() + "_count_per_LS", 
01112 //                               pathName + " count per LS",
01113 //                               nLS_, 0,nLS_);
01114 //        tempME->setAxisTitle("Luminosity Section");
01115 
01116        v->setFilterHistos(filters);
01117 
01118     } // end for paths
01119 
01120     // now set up all of the histos for each path-denom
01121     for(PathInfoCollection::iterator v = hltPaths_.begin(); v!= hltPaths_.end(); ++v ) {
01122 
01123       MonitorElement *NOn=0; 
01124       MonitorElement   *onEtOn=0; 
01125       MonitorElement   *onOneOverEtOn=0; 
01126       MonitorElement   *onEtavsonPhiOn=0;
01127       MonitorElement *NOff=0; 
01128       MonitorElement   *offEtOff=0; 
01129       MonitorElement   *offEtavsoffPhiOff=0;
01130       MonitorElement *NL1=0; 
01131       MonitorElement   *l1EtL1=0; 
01132       MonitorElement   *l1Etavsl1PhiL1=0;
01133       MonitorElement *NL1On=0; 
01134       MonitorElement   *l1EtL1On=0; 
01135       MonitorElement   *l1Etavsl1PhiL1On=0;
01136       MonitorElement *NL1Off=0; 
01137       MonitorElement   *offEtL1Off=0; 
01138       MonitorElement   *offEtavsoffPhiL1Off=0;
01139       MonitorElement *NOnOff=0; 
01140       MonitorElement   *offEtOnOff=0; 
01141       MonitorElement   *offEtavsoffPhiOnOff=0;
01142       MonitorElement *NL1OnUM=0; 
01143       MonitorElement   *l1EtL1OnUM=0; 
01144       MonitorElement   *l1Etavsl1PhiL1OnUM=0;
01145       MonitorElement *NL1OffUM=0; 
01146       MonitorElement   *offEtL1OffUM=0; 
01147       MonitorElement   *offEtavsoffPhiL1OffUM=0;
01148       MonitorElement *NOnOffUM=0; 
01149       MonitorElement   *offEtOnOffUM=0; 
01150       MonitorElement   *offEtavsoffPhiOnOffUM=0;
01151       MonitorElement *offDRL1Off=0; 
01152       MonitorElement   *offDROnOff=0; 
01153       MonitorElement   *l1DRL1On=0;
01154       
01155       std::string pathName = removeVersions(v->getPath());
01156       std::string labelname("dummy");
01157       labelname = pathName + "_wrt_" + v->getDenomPath();
01158 
01159       std::string histoname(labelname+"_NOn");
01160       std::string title(labelname+" N online");
01161       double histEtaMax = 2.5;
01162 
01163       if (v->getObjectType() == trigger::TriggerMuon || v->getObjectType() == trigger::TriggerL1Mu) {
01164 
01165         histEtaMax = muonEtaMax_;
01166 
01167       }
01168       else if (v->getObjectType() == trigger::TriggerElectron || v->getObjectType() == trigger::TriggerL1NoIsoEG || v->getObjectType() == trigger::TriggerL1IsoEG )
01169       {
01170         histEtaMax = electronEtaMax_;
01171       }
01172         else if (v->getObjectType() == trigger::TriggerTau || v->getObjectType() == trigger::TriggerL1TauJet )
01173       {
01174         histEtaMax = tauEtaMax_;
01175       }
01176       else if (v->getObjectType() == trigger::TriggerJet || v->getObjectType() == trigger::TriggerL1CenJet || v->getObjectType() == trigger::TriggerL1ForJet )
01177       {
01178         histEtaMax = jetEtaMax_; 
01179       }
01180         else if (v->getObjectType() == trigger::TriggerBJet)
01181       {
01182         histEtaMax = bjetEtaMax_;
01183       }
01184       else if (v->getObjectType() == trigger::TriggerMET || v->getObjectType() == trigger::TriggerL1ETM )
01185       {
01186         histEtaMax = metEtaMax_; 
01187       }
01188         else if (v->getObjectType() == trigger::TriggerPhoton)
01189       {
01190         histEtaMax = photonEtaMax_; 
01191       }
01192       else if (v->getObjectType() == trigger::TriggerTrack)
01193       {
01194         histEtaMax = trackEtaMax_; 
01195       }
01196 
01197       TString pathfolder = dirname_ + TString("/") + pathName;
01198       dbe_->setCurrentFolder(pathfolder.Data());
01199 
01200       NOn =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01201 
01202 
01203        histoname = labelname+"_NOff";
01204        title = labelname+" N Off";
01205        NOff =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01206        
01207        histoname = labelname+"_NL1";
01208        title = labelname+" N L1";
01209        NL1 =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01210        
01211        histoname = labelname+"_NL1On";
01212        title = labelname+" N L1On";
01213        NL1On =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01214        
01215        histoname = labelname+"_NL1Off";
01216        title = labelname+" N L1Off";
01217        NL1Off =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01218        
01219        histoname = labelname+"_NOnOff";
01220        title = labelname+" N OnOff";
01221        NOnOff =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01222        
01223        histoname = labelname+"_onEtOn";
01224        title = labelname+" onE_t online";
01225        onEtOn =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01226        
01227        histoname = labelname+"_onOneOverEtOn";
01228        title = labelname+" 1 / onE_t online";
01229        onOneOverEtOn =  dbe->book1D(histoname.c_str(), title.c_str(),nBinsOneOverEt_, 0, 0.1);
01230        onOneOverEtOn->setAxisTitle("HLT 1/Et [1/GeV]");
01231        
01232        histoname = labelname+"_offEtOff";
01233        title = labelname+" offE_t offline";
01234        offEtOff =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01235        
01236        histoname = labelname+"_l1EtL1";
01237        title = labelname+" l1E_t L1";
01238        l1EtL1 =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01239        
01240        histoname = labelname+"_onEtaonPhiOn";
01241        title = labelname+" on#eta vs on#phi online";
01242        onEtavsonPhiOn =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
01243        
01244        histoname = labelname+"_offEtaoffPhiOff";
01245        title = labelname+" off#eta vs off#phi offline";
01246        offEtavsoffPhiOff =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
01247        
01248        histoname = labelname+"_l1Etal1PhiL1";
01249        title = labelname+" l1#eta vs l1#phi L1";
01250        l1Etavsl1PhiL1 =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
01251        
01252        histoname = labelname+"_l1EtL1On";
01253        title = labelname+" l1E_t L1+online";
01254        l1EtL1On =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01255        
01256        histoname = labelname+"_offEtL1Off";
01257        title = labelname+" offE_t L1+offline";
01258        offEtL1Off =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01259        
01260        histoname = labelname+"_offEtOnOff";
01261        title = labelname+" offE_t online+offline";
01262        offEtOnOff =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01263        
01264        histoname = labelname+"_l1Etal1PhiL1On";
01265        title = labelname+" l1#eta vs l1#phi L1+online";
01266        l1Etavsl1PhiL1On =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
01267        
01268        histoname = labelname+"_offEtaoffPhiL1Off";
01269        title = labelname+" off#eta vs off#phi L1+offline";
01270        offEtavsoffPhiL1Off =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
01271        
01272        histoname = labelname+"_offEtaoffPhiOnOff";
01273        title = labelname+" off#eta vs off#phi online+offline";
01274        offEtavsoffPhiOnOff =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
01275        
01276        if (useUM) {
01277 
01278          histoname = labelname+"_NL1OnUM";
01279          title = labelname+" N L1OnUM";
01280          NL1OnUM =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01281          
01282          histoname = labelname+"_NL1OffUM";
01283          title = labelname+" N L1OffUM";
01284          NL1OffUM =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01285          
01286          histoname = labelname+"_NOnOffUM";
01287          title = labelname+" N OnOffUM";
01288          NOnOffUM =  dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
01289          
01290          histoname = labelname+"_l1EtL1OnUM";
01291          title = labelname+" l1E_t L1+onlineUM";
01292          l1EtL1OnUM =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01293          
01294          histoname = labelname+"_offEtL1OffUM";
01295          title = labelname+" offE_t L1+offlineUM";
01296          offEtL1OffUM =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01297          
01298          histoname = labelname+"_offEtOnOffUM";
01299          title = labelname+" offE_t online+offlineUM";
01300          offEtOnOffUM =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
01301          
01302          histoname = labelname+"_l1Etal1PhiL1OnUM";
01303          title = labelname+" l1#eta vs l1#phi L1+onlineUM";
01304          l1Etavsl1PhiL1OnUM =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
01305          
01306          histoname = labelname+"_offEtaoffPhiL1OffUM";
01307          title = labelname+" off#eta vs off#phi L1+offlineUM";
01308          offEtavsoffPhiL1OffUM =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
01309          
01310          histoname = labelname+"_offEtaoffPhiOnOffUM";
01311          title = labelname+" off#eta vs off#phi online+offlineUM";
01312          offEtavsoffPhiOnOffUM =  dbe->book2D(histoname.c_str(), title.c_str(), nBins2D_,-histEtaMax,histEtaMax, nBins2D_,-TMath::Pi(), TMath::Pi());
01313          
01314        }    
01315        
01316        histoname = labelname+"_l1DRL1On";
01317        title = labelname+" l1DR L1+online";
01318        l1DRL1On =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, 0, dRMax_); 
01319        
01320        histoname = labelname+"_offDRL1Off";
01321        title = labelname+" offDR L1+offline";
01322        offDRL1Off =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, 0, dRMax_);
01323        
01324        histoname = labelname+"_offDROnOff";
01325        title = labelname+" offDR online+offline";
01326        offDROnOff =  dbe->book1D(histoname.c_str(), title.c_str(),nBins_, 0, dRMax_); 
01327 
01328 
01329        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 
01330 );
01331 
01332     }  // end for hltPath
01333 
01334     // bjk here
01335 //     // HLT_Any
01336 //     // book Count vs LS
01337 //     dbe_->setCurrentFolder(pathsIndividualHLTPathsPerLSFolder_.c_str());
01338 //     MonitorElement* tempME = dbe_->book1D("HLT_Any_count_per_LS", 
01339 //                            "HLT_Any count per LS",
01340 //                            nLS_, 0,nLS_);
01341 //     tempME->setAxisTitle("Luminosity Section");
01342 
01343   } // end if(1) dummy
01344 
01345  if(!doCombineRuns_) fIsSetup = true;
01346 
01347  return;
01348 
01349 }
01350 
01352 void FourVectorHLTOffline::endRun(const edm::Run& run, const edm::EventSetup& c)
01353 {
01354 
01355   LogDebug("FourVectorHLTOffline") << "endRun, run " << run.id();
01356 
01357 }
01358 
01360 void FourVectorHLTOffline::cleanDRMatchSet(mmset& tempSet)
01361 {
01362 
01363   LogDebug("FourVectorHLTOffline") << "cleanDRMatchSet(mmset& tempSet) " << "size of the set (before CLEANING) = " << tempSet.size() << " maps." << endl;
01364 
01365   if(tempSet.size() < 2) return;
01366 
01367   if(tempSet.size() > 10) {
01368 
01369     LogDebug("FourVectorHLTOffline") << "size of the set is too large.  It will be truncated to 10." << endl;
01370     mmset::iterator it = tempSet.begin();
01371     for (int i=0;i<10;i++) {    it++; }
01372     tempSet.erase( it, tempSet.end());
01373     LogDebug("FourVectorHLTOffline") << "size of the set is now = " << tempSet.size() << " maps." << endl;
01374 
01375   }
01376  
01377   bool cleanedOneMap = false;
01378  
01379   // cleaning needed if the set has at least two maps
01380 
01381   while(! cleanedOneMap && tempSet.size() > 1) {
01382 
01383     cleanedOneMap=false;
01384 
01385     //LogTrace("FourVectorHLTOffline") << "cleaning: size of the set  = " << tempSet.size() << " maps." << endl;
01386 
01387     int imap = 0;
01388     for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) {
01389 
01390       fimmap tempMap_j = *setIter_i;
01391 
01392       //LogTrace("FourVectorHLTOffline") << " map " << imap << endl;
01393       //LogTrace("FourVectorHLTOffline") << " --------" << endl;
01394 
01395       for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it) {
01396 
01397         //LogTrace("FourVectorHLTOffline") << " " <<   (*it).first << " :  " << (*it).second << endl;
01398 
01399       }
01400 
01401       imap++;
01402 
01403     }
01404 
01405     // loop i
01406     for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) {
01407      
01408       fimmap tempMap_i = *setIter_i;
01409       fimmap::iterator it = tempMap_i.begin();
01410       int topValue = (*it).second;
01411       //LogTrace("FourVectorHLTOffline") << " topValue = " << topValue << endl;
01412   
01413       
01414       mmset::iterator tempIter_i = setIter_i;
01415   
01416       // from all the other maps, clean entries that have mapped value "topValue"
01417       // loop j
01418       mmset::iterator setIter_j = ++tempIter_i;
01419       while ( setIter_j != tempSet.end( ) ) {
01420   
01421         fimmap tempMap_j = *setIter_j;
01422         //LogTrace("FourVectorHLTOffline") << "  size of the map  = " << tempMap_j.size() << endl;
01423   
01424         fimmap::iterator it = tempMap_j.begin();
01425         while ( it != tempMap_j.end() ) {
01426   
01427           if(topValue == (*it).second) {
01428             
01429             //LogTrace("FourVectorHLTOffline") << "   Ridding map of a doubly-matched object." << endl;
01430             fimmap::iterator tempIt = it;
01431             ++it; //no longer points to item that is going away
01432             tempMap_j.erase(tempIt);
01433             cleanedOneMap = true;
01434   
01435           } else {
01436             ++it;
01437           } // end if
01438 
01439         } //end while
01440   
01441         if(cleanedOneMap) {
01442           
01443           //remove the old map from the set
01444           mmset::iterator tempIt = setIter_j;
01445           ++setIter_j; //no longer points to item that is going away
01446           tempSet.erase(tempIt);
01447   
01448           // insert in the set the new map if it is not an empty map
01449           if(! tempMap_j.empty()) tempSet.insert(tempMap_j);
01450   
01451           break; // break from loop j
01452   
01453        } else {
01454          ++setIter_j;
01455        } // end if
01456 
01457   
01458       }// end while j
01459   
01460       if(cleanedOneMap) break; // break from loop i
01461 
01462     } // end loop i
01463 
01464     if(cleanedOneMap) { 
01465 
01466       // continue cleaning (in while loop)
01467       // but reset flag first
01468       cleanedOneMap=false;
01469       continue; 
01470 
01471     }
01472     else {
01473 
01474       // finished cleaing (break from while loop)
01475       break; 
01476 
01477     }
01478 
01479   } // end while
01480 
01481   //LogTrace("FourVectorHLTOffline") << "cleaned: size of the set  = " << tempSet.size() << " maps." << endl;
01482   int jmap = 0;
01483 
01484   for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) 
01485   {
01486 
01487     fimmap tempMap_j = *setIter_i;
01488 
01489     //LogTrace("FourVectorHLTOffline") << " map " << jmap << endl;
01490     //LogTrace("FourVectorHLTOffline") << " --------" << endl;
01491 
01492     for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it) {
01493 
01494         //LogTrace("FourVectorHLTOffline") << " " <<   (*it).first << " :  " << (*it).second << endl;
01495       
01496     }
01497 
01498     jmap++;
01499 
01500   } // end for
01501 
01502   return;
01503 
01504 }
01505 
01506 void FourVectorHLTOffline::setupHltMatrix(const std::string& label, vector<std::string>& paths) {
01507 
01508     //string groupLabelAny = "HLT_"+label+"_Any";
01509     //paths.push_back(groupLabelAny.c_str());
01510     paths.push_back("HLT_"+label+"_L1_Any");
01511     paths.push_back("HLT_"+label+"_Any");
01512     paths.push_back("HLT_Any");
01513 
01514     string h_name; 
01515     string h_title; 
01516 
01517     dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
01518 
01519     MonitorElement* ME = 0;
01520     MonitorElement* ME_Any = 0;
01521     MonitorElement* ME_Normalized = 0;
01522     MonitorElement* ME_Normalized_Any = 0;
01523 
01524     if (label != "OfflineMonitor" && label != "OnlineHltMonitor" && label != "OnlineMonitor") {
01525       h_name= "HLT_"+label+"_PassPass";
01526       h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass)";
01527       ME = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01528                                         paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01529 
01530       h_name= "HLT_"+label+"_Pass_Any";
01531       h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
01532       ME_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01533                                             paths.size(), -0.5, paths.size()-0.5);
01534       
01535       dbe_->setCurrentFolder(pathsSummaryHLTCorrelationsFolder_.c_str());
01536       h_name= "HLT_"+label+"_PassPass_Normalized";
01537       h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass) normalized to xBin=Pass";
01538       ME_Normalized = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01539                                                    paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01540       h_name= "HLT_"+label+"_Pass_Normalized_Any";
01541       h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
01542       ME_Normalized_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01543                                                        paths.size(), -0.5, paths.size()-0.5);
01544     }
01545 
01546     if (label != "All" && label != "OfflineMonitor" && label != "OnlineHltMonitor" && label != "OnlineMonitor")
01547     {
01548       dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_ + label);
01549       h_name= "HLT_"+label+"_Total_LS";
01550       h_title = label+" HLT paths total count combined per LS ";
01551       MonitorElement* ME_Total_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
01552       ME_Total_LS->setAxisTitle("LS");
01553 
01554 //       for(std::vector<std::string>::iterator i = paths.begin(), e=paths.end(); i!=e; ++i)
01555 //       {
01556 //         h_name= "HLT_"+removeVersions(*i)+"_LS";
01557 //         h_title = removeVersions(*i) + " inside " + label + " HLT paths count per LS ";
01558 //         MonitorElement* ME_Group_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
01559 //     ME_Group_LS->setAxisTitle("LS");
01560 //     /// add this path to the vector of 2D LS paths
01561 //     v_ME_HLTAll_LS.push_back(ME_Group_LS);
01562 //       }
01563 
01564     }
01565     
01566     
01567 //     dbe_->setCurrentFolder(pathsSummaryHLTPathsPerBXFolder_.c_str());
01568 //     h_name= "HLT_"+label+"_BX_LS";
01569 //     h_title = label+" HLT paths total count combined per BX ";
01570 //     MonitorElement* ME_Total_BX = dbe_->book2D(h_name.c_str(), h_title.c_str(),  nLS_, 0, nLS_, 5, -2.5, 2.5);
01571 //     ME_Total_BX->setAxisTitle("LS",1);
01572 //     v_ME_Total_BX.push_back(ME_Total_BX);
01573 
01574 //     h_name= "HLT_"+label+"_BX_LS_Norm";
01575 //     h_title = label+" HLT paths total count combined per BX Normalized to LS";
01576 //     MonitorElement* ME_Total_BX_Norm = dbe_->book2D(h_name.c_str(), h_title.c_str(),  nLS_, 0, nLS_, 5, -2.5, 2.5);
01577 //     ME_Total_BX_Norm->setAxisTitle("LS",1);
01578 //     v_ME_Total_BX_Norm.push_back(ME_Total_BX_Norm);
01579 
01580 // bjk: These are OK
01581       if (label != "OfflineMonitor" && label != "OnlineHltMonitor" && label != "OnlineMonitor") {
01582         for(unsigned int i = 0; i < paths.size(); i++){
01583   
01584           if (ME) {
01585             ME->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01586             ME->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01587           }
01588           //       ME_Group_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01589           if (ME_Normalized){
01590             ME_Normalized->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01591             ME_Normalized->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01592           }
01593           if (ME_Normalized_Any)
01594             ME_Normalized_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01595 
01596           if (ME_Any)
01597             ME_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01598         }
01599       }
01600       
01601 }
01602 
01603 void FourVectorHLTOffline::fillHltMatrix(const edm::TriggerNames & triggerNames) {
01604 
01605 
01606  string fullPathToME; 
01607 
01608  //for (unsigned int mi=0;mi<fGroupName.size();mi++) {
01609   for (unsigned int mi=0;mi<fGroupNamePathsPair.size();mi++) {
01610 
01611 
01612   fullPathToME = "HLT/FourVector/PathsSummary/HLT_"+fGroupNamePathsPair[mi].first+"_PassPass";
01613   MonitorElement* ME_2d = dbe_->get(fullPathToME);
01614   fullPathToME = "HLT/FourVector/PathsSummary/HLT_"+fGroupNamePathsPair[mi].first+"_Pass_Any";
01615   MonitorElement* ME_1d = dbe_->get(fullPathToME);
01616   if(!ME_2d || !ME_1d) {  
01617 
01618     LogTrace("FourVectorHLTOffline") << " ME not valid although I gave full path" << endl;
01619     continue;
01620 
01621   }
01622 
01623   TH2F * hist_2d = ME_2d->getTH2F();
01624   TH1F * hist_1d = ME_1d->getTH1F();
01625 
01626   // Fill HLTPassed Matrix bin (i,j) = (Any,Any)
01627   // --------------------------------------------------------
01628   int anyBinNumber = hist_2d->GetXaxis()->FindBin("HLT_Any");      
01629 
01630   string groupBinLabel = "HLT_"+fGroupNamePathsPair[mi].first+"_Any";
01631   int groupBinNumber = hist_2d->GetXaxis()->FindBin(groupBinLabel.c_str()); 
01632 
01633   // any trigger accepted
01634   if(fTriggerResults->accept()){
01635 
01636     hist_2d->Fill(anyBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
01637     hist_1d->Fill(anyBinNumber-1);//binNumber1 = 0 = first filter
01638 
01639   }
01640 
01641   bool groupPassed = false;
01642   //bool groupL1Passed = false;
01643 
01644   // Main loop over paths
01645   // --------------------
01646 
01647   //for (int i=1; i< hist_2d->GetNbinsX();i++) 
01648   for (unsigned int i=0; i< fGroupNamePathsPair[mi].second.size(); i++)
01649   { 
01650 
01651     //string hltPathName =  hist_2d->GetXaxis()->GetBinLabel(i);
01652     string hltPathName =  fGroupNamePathsPair[mi].second[i];
01653 
01654     // check if this is hlt path name
01655     //unsigned int pathByIndex = triggerNames.triggerIndex(hltPathName);
01656     unsigned int pathByIndex = triggerNames.triggerIndex(fGroupNamePathsPair[mi].second[i]);
01657     if(pathByIndex >= fTriggerResults->size() ) continue;
01658 
01659     // check if its L1 passed
01660     // comment out below but set groupL1Passed to true always
01661     //if(hasL1Passed(hltPathName,triggerNames)) groupL1Passed = true;
01662     //groupL1Passed = true;
01663 
01664     // Fill HLTPassed Matrix and HLTPassFail Matrix
01665     // --------------------------------------------------------
01666 
01667     if(fTriggerResults->accept(pathByIndex)){
01668 
01669       groupPassed = true;
01670       //groupL1Passed = true;
01671 
01672       hist_2d->Fill(i,anyBinNumber-1);//binNumber1 = 0 = first filter
01673       hist_2d->Fill(anyBinNumber-1,i);//binNumber1 = 0 = first filter
01674 
01675       hist_2d->Fill(i,groupBinNumber-1);//binNumber1 = 0 = first filter
01676       hist_2d->Fill(groupBinNumber-1,i);//binNumber1 = 0 = first filter
01677      
01678       hist_1d->Fill(i);//binNumber1 = 0 = first filter
01679 
01680 
01681       //for (int j=1; j< hist_2d->GetNbinsY();j++) 
01682       for (unsigned int j=0; j< fGroupNamePathsPair[mi].second.size(); j++)
01683       { 
01684 
01685         string crossHltPathName =  fGroupNamePathsPair[mi].second[j];
01686   
01687         //unsigned int crosspathByIndex = triggerNames.triggerIndex(hist_2d->GetXaxis()->GetBinLabel(j));
01688         //unsigned int crosspathByIndex = triggerNames.triggerIndex(crossHltPathName);
01689         unsigned int crosspathByIndex = triggerNames.triggerIndex(fGroupNamePathsPair[mi].second[j]);
01690 
01691         if(crosspathByIndex >= fTriggerResults->size() ) continue;
01692   
01693         if(fTriggerResults->accept(crosspathByIndex)){
01694   
01695           hist_2d->Fill(i,j);//binNumber1 = 0 = first filter
01696   
01697         } // end if j path passed
01698   
01699       } // end for j 
01700   
01701     } // end if i passed
01702     
01703 
01704   } // end for i
01705 
01706   if(groupPassed) {
01707     
01708     hist_1d->Fill(groupBinNumber-1);//binNumber1 = 0 = first filter
01709     hist_1d->Fill(groupBinNumber-2);//binNumber1 = 0 = first filter -> Fill L1group as well
01710     hist_2d->Fill(groupBinNumber-1,groupBinNumber-1);//binNumber1 = 0 = first filter
01711     hist_2d->Fill(anyBinNumber-1,groupBinNumber-1);//binNumber1 = 0 = first filter
01712     hist_2d->Fill(groupBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
01713 
01714   }
01715 
01716   /*
01717   string groupL1BinLabel = "HLT_"+fGroupNamePathsPair[mi].first+"_L1_Any";
01718   int groupL1BinNumber = hist_2d->GetXaxis()->FindBin(groupL1BinLabel.c_str());      
01719 
01720   if(groupL1Passed) hist_1d->Fill(groupL1BinNumber-1);//binNumber1 = 0 = first filter
01721   */
01722  } // end for mi
01723 
01724 }
01725 
01726 void FourVectorHLTOffline::setupHltBxPlots()
01727 {
01728 
01729   //pathsSummaryFolder_ = TString("HLT/FourVector/PathsSummary/");
01730   //dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
01731   dbe_->setCurrentFolder(pathsSummaryFolder_);
01732 
01733   // setup HLT bx plot
01734   unsigned int npaths = hltPathsDiagonal_.size();
01735 
01736   ME_HLT_BX = dbe_->book2D("HLT_bx",
01737                          "HLT counts vs Event bx",
01738                          Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
01739   /*
01740   ME_HLT_CUSTOM_BX = dbe_->book2D("HLT_Custom_bx",
01741                          "HLT counts vs Event bx",
01742                          Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
01743                          */
01744   ME_HLT_BX->setAxisTitle("Bunch Crossing");
01745   //ME_HLT_CUSTOM_BX->setAxisTitle("Bunch Crossing");
01746 
01747 
01748   // Set up bin labels on Y axis continuing to cover all npaths
01749   for(unsigned int i = 0; i < npaths; i++){
01750 
01751   if (ME_HLT_BX)
01752     ME_HLT_BX->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01753     //ME_HLT_CUSTOM_BX->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01754 
01755   }
01756 
01757 
01758 }
01759 
01760 void FourVectorHLTOffline::setupHltLsPlots()
01761 {
01762  
01763   unsigned int npaths = hltPathsDiagonal_.size();
01764 
01765   //pathsSummaryHLTPathsPerLSFolder_ = TString("HLT/FourVector/PathsSummary/HLT LS/");
01766   //dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_.c_str());
01767   dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_);
01768 
01769   ME_HLTAll_LS  = dbe_->book2D("All_count_LS",
01770                     "All paths per LS ",
01771                          nLS_, 0, nLS_, npaths+1, -0.5, npaths+1-0.5);
01772   ME_HLTAll_LS->setAxisTitle("Luminosity Section");
01773 
01774   // Set up bin labels on Y axis continuing to cover all npaths
01775   for(unsigned int i = 0; i < npaths; i++){
01776     if (ME_HLTAll_LS)
01777       ME_HLTAll_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01778 
01779   }
01780 
01781   unsigned int i = npaths;
01782 
01783   if (ME_HLTAll_LS)
01784     ME_HLTAll_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, "HLT_Any");
01785 
01786 
01787 }
01788 
01789 
01790 void FourVectorHLTOffline::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c){   
01791 
01792    //int lumi = int(lumiSeg.id().luminosityBlock());
01793    //if(lumi < 74 || lumi > 77) fLumiFlag = false;
01794    //else fLumiFlag = true;
01795 
01796 }
01797 
01798 void FourVectorHLTOffline::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c)
01799 {
01800 
01801    int lumi = int(lumiSeg.id().luminosityBlock());
01802    LogTrace("FourVectorHLTOffline") << " end lumiSection number " << lumi << endl;
01803 
01804    //  countHLTPathHitsEndLumiBlock(lumi);
01805   countHLTGroupHitsEndLumiBlock(lumi);
01806   countHLTGroupL1HitsEndLumiBlock(lumi);
01807 
01808   //  countHLTGroupBXHitsEndLumiBlock(lumi);
01809 
01810 }
01811 
01812 // bjk: we have commented this out
01813 void FourVectorHLTOffline::countHLTGroupBXHitsEndLumiBlock(const int& lumi)
01814 {
01815 
01816  LogTrace("FourVectorHLTOffline") << " countHLTGroupBXHitsEndLumiBlock() lumiSection number " << lumi << endl;
01817 
01818    TH2F * hist_2d_bx = ME_HLT_BX->getTH2F();
01819 
01820    for (std::vector<std::pair<std::string, vector<int> > >::iterator ip = fPathBxTempCountPair.begin(); ip != fPathBxTempCountPair.end(); ++ip) {
01821   
01822     // get the path and its previous count
01823     std::string pathname = ip->first;  
01824     vector<int> prevCount = ip->second;  
01825 
01826     // vector of 5 zeros
01827     vector<int> currCount (5,0);
01828     vector<int> diffCount (5,0);
01829     
01830     // get the current count of path up to now
01831     int pathBin = hist_2d_bx->GetYaxis()->FindBin(pathname.c_str());      
01832 
01833     if(pathBin > hist_2d_bx->GetNbinsY()) {
01834       
01835       LogTrace("FourVectorHLTOffline") << " Cannot find the bin for path " << pathname << endl;
01836       continue;
01837 
01838     }
01839 
01840     for (unsigned int b =0;b<currCount.size();b++) { 
01841 
01842       int bxOffset = b-2;
01843       int bunch = referenceBX_+bxOffset;
01844       if(bunch < 1) bunch += Nbx_ ;
01845       int bxBin = bunch +1; // add one to get the right bin
01846 
01847       
01848       currCount[b] = int(hist_2d_bx->GetBinContent(bxBin, pathBin));  // add one to get the right bin
01849 
01850       LogTrace("FourVectorHLTOffline") << "currCount = " << currCount[b] << endl;
01851 
01852       // count due to prev lumi sec is a difference bw current and previous
01853       diffCount[b] = currCount[b] - prevCount[b];
01854 
01855       LogTrace("FourVectorHLTOffline") << " lumi = " << lumi << "  path " << pathname << "bxOffset = " << bxOffset << "  count = " << diffCount[b] <<  endl;
01856 
01857     } // end for bx b
01858 
01859     // set the counter in the pair to current count
01860     ip->second = currCount;  
01861 
01863    // fill the 2D Group paths' BX count per LS, using currCount
01865    LogTrace("FourVectorHLTOffline")  << "Find " << pathname << endl;
01866 
01867    //check if the path is in this group
01868    for (unsigned int j=0;j<fGroupNamePathsPair.size();j++) { 
01869 
01870       bool isMember = false;
01871 
01872       LogTrace("FourVectorHLTOffline")  << " ---- Group " << fGroupNamePathsPair[j].first << endl;
01873 
01874       // decide if pathname is member of this group
01875       for (unsigned int k = 0; k<(fGroupNamePathsPair[j].second).size();k++) {
01876 
01877         LogTrace("FourVectorHLTOffline")  << " comparing to " <<  fGroupNamePathsPair[j].second[k] << endl; 
01878 
01879         if(fGroupNamePathsPair[j].second[k] == pathname) {
01880 
01881           isMember = true;
01882           break;
01883 
01884         }
01885 
01886       } // end for k
01887 
01888       if(!isMember) {
01889       
01890       LogTrace("FourVectorHLTOffline")  << "Could not find a group to which the path belongs, path = " << pathname << "    group = " << fGroupNamePathsPair[j].first << endl;
01891       continue;
01892 
01893       }
01894 
01895       MonitorElement* ME_2d = v_ME_Total_BX[j];
01896 
01897       if (! ME_2d) {
01898 
01899         LogDebug("FourVectorHLTOffline") << " cannot find ME_2d for group " << fGroupNamePathsPair[j].first  <<  endl;
01900         continue;
01901 
01902       }
01903 
01904       vector<int> updatedLumiCount(5,0);
01905 
01906       float entireBXWindowUpdatedLumiCount = 0;
01907       
01908       TH2F* hist_All = ME_2d->getTH2F();
01909 
01910       for (unsigned int b = 0; b<diffCount.size();b++) {
01911 
01912         // find the bin
01913         int binNumber = b+1; // add one to get right bin
01914 
01915         // update  the bin content  (must do that since events don't ncessarily come in the order
01916         int currentLumiCount = int(hist_All->GetBinContent(lumi+1,binNumber));
01917         updatedLumiCount[b] = currentLumiCount + diffCount[b];
01918         hist_All->SetBinContent(lumi+1,binNumber,updatedLumiCount[b]);
01919 
01920         entireBXWindowUpdatedLumiCount += updatedLumiCount[b];
01921         
01922       } // end for bx b
01923 
01924       MonitorElement* ME_2d_Norm = v_ME_Total_BX_Norm[j];
01925 
01926       if (! ME_2d_Norm) {
01927 
01928         LogDebug("FourVectorHLTOffline") << " cannot find ME_2d_Norm for group " << fGroupNamePathsPair[j].first  <<  endl;
01929         continue;
01930 
01931       }
01932 
01933       TH2F* hist_All_Norm = ME_2d_Norm->getTH2F();
01934 
01935       for (unsigned int b = 0; b<diffCount.size();b++) {
01936 
01937         // find the bin
01938         int binNumber = b+1; // add one to get right bin
01939 
01940         // update  the bin content  but normalized to the whole columb (BX windw +/- 2)
01941         if(entireBXWindowUpdatedLumiCount != 0)
01942          hist_All_Norm->SetBinContent(lumi+1,binNumber,float(updatedLumiCount[b])/entireBXWindowUpdatedLumiCount);
01943 
01944       } // end for bx b
01945     
01946     } // end for group j
01947     
01948   } // end for ip
01949 
01950 }
01951 
01952 void FourVectorHLTOffline::countHLTGroupL1HitsEndLumiBlock(const int& lumi)
01953 {
01954 
01955  LogTrace("FourVectorHLTOffline") << " countHLTGroupL1HitsEndLumiBlock() lumiSection number " << lumi << endl;
01956 
01957  for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
01958 
01959    // get the count of path up to now
01960    string fullPathToME = "HLT/FourVector/PathsSummary/HLT_" + fGroupNamePathsPair[i].first+ "_Pass_Any";
01961    MonitorElement* ME_1d = dbe_->get(fullPathToME);
01962 
01963    if(! ME_1d) {
01964 
01965      LogTrace("FourVectorHLTOffline") << " could not find 1d matrix " << fullPathToME << endl;
01966 
01967      continue;
01968 
01969    }
01970 
01971    LogTrace("FourVectorHLTOffline") << " Looking in histogram "  << fullPathToME << endl;
01972 
01973    TH1F * hist_1d = ME_1d->getTH1F();
01974 
01975    for (std::vector<std::pair<std::string, float> >::iterator ip = fGroupL1TempCountPair.begin(); ip != fGroupL1TempCountPair.end(); ++ip) {
01976   
01977     // get the path and its previous count
01978     string pathname = ip->first;  
01979     float prevCount = ip->second;  
01980 
01981     string binLabel = "HLT_"+pathname+"_L1_Any";
01982     
01983     LogTrace("FourVectorHLTOffline") << " Looking for binLabel = " << binLabel <<  endl;
01984     // get the current count of path up to now
01985     int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());      
01986 
01987     LogTrace("FourVectorHLTOffline") << " pathBin = " << pathBin <<  "  out of histogram total number of bins " << hist_1d->GetNbinsX() <<  endl;
01988     if(pathBin == -1) {
01989       
01990       LogTrace("FourVectorHLTOffline") << " Cannot find the bin for path " << pathname << endl;
01991       continue;
01992 
01993     }
01994 
01995     float currCount = hist_1d->GetBinContent(pathBin)/LSsize_;
01996 
01997     // count due to prev lumi sec is a difference bw current and previous
01998     float diffCount = currCount - prevCount;
01999 
02000     LogTrace("FourVectorHLTOffline") << " lumi = " << lumi << "  path " << pathname << "  count " << diffCount <<  endl;
02001 
02002     // set the counter in the pair to current count
02003     ip->second = currCount;  
02004 
02005 
02007     // fill the 1D individual path count per LS
02009     string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_L1_Total_LS";
02010     MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
02011     if ( ME_1d) { 
02012       
02013       // update  the bin content  (must do that since events don't ncessarily come in the order
02014       float currentLumiCount = ME_1d->getTH1()->GetBinContent(lumi+1);
02015       float updatedLumiCount = currentLumiCount + diffCount;
02016       ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
02017     }
02018     else {
02019 
02020       LogDebug("FourVectorHLTOffline") << " cannot find ME " << fullPathToME_count  <<  endl;
02021 
02022     }
02023 
02024    } // end for ip
02025 
02026  } // end for i
02027 
02028 }
02029 
02030 
02031 void FourVectorHLTOffline::countHLTGroupHitsEndLumiBlock(const int& lumi)
02032 {
02033 
02034  LogTrace("FourVectorHLTOffline") << " countHLTGroupHitsEndLumiBlock() lumiSection number " << lumi << endl;
02035  for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
02036 
02037    // get the count of path up to now
02038    string fullPathToME = "HLT/FourVector/PathsSummary/HLT_" + fGroupNamePathsPair[i].first + "_Pass_Any";
02039    MonitorElement* ME_1d = dbe_->get(fullPathToME);
02040 
02041    if(! ME_1d) {
02042 
02043      LogTrace("FourVectorHLTOffline") << " could not find 1d matrix " << fullPathToME << endl;
02044 
02045      continue;
02046 
02047    }
02048 
02049    LogTrace("FourVectorHLTOffline") << " Looking in histogram "  << fullPathToME << endl;
02050 
02051    TH1F * hist_1d = ME_1d->getTH1F();
02052 
02053    for (std::vector<std::pair<std::string, float> >::iterator ip = fGroupTempCountPair.begin(); ip != fGroupTempCountPair.end(); ++ip) {
02054   
02055     // get the path and its previous count
02056     string pathname = ip->first;  
02057     float prevCount = ip->second;  
02058 
02059     string binLabel = "HLT_"+pathname+"_Any";
02060     
02061     LogTrace("FourVectorHLTOffline") << " Looking for binLabel = " << binLabel <<  endl;
02062     // get the current count of path up to now
02063     int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());      
02064 
02065     LogTrace("FourVectorHLTOffline") << " pathBin = " << pathBin <<  "  out of histogram total number of bins " << hist_1d->GetNbinsX() <<  endl;
02066     if(pathBin == -1) {
02067       
02068       LogTrace("FourVectorHLTOffline") << " Cannot find the bin for path " << pathname << endl;
02069       continue;
02070 
02071     }
02072 
02073     float currCount = hist_1d->GetBinContent(pathBin)/LSsize_;
02074 
02075     // count due to prev lumi sec is a difference bw current and previous
02076     float diffCount = currCount - prevCount;
02077 
02078     LogTrace("FourVectorHLTOffline") << " lumi = " << lumi << "  path " << pathname << "  count " << diffCount <<  endl;
02079 
02080     // set the counter in the pair to current count
02081     ip->second = currCount;  
02082 
02083 
02085     // fill the 1D individual path count per LS
02087     string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_Total_LS";
02088     MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
02089     if ( ME_1d) { 
02090 
02091       // update  the bin content  (must do that since events don't ncessarily come in the order
02092       float currentLumiCount = ME_1d->getTH1()->GetBinContent(lumi+1);
02093       float updatedLumiCount = currentLumiCount + diffCount;
02094       ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
02095 
02096     }
02097     else {
02098 
02099       LogDebug("FourVectorHLTOffline") << " cannot find ME " << fullPathToME_count  <<  endl;
02100 
02101     }
02102 
02103    } // end for ip
02104 
02105  } // end for i
02106 
02107 }
02108 
02109 
02110 void FourVectorHLTOffline::countHLTPathHitsEndLumiBlock(const int& lumi)
02111 {
02112 
02113    LogTrace("FourVectorHLTOffline") << " countHLTPathHitsEndLumiBlock() lumiSection number " << lumi << endl;
02114     // get the count of path up to now
02115    string fullPathToME = "HLT/FourVector/PathsSummary/HLT_All_PassPass";
02116    MonitorElement* ME_2d = dbe_->get(fullPathToME);
02117 
02118    if(! ME_2d) {
02119 
02120      LogTrace("FourVectorHLTOffline") << " could not fine 2d matrix " << fullPathToME << endl;
02121 
02122      return;
02123 
02124    }
02125 
02126    TH2F * hist_2d = ME_2d->getTH2F();
02127 
02128    for (std::vector<std::pair<std::string, float> >::iterator ip = fPathTempCountPair.begin(); ip != fPathTempCountPair.end(); ++ip) {
02129   
02130     // get the path and its previous count
02131     std::string pathname = ip->first;  
02132     float prevCount = ip->second;  
02133     
02134     // get the current count of path up to now
02135     float pathBin = hist_2d->GetXaxis()->FindBin(pathname.c_str());      
02136 
02137     if(pathBin > hist_2d->GetNbinsX()) {
02138       
02139       LogTrace("FourVectorHLTOffline") << " Cannot find the bin for path " << pathname << endl;
02140       continue;
02141 
02142     }
02143 
02144     float currCount = hist_2d->GetBinContent(pathBin, pathBin)/LSsize_;
02145 
02146     // count due to prev lumi sec is a difference bw current and previous
02147     float diffCount = currCount - prevCount;
02148 
02149     LogTrace("FourVectorHLTOffline") << " lumi = " << lumi << "  path " << pathname << "  count " << diffCount <<  endl;
02150 
02151     // set the counter in the pair to current count
02152     ip->second = currCount;  
02153 
02155     // fill the 2D All paths' count per LS
02157     if ( ME_HLTAll_LS) {
02158 
02159       TH2F* hist_All = ME_HLTAll_LS->getTH2F();
02160 
02161       // find the bin
02162       int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
02163       
02164       // update  the bin content  (must do that since events don't ncessarily come in the order
02165       float currentLumiCount = hist_All->GetBinContent(lumi+1,pathBinNumber);
02166       float updatedLumiCount = currentLumiCount + diffCount;
02167       hist_All->SetBinContent(lumi+1,pathBinNumber,updatedLumiCount);
02168     
02169     }
02170     else {
02171 
02172       LogDebug("FourVectorHLTOffline") << " cannot find ME_HLTAll_LS" <<  endl;
02173 
02174     }
02175     
02176 //     for (unsigned int i=0 ; i< v_ME_HLTAll_LS.size(); i++) {  
02177       
02178 //       MonitorElement* tempME = v_ME_HLTAll_LS[i];
02179 
02180 //       if (tempME && tempME->getName().find(pathname) != std::string::npos) {
02181   
02182 //         TH1F* hist_All = tempME->getTH1F();
02183   
02184 // //         // find the bin
02185 // //         int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
02186 // //         // update  the bin content  (must do that since events don't ncessarily come in the order
02187 //         float currentLumiCount = hist_All->GetBinContent(lumi+1);
02188 //         float updatedLumiCount = currentLumiCount + diffCount;
02189 //         hist_All->SetBinContent(lumi+1,updatedLumiCount);
02190       
02191 //       }
02192 //       else {
02193   
02194 //         LogDebug("FourVectorHLTOffline") << " cannot find tempME " <<  endl;
02195   
02196 //       }
02197 
02198 //     }
02199 
02200 
02201     // bjk here
02202 //     ///////////////////////////////////////////
02203 //     // fill the 1D individual path count per LS
02204 //     ///////////////////////////////////////////
02205 //     string fullPathToME_count = pathsIndividualHLTPathsPerLSFolder_ + pathname + "_count_per_LS";
02206 //     MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
02207 //     if ( ME_1d) { 
02208 
02209 //       // update  the bin content  (must do that since events don't ncessarily come in the order
02210 //       float currentLumiCount = ME_1d->getTH1()->GetBinContent(lumi+1);
02211 //       float updatedLumiCount = currentLumiCount + diffCount;
02212 //       ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
02213 
02214 //     }
02215 //     else {
02216 
02217 //       LogDebug("FourVectorHLTOffline") << " cannot find ME " << fullPathToME_count  <<  endl;
02218 
02219 //     }
02220 
02221   } // end for ip
02222 
02223 }
02224 
02225 int FourVectorHLTOffline::getTriggerTypeParsePathName(const string& pathname)
02226 {
02227 
02228    int objectType = 0;
02229 
02230          if (pathname.find("MET") != std::string::npos) 
02231            objectType = trigger::TriggerMET;    
02232          if (pathname.find("SumET") != std::string::npos || pathname.find("SumEt") != std::string::npos || pathname.find("ETT") != std::string::npos) 
02233            objectType = trigger::TriggerTET;    
02234          if (pathname.find("HT") != std::string::npos) 
02235            objectType = trigger::TriggerTET;    
02236          if (pathname.find("Jet") != std::string::npos) 
02237            objectType = trigger::TriggerJet;    
02238          if (pathname.find("Mu") != std::string::npos)
02239            objectType = trigger::TriggerMuon;    
02240          if (pathname.find("Ele") != std::string::npos) 
02241            objectType = trigger::TriggerElectron;    
02242          if (pathname.find("Photon") != std::string::npos) 
02243            objectType = trigger::TriggerPhoton;    
02244          if (pathname.find("EG") != std::string::npos) 
02245            objectType = trigger::TriggerPhoton;    
02246          if (pathname.find("Tau") != std::string::npos) 
02247            objectType = trigger::TriggerTau;    
02248          if (pathname.find("IsoTrack") != std::string::npos) 
02249            objectType = trigger::TriggerTrack;    
02250          if (pathname.find("BTag") != std::string::npos) 
02251            objectType = trigger::TriggerBJet;    
02252 
02253    return objectType;
02254 }
02255 
02256 const string FourVectorHLTOffline::getL1ConditionModuleName(const string& pathname)
02257 {
02258 
02259   // find L1 condition for numpath with numpath objecttype 
02260   // find PSet for L1 global seed for numpath, 
02261   // list module labels for numpath
02262   string l1pathname = "dummy";
02263 
02264   vector<string> numpathmodules = hltConfig_.moduleLabels(pathname);
02265 
02266   for(vector<string>::iterator numpathmodule = numpathmodules.begin();
02267   numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
02268 
02269     if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed") {
02270 
02271      l1pathname = *numpathmodule;
02272      break; 
02273 
02274     }
02275 
02276   } // end for
02277 
02278   return l1pathname;
02279 
02280 }
02281 
02282 
02283 bool FourVectorHLTOffline::hasL1Passed(const string& pathname, const edm::TriggerNames & triggerNames)
02284 {
02285   
02286   bool rc = false;
02287   int l1ModuleIndex = 999;
02288   // --------------------
02289   for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) { 
02290 
02291     if(v->getPath() == pathname ) l1ModuleIndex = v->getL1ModuleIndex();
02292 
02293   }
02294 
02295   unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
02296   if(pathByIndex >= fTriggerResults->size() ) return rc; // path is not in the menu
02297 
02298   // get index of the last module that issued the decision
02299   int lastModule = fTriggerResults->index(pathByIndex);
02300 
02301   // if L1 passed, then it must not be the module that 
02302   // issued the last decision
02303   rc = (l1ModuleIndex < lastModule);
02304 
02305   return rc;
02306 
02307 }
02308 
02309 bool FourVectorHLTOffline::hasHLTPassed(const string& pathname, const edm::TriggerNames & triggerNames)
02310 {
02311   
02312   bool rc = false;
02313 
02314   unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
02315   if(pathByIndex >= fTriggerResults->size() ) return rc; // path is not in the menu
02316 
02317   rc  = fTriggerResults->accept(pathByIndex);
02318 
02319   return rc;
02320 
02321 }
02322 
02323 void FourVectorHLTOffline::selectMuons(const edm::Handle<reco::MuonCollection> & muonHandle)
02324 {
02325   // for every event, first clear vector of selected objects
02326   fSelectedMuons->clear();
02327 
02328   if(muonHandle.isValid()) { 
02329 
02330     for( reco::MuonCollection::const_iterator iter = muonHandle->begin(), iend = muonHandle->end(); iter != iend; ++iter )
02331     {
02332 
02333        if(isGoodMuon(*iter, muon::GlobalMuonPromptTight) && 
02334           isGoodMuon(*iter, muon::TrackerMuonArbitrated))
02335        {
02336             if(isVBTFMuon(*iter)) fSelectedMuons->push_back(*iter);
02337        }
02338    } // end for
02339   
02340     edm::Handle<reco::MuonCollection> localSelMuonsHandle(fSelectedMuons,muonHandle.provenance());
02341     fSelMuonsHandle = localSelMuonsHandle;
02342 
02343   } // end if
02344 
02345 
02346 }
02347 
02348 void FourVectorHLTOffline::selectElectrons(const edm::Event& iEvent, const edm::EventSetup& iSetup, const edm::Handle<reco::GsfElectronCollection> & eleHandle)
02349 {
02350 
02351   // for every event, first clear vector of selected objects
02352   fSelectedElectrons->clear();
02353 
02354 
02355 
02356 
02357   if(eleHandle.isValid()) { 
02358 
02359     for( reco::GsfElectronCollection::const_iterator iter = eleHandle->begin(), iend = eleHandle->end(); iter != iend; ++iter )
02360     {
02361       
02362       edm::Handle< EcalRecHitCollection > pEBRecHits;
02363       iEvent.getByLabel( recHitsEBTag_, pEBRecHits );
02364 
02365       edm::Handle< EcalRecHitCollection > pEERecHits;
02366       iEvent.getByLabel( recHitsEETag_, pEERecHits );
02367 
02368       if(pEBRecHits.isValid() && pEERecHits.isValid()) {
02369       
02370         EcalClusterLazyTools lazyTool(iEvent, iSetup, recHitsEBTag_, recHitsEETag_); 
02371         const reco::CaloCluster* bc = iter->superCluster()->seed().get(); // get the basic cluster
02372       
02373         float eleMaxOver3x3 = ( lazyTool.eMax(*bc) / lazyTool.e3x3(*bc)  );
02374 
02375         if(eleMaxOver3x3 > eleMaxOver3x3_) continue;
02376 
02377       }
02378 
02379       // Only ecalDriven electrons
02380       if(! iter->ecalDriven() ) continue;
02381 
02382 
02383       // Barrel 
02384       if(iter->isEB()) {
02385 
02386         if (
02387                                   iter->dr03TkSumPt()         < dr03TkSumPtEB_ && 
02388                                   iter->dr04EcalRecHitSumEt() < dr04EcalRecHitSumEtEB_ && 
02389                                   iter->dr04HcalTowerSumEt()  < dr04HcalTowerSumEtEB_ &&
02390                                   iter->hadronicOverEm()      < hadronicOverEmEB_ &&
02391                                   fabs(iter->deltaPhiSuperClusterTrackAtVtx()) < deltaPhiSuperClusterTrackAtVtxEB_ && 
02392                                   fabs(iter->deltaEtaSuperClusterTrackAtVtx()) < deltaEtaSuperClusterTrackAtVtxEB_ &&
02393                                   iter->sigmaIetaIeta() < sigmaIetaIetaEB_ &&
02394           //spikes
02395                                   iter->sigmaIetaIeta() > sigmaIetaIetaSpikesEB_
02396         ) {
02397 
02398             fSelectedElectrons->push_back(*iter);
02399 
02400         }
02401 
02402       } // end if
02403 
02404       // EndCap
02405       else if(iter->isEE()) {
02406         if (
02407                                   iter->dr03TkSumPt()         < dr03TkSumPtEC_ && 
02408                                   iter->dr04EcalRecHitSumEt() < dr04EcalRecHitSumEtEC_ && 
02409                                   iter->dr04HcalTowerSumEt()  < dr04HcalTowerSumEtEC_ && 
02410                                   iter->hadronicOverEm()      < hadronicOverEmEC_ && 
02411                                   fabs(iter->deltaPhiSuperClusterTrackAtVtx()) < deltaPhiSuperClusterTrackAtVtxEC_ && 
02412                                   fabs(iter->deltaEtaSuperClusterTrackAtVtx()) < deltaEtaSuperClusterTrackAtVtxEC_ && 
02413                                   iter->sigmaIetaIeta() < sigmaIetaIetaEC_ && 
02414           //spikes
02415                                   iter->sigmaIetaIeta() > sigmaIetaIetaSpikesEC_
02416         ) {
02417 
02418             fSelectedElectrons->push_back(*iter);
02419 
02420           }
02421 
02422       } // end else if
02423 
02424 
02425     } // end for
02426   
02427     edm::Handle<reco::GsfElectronCollection> localSelElectronsHandle(fSelectedElectrons,eleHandle.provenance());
02428     fSelElectronsHandle = localSelElectronsHandle;
02429 
02430   } // end if
02431 
02432 
02433 }
02434 
02435 void FourVectorHLTOffline::selectPhotons(const edm::Handle<reco::PhotonCollection> & phoHandle)
02436 {
02437   // for every event, first clear vector of selected objects
02438   fSelectedPhotons->clear();
02439 
02440   if(phoHandle.isValid()) { 
02441 
02442     for( reco::PhotonCollection::const_iterator iter = phoHandle->begin(), iend = phoHandle->end(); iter != iend; ++iter )
02443     {
02444 
02445       if( 
02446 
02447           //spikes
02448                                   iter->sigmaIetaIeta() > 0.002  &&
02449           iter->maxEnergyXtal() / iter->e3x3() < 0.9
02450 
02451         ) {
02452 
02453           fSelectedPhotons->push_back(*iter);
02454 
02455       }  // end if
02456 
02457     } // end for
02458   
02459     edm::Handle<reco::PhotonCollection> localSelPhotonsHandle(fSelectedPhotons,phoHandle.provenance());
02460     fSelPhotonsHandle = localSelPhotonsHandle;
02461 
02462   } // end if
02463 
02464 
02465 }
02466 
02467 void FourVectorHLTOffline::selectJets(const edm::Event& iEvent, const edm::Handle<reco::CaloJetCollection> & jetHandle)
02468 {
02469   // for every event, first clear vector of selected objects
02470   fSelectedJets->clear();
02471 
02472   if(jetHandle.isValid()) { 
02473 
02474     for( reco::CaloJetCollection::const_iterator iter = jetHandle->begin(), iend = jetHandle->end(); iter != iend; ++iter )
02475     {
02476 
02477        jetID->calculate(iEvent, *iter);
02478        if (iter->emEnergyFraction() > emEnergyFractionJet_ &&
02479            jetID->fHPD() < fHPDJet_ &&
02480            iter->n90() >= n90Jet_ 
02481            ){ 
02482 
02483                 fSelectedJets->push_back(*iter);
02484               
02485             }
02486 
02487     } // end for
02488   
02489     edm::Handle<reco::CaloJetCollection> localSelJetsHandle(fSelectedJets,jetHandle.provenance());
02490     fSelJetsHandle = localSelJetsHandle;
02491 
02492   } // end if
02493 
02494 
02495 }
02496 
02497 void FourVectorHLTOffline::selectMet(const edm::Handle<reco::CaloMETCollection> & metHandle)
02498 {
02499   // for every event, first clear vector of selected objects
02500   fSelectedMet->clear();
02501 
02502   if(metHandle.isValid()) { 
02503 
02504     for( reco::CaloMETCollection::const_iterator iter = metHandle->begin(), iend = metHandle->end(); iter != iend; ++iter )
02505     {
02506 
02507       fSelectedMet->push_back(*iter);
02508 
02509     } // end for
02510   
02511     edm::Handle<reco::CaloMETCollection> localSelMetHandle(fSelectedMet,metHandle.provenance());
02512     fSelMetHandle = localSelMetHandle;
02513 
02514   } // end if
02515 
02516 
02517 }
02518 
02519 
02520 void FourVectorHLTOffline::selectTaus(const edm::Event& iEvent)
02521 {
02522   // for every event, first clear vector of selected objects
02523   fSelectedTaus->clear();
02524 
02525   //first read the tau collection
02526   edm::Handle<reco::PFTauCollection> tauHandle;  
02527   iEvent.getByLabel("hpsPFTauProducer",tauHandle);
02528 
02529   //Now access a discriminator and see if it passed the tag
02530   edm::Handle<reco::PFTauDiscriminator> dscrmt1H;
02531   iEvent.getByLabel(tauDscrmtrLabel1_,dscrmt1H);
02532   edm::Handle<reco::PFTauDiscriminator> dscrmt2H;
02533   iEvent.getByLabel(tauDscrmtrLabel2_,dscrmt2H);
02534   edm::Handle<reco::PFTauDiscriminator> dscrmt3H;
02535   iEvent.getByLabel(tauDscrmtrLabel3_,dscrmt3H);
02536 
02537   if(tauHandle.isValid() && dscrmt1H.isValid() && dscrmt2H.isValid() && dscrmt3H.isValid()) { 
02538 
02539     for(unsigned int i=0;i<tauHandle->size();++i) {
02540 
02541         //create a ref to the PF Tau 
02542         reco::PFTauRef pfTauRef(tauHandle,i);
02543 
02544         float outputDiscmnt1 = (*dscrmt1H)[pfTauRef]; // this should be >0.5 to pass
02545         float outputDiscmnt2 = (*dscrmt2H)[pfTauRef]; // this should be >0.5 to pass
02546         float outputDiscmnt3 = (*dscrmt3H)[pfTauRef]; // this should be >0.5 to pass
02547 
02548         if(outputDiscmnt1>0.5 && outputDiscmnt2>0.5 && outputDiscmnt3 >0.5) {
02549 
02550           fSelectedTaus->push_back((*tauHandle)[i]);
02551 
02552         }
02553 
02554     } // end for
02555 
02556   
02557     edm::Handle<reco::PFTauCollection> localSelTauHandle(fSelectedTaus,tauHandle.provenance());
02558     fSelTausHandle = localSelTauHandle;
02559 
02560   } // end if
02561 
02562 }
02563 
02564 
02565 int FourVectorHLTOffline::getHltThresholdFromName(const string & name)
02566 {
02567   
02568   std::string pathname = name;
02569   //cout << "----------------------------------------------" << endl;
02570   //cout << pathname << endl;
02571 
02572   //remove "L1" substr
02573   if(pathname.find("L1") != std::string::npos) pathname.replace(pathname.find("L1"),2,"");
02574   //remove "L2" substr
02575   if(pathname.find("L2") != std::string::npos) pathname.replace(pathname.find("L2"),2,"");
02576   //remove "8E29" substr
02577   if(pathname.find("8E29") != std::string::npos) pathname.replace(pathname.find("8E29"),4,"");
02578 
02579   int digitLocation=0;
02580   for (unsigned int i=0; i < pathname.length(); i++)
02581   {
02582      if (isdigit(pathname.at(i))) {
02583 
02584        digitLocation = i;
02585        break;
02586 
02587      }
02588   }
02589 
02590   // get the string from the location of the first digit to the end
02591   string hltThresholdString = pathname.substr(digitLocation);
02592 
02593   int hltThreshold = 0;
02594 
02595   // get intiger at the begining of the string
02596   sscanf (hltThresholdString.c_str(),"%d%*s",&hltThreshold);
02597   //printf ("%s -> %s -> %d\n",pathname.c_str(), hltThresholdString.c_str(), hltThreshold);
02598 
02599   return hltThreshold;
02600 
02601 }
02602 
02603 bool FourVectorHLTOffline::isVBTFMuon(const reco::Muon& muon)
02604 {
02605 
02606   reco::TrackRef gm = muon.globalTrack();
02607   reco::TrackRef tk = muon.innerTrack();
02608 
02609   // Quality cuts
02610   // ------------
02611 
02612   // Must have BeamSpot for the 1st qualityCut
02613   if(!fBeamSpotHandle.isValid()) return 0;
02614 
02615   double dxy = gm->dxy(fBeamSpotHandle->position());
02616   double normalizedChi2 = gm->normalizedChi2(); 
02617   int trackerHits = tk->hitPattern().numberOfValidTrackerHits();
02618   int pixelHits = tk->hitPattern().numberOfValidPixelHits();
02619   int muonHits = gm->hitPattern().numberOfValidMuonHits();
02620   int nMatches = muon.numberOfMatches();
02621 
02622   if (fabs(dxy)>dxyCut_) {return 0;}
02623   //               if(plotHistograms_){ h1_["hNormChi2"]->Fill(normalizedChi2);}
02624   if (normalizedChi2>normalizedChi2Cut_) {return 0;}
02625   //               if(plotHistograms_){ h1_["hNHits"]->Fill(trackerHits);}
02626   if (trackerHits<trackerHitsCut_) {return 0;}
02627   //               if(plotHistograms_){ h1_["hNMuonHits"]->Fill(muonHits);}
02628   if (pixelHits<pixelHitsCut_) {return 0;}
02629   //               if(plotHistograms_){ h1_["hNPixelHits"]->Fill(pixelHits);}
02630   if (muonHits<muonHitsCut_) {return 0;}
02631   //               if(plotHistograms_){ h1_["hTracker"]->Fill(mu.isTrackerMuon());}
02632   if (!muon.isTrackerMuon()) {return 0;}
02633   //               if(plotHistograms_){ h1_["hNMatches"]->Fill(nMatches);}
02634   if (nMatches<nMatchesCut_) {return 0;}
02635 
02636   return true;
02637 
02638 }
02639 
02640  string FourVectorHLTOffline::removeVersions(std::string histVersion) {
02641    for (int ii = 100; ii >= 0; ii--) {
02642      string ver = "_v";
02643      string version ="";
02644      stringstream ss;
02645      ss << ver << ii;
02646      ss >> version;
02647      
02648      size_t pos = histVersion.find(version);
02649      if (pos != std::string::npos)
02650        histVersion.erase(pos,version.size());
02651      
02652    }
02653    
02654    return histVersion;
02655  }
02656