Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-17 02:28:28

0001 // -*- C++ -*-
0002 //
0003 // Package:    HLTriggerOffline/B2G
0004 // Class:      B2GSingleLeptonHLTValidation
0005 //
0006 /**\class B2GSingleLeptonHLTValidation B2GSingleLeptonHLTValidation.h
0007  HLTriggerOffline/B2G/interface/B2GSingleLeptonHLTValidation.h
0008 
0009  Description: compute efficiencies of trigger paths on offline reco selection
0010  with respect to pt and eta
0011 
0012  Implementation:
0013      harvesting
0014 */
0015 //
0016 // Original Author:  Elvire Bouvier
0017 //         Created:  Thu, 16 Jan 2014 16:27:35 GMT
0018 //
0019 //
0020 #ifndef B2GSINGLELEPTONHLTVALIDATION
0021 #define B2GSINGLELEPTONHLTVALIDATION
0022 
0023 // system include files
0024 #include <memory>
0025 
0026 // user include files
0027 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
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/ParameterSet/interface/ParameterSet.h"
0035 #include "FWCore/ServiceRegistry/interface/Service.h"
0036 
0037 #include "DQMServices/Core/interface/DQMStore.h"
0038 
0039 #include "DataFormats/Common/interface/TriggerResults.h"
0040 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0041 #include "DataFormats/JetReco/interface/Jet.h"
0042 #include "DataFormats/MuonReco/interface/Muon.h"
0043 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0044 
0045 //
0046 // class declaration
0047 //
0048 
0049 class B2GSingleLeptonHLTValidation : public DQMEDAnalyzer {
0050 public:
0051   explicit B2GSingleLeptonHLTValidation(const edm::ParameterSet &);
0052   ~B2GSingleLeptonHLTValidation() override;
0053 
0054   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0055 
0056 private:
0057   void analyze(const edm::Event &, const edm::EventSetup &) override;
0058   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0059   /// deduce monitorPath from label, the label is expected
0060   /// to be of type 'selectionPath:monitorPath'
0061   std::string monitorPath(const std::string &label) const { return label.substr(label.find(':') + 1); };
0062   /// set configurable labels for trigger monitoring histograms
0063   void triggerBinLabels(const std::vector<std::string> &labels);
0064 
0065   // ----------member data ---------------------------
0066   // DQM
0067   std::string sDir_;
0068   MonitorElement *hNumLeptonPt;
0069   MonitorElement *hDenLeptonPt;
0070   MonitorElement *hNumLeptonEta;
0071   MonitorElement *hDenLeptonEta;
0072   MonitorElement *hNumJetPt;
0073   MonitorElement *hDenJetPt;
0074   MonitorElement *hNumJetEta;
0075   MonitorElement *hDenJetEta;
0076   MonitorElement *hNumTriggerMon;
0077   MonitorElement *hDenTriggerMon;
0078   // Electrons
0079   edm::Ptr<reco::GsfElectron> elec_;
0080   std::string sElectrons_;
0081   edm::EDGetTokenT<edm::View<reco::GsfElectron>> tokElectrons_;
0082   double ptElectrons_;
0083   double etaElectrons_;
0084   double isoElectrons_;
0085   unsigned int minElectrons_;
0086   // Muons
0087   edm::Ptr<reco::Muon> mu_;
0088   std::string sMuons_;
0089   edm::EDGetTokenT<edm::View<reco::Muon>> tokMuons_;
0090   double ptMuons_;
0091   double etaMuons_;
0092   double isoMuons_;
0093   unsigned int minMuons_;
0094   // Jets
0095   edm::Ptr<reco::Jet> jet_;
0096   std::string sJets_;
0097   edm::EDGetTokenT<edm::View<reco::Jet>> tokJets_;
0098   double ptJets_;
0099   double ptJets0_;
0100   double ptJets1_;
0101   double etaJets_;
0102   unsigned int minJets_;
0103   // Trigger
0104   std::string sTrigger_;
0105   edm::EDGetTokenT<edm::TriggerResults> tokTrigger_;
0106   std::vector<std::string> vsPaths_;
0107   // Flags
0108   bool isAll_ = false;
0109   bool isSel_ = false;
0110 };
0111 
0112 inline void B2GSingleLeptonHLTValidation::triggerBinLabels(const std::vector<std::string> &labels) {
0113   for (unsigned int idx = 0; idx < labels.size(); ++idx) {
0114     hNumTriggerMon->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
0115     hDenTriggerMon->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
0116   }
0117 }
0118 
0119 //
0120 // constants, enums and typedefs
0121 //
0122 
0123 //
0124 // static data member definitions
0125 //
0126 
0127 //
0128 // constructors and destructor
0129 //
0130 inline B2GSingleLeptonHLTValidation::B2GSingleLeptonHLTValidation(const edm::ParameterSet &iConfig)
0131     : sDir_(iConfig.getUntrackedParameter<std::string>("sDir", "HLTValidation/B2G/Efficiencies/")),
0132       sElectrons_(iConfig.getUntrackedParameter<std::string>("sElectrons", "gsfElectrons")),
0133       ptElectrons_(iConfig.getUntrackedParameter<double>("ptElectrons", 0.)),
0134       etaElectrons_(iConfig.getUntrackedParameter<double>("etaElectrons", 0.)),
0135       isoElectrons_(iConfig.getUntrackedParameter<double>("isoElectrons", 0.)),
0136       minElectrons_(iConfig.getUntrackedParameter<unsigned int>("minElectrons", 0)),
0137       sMuons_(iConfig.getUntrackedParameter<std::string>("sMuons", "muons")),
0138       ptMuons_(iConfig.getUntrackedParameter<double>("ptMuons", 0.)),
0139       etaMuons_(iConfig.getUntrackedParameter<double>("etaMuons", 0.)),
0140       isoMuons_(iConfig.getUntrackedParameter<double>("isoMuons", 0.)),
0141       minMuons_(iConfig.getUntrackedParameter<unsigned int>("minMuons", 0)),
0142       sJets_(iConfig.getUntrackedParameter<std::string>("sJets", "ak5PFJets")),
0143       ptJets_(iConfig.getUntrackedParameter<double>("ptJets", 0.)),
0144       ptJets0_(iConfig.getUntrackedParameter<double>("ptJets0", 0.)),
0145       ptJets1_(iConfig.getUntrackedParameter<double>("ptJets1", 0.)),
0146       etaJets_(iConfig.getUntrackedParameter<double>("etaJets", 0.)),
0147       minJets_(iConfig.getUntrackedParameter<unsigned int>("minJets", 0)),
0148       sTrigger_(iConfig.getUntrackedParameter<std::string>("sTrigger", "TriggerResults")),
0149       vsPaths_(iConfig.getUntrackedParameter<std::vector<std::string>>("vsPaths"))
0150 
0151 {
0152   // Electrons
0153   tokElectrons_ = consumes<edm::View<reco::GsfElectron>>(edm::InputTag(sElectrons_));
0154   // Muons
0155   tokMuons_ = consumes<edm::View<reco::Muon>>(edm::InputTag(sMuons_));
0156   // Jets
0157   tokJets_ = consumes<edm::View<reco::Jet>>(edm::InputTag(sJets_));
0158   // Trigger
0159   tokTrigger_ = consumes<edm::TriggerResults>(edm::InputTag(sTrigger_, "", "HLT"));
0160 }
0161 
0162 inline B2GSingleLeptonHLTValidation::~B2GSingleLeptonHLTValidation() {
0163   // do anything here that needs to be done at desctruction time
0164   // (e.g. close files, deallocate resources etc.)
0165 }
0166 #endif
0167 
0168 // define this as a plug-in
0169 DEFINE_FWK_MODULE(B2GSingleLeptonHLTValidation);