Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:20

0001 #ifndef FOURVECTORHLT_H
0002 #define FOURVECTORHLT_H
0003 // -*- C++ -*-
0004 //
0005 // Package:    FourVectorHLT
0006 // Class:      FourVectorHLT
0007 //
0008 /**\class FourVectorHLT FourVectorHLT.cc DQM/FourVectorHLT/src/FourVectorHLT.cc
0009 
0010  Description: This is a DQM source meant to plot high-level HLT trigger
0011  quantities as stored in the HLT results object TriggerResults
0012 
0013  Implementation:
0014      <Notes on implementation>
0015 */
0016 //
0017 // Original Author:  Peter Wittich
0018 //         Created:  May 2008
0019 //
0020 //
0021 
0022 // system include files
0023 #include <memory>
0024 #include <unistd.h>
0025 
0026 // user include files
0027 #include "FWCore/Framework/interface/Frameworkfwd.h"
0028 #include "FWCore/Framework/interface/EDAnalyzer.h"
0029 
0030 #include "FWCore/Framework/interface/Event.h"
0031 #include "FWCore/Framework/interface/MakerMacros.h"
0032 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0033 
0034 #include "DQMServices/Core/interface/DQMStore.h"
0035 #include "FWCore/ServiceRegistry/interface/Service.h"
0036 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0037 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0038 #include <iostream>
0039 #include <fstream>
0040 #include <vector>
0041 
0042 //
0043 // class decleration
0044 //
0045 
0046 class FourVectorHLT : public edm::EDAnalyzer {
0047 public:
0048   typedef dqm::legacy::MonitorElement MonitorElement;
0049   typedef dqm::legacy::DQMStore DQMStore;
0050 
0051   explicit FourVectorHLT(const edm::ParameterSet&);
0052   ~FourVectorHLT() override;
0053 
0054 private:
0055   void beginJob() override;
0056   void analyze(const edm::Event&, const edm::EventSetup&) override;
0057   void endJob() override;
0058 
0059   // BeginRun
0060   void beginRun(const edm::Run& run, const edm::EventSetup& c) override;
0061 
0062   // EndRun
0063   void endRun(const edm::Run& run, const edm::EventSetup& c) override;
0064 
0065   // ----------member data ---------------------------
0066   int nev_;
0067   DQMStore* dbe_;
0068 
0069   bool plotAll_;
0070 
0071   unsigned int nBins_;
0072   double ptMin_;
0073   double ptMax_;
0074 
0075   std::string dirname_;
0076   edm::InputTag triggerSummaryLabel_;
0077   edm::InputTag triggerResultLabel_;
0078 
0079   //define Token(-s)
0080   edm::EDGetTokenT<trigger::TriggerEvent> triggerSummaryToken_;
0081 
0082   // helper class to store the data
0083   class PathInfo {
0084     PathInfo() : pathIndex_(-1), pathName_("unset"), objectType_(-1){};
0085 
0086   public:
0087     void setHistos(MonitorElement* const et,
0088                    MonitorElement* const eta,
0089                    MonitorElement* const phi,
0090                    MonitorElement* const etavsphi) {
0091       et_ = et;
0092       eta_ = eta;
0093       phi_ = phi;
0094       etavsphi_ = etavsphi;
0095     }
0096     MonitorElement* getEtHisto() { return et_; }
0097     MonitorElement* getEtaHisto() { return eta_; }
0098     MonitorElement* getPhiHisto() { return phi_; }
0099     MonitorElement* getEtaVsPhiHisto() { return etavsphi_; }
0100     const std::string getName(void) const { return pathName_; }
0101     ~PathInfo(){};
0102     PathInfo(std::string pathName, size_t type, float ptmin, float ptmax)
0103         : pathName_(pathName),
0104           objectType_(type),
0105           et_(nullptr),
0106           eta_(nullptr),
0107           phi_(nullptr),
0108           etavsphi_(nullptr),
0109           ptmin_(ptmin),
0110           ptmax_(ptmax){};
0111     PathInfo(std::string pathName,
0112              size_t type,
0113              MonitorElement* et,
0114              MonitorElement* eta,
0115              MonitorElement* phi,
0116              MonitorElement* etavsphi,
0117              float ptmin,
0118              float ptmax)
0119         : pathName_(pathName),
0120           objectType_(type),
0121           et_(et),
0122           eta_(eta),
0123           phi_(phi),
0124           etavsphi_(etavsphi),
0125           ptmin_(ptmin),
0126           ptmax_(ptmax){};
0127     bool operator==(const std::string v) { return v == pathName_; }
0128 
0129   private:
0130     int pathIndex_;
0131     std::string pathName_;
0132     int objectType_;
0133 
0134     // we don't own this data
0135     MonitorElement *et_, *eta_, *phi_, *etavsphi_;
0136 
0137     float ptmin_, ptmax_;
0138 
0139     const int index() { return pathIndex_; }
0140     const int type() { return objectType_; }
0141 
0142   public:
0143     float getPtMin() const { return ptmin_; }
0144     float getPtMax() const { return ptmax_; }
0145   };
0146 
0147   // simple collection - just
0148   class PathInfoCollection : public std::vector<PathInfo> {
0149   public:
0150     PathInfoCollection() : std::vector<PathInfo>(){};
0151     std::vector<PathInfo>::iterator find(std::string pathName) { return std::find(begin(), end(), pathName); }
0152   };
0153   PathInfoCollection hltPaths_;
0154 };
0155 #endif