Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-11 04:33:06

0001 #ifndef HLTriggerOffline_Egamma_EmDQMReco_H
0002 #define HLTriggerOffline_Egamma_EmDQMReco_H
0003 
0004 // Base Class Headers
0005 #include "CommonTools/Utils/interface/PtComparator.h"
0006 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0007 #include "DQMServices/Core/interface/DQMStore.h"
0008 #include "DataFormats/Common/interface/AssociationMap.h"
0009 #include "DataFormats/Common/interface/Handle.h"
0010 #include "DataFormats/Common/interface/RefToBase.h"
0011 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0012 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
0013 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/Utilities/interface/InputTag.h"
0018 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0019 #include "HepMC/GenParticle.h"
0020 #include "TDirectory.h"
0021 
0022 #include <memory>
0023 #include <vector>
0024 
0025 class EmDQMReco;
0026 
0027 template <class T>
0028 class HistoFillerReco {
0029 public:
0030   HistoFillerReco(EmDQMReco *d) : dqm(d) {}
0031   ~HistoFillerReco() {}
0032 
0033   void fillHistos(edm::Handle<trigger::TriggerEventWithRefs> &triggerObj,
0034                   const edm::Event &iEvent,
0035                   unsigned int n,
0036                   std::vector<reco::Particle> &sortedReco,
0037                   bool plotReco,
0038                   bool plotMonpath);
0039   std::vector<edm::EDGetTokenT<edm::AssociationMap<edm::OneToValue<T, float>>>> isoNameTokens_;
0040 
0041 private:
0042   EmDQMReco *dqm;
0043 };
0044 
0045 class EmDQMReco : public DQMEDAnalyzer {
0046   //----------------------------------------
0047 
0048   /** a class managing a set of MonitorElements for quantities of a fourvector
0049    *  we want to histogram.
0050    */
0051   class FourVectorMonitorElements {
0052   public:
0053     /** @param histogramNameTemplate should be a format string (like used in
0054      * printf(..) for the histogram NAME where the first %s is replaced with 
0055      * et,eta or phi.
0056      *
0057      *  @param histogramTitleTemplate should be a format string (see
0058      * histogramNameTemplate) for the histogram TITLE where the first %s is
0059      * replaced with et,eta or phi.
0060      */
0061     FourVectorMonitorElements(EmDQMReco *_parent,
0062                               DQMStore::IBooker &iBooker,
0063                               const std::string &histogramNameTemplate,
0064                               const std::string &histogramTitleTemplate);
0065 
0066     void fill(const math::XYZTLorentzVector &momentum);
0067 
0068   private:
0069     /** for accessing the histogramming parameters */
0070     EmDQMReco *parent;
0071 
0072     /** DQM objects (histograms) for the variables to be plotted */
0073     MonitorElement *etMonitorElement;
0074     MonitorElement *etaMonitorElement;
0075     MonitorElement *phiMonitorElement;
0076   };
0077   //----------------------------------------
0078 
0079 public:
0080   friend class HistoFillerReco<reco::ElectronCollection>;
0081   friend class HistoFillerReco<reco::RecoEcalCandidateCollection>;
0082   friend class HistoFillerReco<l1extra::L1EmParticleCollection>;
0083 
0084   /// Constructor
0085   explicit EmDQMReco(const edm::ParameterSet &pset);
0086 
0087   /// Destructor
0088   ~EmDQMReco() override;
0089 
0090   // Operations
0091   void analyze(const edm::Event &event, const edm::EventSetup &) override;
0092   void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override;
0093   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0094 
0095 private:
0096   // Input from cfg file
0097 
0098   /** the HLT collections to be looked at */
0099   std::vector<edm::InputTag> theHLTCollectionLabels;
0100 
0101   unsigned int numOfHLTCollectionLabels;  // Will be size of above vector
0102 
0103   bool useHumanReadableHistTitles;
0104   std::vector<std::string> theHLTCollectionHumanNames;  // Human-readable names for the collections
0105   // edm::InputTag theL1Seed;
0106   std::vector<int> theHLTOutputTypes;
0107   std::vector<bool> plotiso;
0108   std::vector<std::vector<edm::InputTag>> isoNames;  // there has to be a better solution
0109   std::vector<std::pair<double, double>> plotBounds;
0110   std::string theHltName;
0111   HLTConfigProvider hltConfig_;
0112   bool isHltConfigInitialized_;
0113 
0114   ////////////////////////////////////////////////////////////
0115   //          Read from configuration file                  //
0116   ////////////////////////////////////////////////////////////
0117   // parameters for generator study
0118   unsigned int reqNum;
0119   int pdgGen;
0120   double recoEtaAcc;
0121   double recoEtAcc;
0122   // plotting paramters
0123   double plotEtaMax;
0124   double plotPtMin;
0125   double plotPtMax;
0126   double plotPhiMax;
0127 
0128   /** number of bins to use for ALL plots (?) */
0129   unsigned int plotBins;
0130 
0131   // preselction cuts
0132   // edm::InputTag recocutCollection_;
0133   unsigned int recocut_;
0134 
0135   /** events which fire this trigger are filled into {et,eta,phi}recomonpath
0136    */
0137   std::string triggerNameRecoMonPath;
0138 
0139   /** process name for the trigger results for events to be filled
0140    *  into {et,eta,phi}recomonpath
0141    */
0142   std::string processNameRecoMonPath;
0143 
0144   /** input tag for the reconstructed electron collection
0145    *  (with respect to which the HLT efficiencies are calculated ?)
0146    */
0147   edm::EDGetTokenT<reco::GsfElectronCollection> recoElectronsInput;
0148   edm::EDGetTokenT<std::vector<reco::SuperCluster>> recoObjectsEBT;
0149   edm::EDGetTokenT<std::vector<reco::SuperCluster>> recoObjectsEET;
0150   edm::EDGetTokenT<edm::TriggerResults> hltResultsT;
0151   edm::EDGetTokenT<trigger::TriggerEventWithRefs> triggerObjT;
0152   ////////////////////////////////////////////////////////////
0153   //          Create Histograms                             //
0154   ////////////////////////////////////////////////////////////
0155   /** \label Et, eta and phi distributions (RECO) for the different
0156    *  HLT modules to be looked at. */
0157   /** @{ */
0158   // std::vector<MonitorElement*> etahist;
0159   //  std::vector<MonitorElement*> ethist;
0160   //  std::vector<MonitorElement*> phiHist;
0161 
0162   std::vector<std::unique_ptr<FourVectorMonitorElements>> standardHist;
0163 
0164   //  std::vector<MonitorElement*> etahistmatchreco;
0165   //  std::vector<MonitorElement*> ethistmatchreco;
0166   //  std::vector<MonitorElement*> phiHistMatchReco;
0167   std::vector<std::unique_ptr<FourVectorMonitorElements>> histMatchReco;
0168 
0169   //  std::vector<MonitorElement*> etahistmatchrecomonpath;
0170   //  std::vector<MonitorElement*> ethistmatchrecomonpath;
0171   //  std::vector<MonitorElement*> phiHistMatchRecoMonPath;
0172   std::vector<std::unique_ptr<FourVectorMonitorElements>> histMatchRecoMonPath;
0173 
0174   //  std::vector<MonitorElement*> histEtOfHltObjMatchToReco;
0175   //  std::vector<MonitorElement*> histEtaOfHltObjMatchToReco;
0176   //  std::vector<MonitorElement*> histPhiOfHltObjMatchToReco;
0177   std::vector<std::unique_ptr<FourVectorMonitorElements>> histHltObjMatchToReco;
0178 
0179   /** @} */
0180 
0181   /** \label Isolation distributions */
0182   /** @{ */
0183   std::vector<MonitorElement *> etahistiso;
0184   std::vector<MonitorElement *> ethistiso;
0185   std::vector<MonitorElement *> phiHistIso;
0186 
0187   std::vector<MonitorElement *> etahistisomatchreco;
0188   std::vector<MonitorElement *> ethistisomatchreco;
0189   std::vector<MonitorElement *> phiHistIsoMatchReco;
0190 
0191   std::vector<MonitorElement *> histEtIsoOfHltObjMatchToReco;
0192   std::vector<MonitorElement *> histEtaIsoOfHltObjMatchToReco;
0193   std::vector<MonitorElement *> histPhiIsoOfHltObjMatchToReco;
0194   /** @} */
0195 
0196   /** Plots of efficiency per step (note that these are NOT
0197    *  filled with four vector quantities but rather event counts) */
0198   MonitorElement *totalreco;
0199   MonitorElement *totalmatchreco;
0200 
0201   /** \name reco histograms */
0202   /** @{ */
0203   //  MonitorElement* etreco;
0204   //  MonitorElement* etareco;
0205   //  MonitorElement* phiReco;
0206   std::unique_ptr<FourVectorMonitorElements> histReco;
0207 
0208   //  MonitorElement* etrecomonpath;
0209   //  MonitorElement* etarecomonpath;
0210   //  MonitorElement* phiRecoMonPath;
0211   std::unique_ptr<FourVectorMonitorElements> histRecoMonpath;
0212 
0213   //  MonitorElement* etahistmonpath;
0214   //  MonitorElement* ethistmonpath;
0215   //  MonitorElement* phiHistMonPath;
0216   std::unique_ptr<FourVectorMonitorElements> histMonpath;
0217   /** @} */
0218 
0219   int eventnum;
0220   // int prescale;
0221 
0222   // interface to DQM framework
0223   std::string dirname_;
0224 
0225   HistoFillerReco<reco::ElectronCollection> *histoFillerEle;
0226   HistoFillerReco<reco::RecoEcalCandidateCollection> *histoFillerClu;
0227   HistoFillerReco<l1extra::L1EmParticleCollection> *histoFillerL1NonIso;
0228   HistoFillerReco<reco::RecoEcalCandidateCollection> *histoFillerPho;
0229   HistoFillerReco<l1extra::L1EmParticleCollection> *histoFillerL1Iso;
0230 
0231   // template <class T> void
0232   // fillHistos(edm::Handle<trigger::TriggerEventWithRefs>&,const edm::Event&
0233   // ,unsigned int, std::vector<reco::Particle>&, bool, bool);
0234   GreaterByPt<reco::Particle> pTComparator_;
0235   GreaterByPt<reco::GsfElectron> pTRecoComparator_;
0236 
0237   //----------------------------------------
0238 };
0239 #endif