Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef MuonPFAnalyzer_H
0002 #define MuonPFAnalyzer_H
0003 
0004 /** \class MuRecoAnalyzer
0005  *
0006  *  DQM monitoring source for PF muons
0007  *
0008  *  \author C. Battilana - CIEMAT
0009  */
0010 
0011 //Base class
0012 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0013 
0014 #include "FWCore/Utilities/interface/InputTag.h"
0015 #include "DQMServices/Core/interface/DQMStore.h"
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017 
0018 #include "DataFormats/MuonReco/interface/Muon.h"
0019 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0020 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0021 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0022 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0023 #include "DataFormats/VertexReco/interface/Vertex.h"
0024 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0025 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0026 
0027 #include <map>
0028 #include <string>
0029 
0030 class MuonPFAnalyzer : public DQMEDAnalyzer {
0031 public:
0032   typedef std::pair<const reco::Muon *, const reco::GenParticle *> RecoGenPair;
0033   typedef std::vector<RecoGenPair> RecoGenCollection;
0034 
0035   /// Constructor
0036   explicit MuonPFAnalyzer(const edm::ParameterSet &);
0037 
0038   /// Destructor
0039   ~MuonPFAnalyzer() override;
0040 
0041   void analyze(const edm::Event &, const edm::EventSetup &) override;
0042   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0043 
0044 private:
0045   // Book histos for a given group of plots (e.g. for Tight TUNEP muons)
0046   void bookHistos(DQMStore::IBooker &, const std::string &);
0047 
0048   // Get a specific plot for a given group
0049   MonitorElement *getPlot(const std::string &group, const std::string &type);
0050 
0051   // Algorithm to identify muon pt track type
0052   int muonTrackType(const reco::Muon *muon, bool usePF);
0053 
0054   // Compute comb. rel. iso. (RECO based) for a given muon
0055   inline float combRelIso(const reco::Muon *muon);
0056 
0057   // Compute delta phi taking into account overflows
0058   inline float fDeltaPhi(float phi1, float phi2);
0059 
0060   // Set labels for code plots
0061   void setCodeLabels(MonitorElement *plot, int nAxis);
0062 
0063   // Fill plot within its range limits
0064   void fillInRange(MonitorElement *plot, int nAxis, double x, double y = 0);
0065 
0066   // Perform reco-gen geometrical matching on a best effort basis
0067   // (if runOnMC == false or no matched gen particles are available gen is set to 0 in theRecoGen)
0068   void recoToGenMatch(edm::Handle<reco::MuonCollection> &reco, edm::Handle<reco::GenParticleCollection> &gen);
0069 
0070   const reco::Vertex getPrimaryVertex(edm::Handle<reco::VertexCollection> &vertex,
0071                                       edm::Handle<reco::BeamSpot> &beamSpot);
0072 
0073   edm::EDGetTokenT<reco::GenParticleCollection> theGenLabel_;
0074   edm::EDGetTokenT<reco::MuonCollection> theRecoLabel_;
0075   edm::EDGetTokenT<reco::VertexCollection> theVertexLabel_;
0076   edm::EDGetTokenT<reco::BeamSpot> theBeamSpotLabel_;
0077 
0078   std::vector<std::string> theMuonKinds;
0079 
0080   std::map<std::string, std::map<std::string, MonitorElement *> > thePlots;
0081   RecoGenCollection theRecoGen;
0082 
0083   double theHighPtTh;
0084   double theRecoGenR;
0085   double theIsoCut;
0086 
0087   bool theRunOnMC;
0088 
0089   std::string theFolder;
0090 };
0091 #endif