Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:49

0001 // -*- C++ -*-
0002 //
0003 // Package:    HLTriggerOffline/B2G
0004 // Class:      B2GHadronicHLTValidation
0005 //
0006 /**\class B2GHadronicHLTValidation B2GHadronicHLTValidation.cc
0007 HLTriggerOffline/B2G/src/B2GHadronicHLTValidation.cc
0008 
0009 Description:
0010 
0011 Description: compute efficiencies of trigger paths on offline reco selection
0012 with respect to pt and eta
0013 
0014 Implementation:
0015 harvesting
0016 */
0017 //
0018 // Original Author:  Elvire Bouvier
0019 //         Created:  Thu, 16 Jan 2014 16:27:35 GMT
0020 //
0021 //
0022 #include "HLTriggerOffline/B2G/interface/B2GHadronicHLTValidation.h"
0023 
0024 // system include files
0025 #include <memory>
0026 
0027 // user include files
0028 #include "FWCore/Framework/interface/Frameworkfwd.h"
0029 
0030 #include "FWCore/Framework/interface/Event.h"
0031 #include "FWCore/Framework/interface/MakerMacros.h"
0032 
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 #include "FWCore/ServiceRegistry/interface/Service.h"
0035 
0036 #include "FWCore/Common/interface/TriggerNames.h"
0037 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0038 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0039 #include "TString.h"
0040 //
0041 // member functions
0042 //
0043 
0044 // ------------ method called for each event  ------------
0045 void B2GHadronicHLTValidation::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0046   using namespace edm;
0047 
0048   isAll_ = false;
0049   isSel_ = false;
0050 
0051   // Jets
0052   Handle<edm::View<reco::Jet>> jets;
0053   if (!iEvent.getByToken(tokJets_, jets))
0054     edm::LogWarning("B2GHadronicHLTValidation") << "Jets collection not found \n";
0055   unsigned int nGoodJ = 0;
0056   double ht = 0.0;
0057   // Check to see if we want asymmetric jet pt cuts
0058   if (ptJets0_ > 0.0 || ptJets1_ > 0.0) {
0059     if (ptJets0_ > 0.0) {
0060       if (!jets->empty() && jets->at(0).pt() > ptJets0_) {
0061         nGoodJ++;
0062         jet_ = jets->ptrAt(0);
0063       }
0064     }
0065     if (ptJets1_ > 0.0) {
0066       if (jets->size() > 1 && jets->at(1).pt() > ptJets1_) {
0067         nGoodJ++;
0068         jet_ = jets->ptrAt(1);
0069       }
0070     }
0071   } else if (minJets_ > 0 || htMin_ > 0) {
0072     for (edm::View<reco::Jet>::const_iterator j = jets->begin(); j != jets->end(); ++j) {
0073       if (j->pt() < ptJets_)
0074         continue;
0075       if (fabs(j->eta()) > etaJets_)
0076         continue;
0077       nGoodJ++;
0078       ht += j->pt();
0079       if (nGoodJ == minJets_)
0080         jet_ = jets->ptrAt(j - jets->begin());
0081     }
0082   }
0083 
0084   if (nGoodJ >= minJets_ || ht > htMin_)
0085     isAll_ = true;
0086 
0087   // Trigger
0088   Handle<edm::TriggerResults> triggerTable;
0089   if (!iEvent.getByToken(tokTrigger_, triggerTable))
0090     edm::LogWarning("B2GHadronicHLTValidation") << "Trigger collection not found \n";
0091   const edm::TriggerNames &triggerNames = iEvent.triggerNames(*triggerTable);
0092   bool isInteresting = false;
0093   for (unsigned int i = 0; i < triggerNames.triggerNames().size(); ++i) {
0094     TString name = triggerNames.triggerNames()[i].c_str();
0095     for (unsigned int j = 0; j < vsPaths_.size(); j++) {
0096       if (name.Contains(TString(vsPaths_[j]), TString::kIgnoreCase)) {
0097         isInteresting = true;
0098         break;
0099       }
0100     }
0101     if (isInteresting)
0102       break;
0103   }
0104 
0105   if (isAll_ && isInteresting)
0106     isSel_ = true;
0107   else
0108     isSel_ = false;
0109 
0110   // Histos
0111   if (isAll_) {
0112     if (jet_.isNonnull()) {
0113       hDenJetPt->Fill(jet_->pt());
0114       hDenJetEta->Fill(jet_->eta());
0115     }
0116     for (unsigned int idx = 0; idx < vsPaths_.size(); ++idx) {
0117       hDenTriggerMon->Fill(idx + 0.5);
0118     }
0119   }
0120   if (isSel_) {
0121     hNumJetPt->Fill(jet_->pt());
0122     hNumJetEta->Fill(jet_->eta());
0123     for (unsigned int i = 0; i < triggerNames.triggerNames().size(); ++i) {
0124       TString name = triggerNames.triggerNames()[i].c_str();
0125       for (unsigned int j = 0; j < vsPaths_.size(); j++) {
0126         if (name.Contains(TString(vsPaths_[j]), TString::kIgnoreCase)) {
0127           hNumTriggerMon->Fill(j + 0.5);
0128         }
0129       }
0130     }
0131   }
0132 }
0133 
0134 // ------------ booking histograms -----------
0135 void B2GHadronicHLTValidation::bookHistograms(DQMStore::IBooker &dbe, edm::Run const &, edm::EventSetup const &) {
0136   dbe.setCurrentFolder(sDir_);
0137   hDenJetPt = dbe.book1D("PtLastJetAll", "PtLastJetAll", 60, 0., 3000.);
0138   hDenJetEta = dbe.book1D("EtaLastJetAll", "EtaLastJetAll", 30, -3., 3.);
0139   hNumJetPt = dbe.book1D("PtLastJetSel", "PtLastJetSel", 60, 0., 3000.);
0140   hNumJetEta = dbe.book1D("EtaLastJetSel", "EtaLastJetSel", 30, -3., 3.);
0141   // determine number of bins for trigger monitoring
0142   unsigned int nPaths = vsPaths_.size();
0143   // monitored trigger occupancy for single lepton triggers
0144   hNumTriggerMon = dbe.book1D("TriggerMonSel", "TriggerMonSel", nPaths, 0., nPaths);
0145   hDenTriggerMon = dbe.book1D("TriggerMonAll", "TriggerMonAll", nPaths, 0., nPaths);
0146   // set bin labels for trigger monitoring
0147   triggerBinLabels(vsPaths_);
0148 }
0149 
0150 // ------------ method fills 'descriptions' with the allowed parameters for the
0151 // module  ------------
0152 void B2GHadronicHLTValidation::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0153   // The following says we do not know what parameters are allowed so do no
0154   // validation
0155   // Please change this to state exactly what you do use, even if it is no
0156   // parameters
0157   edm::ParameterSetDescription desc;
0158   desc.setUnknown();
0159   descriptions.addDefault(desc);
0160 }