Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:51

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 <vector>
0039 #include "TFile.h"
0040 #include "TNtuple.h"
0041 #include "TString.h"
0042 #include "TPRegexp.h"
0043 
0044 //////////////////////////////////////////////////////////////////////////////
0045 //////// Typedefs and Constants //////////////////////////////////////////////
0046 
0047 using LorentzVector = math::XYZTLorentzVector;
0048 
0049 const double NOMATCH = 999.;
0050 const std::string EFFICIENCY_SUFFIXES[2] = {"denom", "numer"};
0051 
0052 //////////////////////////////////////////////////////////////////////////////
0053 //////// HLTMuonMatchAndPlot Class Definition ////////////////////////////////
0054 
0055 class HLTMuonMatchAndPlot {
0056 public:
0057   typedef dqm::legacy::DQMStore DQMStore;
0058   typedef dqm::legacy::MonitorElement MonitorElement;
0059 
0060   /// Constructor
0061   HLTMuonMatchAndPlot(const edm::ParameterSet &, std::string, std::string, bool);
0062 
0063   // Analyzer Methods
0064   void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &);
0065   void analyze(edm::Handle<reco::MuonCollection> &,
0066                edm::Handle<reco::BeamSpot> &,
0067                edm::Handle<reco::VertexCollection> &,
0068                edm::Handle<trigger::TriggerEvent> &,
0069                edm::Handle<edm::TriggerResults> &,
0070                const edm::TriggerNames &);
0071   void endRun(const edm::Run &, const edm::EventSetup &);
0072 
0073   // Helper Methods
0074   bool fillEdges(size_t &nBins, float *&edges, const std::vector<double> &binning);
0075   template <class T>
0076   void fillMapFromPSet(std::map<std::string, T> &, const edm::ParameterSet &, const std::string &);
0077   template <class T1, class T2>
0078   std::vector<size_t> matchByDeltaR(const std::vector<T1> &, const std::vector<T2> &, const double maxDeltaR = NOMATCH);
0079 
0080 private:
0081   // Internal Methods
0082   void book1D(DQMStore::IBooker &, std::string, const std::string &, std::string);
0083   void book2D(DQMStore::IBooker &, const std::string &, const std::string &, const std::string &, const std::string &);
0084   reco::MuonCollection selectedMuons(const reco::MuonCollection &, const reco::BeamSpot &, bool);
0085   trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &,
0086                                                           const trigger::TriggerEvent &);
0087 
0088   // Input from Configuration File
0089   std::string hltProcessName_;
0090   std::string destination_;
0091   std::vector<std::string> requiredTriggers_;
0092   std::map<std::string, std::vector<double> > binParams_;
0093   std::map<std::string, double> plotCuts_;
0094   edm::ParameterSet targetParams_;
0095   edm::ParameterSet probeParams_;
0096 
0097   // Member Variables
0098   std::string triggerLevel_;
0099   unsigned int cutMinPt_;
0100   std::string hltPath_;
0101   std::string moduleLabel_;
0102   bool isLastFilter_;
0103   std::map<std::string, MonitorElement *> hists_;
0104 
0105   double targetMuonEtaMax_;
0106   double targetMuonEtaMin_;
0107   bool targetIsMuonGlb_;
0108   double targetZ0Cut_;
0109   double targetD0Cut_;
0110   double targetptCutZ_;
0111   double targetptCutJpsi_;
0112   double probeMuonEtaMax_;
0113   double probeMuonEtaMin_;
0114   bool probeIsMuonGlb_;
0115   double probeZ0Cut_;
0116   double probeD0Cut_;
0117   double triggerEtaMaxCut_;
0118   double triggerEtaMinCut_;
0119 };
0120 
0121 #endif