Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-12 22:34:20

0001 #ifndef DQMOffline_Trigger_HLTMuonMatchAndPlot_H
0002 #define DQMOffline_Trigger_HLTMuonMatchAndPlot_H
0003 
0004 /** \class HLTMuonMatchAndPlot
0005  *  Match reconstructed muons to HLT objects and plot efficiencies.
0006  *
0007  *  Note that this is not a true EDAnalyzer;
0008  *
0009  *  Documentation available on the CMS TWiki:
0010  *  https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLTOfflinePerformance
0011  *
0012  *  
0013  *  \author  J. Slaunwhite, Jeff Klukas
0014  */
0015 
0016 // Base Class Headers
0017 
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/Framework/interface/MakerMacros.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "FWCore/Utilities/interface/InputTag.h"
0022 #include "DataFormats/Common/interface/Handle.h"
0023 
0024 #include "DQMServices/Core/interface/DQMStore.h"
0025 
0026 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0027 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
0028 #include "DataFormats/Common/interface/TriggerResults.h"
0029 #include "DataFormats/MuonReco/interface/Muon.h"
0030 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0031 #include "DataFormats/VertexReco/interface/Vertex.h"
0032 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0033 #include "DataFormats/Math/interface/LorentzVector.h"
0034 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0035 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0036 #include "DataFormats/Math/interface/deltaR.h"
0037 
0038 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0039 
0040 #include <vector>
0041 #include "TFile.h"
0042 #include "TNtuple.h"
0043 #include "TString.h"
0044 #include "TPRegexp.h"
0045 
0046 //////////////////////////////////////////////////////////////////////////////
0047 //////// Typedefs and Constants //////////////////////////////////////////////
0048 
0049 using LorentzVector = math::XYZTLorentzVector;
0050 
0051 const double NOMATCH = 999.;
0052 const std::string EFFICIENCY_SUFFIXES[2] = {"denom", "numer"};
0053 
0054 //////////////////////////////////////////////////////////////////////////////
0055 //////// HLTMuonMatchAndPlot Class Definition ////////////////////////////////
0056 
0057 class HLTMuonMatchAndPlot {
0058 public:
0059   typedef dqm::legacy::DQMStore DQMStore;
0060   typedef dqm::legacy::MonitorElement MonitorElement;
0061 
0062   /// Constructor
0063   HLTMuonMatchAndPlot(const edm::ParameterSet &, std::string, std::string, bool);
0064 
0065   // Analyzer Methods
0066   void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &);
0067   void analyze(edm::Handle<reco::MuonCollection> &,
0068                edm::Handle<reco::BeamSpot> &,
0069                edm::Handle<reco::VertexCollection> &,
0070                edm::Handle<trigger::TriggerEvent> &,
0071                edm::Handle<edm::TriggerResults> &,
0072                const edm::TriggerNames &);
0073   void endRun(const edm::Run &, const edm::EventSetup &);
0074 
0075   // Helper Methods
0076   bool fillEdges(size_t &nBins, float *&edges, const std::vector<double> &binning);
0077   template <class T>
0078   void fillMapFromPSet(std::map<std::string, T> &, const edm::ParameterSet &, const std::string &);
0079   template <class T1, class T2>
0080   std::vector<size_t> matchByDeltaR(const std::vector<T1> &, const std::vector<T2> &, const double maxDeltaR = NOMATCH);
0081 
0082 private:
0083   // Internal Methods
0084   void book1D(DQMStore::IBooker &, std::string, const std::string &, std::string);
0085   void book2D(DQMStore::IBooker &, const std::string &, const std::string &, const std::string &, const std::string &);
0086   reco::MuonCollection selectedMuons(const reco::MuonCollection &,
0087                                      const reco::BeamSpot &,
0088                                      bool,
0089                                      const StringCutObjectSelector<reco::Muon> &,
0090                                      double,
0091                                      double);
0092 
0093   trigger::TriggerObjectCollection selectedTriggerObjects(
0094       const trigger::TriggerObjectCollection &,
0095       const trigger::TriggerEvent &,
0096       bool hasTriggerCuts,
0097       const StringCutObjectSelector<trigger::TriggerObject> &triggerSelector);
0098 
0099   // Input from Configuration File
0100   std::string hltProcessName_;
0101   std::string destination_;
0102   std::vector<std::string> requiredTriggers_;
0103   std::map<std::string, std::vector<double> > binParams_;
0104   std::map<std::string, double> plotCuts_;
0105   edm::ParameterSet targetParams_;
0106   edm::ParameterSet probeParams_;
0107 
0108   // Member Variables
0109   std::string triggerLevel_;
0110   unsigned int cutMinPt_;
0111   std::string hltPath_;
0112   std::string moduleLabel_;
0113   bool isLastFilter_;
0114   std::map<std::string, MonitorElement *> hists_;
0115 
0116   // Selectors
0117   bool hasTargetRecoCuts;
0118   bool hasProbeRecoCuts;
0119 
0120   StringCutObjectSelector<reco::Muon> targetMuonSelector_;
0121   double targetZ0Cut_;
0122   double targetD0Cut_;
0123   double targetptCutZ_;
0124   double targetptCutJpsi_;
0125   StringCutObjectSelector<reco::Muon> probeMuonSelector_;
0126   double probeZ0Cut_;
0127   double probeD0Cut_;
0128 
0129   StringCutObjectSelector<trigger::TriggerObject> triggerSelector_;
0130   bool hasTriggerCuts_;
0131 };
0132 
0133 #endif