Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-29 23:10:49

0001 #ifndef HLTriggerOffline_Muon_HLTMuonPlotter_H
0002 #define HLTriggerOffline_Muon_HLTMuonPlotter_H
0003 
0004 /** \class HLTMuonPlotter
0005  *  Generate histograms for muon trigger efficiencies
0006  *  Documentation available on the CMS TWiki:
0007  *  https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLTOfflinePerformance
0008  *
0009  *  \author  J. Klukas, M. Vander Donckt, J. Alcaraz
0010  */
0011 
0012 #include "FWCore/Framework/interface/ConsumesCollector.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/Frameworkfwd.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 
0017 #include "DataFormats/Candidate/interface/Candidate.h"
0018 #include "DataFormats/Candidate/interface/Particle.h"
0019 #include "DataFormats/Common/interface/RefToBase.h"
0020 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0021 #include "DataFormats/L1Trigger/interface/Muon.h"
0022 #include "DataFormats/TrackReco/interface/Track.h"
0023 
0024 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0025 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
0026 #include "DataFormats/MuonReco/interface/Muon.h"
0027 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0028 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
0029 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
0030 
0031 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0032 
0033 #include "MuonAnalysis/MuonAssociators/interface/L1MuonMatcherAlgo.h"
0034 
0035 #include "DQMServices/Core/interface/DQMStore.h"
0036 
0037 #include <algorithm>
0038 #include <cctype>
0039 #include <iostream>
0040 #include <map>
0041 #include <set>
0042 #include <tuple>
0043 #include <vector>
0044 
0045 #include "TPRegexp.h"
0046 
0047 class HLTMuonPlotter {
0048 public:
0049   typedef dqm::legacy::DQMStore DQMStore;
0050   typedef dqm::legacy::MonitorElement MonitorElement;
0051   typedef L1MuonMatcherAlgoT<edm::Transition::BeginRun> L1MuonMatcherAlgoForDQM;
0052 
0053   HLTMuonPlotter(const edm::ParameterSet &,
0054                  std::string,
0055                  const std::vector<std::string> &,
0056                  const std::vector<std::string> &,
0057                  const edm::EDGetTokenT<trigger::TriggerEventWithRefs> &,
0058                  const edm::EDGetTokenT<reco::GenParticleCollection> &,
0059                  const edm::EDGetTokenT<reco::MuonCollection> &,
0060                  const L1MuonMatcherAlgoForDQM &);
0061 
0062   ~HLTMuonPlotter() {
0063     delete genMuonSelector_;
0064     delete recMuonSelector_;
0065   }
0066 
0067   void beginJob();
0068   void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &);
0069   void analyze(const edm::Event &, const edm::EventSetup &);
0070 
0071 private:
0072   struct MatchStruct {
0073     const reco::Candidate *candBase;
0074     const l1t::Muon *candL1;
0075     std::vector<const reco::RecoChargedCandidate *> candHlt;
0076     MatchStruct() {
0077       candBase = nullptr;
0078       candL1 = nullptr;
0079     }
0080     MatchStruct(const reco::Candidate *cand) {
0081       candBase = cand;
0082       candL1 = nullptr;
0083     }
0084     bool operator<(MatchStruct match) { return candBase->pt() < match.candBase->pt(); }
0085     bool operator>(MatchStruct match) { return candBase->pt() > match.candBase->pt(); }
0086   };
0087   struct matchesByDescendingPt {
0088     bool operator()(MatchStruct a, MatchStruct b) { return a.candBase->pt() > b.candBase->pt(); }
0089   };
0090 
0091   void analyzePath(const edm::Event &,
0092                    const std::string &,
0093                    const std::string &,
0094                    const std::vector<MatchStruct> &,
0095                    edm::Handle<trigger::TriggerEventWithRefs>);
0096   void findMatches(std::vector<MatchStruct> &,
0097                    const l1t::MuonVectorRef &candsL1,
0098                    const std::vector<std::vector<const reco::RecoChargedCandidate *>> &);
0099   void bookHist(DQMStore::IBooker &, std::string, std::string, std::string, std::string);
0100 
0101   std::string hltPath_;
0102   std::string hltProcessName_;
0103 
0104   std::vector<std::string> moduleLabels_;
0105   std::vector<std::string> stepLabels_;
0106 
0107   edm::EDGetTokenT<trigger::TriggerEventWithRefs> hltTriggerSummaryRAW_;
0108   edm::EDGetTokenT<reco::GenParticleCollection> genParticleLabel_;
0109   edm::EDGetTokenT<reco::MuonCollection> recMuonLabel_;
0110 
0111   std::vector<double> parametersEta_;
0112   std::vector<double> parametersPhi_;
0113   std::vector<double> parametersTurnOn_;
0114 
0115   double cutMinPt_;
0116   double cutMaxEta_;
0117   unsigned int cutMotherId_;
0118   std::vector<double> cutsDr_;
0119   std::string genMuonCut_;
0120   std::string recMuonCut_;
0121 
0122   StringCutObjectSelector<reco::GenParticle> *genMuonSelector_;
0123   StringCutObjectSelector<reco::Muon> *recMuonSelector_;
0124 
0125   L1MuonMatcherAlgoForDQM l1Matcher_;
0126 
0127   std::map<std::string, MonitorElement *> elements_;
0128 };
0129 
0130 #endif