CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/HLTriggerOffline/Common/src/FourVectorHLTriggerOffline.cc

Go to the documentation of this file.
00001 // $Id: FourVectorHLTriggerOffline.cc,v 1.40 2011/10/28 16:34:34 olzem Exp $
00002 // See header file for information. 
00003 #include "TMath.h"
00004 #include "HLTriggerOffline/Common/interface/FourVectorHLTriggerOffline.h"
00005 #include "FWCore/Common/interface/TriggerNames.h"
00006 
00007 #include <map>
00008 #include <utility>
00009 
00010 
00011 using namespace edm;
00012 using namespace trigger;
00013 
00014 FourVectorHLTriggerOffline::FourVectorHLTriggerOffline(const edm::ParameterSet& iConfig):
00015   resetMe_(true),  currentRun_(-99)
00016 {
00017   LogDebug("FourVectorHLTriggerOffline") << "constructor...." ;
00018 
00019   dbe_ = Service < DQMStore > ().operator->();
00020   if ( ! dbe_ ) {
00021     LogInfo("FourVectorHLTriggerOffline") << "unabel to get DQMStore service?";
00022   }
00023   if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
00024     dbe_->setVerbose(0);
00025   }
00026   
00027   dirname_ = iConfig.getUntrackedParameter("dirname",
00028                                            std::string("HLT/FourVector/"));
00029   //dirname_ +=  iConfig.getParameter<std::string>("@module_label");
00030   
00031   if (dbe_ != 0 ) {
00032     dbe_->setCurrentFolder(dirname_);
00033   }
00034   
00035   processname_ = iConfig.getParameter<std::string>("processname");
00036 
00037   // plotting paramters
00038   ptMin_ = iConfig.getUntrackedParameter<double>("ptMin",0.);
00039   ptMax_ = iConfig.getUntrackedParameter<double>("ptMax",1000.);
00040   nBins_ = iConfig.getUntrackedParameter<unsigned int>("Nbins",20);
00041   
00042   plotAll_ = iConfig.getUntrackedParameter<bool>("plotAll", false);
00043      // this is the list of paths to look at.
00044      std::vector<edm::ParameterSet> paths = 
00045      iConfig.getParameter<std::vector<edm::ParameterSet> >("paths");
00046      for(std::vector<edm::ParameterSet>::iterator 
00047         pathconf = paths.begin() ; pathconf != paths.end(); 
00048       pathconf++) {
00049        std::pair<std::string, std::string> custompathnamepair;
00050        custompathnamepair.first =pathconf->getParameter<std::string>("pathname"); 
00051        custompathnamepair.second = pathconf->getParameter<std::string>("denompathname");   
00052        custompathnamepairs_.push_back(custompathnamepair);
00053        //    customdenompathnames_.push_back(pathconf->getParameter<std::string>("denompathname"));  
00054        // custompathnames_.push_back(pathconf->getParameter<std::string>("pathname"));  
00055     }
00056 
00057   if (hltPaths_.size() > 0)
00058     {
00059       // book a histogram of scalers
00060      scalersSelect = dbe_->book1D("selectedScalers","Selected Scalers", hltPaths_.size(), 0.0, (double)hltPaths_.size());
00061     }
00062 
00063  
00064   triggerSummaryLabel_ = 
00065     iConfig.getParameter<edm::InputTag>("triggerSummaryLabel");
00066   triggerResultsLabel_ = 
00067     iConfig.getParameter<edm::InputTag>("triggerResultsLabel");
00068 
00069   electronEtaMax_ = iConfig.getUntrackedParameter<double>("electronEtaMax",2.5);
00070   electronEtMin_ = iConfig.getUntrackedParameter<double>("electronEtMin",3.0);
00071   electronDRMatch_  =iConfig.getUntrackedParameter<double>("electronDRMatch",0.3); 
00072 
00073   muonEtaMax_ = iConfig.getUntrackedParameter<double>("muonEtaMax",2.1);
00074   muonEtMin_ = iConfig.getUntrackedParameter<double>("muonEtMin",3.0);
00075   muonDRMatch_  =iConfig.getUntrackedParameter<double>("muonDRMatch",0.3); 
00076 
00077   tauEtaMax_ = iConfig.getUntrackedParameter<double>("tauEtaMax",2.5);
00078   tauEtMin_ = iConfig.getUntrackedParameter<double>("tauEtMin",3.0);
00079   tauDRMatch_  =iConfig.getUntrackedParameter<double>("tauDRMatch",0.3); 
00080 
00081   jetEtaMax_ = iConfig.getUntrackedParameter<double>("jetEtaMax",5.0);
00082   jetEtMin_ = iConfig.getUntrackedParameter<double>("jetEtMin",10.0);
00083   jetDRMatch_  =iConfig.getUntrackedParameter<double>("jetDRMatch",0.3); 
00084 
00085   bjetEtaMax_ = iConfig.getUntrackedParameter<double>("bjetEtaMax",2.5);
00086   bjetEtMin_ = iConfig.getUntrackedParameter<double>("bjetEtMin",10.0);
00087   bjetDRMatch_  =iConfig.getUntrackedParameter<double>("bjetDRMatch",0.3); 
00088 
00089   photonEtaMax_ = iConfig.getUntrackedParameter<double>("photonEtaMax",2.5);
00090   photonEtMin_ = iConfig.getUntrackedParameter<double>("photonEtMin",3.0);
00091   photonDRMatch_  =iConfig.getUntrackedParameter<double>("photonDRMatch",0.3); 
00092 
00093   trackEtaMax_ = iConfig.getUntrackedParameter<double>("trackEtaMax",2.5);
00094   trackEtMin_ = iConfig.getUntrackedParameter<double>("trackEtMin",3.0);
00095   trackDRMatch_  =iConfig.getUntrackedParameter<double>("trackDRMatch",0.3); 
00096 
00097   metMin_ = iConfig.getUntrackedParameter<double>("metMin",10.0);
00098   htMin_ = iConfig.getUntrackedParameter<double>("htMin",10.0);
00099   sumEtMin_ = iConfig.getUntrackedParameter<double>("sumEtMin",10.0);
00100   
00101 }
00102 
00103 
00104 FourVectorHLTriggerOffline::~FourVectorHLTriggerOffline()
00105 {
00106  
00107    // do anything here that needs to be done at desctruction time
00108    // (e.g. close files, deallocate resources etc.)
00109 
00110 }
00111 
00112 
00113 //
00114 // member functions
00115 //
00116 
00117 // ------------ method called to for each event  ------------
00118 void
00119 FourVectorHLTriggerOffline::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00120 {
00121   using namespace edm;
00122   using namespace trigger;
00123   ++nev_;
00124   LogDebug("FourVectorHLTriggerOffline")<< " analyze...." ;
00125   
00126   Handle<reco::GenParticleCollection> genParticles;
00127   iEvent.getByLabel("genParticles", genParticles);
00128   if(!genParticles.isValid()) { 
00129     edm::LogInfo("FourVectorHLTriggerOffline") << "genParticles not found, "
00130       "skipping event"; 
00131     return;
00132   }
00133 
00134   Handle<reco::GenJetCollection> genJets;
00135   iEvent.getByLabel("iterativeCone5GenJets",genJets);
00136   if(!genJets.isValid()) { 
00137     edm::LogInfo("FourVectorHLTriggerOffline") << "genJets not found, "
00138       "skipping event"; 
00139     return;
00140   }
00141 
00142   Handle<reco::GenMETCollection> genMets;
00143   iEvent.getByLabel("genMetTrue",genMets);
00144   if(!genMets.isValid()) { 
00145     edm::LogInfo("FourVectorHLTriggerOffline") << "genMets not found, "
00146       "skipping event"; 
00147     return;
00148   }
00149 
00150   edm::Handle<TriggerResults> triggerResults;
00151   iEvent.getByLabel(triggerResultsLabel_,triggerResults);
00152   if(!triggerResults.isValid()) {
00153     edm::InputTag triggerResultsLabelFU(triggerResultsLabel_.label(),triggerResultsLabel_.instance(), "FU");
00154    iEvent.getByLabel(triggerResultsLabelFU,triggerResults);
00155   if(!triggerResults.isValid()) {
00156     edm::LogInfo("FourVectorHLTriggerOffline") << "TriggerResults not found, "
00157       "skipping event"; 
00158     return;
00159    }
00160   }
00161   const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
00162   int npath = triggerResults->size();
00163 
00164   edm::Handle<TriggerEvent> triggerObj;
00165   iEvent.getByLabel(triggerSummaryLabel_,triggerObj); 
00166   if(!triggerObj.isValid()) {
00167     edm::InputTag triggerSummaryLabelFU(triggerSummaryLabel_.label(),triggerSummaryLabel_.instance(), "FU");
00168    iEvent.getByLabel(triggerSummaryLabelFU,triggerObj);
00169   if(!triggerObj.isValid()) {
00170     edm::LogInfo("FourVectorHLTriggerOffline") << "TriggerEvent not found, "
00171       "skipping event"; 
00172     return;
00173    }
00174   }
00175 
00176   edm::Handle<reco::MuonCollection> muonHandle;
00177   iEvent.getByLabel("muons",muonHandle);
00178   if(!muonHandle.isValid()) { 
00179     edm::LogInfo("FourVectorHLTriggerOffline") << "muonHandle not found, ";
00180     //  "skipping event"; 
00181     //  return;
00182    }
00183 
00184   edm::Handle<reco::GsfElectronCollection> gsfElectrons;
00185   iEvent.getByLabel("gsfElectrons",gsfElectrons); 
00186   if(!gsfElectrons.isValid()) { 
00187     edm::LogInfo("FourVectorHLTriggerOffline") << "gsfElectrons not found, ";
00188       //"skipping event"; 
00189       //return;
00190   }
00191 
00192   edm::Handle<reco::CaloTauCollection> tauHandle;
00193   iEvent.getByLabel("caloRecoTauProducer",tauHandle);
00194   if(!tauHandle.isValid()) { 
00195     edm::LogInfo("FourVectorHLTriggerOffline") << "tauHandle not found, ";
00196       //"skipping event"; 
00197       //return;
00198   }
00199 
00200   edm::Handle<reco::CaloJetCollection> jetHandle;
00201   iEvent.getByLabel("iterativeCone5CaloJets",jetHandle);
00202   if(!jetHandle.isValid()) { 
00203     edm::LogInfo("FourVectorHLTriggerOffline") << "jetHandle not found, ";
00204       //"skipping event"; 
00205       //return;
00206   }
00207  
00208    // Get b tag information
00209  edm::Handle<reco::JetTagCollection> bTagIPHandle;
00210  iEvent.getByLabel("jetProbabilityBJetTags", bTagIPHandle);
00211  if (!bTagIPHandle.isValid()) {
00212     edm::LogInfo("FourVectorHLTriggerOffline") << "mTagIPHandle trackCountingHighEffJetTags not found, ";
00213       //"skipping event"; 
00214       //return;
00215   }
00216 
00217    // Get b tag information
00218  edm::Handle<reco::JetTagCollection> bTagMuHandle;
00219  iEvent.getByLabel("softMuonBJetTags", bTagMuHandle);
00220  if (!bTagMuHandle.isValid()) {
00221     edm::LogInfo("FourVectorHLTriggerOffline") << "bTagMuHandle  not found, ";
00222       //"skipping event"; 
00223       //return;
00224   }
00225 
00226   edm::Handle<reco::CaloMETCollection> metHandle;
00227   iEvent.getByLabel("met",metHandle);
00228   if(!metHandle.isValid()) { 
00229     edm::LogInfo("FourVectorHLTriggerOffline") << "metHandle not found, ";
00230       //"skipping event"; 
00231       //return;
00232   }
00233 
00234   edm::Handle<reco::PhotonCollection> photonHandle;
00235   iEvent.getByLabel("photons",photonHandle);
00236   if(!photonHandle.isValid()) { 
00237     edm::LogInfo("FourVectorHLTriggerOffline") << "photonHandle not found, ";
00238       //"skipping event"; 
00239       //return;
00240   }
00241 
00242   edm::Handle<reco::TrackCollection> trackHandle;
00243   iEvent.getByLabel("pixelTracks",trackHandle);
00244   if(!trackHandle.isValid()) { 
00245     edm::LogInfo("FourVectorHLTriggerOffline") << "trackHandle not found, ";
00246       //"skipping event"; 
00247       //return;
00248   }
00249 
00250   const trigger::TriggerObjectCollection & toc(triggerObj->getObjects());
00251 
00252   // electron Monitor
00253         // ------------
00254   objMon<reco::GsfElectronCollection> eleMon;
00255   eleMon.setReco(gsfElectrons);
00256   eleMon.setMC(genParticles, 11, 1);
00257   eleMon.setLimits(electronEtaMax_, electronEtMin_, electronDRMatch_);
00258   
00259   eleMon.pushTriggerType(TriggerElectron);
00260   eleMon.pushTriggerType(TriggerL1NoIsoEG);
00261   eleMon.pushTriggerType(TriggerL1IsoEG);
00262 
00263   eleMon.pushL1TriggerType(TriggerL1NoIsoEG);
00264   eleMon.pushL1TriggerType(TriggerL1IsoEG);
00265 
00266   // muon Monitor
00267         // ------------
00268   objMon<reco::MuonCollection>  muoMon;
00269   muoMon.setReco(muonHandle);
00270   muoMon.setMC(genParticles, 13, 1);
00271   muoMon.setLimits(muonEtaMax_, muonEtMin_, muonDRMatch_);
00272   
00273   muoMon.pushTriggerType(TriggerMuon);
00274   muoMon.pushTriggerType(TriggerL1Mu);
00275 
00276   muoMon.pushL1TriggerType(TriggerL1Mu);
00277         
00278   // tau Monitor
00279         // ------------
00280   objMon<reco::CaloTauCollection>  tauMon;
00281   tauMon.setReco(tauHandle);
00282   tauMon.setMC(genParticles, 15, 3);
00283   tauMon.setLimits(tauEtaMax_, tauEtMin_, tauDRMatch_);
00284   
00285   tauMon.pushTriggerType(TriggerTau);
00286   tauMon.pushTriggerType(TriggerL1TauJet);
00287 
00288   tauMon.pushL1TriggerType(TriggerL1TauJet);
00289   tauMon.pushL1TriggerType(TriggerL1CenJet);
00290   tauMon.pushL1TriggerType(TriggerL1ForJet);
00291         
00292   // photon Monitor
00293         // ------------
00294   objMon<reco::PhotonCollection> phoMon;
00295   phoMon.setReco(photonHandle);
00296   phoMon.setMC(genParticles, 22, 1);
00297   phoMon.setLimits(photonEtaMax_, photonEtMin_, photonDRMatch_);
00298   
00299   phoMon.pushTriggerType(TriggerPhoton);
00300 
00301   phoMon.pushL1TriggerType(TriggerL1NoIsoEG);
00302   phoMon.pushL1TriggerType(TriggerL1IsoEG);
00303 
00304   // jet Monitor - NOTICE: we use genJets for MC
00305         // -------------------------------------------
00306   objMon<reco::CaloJetCollection> jetMon;
00307   jetMon.setReco(jetHandle);
00308   jetMon.setGenJets(true, genJets);
00309   jetMon.setLimits(jetEtaMax_, jetEtMin_, jetDRMatch_);
00310 
00311   jetMon.pushTriggerType(TriggerJet);
00312   jetMon.pushTriggerType(TriggerL1CenJet);
00313   jetMon.pushTriggerType(TriggerL1ForJet);
00314   
00315   jetMon.pushL1TriggerType(TriggerL1CenJet);
00316   jetMon.pushL1TriggerType(TriggerL1ForJet);
00317   jetMon.pushL1TriggerType(TriggerL1TauJet);
00318 
00319   // btag Monitor - NOTICE: we use genJets for MC
00320         // -------------------------------------------
00321   //objMon<reco::JetTagCollection> btagIPMon;
00322   objMon<reco::CaloJetCollection> btagIPMon; // CaloJet will not be used, this is only place holder
00323   //btagIPMon.setReco(jetHandle);
00324   btagIPMon.setRecoB(bTagIPHandle);
00325   btagIPMon.setMC(genParticles, 5, 3);
00326   btagIPMon.setGenJets(true, genJets);
00327   btagIPMon.setBJetsFlag(true);
00328   btagIPMon.setLimits(bjetEtaMax_, bjetEtMin_, bjetDRMatch_);
00329 
00330   btagIPMon.pushTriggerType(TriggerBJet);
00331   btagIPMon.pushTriggerType(TriggerJet);
00332 
00333   btagIPMon.pushL1TriggerType(TriggerL1CenJet);
00334   btagIPMon.pushL1TriggerType(TriggerL1ForJet);
00335   btagIPMon.pushL1TriggerType(TriggerL1TauJet);
00336 
00337   //objMon<reco::JetTagCollection> btagMuMon;
00338   objMon<reco::CaloJetCollection> btagMuMon; // CaloJet will not be used, this is only place holder
00339   //btagMuMon.setReco(jetHandle);
00340   btagMuMon.setRecoB(bTagMuHandle);
00341   btagMuMon.setMC(genParticles, 5, 3);
00342   btagMuMon.setGenJets(true, genJets);
00343   btagMuMon.setBJetsFlag(true);
00344   btagMuMon.setLimits(bjetEtaMax_, bjetEtMin_, bjetDRMatch_);
00345 
00346   btagMuMon.pushTriggerType(TriggerBJet);
00347   btagMuMon.pushTriggerType(TriggerJet);
00348 
00349   btagMuMon.pushL1TriggerType(TriggerL1CenJet);
00350   btagMuMon.pushL1TriggerType(TriggerL1ForJet);
00351   btagMuMon.pushL1TriggerType(TriggerL1TauJet);
00352 
00353  
00354   objMon<reco::CaloJetCollection> btagMon; // Generic btagMon
00355 
00356     for(PathInfoCollection::iterator v = hltPaths_.begin();
00357         v!= hltPaths_.end(); ++v ) 
00358 { 
00359     //LogTrace("FourVectorHLTriggerOffline") << " path " << v->getPath() << std::endl;
00360               if (v->getPath().find("BTagIP") != std::string::npos ) btagMon = btagIPMon;
00361                                 else btagMon = btagMuMon;
00362 
00363 
00364   // did we pass the denomPath?
00365   bool denompassed = false;  
00366   for(int i = 0; i < npath; ++i) {
00367      if (triggerNames.triggerName(i).find(v->getDenomPath()) != std::string::npos && triggerResults->accept(i))
00368        { 
00369         denompassed = true;
00370         break;
00371        }
00372   }
00373 
00374   if (denompassed)
00375   {  
00376 
00377       eleMon.clearSets();
00378       muoMon.clearSets();
00379       tauMon.clearSets();
00380       phoMon.clearSets();
00381       jetMon.clearSets();
00382       btagMon.clearSets();
00383 
00384       // UNUSED
00385       //       int triggertype = 0;     
00386       //       triggertype = v->getObjectType();
00387 
00388       bool l1accept = false;
00389       edm::InputTag l1testTag(v->getl1Path(),"",processname_);
00390       const int l1index = triggerObj->filterIndex(l1testTag);
00391       if ( l1index >= triggerObj->sizeFilters() ) {
00392         edm::LogInfo("FourVectorHLTriggerOffline") << "no index "<< l1index << " of that name " << v->getl1Path() << "\t" << "\t" << l1testTag;
00393         continue; // not in this event
00394       }
00395 
00396       const trigger::Vids & idtype = triggerObj->filterIds(l1index);
00397       const trigger::Keys & l1k = triggerObj->filterKeys(l1index);
00398       l1accept = l1k.size() > 0;
00399 
00400 
00401       eleMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00402                 muoMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00403                 tauMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00404                 phoMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00405                 jetMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00406                 btagMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00407   
00408                 eleMon.fillL1Match(this);
00409                 muoMon.fillL1Match(this);
00410                 tauMon.fillL1Match(this);
00411                 phoMon.fillL1Match(this);
00412                 jetMon.fillL1Match(this);
00413                 btagMon.fillL1Match(this);
00414   
00415      // did we pass the numerator path?
00416      bool numpassed = false;
00417      for(int i = 0; i < npath; ++i) {
00418 
00419         if (triggerNames.triggerName(i) == v->getPath() && triggerResults->accept(i)) numpassed = true;
00420 
00421      }
00422 
00423      if (numpassed)
00424      { 
00425 
00426         if (!l1accept) {
00427            edm::LogInfo("FourVectorHLTriggerOffline") << "l1 seed path not accepted for hlt path "<< v->getPath() << "\t" << v->getl1Path();
00428         }
00429 
00430         // fill scaler histograms
00431         edm::InputTag filterTag = v->getTag();
00432 
00433               // loop through indices and see if the filter is on the list of filters used by this path
00434       
00435         if (v->getLabel() == "dummy"){
00436         const std::vector<std::string> filterLabels = hltConfig_.moduleLabels(v->getPath());
00437               //loop over labels
00438         for (std::vector<std::string>::const_iterator labelIter= filterLabels.begin(); labelIter!=filterLabels.end(); labelIter++)          
00439               {
00440 
00441                 //std::cout << v->getPath() << "\t" << *labelIter << std::endl;
00442           // last match wins...
00443                 edm::InputTag testTag(*labelIter,"",processname_);
00444           int testindex = triggerObj->filterIndex(testTag);
00445           if ( !(testindex >= triggerObj->sizeFilters()) ) {
00446 
00447                   //std::cout << "found one! " << v->getPath() << "\t" << testTag.label() << std::endl; 
00448             filterTag = testTag; v->setLabel(*labelIter);}
00449                 }
00450         }
00451         
00452         const int index = triggerObj->filterIndex(filterTag);
00453         if ( index >= triggerObj->sizeFilters() ) {
00454 
00455                 //        std::cout << "WTF no index "<< index << " of that name "
00456                 //           << filterTag << std::endl;
00457                 continue; // not in this event
00458 
00459         }
00460 
00461         //LogDebug("FourVectorHLTriggerOffline") << "filling ... " ;
00462         const trigger::Keys & k = triggerObj->filterKeys(index);
00463         //      const trigger::Vids & idtype = triggerObj->filterIds(index);
00464         // assume for now the first object type is the same as all objects in the collection
00465         //    std::cout << filterTag << "\t" << idtype.size() << "\t" << k.size() << std::endl;
00466         //     std::cout << "path " << v->getPath() << " trigger type "<<triggertype << std::endl;
00467         //if (k.size() > 0) v->getNOnHisto()->Fill(k.size());
00468 
00469 
00470         unsigned int NOn=0;
00471 
00472         for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
00473 
00474           eleMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00475           muoMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00476           tauMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00477           phoMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00478           jetMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00479           btagMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00480 
00481         } //online object loop
00482 
00483         eleMon.fillOnlineMatch(this, l1k, toc);
00484         muoMon.fillOnlineMatch(this, l1k, toc);
00485         tauMon.fillOnlineMatch(this, l1k, toc);
00486         phoMon.fillOnlineMatch(this, l1k, toc);
00487         jetMon.fillOnlineMatch(this, l1k, toc);
00488         btagMon.fillOnlineMatch(this, l1k, toc);
00489 
00490         eleMon.monitorOffline(this);
00491         muoMon.monitorOffline(this);
00492         tauMon.monitorOffline(this);
00493         phoMon.monitorOffline(this);
00494         jetMon.monitorOffline(this);
00495         btagMon.monitorOffline(this);
00496 
00497         eleMon.fillOffMatch(this);
00498         muoMon.fillOffMatch(this);
00499         tauMon.fillOffMatch(this);
00500         phoMon.fillOffMatch(this);
00501         jetMon.fillOffMatch(this);
00502         btagMon.fillOffMatch(this);
00503 
00504 
00505      } //numpassed
00506 
00507     
00508 
00509    } //denompassed
00510 
00511   } //pathinfo loop
00512 
00513 }
00514 
00515 
00516 
00517 // -- method called once each job just before starting event loop  --------
00518 void 
00519 FourVectorHLTriggerOffline::beginJob()
00520 {
00521   nev_ = 0;
00522   DQMStore *dbe = 0;
00523   dbe = Service<DQMStore>().operator->();
00524   
00525   if (dbe) {
00526     dbe->setCurrentFolder(dirname_);
00527     dbe->rmdir(dirname_);
00528   }
00529   
00530   
00531   if (dbe) {
00532     dbe->setCurrentFolder(dirname_);
00533     }  
00534 }
00535 
00536 // - method called once each job just after ending the event loop  ------------
00537 void 
00538 FourVectorHLTriggerOffline::endJob() 
00539 {
00540    LogInfo("FourVectorHLTriggerOffline") << "analyzed " << nev_ << " events";
00541    return;
00542 }
00543 
00544 
00545 // BeginRun
00546 void FourVectorHLTriggerOffline::beginRun(const edm::Run& run, const edm::EventSetup& c)
00547 {
00548   LogDebug("FourVectorHLTriggerOffline") << "beginRun, run " << run.id();
00549   // HLT config does not change within runs!
00550 
00551   bool changed(false);  
00552   if (!hltConfig_.init(run, c, processname_, changed)) {
00553     processname_ = "FU";
00554     if (!hltConfig_.init(run, c, processname_, changed)){
00555   LogDebug("FourVectorHLTriggerOffline") << "HLTConfigProvider failed to initialize.";
00556     }
00557     // check if trigger name in (new) config
00558     //  std::cout << "Available TriggerNames are: " << std::endl;
00559     //  hltConfig_.dump("Triggers");
00560       }
00561 
00562 
00563   if (1)
00564  {
00565   DQMStore *dbe = 0;
00566   dbe = Service<DQMStore>().operator->();
00567   
00568   if (dbe) {
00569     dbe->setCurrentFolder(dirname_);
00570   }
00571 
00572 
00573     const unsigned int n(hltConfig_.size());
00574     if (plotAll_){
00575     for (unsigned int j=0; j!=n; ++j) {
00576     std::string pathname = hltConfig_.triggerName(j);  
00577     std::string l1pathname = "dummy";
00578     for (unsigned int i=0; i!=n; ++i) {
00579       // std::cout << hltConfig_.triggerName(i) << std::endl;
00580     
00581     std::string denompathname = hltConfig_.triggerName(i);  
00582     int objectType = 0;
00583     int denomobjectType = 0;
00584     //parse pathname to guess object type
00585     if (pathname.find("MET") != std::string::npos) 
00586       objectType = trigger::TriggerMET;    
00587     if (pathname.find("SumET") != std::string::npos) 
00588       objectType = trigger::TriggerTET;    
00589     if (pathname.find("HT") != std::string::npos) 
00590       objectType = trigger::TriggerTET;    
00591     if (pathname.find("Jet") != std::string::npos) 
00592       objectType = trigger::TriggerJet;    
00593     if (pathname.find("Mu") != std::string::npos)
00594       objectType = trigger::TriggerMuon;    
00595     if (pathname.find("Ele") != std::string::npos) 
00596       objectType = trigger::TriggerElectron;    
00597     if (pathname.find("Photon") != std::string::npos) 
00598       objectType = trigger::TriggerPhoton;    
00599     if (pathname.find("Tau") != std::string::npos) 
00600       objectType = trigger::TriggerTau;    
00601     if (pathname.find("IsoTrack") != std::string::npos) 
00602       objectType = trigger::TriggerTrack;    
00603     if (pathname.find("BTag") != std::string::npos)
00604       objectType = trigger::TriggerBJet;    
00605 
00606     //parse denompathname to guess denomobject type
00607     if (denompathname.find("MET") != std::string::npos) 
00608       denomobjectType = trigger::TriggerMET;    
00609     if (denompathname.find("SumET") != std::string::npos) 
00610       denomobjectType = trigger::TriggerTET;    
00611     if (denompathname.find("HT") != std::string::npos) 
00612       denomobjectType = trigger::TriggerTET;    
00613     if (denompathname.find("Jet") != std::string::npos) 
00614       denomobjectType = trigger::TriggerJet;    
00615     if (denompathname.find("Mu") != std::string::npos)
00616       denomobjectType = trigger::TriggerMuon;    
00617     if (denompathname.find("Ele") != std::string::npos) 
00618       denomobjectType = trigger::TriggerElectron;    
00619     if (denompathname.find("Photon") != std::string::npos) 
00620       denomobjectType = trigger::TriggerPhoton;    
00621     if (denompathname.find("Tau") != std::string::npos) 
00622       denomobjectType = trigger::TriggerTau;    
00623     if (denompathname.find("IsoTrack") != std::string::npos) 
00624       denomobjectType = trigger::TriggerTrack;    
00625     if (denompathname.find("BTag") != std::string::npos) 
00626       denomobjectType = trigger::TriggerBJet;    
00627 
00628     // find L1 condition for numpath with numpath objecttype 
00629 
00630     // find PSet for L1 global seed for numpath, 
00631     // list module labels for numpath
00632     std::vector<std::string> numpathmodules = hltConfig_.moduleLabels(pathname);
00633 
00634             for(std::vector<std::string>::iterator numpathmodule = numpathmodules.begin();
00635           numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
00636               //  std::cout << pathname << "\t" << *numpathmodule << "\t" << hltConfig_.moduleType(*numpathmodule) << std::endl;
00637               if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed")
00638                 {
00639                   edm::ParameterSet l1GTPSet = hltConfig_.modulePSet(*numpathmodule);
00640                   //                  std::cout << l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression") << std::endl;
00641                   //  l1pathname = l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression");
00642                   l1pathname = *numpathmodule; 
00643                   break; 
00644                 }
00645   } 
00646    
00647     
00648 
00649     std::string filtername("dummy");
00650     float ptMin = 0.0;
00651     float ptMax = 100.0;
00652     if (plotAll_ && denomobjectType == objectType && objectType != 0)
00653     hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00654 
00655     }
00656     }
00657 
00658     }
00659     else
00660     {
00661      // plot all diagonal combinations plus any other specified pairs
00662     for (unsigned int i=0; i!=n; ++i) {
00663       std::string denompathname = "";  
00664       std::string pathname = hltConfig_.triggerName(i);  
00665       std::string l1pathname = "dummy";
00666       int objectType = 0;
00667       //       int denomobjectType = 0; // UNUSED
00668     //parse pathname to guess object type
00669     if (pathname.find("MET") != std::string::npos) 
00670       objectType = trigger::TriggerMET;    
00671     if (pathname.find("SumET") != std::string::npos) 
00672       objectType = trigger::TriggerTET;    
00673     if (pathname.find("HT") != std::string::npos) 
00674       objectType = trigger::TriggerTET;    
00675     if (pathname.find("Jet") != std::string::npos) 
00676       objectType = trigger::TriggerJet;    
00677     if (pathname.find("Mu") != std::string::npos)
00678       objectType = trigger::TriggerMuon;    
00679     if (pathname.find("Ele") != std::string::npos) 
00680       objectType = trigger::TriggerElectron;    
00681     if (pathname.find("Photon") != std::string::npos) 
00682       objectType = trigger::TriggerPhoton;    
00683     if (pathname.find("Tau") != std::string::npos) 
00684       objectType = trigger::TriggerTau;    
00685     if (pathname.find("IsoTrack") != std::string::npos) 
00686       objectType = trigger::TriggerTrack;    
00687     if (pathname.find("BTag") != std::string::npos) 
00688       objectType = trigger::TriggerBJet;    
00689 
00690     // UNUSED
00691     //     //parse denompathname to guess denomobject type
00692     //     if (denompathname.find("MET") != std::string::npos) 
00693     //       denomobjectType = trigger::TriggerMET;    
00694     //     if (denompathname.find("SumET") != std::string::npos) 
00695     //       denomobjectType = trigger::TriggerTET;    
00696     //     if (denompathname.find("HT") != std::string::npos) 
00697     //       denomobjectType = trigger::TriggerTET;    
00698     //     if (denompathname.find("Jet") != std::string::npos) 
00699     //       denomobjectType = trigger::TriggerJet;    
00700     //     if (denompathname.find("Mu") != std::string::npos)
00701     //       denomobjectType = trigger::TriggerMuon;    
00702     //     if (denompathname.find("Ele") != std::string::npos) 
00703     //       denomobjectType = trigger::TriggerElectron;    
00704     //     if (denompathname.find("Photon") != std::string::npos) 
00705     //       denomobjectType = trigger::TriggerPhoton;    
00706     //     if (denompathname.find("Tau") != std::string::npos) 
00707     //       denomobjectType = trigger::TriggerTau;    
00708     //     if (denompathname.find("IsoTrack") != std::string::npos) 
00709     //       denomobjectType = trigger::TriggerTrack;    
00710     //     if (denompathname.find("BTag") != std::string::npos) 
00711     //       denomobjectType = trigger::TriggerBJet;    
00712     // find L1 condition for numpath with numpath objecttype 
00713     
00714     // find PSet for L1 global seed for numpath, 
00715     // list module labels for numpath
00716     std::vector<std::string> numpathmodules = hltConfig_.moduleLabels(pathname);
00717 
00718     for(std::vector<std::string>::iterator numpathmodule = numpathmodules.begin();
00719           numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
00720               //  std::cout << pathname << "\t" << *numpathmodule << "\t" << hltConfig_.moduleType(*numpathmodule) << std::endl;
00721               if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed")
00722                 {
00723                   edm::ParameterSet l1GTPSet = hltConfig_.modulePSet(*numpathmodule);
00724                   //                  std::cout << l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression") << std::endl;
00725                   //l1pathname = l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression"); 
00726                   l1pathname = *numpathmodule;
00727                   break; 
00728                 }
00729     } 
00730    
00731     
00732 
00733 
00734 
00735     std::string filtername("dummy");
00736     float ptMin = 0.0;
00737     float ptMax = 100.0;
00738     if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00739     if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00740     if (objectType == trigger::TriggerMuon) ptMax = 100.0;
00741     if (objectType == trigger::TriggerTau) ptMax = 100.0;
00742     if (objectType == trigger::TriggerJet) ptMax = 300.0;
00743     if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00744     if (objectType == trigger::TriggerMET) ptMax = 300.0;
00745     if (objectType == trigger::TriggerTET) ptMax = 300.0;
00746     if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00747 
00748     if (objectType != 0){
00749     hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00750       //create folder for pathname
00751      }
00752     }
00753     // now loop over denom/num path pairs specified in cfg, 
00754     // recording the off-diagonal ones
00755     for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair)
00756     {
00757       if (custompathnamepair->first != custompathnamepair->second)
00758         {
00759 
00760       std::string denompathname = custompathnamepair->second;  
00761       std::string pathname = custompathnamepair->first;  
00762      
00763       // check that these exist
00764       bool foundfirst = false;
00765       bool foundsecond = false;
00766       for (unsigned int i=0; i!=n; ++i) {
00767         if (hltConfig_.triggerName(i) == denompathname) foundsecond = true;
00768         if (hltConfig_.triggerName(i) == pathname) foundfirst = true;
00769       } 
00770       if (!foundfirst)
00771         {
00772           edm::LogInfo("FourVectorHLTriggerOffline") << "pathname not found, ignoring " << pathname;
00773           continue;
00774         }
00775       if (!foundsecond)
00776         {
00777           edm::LogInfo("FourVectorHLTriggerOffline") << "denompathname not found, ignoring " << pathname;
00778           continue;
00779         }
00780 
00781      //std::cout << pathname << "\t" << denompathname << std::endl;
00782       std::string l1pathname = "dummy";
00783       int objectType = 0;
00784       //int denomobjectType = 0;
00785     //parse pathname to guess object type
00786     if (pathname.find("MET") != std::string::npos) 
00787       objectType = trigger::TriggerMET;    
00788     if (pathname.find("SumET") != std::string::npos) 
00789       objectType = trigger::TriggerTET;    
00790     if (pathname.find("HT") != std::string::npos) 
00791       objectType = trigger::TriggerTET;    
00792     if (pathname.find("Jet") != std::string::npos) 
00793       objectType = trigger::TriggerJet;    
00794     if (pathname.find("Mu") != std::string::npos)
00795       objectType = trigger::TriggerMuon;    
00796     if (pathname.find("Ele") != std::string::npos) 
00797       objectType = trigger::TriggerElectron;    
00798     if (pathname.find("Photon") != std::string::npos) 
00799       objectType = trigger::TriggerPhoton;    
00800     if (pathname.find("Tau") != std::string::npos) 
00801       objectType = trigger::TriggerTau;    
00802     if (pathname.find("IsoTrack") != std::string::npos) 
00803       objectType = trigger::TriggerTrack;    
00804     if (pathname.find("BTag") != std::string::npos)
00805       objectType = trigger::TriggerBJet;    
00806     // find L1 condition for numpath with numpath objecttype 
00807 
00808     // find PSet for L1 global seed for numpath, 
00809     // list module labels for numpath
00810   
00811     std::vector<std::string> numpathmodules = hltConfig_.moduleLabels(pathname);
00812     
00813     for(std::vector<std::string>::iterator numpathmodule = numpathmodules.begin();
00814           numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
00815               //  std::cout << pathname << "\t" << *numpathmodule << "\t" << hltConfig_.moduleType(*numpathmodule) << std::endl;
00816               if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed")
00817                 {
00818                   edm::ParameterSet l1GTPSet = hltConfig_.modulePSet(*numpathmodule);
00819                   //                  std::cout << l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression") << std::endl;
00820                   // l1pathname = l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression");
00821                   l1pathname = *numpathmodule;
00822                   //std::cout << *numpathmodule << std::endl; 
00823                   break; 
00824                 }
00825     }
00826     
00827     
00828 
00829 
00830 
00831     std::string filtername("dummy");
00832     float ptMin = 0.0;
00833     float ptMax = 100.0;
00834     if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00835     if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00836     if (objectType == trigger::TriggerMuon) ptMax = 100.0;
00837     if (objectType == trigger::TriggerTau) ptMax = 100.0;
00838     if (objectType == trigger::TriggerJet) ptMax = 300.0;
00839     if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00840     if (objectType == trigger::TriggerMET) ptMax = 300.0;
00841     if (objectType == trigger::TriggerTET) ptMax = 300.0;
00842     if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00843 
00844     if (objectType != 0)
00845     hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00846     
00847         }
00848     }
00849 
00850     }
00851 
00852 
00853 
00854     // now set up all of the histos for each path
00855     for(PathInfoCollection::iterator v = hltPaths_.begin();
00856           v!= hltPaths_.end(); ++v ) {
00857         MonitorElement *NOn, *onEtOn, *onEtavsonPhiOn=0;
00858         MonitorElement *NMc, *mcEtMc, *mcEtavsmcPhiMc=0;
00859         MonitorElement *NOff, *offEtOff, *offEtavsoffPhiOff=0;
00860         MonitorElement *NL1, *l1EtL1, *l1Etavsl1PhiL1=0;
00861         MonitorElement *NL1On, *l1EtL1On, *l1Etavsl1PhiL1On=0;
00862         MonitorElement *NL1Off, *offEtL1Off, *offEtavsoffPhiL1Off=0;
00863         MonitorElement *NOnOff, *offEtOnOff, *offEtavsoffPhiOnOff=0;
00864         MonitorElement *NL1Mc, *mcEtL1Mc, *mcEtavsmcPhiL1Mc=0;
00865         MonitorElement *NOffMc, *mcEtOffMc, *mcEtavsmcPhiOffMc=0;
00866         MonitorElement *NOnMc, *mcEtOnMc, *mcEtavsmcPhiOnMc=0;
00867         MonitorElement *NL1OnUM, *l1EtL1OnUM, *l1Etavsl1PhiL1OnUM=0;
00868         MonitorElement *NL1OffUM, *offEtL1OffUM, *offEtavsoffPhiL1OffUM=0;
00869         MonitorElement *NOnOffUM, *offEtOnOffUM, *offEtavsoffPhiOnOffUM=0;
00870         MonitorElement *NL1McUM, *mcEtL1McUM, *mcEtavsmcPhiL1McUM=0;
00871         MonitorElement *NOffMcUM, *mcEtOffMcUM, *mcEtavsmcPhiOffMcUM=0;
00872         MonitorElement *NOnMcUM, *mcEtOnMcUM, *mcEtavsmcPhiOnMcUM=0;
00873   MonitorElement *mcDRL1Mc, *mcDROnMc, *mcDROffMc,
00874                    *offDRL1Off, *offDROnOff, *l1DRL1On=0;
00875         std::string labelname("dummy");
00876         labelname = v->getPath() + "_wrt_" + v->getDenomPath();
00877         std::string histoname(labelname+"_NOn");
00878         std::string title(labelname+" N online");
00879 
00880 
00881 
00882         double histEtaMax = 2.5;
00883         if (v->getObjectType() == trigger::TriggerMuon || v->getObjectType() == trigger::TriggerL1Mu) 
00884           {
00885             histEtaMax = muonEtaMax_;
00886           }
00887         else if (v->getObjectType() == trigger::TriggerElectron || v->getObjectType() == trigger::TriggerL1NoIsoEG || v->getObjectType() == trigger::TriggerL1IsoEG )
00888           {
00889             histEtaMax = electronEtaMax_;
00890           }
00891         else if (v->getObjectType() == trigger::TriggerTau || v->getObjectType() == trigger::TriggerL1TauJet )
00892           {
00893             histEtaMax = tauEtaMax_;
00894           }
00895         else if (v->getObjectType() == trigger::TriggerJet || v->getObjectType() == trigger::TriggerL1CenJet || v->getObjectType() == trigger::TriggerL1ForJet )
00896           {
00897             histEtaMax = jetEtaMax_; 
00898           }
00899         else if (v->getObjectType() == trigger::TriggerBJet)
00900           {
00901             histEtaMax = bjetEtaMax_;
00902           }
00903         else if (v->getObjectType() == trigger::TriggerMET || v->getObjectType() == trigger::TriggerL1ETM )
00904           {
00905             histEtaMax = 5.0; 
00906           }
00907         else if (v->getObjectType() == trigger::TriggerPhoton)
00908           {
00909             histEtaMax = photonEtaMax_; 
00910           }
00911         else if (v->getObjectType() == trigger::TriggerTrack)
00912           {
00913             histEtaMax = trackEtaMax_; 
00914           }
00915 
00916         TString pathfolder = dirname_ + TString("/") + v->getPath();
00917         dbe_->setCurrentFolder(pathfolder.Data());
00918 
00919         NOn =  dbe->book1D(histoname.c_str(),
00920                           title.c_str(),10,
00921                           0.5,
00922                           10.5);
00923 
00924         histoname = labelname+"_NMc";
00925         title = labelname+" N Mc";
00926         NMc =  dbe->book1D(histoname.c_str(),
00927                           title.c_str(),10,
00928                           0.5,
00929                           10.5);
00930 
00931         histoname = labelname+"_NOff";
00932         title = labelname+" N Off";
00933         NOff =  dbe->book1D(histoname.c_str(),
00934                           title.c_str(),10,
00935                           0.5,
00936                           10.5);
00937       
00938         histoname = labelname+"_NL1";
00939         title = labelname+" N L1";
00940         NL1 =  dbe->book1D(histoname.c_str(),
00941                           title.c_str(),10,
00942                           0.5,
00943                           10.5);
00944 
00945         histoname = labelname+"_NL1On";
00946         title = labelname+" N L1On";
00947         NL1On =  dbe->book1D(histoname.c_str(),
00948                           title.c_str(),10,
00949                           0.5,
00950                           10.5);
00951 
00952         histoname = labelname+"_NL1Off";
00953         title = labelname+" N L1Off";
00954         NL1Off =  dbe->book1D(histoname.c_str(),
00955                           title.c_str(),10,
00956                           0.5,
00957                           10.5);
00958 
00959         histoname = labelname+"_NOnOff";
00960         title = labelname+" N OnOff";
00961         NOnOff =  dbe->book1D(histoname.c_str(),
00962                           title.c_str(),10,
00963                           0.5,
00964                           10.5);
00965 
00966         histoname = labelname+"_NL1Mc";
00967         title = labelname+" N L1Mc";
00968         NL1Mc =  dbe->book1D(histoname.c_str(),
00969                           title.c_str(),10,
00970                           0.5,
00971                           10.5);
00972 
00973         histoname = labelname+"_NOffMc";
00974         title = labelname+" N OffMc";
00975         NOffMc =  dbe->book1D(histoname.c_str(),
00976                           title.c_str(),10,
00977                           0.5,
00978                           10.5);
00979 
00980         histoname = labelname+"_NOnMc";
00981         title = labelname+" N OnMc";
00982         NOnMc =  dbe->book1D(histoname.c_str(),
00983                           title.c_str(),10,
00984                           0.5,
00985                           10.5);
00986 
00987         histoname = labelname+"_NL1OnUM";
00988         title = labelname+" N L1OnUM";
00989         NL1OnUM =  dbe->book1D(histoname.c_str(),
00990                           title.c_str(),10,
00991                           0.5,
00992                           10.5);
00993 
00994         histoname = labelname+"_NL1OffUM";
00995         title = labelname+" N L1OffUM";
00996         NL1OffUM =  dbe->book1D(histoname.c_str(),
00997                           title.c_str(),10,
00998                           0.5,
00999                           10.5);
01000 
01001         histoname = labelname+"_NOnOffUM";
01002         title = labelname+" N OnOffUM";
01003         NOnOffUM =  dbe->book1D(histoname.c_str(),
01004                           title.c_str(),10,
01005                           0.5,
01006                           10.5);
01007 
01008         histoname = labelname+"_NL1McUM";
01009         title = labelname+" N L1McUM";
01010         NL1McUM =  dbe->book1D(histoname.c_str(),
01011                           title.c_str(),10,
01012                           0.5,
01013                           10.5);
01014 
01015         histoname = labelname+"_NOffMcUM";
01016         title = labelname+" N OffMcUM";
01017         NOffMcUM =  dbe->book1D(histoname.c_str(),
01018                           title.c_str(),10,
01019                           0.5,
01020                           10.5);
01021 
01022         histoname = labelname+"_NOnMcUM";
01023         title = labelname+" N OnMcUM";
01024         NOnMcUM =  dbe->book1D(histoname.c_str(),
01025                           title.c_str(),10,
01026                           0.5,
01027                           10.5);
01028 
01029         histoname = labelname+"_mcEtMc";
01030         title = labelname+" mcE_t Mc";
01031         mcEtMc =  dbe->book1D(histoname.c_str(),
01032                            title.c_str(),nBins_, 
01033                            v->getPtMin(),
01034                            v->getPtMax());
01035 
01036         histoname = labelname+"_onEtOn";
01037         title = labelname+" onE_t online";
01038         onEtOn =  dbe->book1D(histoname.c_str(),
01039                            title.c_str(),nBins_, 
01040                            v->getPtMin(),
01041                            v->getPtMax());
01042 
01043         histoname = labelname+"_offEtOff";
01044         title = labelname+" offE_t offline";
01045         offEtOff =  dbe->book1D(histoname.c_str(),
01046                            title.c_str(),nBins_, 
01047                            v->getPtMin(),
01048                            v->getPtMax());
01049 
01050         histoname = labelname+"_l1EtL1";
01051         title = labelname+" l1E_t L1";
01052         l1EtL1 =  dbe->book1D(histoname.c_str(),
01053                            title.c_str(),nBins_, 
01054                            v->getPtMin(),
01055                            v->getPtMax());
01056 
01057         int nBins2D = 10;
01058 
01059         histoname = labelname+"_mcEtamcPhiMc";
01060         title = labelname+" mc#eta vs mc#phi Mc";
01061         mcEtavsmcPhiMc =  dbe->book2D(histoname.c_str(),
01062                                 title.c_str(),
01063                                 nBins2D,-histEtaMax,histEtaMax,
01064                                 nBins2D,-TMath::Pi(), TMath::Pi());
01065 
01066         histoname = labelname+"_onEtaonPhiOn";
01067         title = labelname+" on#eta vs on#phi online";
01068         onEtavsonPhiOn =  dbe->book2D(histoname.c_str(),
01069                                 title.c_str(),
01070                                 nBins2D,-histEtaMax,histEtaMax,
01071                                 nBins2D,-TMath::Pi(), TMath::Pi());
01072 
01073         histoname = labelname+"_offEtaoffPhiOff";
01074         title = labelname+" off#eta vs off#phi offline";
01075         offEtavsoffPhiOff =  dbe->book2D(histoname.c_str(),
01076                                 title.c_str(),
01077                                 nBins2D,-histEtaMax,histEtaMax,
01078                                 nBins2D,-TMath::Pi(), TMath::Pi());
01079 
01080         histoname = labelname+"_l1Etal1PhiL1";
01081         title = labelname+" l1#eta vs l1#phi L1";
01082         l1Etavsl1PhiL1 =  dbe->book2D(histoname.c_str(),
01083                                 title.c_str(),
01084                                 nBins2D,-histEtaMax,histEtaMax,
01085                                 nBins2D,-TMath::Pi(), TMath::Pi());
01086 
01087         histoname = labelname+"_l1EtL1On";
01088         title = labelname+" l1E_t L1+online";
01089         l1EtL1On =  dbe->book1D(histoname.c_str(),
01090                            title.c_str(),nBins_, 
01091                            v->getPtMin(),
01092                            v->getPtMax());
01093 
01094         histoname = labelname+"_offEtL1Off";
01095         title = labelname+" offE_t L1+offline";
01096         offEtL1Off =  dbe->book1D(histoname.c_str(),
01097                            title.c_str(),nBins_, 
01098                            v->getPtMin(),
01099                            v->getPtMax());
01100 
01101         histoname = labelname+"_offEtOnOff";
01102         title = labelname+" offE_t online+offline";
01103         offEtOnOff =  dbe->book1D(histoname.c_str(),
01104                            title.c_str(),nBins_, 
01105                            v->getPtMin(),
01106                            v->getPtMax());
01107 
01108         histoname = labelname+"_mcEtL1Mc";
01109         title = labelname+" mcE_t L1+MC truth";
01110         mcEtL1Mc =  dbe->book1D(histoname.c_str(),
01111                            title.c_str(),nBins_, 
01112                            v->getPtMin(),
01113                            v->getPtMax());
01114 
01115         histoname = labelname+"_mcEtOffMc";
01116         title = labelname+" mcE_t Off+MC truth";
01117         mcEtOffMc =  dbe->book1D(histoname.c_str(),
01118                            title.c_str(),nBins_, 
01119                            v->getPtMin(),
01120                            v->getPtMax());
01121 
01122         histoname = labelname+"_mcEtOnMc";
01123         title = labelname+" mcE_t online+MC truth";
01124         mcEtOnMc =  dbe->book1D(histoname.c_str(),
01125                            title.c_str(),nBins_, 
01126                            v->getPtMin(),
01127                            v->getPtMax());
01128 
01129         histoname = labelname+"_l1Etal1PhiL1On";
01130         title = labelname+" l1#eta vs l1#phi L1+online";
01131         l1Etavsl1PhiL1On =  dbe->book2D(histoname.c_str(),
01132                                 title.c_str(),
01133                                 nBins2D,-histEtaMax,histEtaMax,
01134                                 nBins2D,-TMath::Pi(), TMath::Pi());
01135 
01136         histoname = labelname+"_offEtaoffPhiL1Off";
01137         title = labelname+" off#eta vs off#phi L1+offline";
01138         offEtavsoffPhiL1Off =  dbe->book2D(histoname.c_str(),
01139                                 title.c_str(),
01140                                 nBins2D,-histEtaMax,histEtaMax,
01141                                 nBins2D,-TMath::Pi(), TMath::Pi());
01142 
01143         histoname = labelname+"_offEtaoffPhiOnOff";
01144         title = labelname+" off#eta vs off#phi online+offline";
01145         offEtavsoffPhiOnOff =  dbe->book2D(histoname.c_str(),
01146                                 title.c_str(),
01147                                 nBins2D,-histEtaMax,histEtaMax,
01148                                 nBins2D,-TMath::Pi(), TMath::Pi());
01149 
01150         histoname = labelname+"_mcEtamcPhiL1Mc";
01151         title = labelname+" mc#eta vs mc#phi L1+MC truth";
01152         mcEtavsmcPhiL1Mc =  dbe->book2D(histoname.c_str(),
01153                                 title.c_str(),
01154                                 nBins2D,-histEtaMax,histEtaMax,
01155                                 nBins2D,-TMath::Pi(), TMath::Pi());
01156 
01157         histoname = labelname+"_mcEtamcPhiOffMc";
01158         title = labelname+" mc#eta vs mc#phi Off+MC truth";
01159         mcEtavsmcPhiOffMc =  dbe->book2D(histoname.c_str(),
01160                                 title.c_str(),
01161                                 nBins2D,-histEtaMax,histEtaMax,
01162                                 nBins2D,-TMath::Pi(), TMath::Pi());
01163 
01164 
01165         histoname = labelname+"_mcEtamcPhiOnMc";
01166         title = labelname+" mc#eta vs mc#phi online+MC truth";
01167         mcEtavsmcPhiOnMc =  dbe->book2D(histoname.c_str(),
01168                                 title.c_str(),
01169                                 nBins2D,-histEtaMax,histEtaMax,
01170                                 nBins2D,-TMath::Pi(), TMath::Pi());
01171 
01172         histoname = labelname+"_l1EtL1OnUM";
01173         title = labelname+" l1E_t L1+onlineUM";
01174         l1EtL1OnUM =  dbe->book1D(histoname.c_str(),
01175                            title.c_str(),nBins_, 
01176                            v->getPtMin(),
01177                            v->getPtMax());
01178 
01179         histoname = labelname+"_offEtL1OffUM";
01180         title = labelname+" offE_t L1+offlineUM";
01181         offEtL1OffUM =  dbe->book1D(histoname.c_str(),
01182                            title.c_str(),nBins_, 
01183                            v->getPtMin(),
01184                            v->getPtMax());
01185 
01186         histoname = labelname+"_offEtOnOffUM";
01187         title = labelname+" offE_t online+offlineUM";
01188         offEtOnOffUM =  dbe->book1D(histoname.c_str(),
01189                            title.c_str(),nBins_, 
01190                            v->getPtMin(),
01191                            v->getPtMax());
01192 
01193         histoname = labelname+"_mcEtL1McUM";
01194         title = labelname+" mcE_t L1+MC truthUM";
01195         mcEtL1McUM =  dbe->book1D(histoname.c_str(),
01196                            title.c_str(),nBins_, 
01197                            v->getPtMin(),
01198                            v->getPtMax());
01199 
01200         histoname = labelname+"_mcEtOffMcUM";
01201         title = labelname+" mcE_t Off+MC truthUM";
01202         mcEtOffMcUM =  dbe->book1D(histoname.c_str(),
01203                            title.c_str(),nBins_, 
01204                            v->getPtMin(),
01205                            v->getPtMax());
01206 
01207         histoname = labelname+"_mcEtOnMcUM";
01208         title = labelname+" mcE_t online+MC truthUM";
01209         mcEtOnMcUM =  dbe->book1D(histoname.c_str(),
01210                            title.c_str(),nBins_, 
01211                            v->getPtMin(),
01212                            v->getPtMax());
01213 
01214         histoname = labelname+"_l1Etal1PhiL1OnUM";
01215         title = labelname+" l1#eta vs l1#phi L1+onlineUM";
01216         l1Etavsl1PhiL1OnUM =  dbe->book2D(histoname.c_str(),
01217                                 title.c_str(),
01218                                 nBins2D,-histEtaMax,histEtaMax,
01219                                 nBins2D,-TMath::Pi(), TMath::Pi());
01220 
01221         histoname = labelname+"_offEtaoffPhiL1OffUM";
01222         title = labelname+" off#eta vs off#phi L1+offlineUM";
01223         offEtavsoffPhiL1OffUM =  dbe->book2D(histoname.c_str(),
01224                                 title.c_str(),
01225                                 nBins2D,-histEtaMax,histEtaMax,
01226                                 nBins2D,-TMath::Pi(), TMath::Pi());
01227 
01228         histoname = labelname+"_offEtaoffPhiOnOffUM";
01229         title = labelname+" off#eta vs off#phi online+offlineUM";
01230         offEtavsoffPhiOnOffUM =  dbe->book2D(histoname.c_str(),
01231                                 title.c_str(),
01232                                 nBins2D,-histEtaMax,histEtaMax,
01233                                 nBins2D,-TMath::Pi(), TMath::Pi());
01234 
01235         histoname = labelname+"_mcEtamcPhiL1McUM";
01236         title = labelname+" mc#eta vs mc#phi L1+MC truthUM";
01237         mcEtavsmcPhiL1McUM =  dbe->book2D(histoname.c_str(),
01238                                 title.c_str(),
01239                                 nBins2D,-histEtaMax,histEtaMax,
01240                                 nBins2D,-TMath::Pi(), TMath::Pi());
01241 
01242         histoname = labelname+"_mcEtamcPhiOffMcUM";
01243         title = labelname+" mc#eta vs mc#phi Off+MC truthUM";
01244         mcEtavsmcPhiOffMcUM =  dbe->book2D(histoname.c_str(),
01245                                 title.c_str(),
01246                                 nBins2D,-histEtaMax,histEtaMax,
01247                                 nBins2D,-TMath::Pi(), TMath::Pi());
01248 
01249         histoname = labelname+"_mcEtamcPhiOnMcUM";
01250         title = labelname+" mc#eta vs mc#phi online+MC truthUM";
01251         mcEtavsmcPhiOnMcUM =  dbe->book2D(histoname.c_str(),
01252                                 title.c_str(),
01253                                 nBins2D,-histEtaMax,histEtaMax,
01254                                 nBins2D,-TMath::Pi(), TMath::Pi());
01255 
01256         histoname = labelname+"_l1DRL1On";
01257         title = labelname+" l1DR L1+online";
01258         l1DRL1On =  dbe->book1D(histoname.c_str(),
01259                            title.c_str(),nBins_, 0, 1.);
01260 
01261         histoname = labelname+"_offDRL1Off";
01262         title = labelname+" offDR L1+offline";
01263         offDRL1Off =  dbe->book1D(histoname.c_str(),
01264                            title.c_str(),nBins_, 0, 1.);
01265 
01266         histoname = labelname+"_offDROnOff";
01267         title = labelname+" offDR online+offline";
01268         offDROnOff =  dbe->book1D(histoname.c_str(),
01269                            title.c_str(),nBins_, 0, 1.);
01270 
01271         histoname = labelname+"_mcDRL1Mc";
01272         title = labelname+" mcDR L1+MC truth";
01273         mcDRL1Mc =  dbe->book1D(histoname.c_str(),
01274                            title.c_str(),nBins_, 0, 1.);
01275 
01276         histoname = labelname+"_mcDROffMc";
01277         title = labelname+" mcDR Off+MC truth";
01278         mcDROffMc =  dbe->book1D(histoname.c_str(),
01279                            title.c_str(),nBins_, 0, 1.);
01280 
01281         histoname = labelname+"_mcDROnMc";
01282         title = labelname+" mcDR online+MC truth";
01283         mcDROnMc =  dbe->book1D(histoname.c_str(),
01284                            title.c_str(),nBins_, 0, 1.);
01285 
01286 
01287         v->setHistos( NMc, mcEtMc, mcEtavsmcPhiMc, NOn, onEtOn, onEtavsonPhiOn, NOff, offEtOff, offEtavsoffPhiOff, NL1, l1EtL1, l1Etavsl1PhiL1, NL1On, l1EtL1On, l1Etavsl1PhiL1On, NL1Off, offEtL1Off, offEtavsoffPhiL1Off, NOnOff, offEtOnOff, offEtavsoffPhiOnOff, NL1Mc, mcEtL1Mc, mcEtavsmcPhiL1Mc, NOffMc, mcEtOffMc, mcEtavsmcPhiOffMc, NOnMc, mcEtOnMc, mcEtavsmcPhiOnMc, NL1OnUM, l1EtL1OnUM, l1Etavsl1PhiL1OnUM, NL1OffUM, offEtL1OffUM, offEtavsoffPhiL1OffUM, NOnOffUM, offEtOnOffUM, offEtavsoffPhiOnOffUM, NL1McUM, mcEtL1McUM, mcEtavsmcPhiL1McUM, NOffMcUM, mcEtOffMcUM, mcEtavsmcPhiOffMcUM, NOnMcUM, mcEtOnMcUM, mcEtavsmcPhiOnMcUM, mcDRL1Mc, mcDROnMc, mcDROffMc, offDRL1Off, offDROnOff, l1DRL1On
01288 );
01289 
01290 
01291     }
01292  }
01293  return;
01294 
01295 
01296 
01297 }
01298 
01300 void FourVectorHLTriggerOffline::endRun(const edm::Run& run, const edm::EventSetup& c)
01301 {
01302   LogDebug("FourVectorHLTriggerOffline") << "endRun, run " << run.id();
01303 }
01304 
01306 void FourVectorHLTriggerOffline::cleanDRMatchSet(mmset& tempSet)
01307 {
01308 
01309  LogDebug("FourVectorHLTriggerOffline") << "cleanDRMatchSet(mmset& tempSet) " << std::endl;
01310  LogDebug("FourVectorHLTriggerOffline") << "size of the set (before CLEANED)= " << tempSet.size() << " maps." << std::endl;
01311 
01312  if(tempSet.size() < 2) return;
01313  
01314  bool cleanedOneMap = false;
01315  
01316  // cleaning needed if the set has at least two maps
01317 
01318  while(! cleanedOneMap && tempSet.size() > 1) {
01319 
01320  cleanedOneMap=false;
01321 
01322  //LogTrace("FourVectorHLTriggerOffline") << "cleaning: size of the set  = " << tempSet.size() << " maps." << std::endl;
01323 
01324  int imap = 0;
01325  for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) 
01326  {
01327 
01328       fimmap tempMap_j = *setIter_i;
01329 
01330       //LogTrace("FourVectorHLTriggerOffline") << " map " << imap << std::endl;
01331       //LogTrace("FourVectorHLTriggerOffline") << " --------" << std::endl;
01332       for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it)
01333       {
01334 
01335         //LogTrace("FourVectorHLTriggerOffline") << " " <<   (*it).first << " :  " << (*it).second << std::endl;
01336 
01337       }
01338 
01339       imap++;
01340 
01341  }
01342 
01343  // loop i
01344  for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) 
01345  {
01346      
01347     fimmap tempMap_i = *setIter_i;
01348     fimmap::iterator it = tempMap_i.begin();
01349     int topValue = (*it).second;
01350     //LogTrace("FourVectorHLTriggerOffline") << " topValue = " << topValue << std::endl;
01351 
01352     
01353     mmset::iterator tempIter_i = setIter_i;
01354 
01355     // from all the other maps, clean entries that have mapped value "topValue"
01356     // loop j
01357     for ( mmset::iterator setIter_j = ++tempIter_i; setIter_j != tempSet.end( ); setIter_j++ ) 
01358     {
01359 
01360       fimmap tempMap_j = *setIter_j;
01361       //LogTrace("FourVectorHLTriggerOffline") << "  size of the map  = " << tempMap_j.size() << std::endl;
01362 
01363       for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it)
01364       {
01365 
01366         if(topValue == (*it).second) 
01367         {
01368                                   
01369           //LogTrace("FourVectorHLTriggerOffline") << "   Ridding map of a doubly-matched object." << std::endl;
01370           tempMap_j.erase(it);
01371 
01372           cleanedOneMap = true;
01373 
01374         }
01375 
01376      } //end for
01377 
01378      if(cleanedOneMap) 
01379      {
01380         
01381         //remove the old map from the set
01382         tempSet.erase(setIter_j);
01383 
01384         // insert in the set the new map if it is not an empty map
01385         if(! tempMap_j.empty()) tempSet.insert(tempMap_j);
01386 
01387         break; // break from loop j
01388 
01389      } // end if
01390 
01391     }// end loop j 
01392 
01393     if(cleanedOneMap) break; // break from loop i
01394 
01395  } // end loop i
01396 
01397  if(cleanedOneMap) 
01398  { 
01399 
01400   // continue cleaning (in while loop)
01401   // but reset flag first
01402   cleanedOneMap=false;
01403   continue; 
01404 
01405  }
01406  else {
01407 
01408   // finished cleaing (break from while loop)
01409   break; 
01410 
01411  }
01412 
01413 } // end while
01414 
01415  //LogTrace("FourVectorHLTriggerOffline") << "cleaned: size of the set  = " << tempSet.size() << " maps." << std::endl;
01416  int jmap = 0;
01417 
01418  for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) 
01419  {
01420 
01421       fimmap tempMap_j = *setIter_i;
01422 
01423       //LogTrace("FourVectorHLTriggerOffline") << " map " << jmap << std::endl;
01424       //LogTrace("FourVectorHLTriggerOffline") << " --------" << std::endl;
01425 
01426       for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it)
01427       {
01428 
01429         //LogTrace("FourVectorHLTriggerOffline") << " " <<   (*it).first << " :  " << (*it).second << std::endl;
01430       
01431       }
01432 
01433       jmap++;
01434 
01435  } // end for
01436 
01437 
01438  return;
01439 }
01440