CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/HLTriggerOffline/Common/src/FourVectorHLTriggerOffline.cc

Go to the documentation of this file.
00001 // $Id: FourVectorHLTriggerOffline.cc,v 1.37.2.2 2010/08/03 16:08:23 wmtan 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       int triggertype = 0;     
00385       triggertype = v->getObjectType();
00386 
00387       bool l1accept = false;
00388       edm::InputTag l1testTag(v->getl1Path(),"",processname_);
00389       const int l1index = triggerObj->filterIndex(l1testTag);
00390       if ( l1index >= triggerObj->sizeFilters() ) {
00391         edm::LogInfo("FourVectorHLTriggerOffline") << "no index "<< l1index << " of that name " << v->getl1Path() << "\t" << "\t" << l1testTag;
00392         continue; // not in this event
00393       }
00394 
00395       const trigger::Vids & idtype = triggerObj->filterIds(l1index);
00396       const trigger::Keys & l1k = triggerObj->filterKeys(l1index);
00397       l1accept = l1k.size() > 0;
00398 
00399 
00400       eleMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00401                 muoMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00402                 tauMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00403                 phoMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00404                 jetMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00405                 btagMon.monitorDenominator(v, l1accept, idtype, l1k, toc);
00406   
00407                 eleMon.fillL1Match(this);
00408                 muoMon.fillL1Match(this);
00409                 tauMon.fillL1Match(this);
00410                 phoMon.fillL1Match(this);
00411                 jetMon.fillL1Match(this);
00412                 btagMon.fillL1Match(this);
00413   
00414      // did we pass the numerator path?
00415      bool numpassed = false;
00416      for(int i = 0; i < npath; ++i) {
00417 
00418         if (triggerNames.triggerName(i) == v->getPath() && triggerResults->accept(i)) numpassed = true;
00419 
00420      }
00421 
00422      if (numpassed)
00423      { 
00424 
00425         if (!l1accept) {
00426            edm::LogInfo("FourVectorHLTriggerOffline") << "l1 seed path not accepted for hlt path "<< v->getPath() << "\t" << v->getl1Path();
00427         }
00428 
00429         // fill scaler histograms
00430         edm::InputTag filterTag = v->getTag();
00431 
00432               // loop through indices and see if the filter is on the list of filters used by this path
00433       
00434         if (v->getLabel() == "dummy"){
00435         const std::vector<std::string> filterLabels = hltConfig_.moduleLabels(v->getPath());
00436               //loop over labels
00437         for (std::vector<std::string>::const_iterator labelIter= filterLabels.begin(); labelIter!=filterLabels.end(); labelIter++)          
00438               {
00439 
00440                 //std::cout << v->getPath() << "\t" << *labelIter << std::endl;
00441           // last match wins...
00442                 edm::InputTag testTag(*labelIter,"",processname_);
00443           int testindex = triggerObj->filterIndex(testTag);
00444           if ( !(testindex >= triggerObj->sizeFilters()) ) {
00445 
00446                   //std::cout << "found one! " << v->getPath() << "\t" << testTag.label() << std::endl; 
00447             filterTag = testTag; v->setLabel(*labelIter);}
00448                 }
00449         }
00450         
00451         const int index = triggerObj->filterIndex(filterTag);
00452         if ( index >= triggerObj->sizeFilters() ) {
00453 
00454                 //        std::cout << "WTF no index "<< index << " of that name "
00455                 //           << filterTag << std::endl;
00456                 continue; // not in this event
00457 
00458         }
00459 
00460         //LogDebug("FourVectorHLTriggerOffline") << "filling ... " ;
00461         const trigger::Keys & k = triggerObj->filterKeys(index);
00462         //      const trigger::Vids & idtype = triggerObj->filterIds(index);
00463         // assume for now the first object type is the same as all objects in the collection
00464         //    std::cout << filterTag << "\t" << idtype.size() << "\t" << k.size() << std::endl;
00465         //     std::cout << "path " << v->getPath() << " trigger type "<<triggertype << std::endl;
00466         //if (k.size() > 0) v->getNOnHisto()->Fill(k.size());
00467 
00468 
00469         unsigned int NOn=0;
00470 
00471         for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
00472 
00473           eleMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00474           muoMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00475           tauMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00476           phoMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00477           jetMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00478           btagMon.monitorOnline(idtype, l1k, ki, toc, NOn);
00479 
00480         } //online object loop
00481 
00482         eleMon.fillOnlineMatch(this, l1k, toc);
00483         muoMon.fillOnlineMatch(this, l1k, toc);
00484         tauMon.fillOnlineMatch(this, l1k, toc);
00485         phoMon.fillOnlineMatch(this, l1k, toc);
00486         jetMon.fillOnlineMatch(this, l1k, toc);
00487         btagMon.fillOnlineMatch(this, l1k, toc);
00488 
00489         eleMon.monitorOffline(this);
00490         muoMon.monitorOffline(this);
00491         tauMon.monitorOffline(this);
00492         phoMon.monitorOffline(this);
00493         jetMon.monitorOffline(this);
00494         btagMon.monitorOffline(this);
00495 
00496         eleMon.fillOffMatch(this);
00497         muoMon.fillOffMatch(this);
00498         tauMon.fillOffMatch(this);
00499         phoMon.fillOffMatch(this);
00500         jetMon.fillOffMatch(this);
00501         btagMon.fillOffMatch(this);
00502 
00503 
00504      } //numpassed
00505 
00506     
00507 
00508    } //denompassed
00509 
00510   } //pathinfo loop
00511 
00512 }
00513 
00514 
00515 
00516 // -- method called once each job just before starting event loop  --------
00517 void 
00518 FourVectorHLTriggerOffline::beginJob()
00519 {
00520   nev_ = 0;
00521   DQMStore *dbe = 0;
00522   dbe = Service<DQMStore>().operator->();
00523   
00524   if (dbe) {
00525     dbe->setCurrentFolder(dirname_);
00526     dbe->rmdir(dirname_);
00527   }
00528   
00529   
00530   if (dbe) {
00531     dbe->setCurrentFolder(dirname_);
00532     }  
00533 }
00534 
00535 // - method called once each job just after ending the event loop  ------------
00536 void 
00537 FourVectorHLTriggerOffline::endJob() 
00538 {
00539    LogInfo("FourVectorHLTriggerOffline") << "analyzed " << nev_ << " events";
00540    return;
00541 }
00542 
00543 
00544 // BeginRun
00545 void FourVectorHLTriggerOffline::beginRun(const edm::Run& run, const edm::EventSetup& c)
00546 {
00547   LogDebug("FourVectorHLTriggerOffline") << "beginRun, run " << run.id();
00548 // HLT config does not change within runs!
00549 
00550   bool changed(false);  
00551   if (!hltConfig_.init(run, c, processname_, changed)) {
00552     processname_ = "FU";
00553     if (!hltConfig_.init(run, c, processname_, changed)){
00554   LogDebug("FourVectorHLTriggerOffline") << "HLTConfigProvider failed to initialize.";
00555     }
00556     // check if trigger name in (new) config
00557     //  std::cout << "Available TriggerNames are: " << std::endl;
00558     //  hltConfig_.dump("Triggers");
00559       }
00560 
00561 
00562   if (1)
00563  {
00564   DQMStore *dbe = 0;
00565   dbe = Service<DQMStore>().operator->();
00566   
00567   if (dbe) {
00568     dbe->setCurrentFolder(dirname_);
00569   }
00570 
00571 
00572     const unsigned int n(hltConfig_.size());
00573     if (plotAll_){
00574     for (unsigned int j=0; j!=n; ++j) {
00575     std::string pathname = hltConfig_.triggerName(j);  
00576     std::string l1pathname = "dummy";
00577     for (unsigned int i=0; i!=n; ++i) {
00578       // std::cout << hltConfig_.triggerName(i) << std::endl;
00579     
00580     std::string denompathname = hltConfig_.triggerName(i);  
00581     int objectType = 0;
00582     int denomobjectType = 0;
00583     //parse pathname to guess object type
00584     if (pathname.find("MET") != std::string::npos) 
00585       objectType = trigger::TriggerMET;    
00586     if (pathname.find("SumET") != std::string::npos) 
00587       objectType = trigger::TriggerTET;    
00588     if (pathname.find("HT") != std::string::npos) 
00589       objectType = trigger::TriggerTET;    
00590     if (pathname.find("Jet") != std::string::npos) 
00591       objectType = trigger::TriggerJet;    
00592     if (pathname.find("Mu") != std::string::npos)
00593       objectType = trigger::TriggerMuon;    
00594     if (pathname.find("Ele") != std::string::npos) 
00595       objectType = trigger::TriggerElectron;    
00596     if (pathname.find("Photon") != std::string::npos) 
00597       objectType = trigger::TriggerPhoton;    
00598     if (pathname.find("Tau") != std::string::npos) 
00599       objectType = trigger::TriggerTau;    
00600     if (pathname.find("IsoTrack") != std::string::npos) 
00601       objectType = trigger::TriggerTrack;    
00602     if (pathname.find("BTag") != std::string::npos)
00603       objectType = trigger::TriggerBJet;    
00604 
00605     //parse denompathname to guess denomobject type
00606     if (denompathname.find("MET") != std::string::npos) 
00607       denomobjectType = trigger::TriggerMET;    
00608     if (denompathname.find("SumET") != std::string::npos) 
00609       denomobjectType = trigger::TriggerTET;    
00610     if (denompathname.find("HT") != std::string::npos) 
00611       denomobjectType = trigger::TriggerTET;    
00612     if (denompathname.find("Jet") != std::string::npos) 
00613       denomobjectType = trigger::TriggerJet;    
00614     if (denompathname.find("Mu") != std::string::npos)
00615       denomobjectType = trigger::TriggerMuon;    
00616     if (denompathname.find("Ele") != std::string::npos) 
00617       denomobjectType = trigger::TriggerElectron;    
00618     if (denompathname.find("Photon") != std::string::npos) 
00619       denomobjectType = trigger::TriggerPhoton;    
00620     if (denompathname.find("Tau") != std::string::npos) 
00621       denomobjectType = trigger::TriggerTau;    
00622     if (denompathname.find("IsoTrack") != std::string::npos) 
00623       denomobjectType = trigger::TriggerTrack;    
00624     if (denompathname.find("BTag") != std::string::npos) 
00625       denomobjectType = trigger::TriggerBJet;    
00626 
00627     // find L1 condition for numpath with numpath objecttype 
00628 
00629     // find PSet for L1 global seed for numpath, 
00630     // list module labels for numpath
00631     std::vector<std::string> numpathmodules = hltConfig_.moduleLabels(pathname);
00632 
00633             for(std::vector<std::string>::iterator numpathmodule = numpathmodules.begin();
00634           numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
00635               //  std::cout << pathname << "\t" << *numpathmodule << "\t" << hltConfig_.moduleType(*numpathmodule) << std::endl;
00636               if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed")
00637                 {
00638                   edm::ParameterSet l1GTPSet = hltConfig_.modulePSet(*numpathmodule);
00639                   //                  std::cout << l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression") << std::endl;
00640                   //  l1pathname = l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression");
00641                   l1pathname = *numpathmodule; 
00642                   break; 
00643                 }
00644   } 
00645    
00646     
00647 
00648     std::string filtername("dummy");
00649     float ptMin = 0.0;
00650     float ptMax = 100.0;
00651     if (plotAll_ && denomobjectType == objectType && objectType != 0)
00652     hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00653 
00654     }
00655     }
00656 
00657     }
00658     else
00659     {
00660      // plot all diagonal combinations plus any other specified pairs
00661     for (unsigned int i=0; i!=n; ++i) {
00662       std::string denompathname = "";  
00663       std::string pathname = hltConfig_.triggerName(i);  
00664       std::string l1pathname = "dummy";
00665       int objectType = 0;
00666       int denomobjectType = 0;
00667     //parse pathname to guess object type
00668     if (pathname.find("MET") != std::string::npos) 
00669       objectType = trigger::TriggerMET;    
00670     if (pathname.find("SumET") != std::string::npos) 
00671       objectType = trigger::TriggerTET;    
00672     if (pathname.find("HT") != std::string::npos) 
00673       objectType = trigger::TriggerTET;    
00674     if (pathname.find("Jet") != std::string::npos) 
00675       objectType = trigger::TriggerJet;    
00676     if (pathname.find("Mu") != std::string::npos)
00677       objectType = trigger::TriggerMuon;    
00678     if (pathname.find("Ele") != std::string::npos) 
00679       objectType = trigger::TriggerElectron;    
00680     if (pathname.find("Photon") != std::string::npos) 
00681       objectType = trigger::TriggerPhoton;    
00682     if (pathname.find("Tau") != std::string::npos) 
00683       objectType = trigger::TriggerTau;    
00684     if (pathname.find("IsoTrack") != std::string::npos) 
00685       objectType = trigger::TriggerTrack;    
00686     if (pathname.find("BTag") != std::string::npos) 
00687       objectType = trigger::TriggerBJet;    
00688 
00689     //parse denompathname to guess denomobject type
00690     if (denompathname.find("MET") != std::string::npos) 
00691       denomobjectType = trigger::TriggerMET;    
00692     if (denompathname.find("SumET") != std::string::npos) 
00693       denomobjectType = trigger::TriggerTET;    
00694     if (denompathname.find("HT") != std::string::npos) 
00695       denomobjectType = trigger::TriggerTET;    
00696     if (denompathname.find("Jet") != std::string::npos) 
00697       denomobjectType = trigger::TriggerJet;    
00698     if (denompathname.find("Mu") != std::string::npos)
00699       denomobjectType = trigger::TriggerMuon;    
00700     if (denompathname.find("Ele") != std::string::npos) 
00701       denomobjectType = trigger::TriggerElectron;    
00702     if (denompathname.find("Photon") != std::string::npos) 
00703       denomobjectType = trigger::TriggerPhoton;    
00704     if (denompathname.find("Tau") != std::string::npos) 
00705       denomobjectType = trigger::TriggerTau;    
00706     if (denompathname.find("IsoTrack") != std::string::npos) 
00707       denomobjectType = trigger::TriggerTrack;    
00708     if (denompathname.find("BTag") != std::string::npos) 
00709       denomobjectType = trigger::TriggerBJet;    
00710     // find L1 condition for numpath with numpath objecttype 
00711 
00712     // find PSet for L1 global seed for numpath, 
00713     // list module labels for numpath
00714     std::vector<std::string> numpathmodules = hltConfig_.moduleLabels(pathname);
00715 
00716     for(std::vector<std::string>::iterator numpathmodule = numpathmodules.begin();
00717           numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
00718               //  std::cout << pathname << "\t" << *numpathmodule << "\t" << hltConfig_.moduleType(*numpathmodule) << std::endl;
00719               if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed")
00720                 {
00721                   edm::ParameterSet l1GTPSet = hltConfig_.modulePSet(*numpathmodule);
00722                   //                  std::cout << l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression") << std::endl;
00723                   //l1pathname = l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression"); 
00724                   l1pathname = *numpathmodule;
00725                   break; 
00726                 }
00727     } 
00728    
00729     
00730 
00731 
00732 
00733     std::string filtername("dummy");
00734     float ptMin = 0.0;
00735     float ptMax = 100.0;
00736     if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00737     if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00738     if (objectType == trigger::TriggerMuon) ptMax = 100.0;
00739     if (objectType == trigger::TriggerTau) ptMax = 100.0;
00740     if (objectType == trigger::TriggerJet) ptMax = 300.0;
00741     if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00742     if (objectType == trigger::TriggerMET) ptMax = 300.0;
00743     if (objectType == trigger::TriggerTET) ptMax = 300.0;
00744     if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00745 
00746     if (objectType != 0){
00747     hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00748       //create folder for pathname
00749      }
00750     }
00751     // now loop over denom/num path pairs specified in cfg, 
00752     // recording the off-diagonal ones
00753     for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair)
00754     {
00755       if (custompathnamepair->first != custompathnamepair->second)
00756         {
00757 
00758       std::string denompathname = custompathnamepair->second;  
00759       std::string pathname = custompathnamepair->first;  
00760      
00761       // check that these exist
00762       bool foundfirst = false;
00763       bool foundsecond = false;
00764       for (unsigned int i=0; i!=n; ++i) {
00765         if (hltConfig_.triggerName(i) == denompathname) foundsecond = true;
00766         if (hltConfig_.triggerName(i) == pathname) foundfirst = true;
00767       } 
00768       if (!foundfirst)
00769         {
00770           edm::LogInfo("FourVectorHLTriggerOffline") << "pathname not found, ignoring " << pathname;
00771           continue;
00772         }
00773       if (!foundsecond)
00774         {
00775           edm::LogInfo("FourVectorHLTriggerOffline") << "denompathname not found, ignoring " << pathname;
00776           continue;
00777         }
00778 
00779      //std::cout << pathname << "\t" << denompathname << std::endl;
00780       std::string l1pathname = "dummy";
00781       int objectType = 0;
00782       //int denomobjectType = 0;
00783     //parse pathname to guess object type
00784     if (pathname.find("MET") != std::string::npos) 
00785       objectType = trigger::TriggerMET;    
00786     if (pathname.find("SumET") != std::string::npos) 
00787       objectType = trigger::TriggerTET;    
00788     if (pathname.find("HT") != std::string::npos) 
00789       objectType = trigger::TriggerTET;    
00790     if (pathname.find("Jet") != std::string::npos) 
00791       objectType = trigger::TriggerJet;    
00792     if (pathname.find("Mu") != std::string::npos)
00793       objectType = trigger::TriggerMuon;    
00794     if (pathname.find("Ele") != std::string::npos) 
00795       objectType = trigger::TriggerElectron;    
00796     if (pathname.find("Photon") != std::string::npos) 
00797       objectType = trigger::TriggerPhoton;    
00798     if (pathname.find("Tau") != std::string::npos) 
00799       objectType = trigger::TriggerTau;    
00800     if (pathname.find("IsoTrack") != std::string::npos) 
00801       objectType = trigger::TriggerTrack;    
00802     if (pathname.find("BTag") != std::string::npos)
00803       objectType = trigger::TriggerBJet;    
00804     // find L1 condition for numpath with numpath objecttype 
00805 
00806     // find PSet for L1 global seed for numpath, 
00807     // list module labels for numpath
00808   
00809     std::vector<std::string> numpathmodules = hltConfig_.moduleLabels(pathname);
00810     
00811     for(std::vector<std::string>::iterator numpathmodule = numpathmodules.begin();
00812           numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
00813               //  std::cout << pathname << "\t" << *numpathmodule << "\t" << hltConfig_.moduleType(*numpathmodule) << std::endl;
00814               if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed")
00815                 {
00816                   edm::ParameterSet l1GTPSet = hltConfig_.modulePSet(*numpathmodule);
00817                   //                  std::cout << l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression") << std::endl;
00818                   // l1pathname = l1GTPSet.getParameter<std::string>("L1SeedsLogicalExpression");
00819                   l1pathname = *numpathmodule;
00820                   //std::cout << *numpathmodule << std::endl; 
00821                   break; 
00822                 }
00823     }
00824     
00825     
00826 
00827 
00828 
00829     std::string filtername("dummy");
00830     float ptMin = 0.0;
00831     float ptMax = 100.0;
00832     if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00833     if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00834     if (objectType == trigger::TriggerMuon) ptMax = 100.0;
00835     if (objectType == trigger::TriggerTau) ptMax = 100.0;
00836     if (objectType == trigger::TriggerJet) ptMax = 300.0;
00837     if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00838     if (objectType == trigger::TriggerMET) ptMax = 300.0;
00839     if (objectType == trigger::TriggerTET) ptMax = 300.0;
00840     if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00841 
00842     if (objectType != 0)
00843     hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
00844     
00845         }
00846     }
00847 
00848     }
00849 
00850 
00851 
00852     // now set up all of the histos for each path
00853     for(PathInfoCollection::iterator v = hltPaths_.begin();
00854           v!= hltPaths_.end(); ++v ) {
00855         MonitorElement *NOn, *onEtOn, *onEtavsonPhiOn=0;
00856         MonitorElement *NMc, *mcEtMc, *mcEtavsmcPhiMc=0;
00857         MonitorElement *NOff, *offEtOff, *offEtavsoffPhiOff=0;
00858         MonitorElement *NL1, *l1EtL1, *l1Etavsl1PhiL1=0;
00859         MonitorElement *NL1On, *l1EtL1On, *l1Etavsl1PhiL1On=0;
00860         MonitorElement *NL1Off, *offEtL1Off, *offEtavsoffPhiL1Off=0;
00861         MonitorElement *NOnOff, *offEtOnOff, *offEtavsoffPhiOnOff=0;
00862         MonitorElement *NL1Mc, *mcEtL1Mc, *mcEtavsmcPhiL1Mc=0;
00863         MonitorElement *NOffMc, *mcEtOffMc, *mcEtavsmcPhiOffMc=0;
00864         MonitorElement *NOnMc, *mcEtOnMc, *mcEtavsmcPhiOnMc=0;
00865         MonitorElement *NL1OnUM, *l1EtL1OnUM, *l1Etavsl1PhiL1OnUM=0;
00866         MonitorElement *NL1OffUM, *offEtL1OffUM, *offEtavsoffPhiL1OffUM=0;
00867         MonitorElement *NOnOffUM, *offEtOnOffUM, *offEtavsoffPhiOnOffUM=0;
00868         MonitorElement *NL1McUM, *mcEtL1McUM, *mcEtavsmcPhiL1McUM=0;
00869         MonitorElement *NOffMcUM, *mcEtOffMcUM, *mcEtavsmcPhiOffMcUM=0;
00870         MonitorElement *NOnMcUM, *mcEtOnMcUM, *mcEtavsmcPhiOnMcUM=0;
00871   MonitorElement *mcDRL1Mc, *mcDROnMc, *mcDROffMc,
00872                    *offDRL1Off, *offDROnOff, *l1DRL1On=0;
00873         std::string labelname("dummy");
00874         labelname = v->getPath() + "_wrt_" + v->getDenomPath();
00875         std::string histoname(labelname+"_NOn");
00876         std::string title(labelname+" N online");
00877 
00878 
00879 
00880         double histEtaMax = 2.5;
00881         if (v->getObjectType() == trigger::TriggerMuon || v->getObjectType() == trigger::TriggerL1Mu) 
00882           {
00883             histEtaMax = muonEtaMax_;
00884           }
00885         else if (v->getObjectType() == trigger::TriggerElectron || v->getObjectType() == trigger::TriggerL1NoIsoEG || v->getObjectType() == trigger::TriggerL1IsoEG )
00886           {
00887             histEtaMax = electronEtaMax_;
00888           }
00889         else if (v->getObjectType() == trigger::TriggerTau || v->getObjectType() == trigger::TriggerL1TauJet )
00890           {
00891             histEtaMax = tauEtaMax_;
00892           }
00893         else if (v->getObjectType() == trigger::TriggerJet || v->getObjectType() == trigger::TriggerL1CenJet || v->getObjectType() == trigger::TriggerL1ForJet )
00894           {
00895             histEtaMax = jetEtaMax_; 
00896           }
00897         else if (v->getObjectType() == trigger::TriggerBJet)
00898           {
00899             histEtaMax = bjetEtaMax_;
00900           }
00901         else if (v->getObjectType() == trigger::TriggerMET || v->getObjectType() == trigger::TriggerL1ETM )
00902           {
00903             histEtaMax = 5.0; 
00904           }
00905         else if (v->getObjectType() == trigger::TriggerPhoton)
00906           {
00907             histEtaMax = photonEtaMax_; 
00908           }
00909         else if (v->getObjectType() == trigger::TriggerTrack)
00910           {
00911             histEtaMax = trackEtaMax_; 
00912           }
00913 
00914         TString pathfolder = dirname_ + TString("/") + v->getPath();
00915         dbe_->setCurrentFolder(pathfolder.Data());
00916 
00917         NOn =  dbe->book1D(histoname.c_str(),
00918                           title.c_str(),10,
00919                           0.5,
00920                           10.5);
00921 
00922         histoname = labelname+"_NMc";
00923         title = labelname+" N Mc";
00924         NMc =  dbe->book1D(histoname.c_str(),
00925                           title.c_str(),10,
00926                           0.5,
00927                           10.5);
00928 
00929         histoname = labelname+"_NOff";
00930         title = labelname+" N Off";
00931         NOff =  dbe->book1D(histoname.c_str(),
00932                           title.c_str(),10,
00933                           0.5,
00934                           10.5);
00935       
00936         histoname = labelname+"_NL1";
00937         title = labelname+" N L1";
00938         NL1 =  dbe->book1D(histoname.c_str(),
00939                           title.c_str(),10,
00940                           0.5,
00941                           10.5);
00942 
00943         histoname = labelname+"_NL1On";
00944         title = labelname+" N L1On";
00945         NL1On =  dbe->book1D(histoname.c_str(),
00946                           title.c_str(),10,
00947                           0.5,
00948                           10.5);
00949 
00950         histoname = labelname+"_NL1Off";
00951         title = labelname+" N L1Off";
00952         NL1Off =  dbe->book1D(histoname.c_str(),
00953                           title.c_str(),10,
00954                           0.5,
00955                           10.5);
00956 
00957         histoname = labelname+"_NOnOff";
00958         title = labelname+" N OnOff";
00959         NOnOff =  dbe->book1D(histoname.c_str(),
00960                           title.c_str(),10,
00961                           0.5,
00962                           10.5);
00963 
00964         histoname = labelname+"_NL1Mc";
00965         title = labelname+" N L1Mc";
00966         NL1Mc =  dbe->book1D(histoname.c_str(),
00967                           title.c_str(),10,
00968                           0.5,
00969                           10.5);
00970 
00971         histoname = labelname+"_NOffMc";
00972         title = labelname+" N OffMc";
00973         NOffMc =  dbe->book1D(histoname.c_str(),
00974                           title.c_str(),10,
00975                           0.5,
00976                           10.5);
00977 
00978         histoname = labelname+"_NOnMc";
00979         title = labelname+" N OnMc";
00980         NOnMc =  dbe->book1D(histoname.c_str(),
00981                           title.c_str(),10,
00982                           0.5,
00983                           10.5);
00984 
00985         histoname = labelname+"_NL1OnUM";
00986         title = labelname+" N L1OnUM";
00987         NL1OnUM =  dbe->book1D(histoname.c_str(),
00988                           title.c_str(),10,
00989                           0.5,
00990                           10.5);
00991 
00992         histoname = labelname+"_NL1OffUM";
00993         title = labelname+" N L1OffUM";
00994         NL1OffUM =  dbe->book1D(histoname.c_str(),
00995                           title.c_str(),10,
00996                           0.5,
00997                           10.5);
00998 
00999         histoname = labelname+"_NOnOffUM";
01000         title = labelname+" N OnOffUM";
01001         NOnOffUM =  dbe->book1D(histoname.c_str(),
01002                           title.c_str(),10,
01003                           0.5,
01004                           10.5);
01005 
01006         histoname = labelname+"_NL1McUM";
01007         title = labelname+" N L1McUM";
01008         NL1McUM =  dbe->book1D(histoname.c_str(),
01009                           title.c_str(),10,
01010                           0.5,
01011                           10.5);
01012 
01013         histoname = labelname+"_NOffMcUM";
01014         title = labelname+" N OffMcUM";
01015         NOffMcUM =  dbe->book1D(histoname.c_str(),
01016                           title.c_str(),10,
01017                           0.5,
01018                           10.5);
01019 
01020         histoname = labelname+"_NOnMcUM";
01021         title = labelname+" N OnMcUM";
01022         NOnMcUM =  dbe->book1D(histoname.c_str(),
01023                           title.c_str(),10,
01024                           0.5,
01025                           10.5);
01026 
01027         histoname = labelname+"_mcEtMc";
01028         title = labelname+" mcE_t Mc";
01029         mcEtMc =  dbe->book1D(histoname.c_str(),
01030                            title.c_str(),nBins_, 
01031                            v->getPtMin(),
01032                            v->getPtMax());
01033 
01034         histoname = labelname+"_onEtOn";
01035         title = labelname+" onE_t online";
01036         onEtOn =  dbe->book1D(histoname.c_str(),
01037                            title.c_str(),nBins_, 
01038                            v->getPtMin(),
01039                            v->getPtMax());
01040 
01041         histoname = labelname+"_offEtOff";
01042         title = labelname+" offE_t offline";
01043         offEtOff =  dbe->book1D(histoname.c_str(),
01044                            title.c_str(),nBins_, 
01045                            v->getPtMin(),
01046                            v->getPtMax());
01047 
01048         histoname = labelname+"_l1EtL1";
01049         title = labelname+" l1E_t L1";
01050         l1EtL1 =  dbe->book1D(histoname.c_str(),
01051                            title.c_str(),nBins_, 
01052                            v->getPtMin(),
01053                            v->getPtMax());
01054 
01055         int nBins2D = 10;
01056 
01057         histoname = labelname+"_mcEtamcPhiMc";
01058         title = labelname+" mc#eta vs mc#phi Mc";
01059         mcEtavsmcPhiMc =  dbe->book2D(histoname.c_str(),
01060                                 title.c_str(),
01061                                 nBins2D,-histEtaMax,histEtaMax,
01062                                 nBins2D,-TMath::Pi(), TMath::Pi());
01063 
01064         histoname = labelname+"_onEtaonPhiOn";
01065         title = labelname+" on#eta vs on#phi online";
01066         onEtavsonPhiOn =  dbe->book2D(histoname.c_str(),
01067                                 title.c_str(),
01068                                 nBins2D,-histEtaMax,histEtaMax,
01069                                 nBins2D,-TMath::Pi(), TMath::Pi());
01070 
01071         histoname = labelname+"_offEtaoffPhiOff";
01072         title = labelname+" off#eta vs off#phi offline";
01073         offEtavsoffPhiOff =  dbe->book2D(histoname.c_str(),
01074                                 title.c_str(),
01075                                 nBins2D,-histEtaMax,histEtaMax,
01076                                 nBins2D,-TMath::Pi(), TMath::Pi());
01077 
01078         histoname = labelname+"_l1Etal1PhiL1";
01079         title = labelname+" l1#eta vs l1#phi L1";
01080         l1Etavsl1PhiL1 =  dbe->book2D(histoname.c_str(),
01081                                 title.c_str(),
01082                                 nBins2D,-histEtaMax,histEtaMax,
01083                                 nBins2D,-TMath::Pi(), TMath::Pi());
01084 
01085         histoname = labelname+"_l1EtL1On";
01086         title = labelname+" l1E_t L1+online";
01087         l1EtL1On =  dbe->book1D(histoname.c_str(),
01088                            title.c_str(),nBins_, 
01089                            v->getPtMin(),
01090                            v->getPtMax());
01091 
01092         histoname = labelname+"_offEtL1Off";
01093         title = labelname+" offE_t L1+offline";
01094         offEtL1Off =  dbe->book1D(histoname.c_str(),
01095                            title.c_str(),nBins_, 
01096                            v->getPtMin(),
01097                            v->getPtMax());
01098 
01099         histoname = labelname+"_offEtOnOff";
01100         title = labelname+" offE_t online+offline";
01101         offEtOnOff =  dbe->book1D(histoname.c_str(),
01102                            title.c_str(),nBins_, 
01103                            v->getPtMin(),
01104                            v->getPtMax());
01105 
01106         histoname = labelname+"_mcEtL1Mc";
01107         title = labelname+" mcE_t L1+MC truth";
01108         mcEtL1Mc =  dbe->book1D(histoname.c_str(),
01109                            title.c_str(),nBins_, 
01110                            v->getPtMin(),
01111                            v->getPtMax());
01112 
01113         histoname = labelname+"_mcEtOffMc";
01114         title = labelname+" mcE_t Off+MC truth";
01115         mcEtOffMc =  dbe->book1D(histoname.c_str(),
01116                            title.c_str(),nBins_, 
01117                            v->getPtMin(),
01118                            v->getPtMax());
01119 
01120         histoname = labelname+"_mcEtOnMc";
01121         title = labelname+" mcE_t online+MC truth";
01122         mcEtOnMc =  dbe->book1D(histoname.c_str(),
01123                            title.c_str(),nBins_, 
01124                            v->getPtMin(),
01125                            v->getPtMax());
01126 
01127         histoname = labelname+"_l1Etal1PhiL1On";
01128         title = labelname+" l1#eta vs l1#phi L1+online";
01129         l1Etavsl1PhiL1On =  dbe->book2D(histoname.c_str(),
01130                                 title.c_str(),
01131                                 nBins2D,-histEtaMax,histEtaMax,
01132                                 nBins2D,-TMath::Pi(), TMath::Pi());
01133 
01134         histoname = labelname+"_offEtaoffPhiL1Off";
01135         title = labelname+" off#eta vs off#phi L1+offline";
01136         offEtavsoffPhiL1Off =  dbe->book2D(histoname.c_str(),
01137                                 title.c_str(),
01138                                 nBins2D,-histEtaMax,histEtaMax,
01139                                 nBins2D,-TMath::Pi(), TMath::Pi());
01140 
01141         histoname = labelname+"_offEtaoffPhiOnOff";
01142         title = labelname+" off#eta vs off#phi online+offline";
01143         offEtavsoffPhiOnOff =  dbe->book2D(histoname.c_str(),
01144                                 title.c_str(),
01145                                 nBins2D,-histEtaMax,histEtaMax,
01146                                 nBins2D,-TMath::Pi(), TMath::Pi());
01147 
01148         histoname = labelname+"_mcEtamcPhiL1Mc";
01149         title = labelname+" mc#eta vs mc#phi L1+MC truth";
01150         mcEtavsmcPhiL1Mc =  dbe->book2D(histoname.c_str(),
01151                                 title.c_str(),
01152                                 nBins2D,-histEtaMax,histEtaMax,
01153                                 nBins2D,-TMath::Pi(), TMath::Pi());
01154 
01155         histoname = labelname+"_mcEtamcPhiOffMc";
01156         title = labelname+" mc#eta vs mc#phi Off+MC truth";
01157         mcEtavsmcPhiOffMc =  dbe->book2D(histoname.c_str(),
01158                                 title.c_str(),
01159                                 nBins2D,-histEtaMax,histEtaMax,
01160                                 nBins2D,-TMath::Pi(), TMath::Pi());
01161 
01162 
01163         histoname = labelname+"_mcEtamcPhiOnMc";
01164         title = labelname+" mc#eta vs mc#phi online+MC truth";
01165         mcEtavsmcPhiOnMc =  dbe->book2D(histoname.c_str(),
01166                                 title.c_str(),
01167                                 nBins2D,-histEtaMax,histEtaMax,
01168                                 nBins2D,-TMath::Pi(), TMath::Pi());
01169 
01170         histoname = labelname+"_l1EtL1OnUM";
01171         title = labelname+" l1E_t L1+onlineUM";
01172         l1EtL1OnUM =  dbe->book1D(histoname.c_str(),
01173                            title.c_str(),nBins_, 
01174                            v->getPtMin(),
01175                            v->getPtMax());
01176 
01177         histoname = labelname+"_offEtL1OffUM";
01178         title = labelname+" offE_t L1+offlineUM";
01179         offEtL1OffUM =  dbe->book1D(histoname.c_str(),
01180                            title.c_str(),nBins_, 
01181                            v->getPtMin(),
01182                            v->getPtMax());
01183 
01184         histoname = labelname+"_offEtOnOffUM";
01185         title = labelname+" offE_t online+offlineUM";
01186         offEtOnOffUM =  dbe->book1D(histoname.c_str(),
01187                            title.c_str(),nBins_, 
01188                            v->getPtMin(),
01189                            v->getPtMax());
01190 
01191         histoname = labelname+"_mcEtL1McUM";
01192         title = labelname+" mcE_t L1+MC truthUM";
01193         mcEtL1McUM =  dbe->book1D(histoname.c_str(),
01194                            title.c_str(),nBins_, 
01195                            v->getPtMin(),
01196                            v->getPtMax());
01197 
01198         histoname = labelname+"_mcEtOffMcUM";
01199         title = labelname+" mcE_t Off+MC truthUM";
01200         mcEtOffMcUM =  dbe->book1D(histoname.c_str(),
01201                            title.c_str(),nBins_, 
01202                            v->getPtMin(),
01203                            v->getPtMax());
01204 
01205         histoname = labelname+"_mcEtOnMcUM";
01206         title = labelname+" mcE_t online+MC truthUM";
01207         mcEtOnMcUM =  dbe->book1D(histoname.c_str(),
01208                            title.c_str(),nBins_, 
01209                            v->getPtMin(),
01210                            v->getPtMax());
01211 
01212         histoname = labelname+"_l1Etal1PhiL1OnUM";
01213         title = labelname+" l1#eta vs l1#phi L1+onlineUM";
01214         l1Etavsl1PhiL1OnUM =  dbe->book2D(histoname.c_str(),
01215                                 title.c_str(),
01216                                 nBins2D,-histEtaMax,histEtaMax,
01217                                 nBins2D,-TMath::Pi(), TMath::Pi());
01218 
01219         histoname = labelname+"_offEtaoffPhiL1OffUM";
01220         title = labelname+" off#eta vs off#phi L1+offlineUM";
01221         offEtavsoffPhiL1OffUM =  dbe->book2D(histoname.c_str(),
01222                                 title.c_str(),
01223                                 nBins2D,-histEtaMax,histEtaMax,
01224                                 nBins2D,-TMath::Pi(), TMath::Pi());
01225 
01226         histoname = labelname+"_offEtaoffPhiOnOffUM";
01227         title = labelname+" off#eta vs off#phi online+offlineUM";
01228         offEtavsoffPhiOnOffUM =  dbe->book2D(histoname.c_str(),
01229                                 title.c_str(),
01230                                 nBins2D,-histEtaMax,histEtaMax,
01231                                 nBins2D,-TMath::Pi(), TMath::Pi());
01232 
01233         histoname = labelname+"_mcEtamcPhiL1McUM";
01234         title = labelname+" mc#eta vs mc#phi L1+MC truthUM";
01235         mcEtavsmcPhiL1McUM =  dbe->book2D(histoname.c_str(),
01236                                 title.c_str(),
01237                                 nBins2D,-histEtaMax,histEtaMax,
01238                                 nBins2D,-TMath::Pi(), TMath::Pi());
01239 
01240         histoname = labelname+"_mcEtamcPhiOffMcUM";
01241         title = labelname+" mc#eta vs mc#phi Off+MC truthUM";
01242         mcEtavsmcPhiOffMcUM =  dbe->book2D(histoname.c_str(),
01243                                 title.c_str(),
01244                                 nBins2D,-histEtaMax,histEtaMax,
01245                                 nBins2D,-TMath::Pi(), TMath::Pi());
01246 
01247         histoname = labelname+"_mcEtamcPhiOnMcUM";
01248         title = labelname+" mc#eta vs mc#phi online+MC truthUM";
01249         mcEtavsmcPhiOnMcUM =  dbe->book2D(histoname.c_str(),
01250                                 title.c_str(),
01251                                 nBins2D,-histEtaMax,histEtaMax,
01252                                 nBins2D,-TMath::Pi(), TMath::Pi());
01253 
01254         histoname = labelname+"_l1DRL1On";
01255         title = labelname+" l1DR L1+online";
01256         l1DRL1On =  dbe->book1D(histoname.c_str(),
01257                            title.c_str(),nBins_, 0, 1.);
01258 
01259         histoname = labelname+"_offDRL1Off";
01260         title = labelname+" offDR L1+offline";
01261         offDRL1Off =  dbe->book1D(histoname.c_str(),
01262                            title.c_str(),nBins_, 0, 1.);
01263 
01264         histoname = labelname+"_offDROnOff";
01265         title = labelname+" offDR online+offline";
01266         offDROnOff =  dbe->book1D(histoname.c_str(),
01267                            title.c_str(),nBins_, 0, 1.);
01268 
01269         histoname = labelname+"_mcDRL1Mc";
01270         title = labelname+" mcDR L1+MC truth";
01271         mcDRL1Mc =  dbe->book1D(histoname.c_str(),
01272                            title.c_str(),nBins_, 0, 1.);
01273 
01274         histoname = labelname+"_mcDROffMc";
01275         title = labelname+" mcDR Off+MC truth";
01276         mcDROffMc =  dbe->book1D(histoname.c_str(),
01277                            title.c_str(),nBins_, 0, 1.);
01278 
01279         histoname = labelname+"_mcDROnMc";
01280         title = labelname+" mcDR online+MC truth";
01281         mcDROnMc =  dbe->book1D(histoname.c_str(),
01282                            title.c_str(),nBins_, 0, 1.);
01283 
01284 
01285         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
01286 );
01287 
01288 
01289     }
01290  }
01291  return;
01292 
01293 
01294 
01295 }
01296 
01298 void FourVectorHLTriggerOffline::endRun(const edm::Run& run, const edm::EventSetup& c)
01299 {
01300   LogDebug("FourVectorHLTriggerOffline") << "endRun, run " << run.id();
01301 }
01302 
01304 void FourVectorHLTriggerOffline::cleanDRMatchSet(mmset& tempSet)
01305 {
01306 
01307  LogDebug("FourVectorHLTriggerOffline") << "cleanDRMatchSet(mmset& tempSet) " << std::endl;
01308  LogDebug("FourVectorHLTriggerOffline") << "size of the set (before CLEANED)= " << tempSet.size() << " maps." << std::endl;
01309 
01310  if(tempSet.size() < 2) return;
01311  
01312  bool cleanedOneMap = false;
01313  
01314  // cleaning needed if the set has at least two maps
01315 
01316  while(! cleanedOneMap && tempSet.size() > 1) {
01317 
01318  cleanedOneMap=false;
01319 
01320  //LogTrace("FourVectorHLTriggerOffline") << "cleaning: size of the set  = " << tempSet.size() << " maps." << std::endl;
01321 
01322  int imap = 0;
01323  for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) 
01324  {
01325 
01326       fimmap tempMap_j = *setIter_i;
01327 
01328       //LogTrace("FourVectorHLTriggerOffline") << " map " << imap << std::endl;
01329       //LogTrace("FourVectorHLTriggerOffline") << " --------" << std::endl;
01330       for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it)
01331       {
01332 
01333         //LogTrace("FourVectorHLTriggerOffline") << " " <<   (*it).first << " :  " << (*it).second << std::endl;
01334 
01335       }
01336 
01337       imap++;
01338 
01339  }
01340 
01341  // loop i
01342  for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) 
01343  {
01344      
01345     fimmap tempMap_i = *setIter_i;
01346     fimmap::iterator it = tempMap_i.begin();
01347     int topValue = (*it).second;
01348     //LogTrace("FourVectorHLTriggerOffline") << " topValue = " << topValue << std::endl;
01349 
01350     
01351     mmset::iterator tempIter_i = setIter_i;
01352 
01353     // from all the other maps, clean entries that have mapped value "topValue"
01354     // loop j
01355     for ( mmset::iterator setIter_j = ++tempIter_i; setIter_j != tempSet.end( ); setIter_j++ ) 
01356     {
01357 
01358       fimmap tempMap_j = *setIter_j;
01359       //LogTrace("FourVectorHLTriggerOffline") << "  size of the map  = " << tempMap_j.size() << std::endl;
01360 
01361       for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it)
01362       {
01363 
01364         if(topValue == (*it).second) 
01365         {
01366                                   
01367           //LogTrace("FourVectorHLTriggerOffline") << "   Ridding map of a doubly-matched object." << std::endl;
01368           tempMap_j.erase(it);
01369 
01370           cleanedOneMap = true;
01371 
01372         }
01373 
01374      } //end for
01375 
01376      if(cleanedOneMap) 
01377      {
01378         
01379         //remove the old map from the set
01380         tempSet.erase(setIter_j);
01381 
01382         // insert in the set the new map if it is not an empty map
01383         if(! tempMap_j.empty()) tempSet.insert(tempMap_j);
01384 
01385         break; // break from loop j
01386 
01387      } // end if
01388 
01389     }// end loop j 
01390 
01391     if(cleanedOneMap) break; // break from loop i
01392 
01393  } // end loop i
01394 
01395  if(cleanedOneMap) 
01396  { 
01397 
01398   // continue cleaning (in while loop)
01399   // but reset flag first
01400   cleanedOneMap=false;
01401   continue; 
01402 
01403  }
01404  else {
01405 
01406   // finished cleaing (break from while loop)
01407   break; 
01408 
01409  }
01410 
01411 } // end while
01412 
01413  //LogTrace("FourVectorHLTriggerOffline") << "cleaned: size of the set  = " << tempSet.size() << " maps." << std::endl;
01414  int jmap = 0;
01415 
01416  for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) 
01417  {
01418 
01419       fimmap tempMap_j = *setIter_i;
01420 
01421       //LogTrace("FourVectorHLTriggerOffline") << " map " << jmap << std::endl;
01422       //LogTrace("FourVectorHLTriggerOffline") << " --------" << std::endl;
01423 
01424       for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it)
01425       {
01426 
01427         //LogTrace("FourVectorHLTriggerOffline") << " " <<   (*it).first << " :  " << (*it).second << std::endl;
01428       
01429       }
01430 
01431       jmap++;
01432 
01433  } // end for
01434 
01435 
01436  return;
01437 }
01438