CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EmDQM.h
Go to the documentation of this file.
1 #ifndef HLTriggerOffline_Egamma_EmDQM_H
2 #define HLTriggerOffline_Egamma_EmDQM_H
3 
4 
5 // Base Class Headers
30 #include "HepMC/GenParticle.h"
33 
34 #include <boost/regex.hpp>
35 #include <boost/lexical_cast.hpp>
36 #include <boost/foreach.hpp>
37 
38 #include "TDirectory.h"
39 #include "TFile.h"
40 #include "TH1F.h"
41 #include <memory>
42 #include <math.h>
43 #include <iostream>
44 #include <string>
45 #include <vector>
46 #include <Math/VectorUtil.h>
47 
48 class EmDQM;
49 
50 template <class T>
51 class HistoFiller {
52  public:
53  HistoFiller(EmDQM* d):dqm(d) {};
55 
56  void fillHistos(edm::Handle<trigger::TriggerEventWithRefs>& ,const edm::Event& ,unsigned int, unsigned int, std::vector<reco::Particle>&, bool & );
57  //std::vector<edm::EDGetTokenT<edm::AssociationMap<edm::OneToValue< T , float>>>> isoNameTokens_;
58 
59  private:
61 };
62 
63 class EmDQM : public DQMEDAnalyzer{
64 public:
65 
67  friend class HistoFiller<reco::RecoEcalCandidateCollection>;
68  friend class HistoFiller<l1extra::L1EmParticleCollection>;
69 
71  explicit EmDQM(const edm::ParameterSet& pset);
72 
74  ~EmDQM();
75 
76  // Operations
77 
78  void analyze(const edm::Event & event, const edm::EventSetup&);
79  void beginJob();
80  void endJob();
81 
82  void dqmBeginRun(edm::Run const&, edm::EventSetup const&);
83  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
84  void endRun(edm::Run const&, edm::EventSetup const&);
85 
86 private:
87  // interface to DQM framework
89 
90  HistoFiller<reco::ElectronCollection>* histoFillerEle;
91  HistoFiller<reco::RecoEcalCandidateCollection>* histoFillerClu;
92  HistoFiller<l1extra::L1EmParticleCollection>* histoFillerL1NonIso;
93  HistoFiller<reco::RecoEcalCandidateCollection>* histoFillerPho;
94  HistoFiller<l1extra::L1EmParticleCollection>* histoFillerL1Iso;
95 
96  // run in automatic configuration generation mode
98  // parameter set from config file
100  // global parameters
102  unsigned int verbosity_;
103  double genEtaAcc_;
104  double genEtAcc_;
105  bool isData_;
106  double ptMax_;
107  double ptMin_;
108  double etaMax_;
109  double phiMax_;
110  unsigned int nbins_;
111  unsigned int minEtForEtaEffPlot_;
116 
123  bool checkGeneratedParticlesRequirement(const edm::Event &event);
124 
129  bool checkRecoParticlesRequirement(const edm::Event & event);
130 
133 
134  // routines to build validation configuration from HLTConfiguration
135  int countSubstring(const std::string&, const std::string&);
136  std::vector<std::vector<std::string> > findEgammaPaths();
137  std::vector<std::string> getFilterModules(const std::string&);
138  double getPrimaryEtCut(const std::string&);
139  edm::ParameterSet makePSetForL1SeedFilter(const std::string&);
141  edm::ParameterSet makePSetForEtFilter(const std::string&);
148 
149  // set validation configuration parameters for a trigger path
150  void SetVarsFromPSet(std::vector<edm::ParameterSet>::iterator);
151 
152  // generated parameter set for trigger path
153  std::vector<edm::ParameterSet> paramSets;
154  // input from generated parameter set
155  unsigned int pathIndex;
156  std::vector<edm::InputTag> theHLTCollectionLabels;
157  unsigned int numOfHLTCollectionLabels; // Will be size of above vector
158  std::vector<std::string> theHLTCollectionHumanNames; // Human-readable names for the collections
160  std::vector<int> theHLTOutputTypes;
161  std::vector<bool> plotiso;
162  std::vector<std::vector<edm::InputTag> > isoNames; // there has to be a better solution
163  std::vector<std::pair<double,double> > plotBounds;
164  std::vector<unsigned int> nCandCuts;
165  // paramters for generator study
166  unsigned int reqNum;
167  int pdgGen;
168  // plotting parameters
169  double plotEtMin;
170  double plotPtMin ;
171  double plotPtMax ;
172 
180 
182  unsigned int gencut_;
183 
185  std::vector<std::set<std::string> > hltCollectionLabelsFoundPerPath;
186  std::set<std::string> hltCollectionLabelsFound;
187 
189  std::vector<std::set<std::string> > hltCollectionLabelsMissedPerPath;
190  std::set<std::string> hltCollectionLabelsMissed;
191 
192 
194  // Create Histogram containers
196  // Et & eta distributions
197  std::vector<std::vector<MonitorElement*> > etahists;
198  std::vector<std::vector<MonitorElement*> > phihists;
199  std::vector<std::vector<MonitorElement*> > ethists;
200  std::vector<std::vector<MonitorElement*> > etahistmatchs;
201  std::vector<std::vector<MonitorElement*> > phihistmatchs;
202  std::vector<std::vector<MonitorElement*> > ethistmatchs;
203  std::vector<std::vector<MonitorElement*> > histEtOfHltObjMatchToGens;
204  std::vector<std::vector<MonitorElement*> > histEtaOfHltObjMatchToGens;
205  std::vector<std::vector<MonitorElement*> > histPhiOfHltObjMatchToGens;
206  // Plots of efficiency per step
207  std::vector<MonitorElement*> totals;
208  std::vector<MonitorElement*> totalmatchs;
209  //generator histograms
210  std::vector<MonitorElement*> etgens;
211  std::vector<MonitorElement*> etagens;
212  std::vector<MonitorElement*> phigens;
213 
214  GreaterByPt<reco::Particle> pTComparator_;
215  GreaterByPt<reco::GenParticle> pTGenComparator_;
216 
217  // tokens for data access
218  edm::EDGetTokenT<edm::View<reco::Candidate> > genParticles_token;
219  edm::EDGetTokenT<trigger::TriggerEventWithRefs> triggerObject_token;
220  edm::EDGetTokenT<edm::TriggerResults> hltResults_token;
221  edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_fidWenu_token;
222  edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_fidZee_token;
223  edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_fidTripleEle_token;
224  edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_fidGammaJet_token;
225  edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_fidDiGamma_token;
226  edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_manualConf_token;
227 
228  // static variables
229  //
230  // trigger types considered
231  static const unsigned TYPE_SINGLE_ELE = 0;
232  static const unsigned TYPE_DOUBLE_ELE = 1;
233  static const unsigned TYPE_SINGLE_PHOTON = 2;
234  static const unsigned TYPE_DOUBLE_PHOTON = 3;
235  static const unsigned TYPE_TRIPLE_ELE = 4;
236 
237  // verbosity levels
238  static const unsigned OUTPUT_SILENT = 0;
239  static const unsigned OUTPUT_ERRORS = 1;
240  static const unsigned OUTPUT_WARNINGS = 2;
241  static const unsigned OUTPUT_ALL = 3;
242 };
243 #endif
edm::ParameterSet makePSetForEgammaGenericFilter(const std::string &)
Definition: EmDQM.cc:1321
double ptMax_
Definition: EmDQM.h:106
std::vector< MonitorElement * > totals
Definition: EmDQM.h:207
edm::ParameterSet makePSetForEgammaGenericQuadraticFilter(const std::string &)
Definition: EmDQM.cc:1399
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidZee_token
Definition: EmDQM.h:222
void fillHistos(edm::Handle< trigger::TriggerEventWithRefs > &, const edm::Event &, unsigned int, unsigned int, std::vector< reco::Particle > &, bool &)
Definition: EmDQM.cc:863
edm::EDGetTokenT< edm::View< reco::Candidate > > genParticles_token
Definition: EmDQM.h:218
void beginJob()
Definition: EmDQM.cc:66
std::vector< std::vector< MonitorElement * > > histEtOfHltObjMatchToGens
Definition: EmDQM.h:203
std::vector< std::vector< std::string > > findEgammaPaths()
Definition: EmDQM.cc:1081
bool checkRecoParticlesRequirement(const edm::Event &event)
Definition: EmDQM.cc:645
unsigned int numOfHLTCollectionLabels
Definition: EmDQM.h:157
std::vector< std::vector< MonitorElement * > > phihists
Definition: EmDQM.h:198
std::string dirname_
Definition: EmDQM.h:88
std::vector< std::set< std::string > > hltCollectionLabelsMissedPerPath
Definition: EmDQM.h:189
bool noPhiPlots_
Definition: EmDQM.h:114
static const unsigned OUTPUT_ALL
Definition: EmDQM.h:241
int pdgGen
Definition: EmDQM.h:167
std::set< std::string > hltCollectionLabelsFound
Definition: EmDQM.h:186
edm::InputTag theL1Seed
Definition: EmDQM.h:159
std::vector< std::vector< MonitorElement * > > histPhiOfHltObjMatchToGens
Definition: EmDQM.h:205
std::vector< std::set< std::string > > hltCollectionLabelsFoundPerPath
Definition: EmDQM.h:185
double phiMax_
Definition: EmDQM.h:109
HLTConfigProvider hltConfig_
The instance of the HLTConfigProvider as a data member.
Definition: EmDQM.h:132
HistoFiller(EmDQM *d)
Definition: EmDQM.h:53
edm::ParameterSet makePSetForOneOEMinusOneOPFilter(const std::string &)
Definition: EmDQM.cc:1270
static const unsigned TYPE_DOUBLE_PHOTON
Definition: EmDQM.h:234
edm::ParameterSet makePSetForElectronGenericFilter(const std::string &)
Definition: EmDQM.cc:1476
HistoFiller< reco::ElectronCollection > * histoFillerEle
Definition: EmDQM.h:90
double plotEtMin
Definition: EmDQM.h:169
Definition: EmDQM.h:63
std::vector< std::vector< MonitorElement * > > etahists
Definition: EmDQM.h:197
static const unsigned OUTPUT_ERRORS
Definition: EmDQM.h:239
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidWenu_token
Definition: EmDQM.h:221
EmDQM * dqm
Definition: EmDQM.h:60
GreaterByPt< reco::GenParticle > pTGenComparator_
Definition: EmDQM.h:215
std::vector< std::vector< edm::InputTag > > isoNames
Definition: EmDQM.h:162
edm::ParameterSet makePSetForL1SeedFilter(const std::string &)
Definition: EmDQM.cc:1180
std::vector< MonitorElement * > etagens
Definition: EmDQM.h:211
std::vector< std::vector< MonitorElement * > > ethists
Definition: EmDQM.h:199
std::vector< std::string > getFilterModules(const std::string &)
Definition: EmDQM.cc:1137
static const unsigned OUTPUT_SILENT
Definition: EmDQM.h:238
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQM.h:156
HistoFiller< l1extra::L1EmParticleCollection > * histoFillerL1Iso
Definition: EmDQM.h:94
HistoFiller< l1extra::L1EmParticleCollection > * histoFillerL1NonIso
Definition: EmDQM.h:92
std::vector< std::vector< MonitorElement * > > ethistmatchs
Definition: EmDQM.h:202
unsigned int gencut_
Definition: EmDQM.h:182
std::vector< unsigned int > nCandCuts
Definition: EmDQM.h:164
HistoFiller< reco::RecoEcalCandidateCollection > * histoFillerPho
Definition: EmDQM.h:93
edm::InputTag triggerObject_
Definition: EmDQM.h:101
void endRun(edm::Run const &, edm::EventSetup const &)
Definition: EmDQM.cc:1016
static const unsigned OUTPUT_WARNINGS
Definition: EmDQM.h:240
double plotPtMax
Definition: EmDQM.h:171
bool noIsolationPlots_
Definition: EmDQM.h:115
void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
Definition: EmDQM.cc:72
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidGammaJet_token
Definition: EmDQM.h:224
std::set< std::string > hltCollectionLabelsMissed
Definition: EmDQM.h:190
~HistoFiller()
Definition: EmDQM.h:54
std::vector< std::vector< MonitorElement * > > etahistmatchs
Definition: EmDQM.h:200
void SetVarsFromPSet(std::vector< edm::ParameterSet >::iterator)
Definition: EmDQM.cc:1542
const edm::ParameterSet & pset
Definition: EmDQM.h:99
double plotPtMin
Definition: EmDQM.h:170
edm::InputTag gencutCollection_
Definition: EmDQM.h:179
edm::ParameterSet makePSetForEgammaDoubleEtDeltaPhiFilter(const std::string &)
Definition: EmDQM.cc:1304
unsigned int nbins_
Definition: EmDQM.h:110
std::vector< std::vector< MonitorElement * > > phihistmatchs
Definition: EmDQM.h:201
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
bool isData_
Definition: EmDQM.h:105
static const unsigned TYPE_SINGLE_PHOTON
Definition: EmDQM.h:233
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidDiGamma_token
Definition: EmDQM.h:225
double ptMin_
Definition: EmDQM.h:107
bool checkGeneratedParticlesRequirement(const edm::Event &event)
Definition: EmDQM.cc:588
std::vector< edm::ParameterSet > paramSets
Definition: EmDQM.h:153
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidTripleEle_token
Definition: EmDQM.h:223
std::vector< std::vector< MonitorElement * > > histEtaOfHltObjMatchToGens
Definition: EmDQM.h:204
int countSubstring(const std::string &, const std::string &)
Definition: EmDQM.cc:1066
void analyze(const edm::Event &event, const edm::EventSetup &)
Definition: EmDQM.cc:706
double genEtAcc_
Definition: EmDQM.h:104
string const
Definition: compareJSON.py:14
bool autoConfMode_
Definition: EmDQM.h:97
static const unsigned TYPE_SINGLE_ELE
Definition: EmDQM.h:231
double getPrimaryEtCut(const std::string &)
Definition: EmDQM.cc:1162
edm::ParameterSet makePSetForL1SeedToSuperClusterMatchFilter(const std::string &)
Definition: EmDQM.cc:1231
unsigned int pathIndex
Definition: EmDQM.h:155
bool useHumanReadableHistTitles_
Definition: EmDQM.h:112
edm::EDGetTokenT< trigger::TriggerEventWithRefs > triggerObject_token
Definition: EmDQM.h:219
std::vector< MonitorElement * > totalmatchs
Definition: EmDQM.h:208
static const unsigned TYPE_DOUBLE_ELE
Definition: EmDQM.h:232
HistoFiller< reco::RecoEcalCandidateCollection > * histoFillerClu
Definition: EmDQM.h:91
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: EmDQM.cc:392
static const unsigned TYPE_TRIPLE_ELE
Definition: EmDQM.h:235
bool mcMatchedOnly_
Definition: EmDQM.h:113
std::vector< std::string > theHLTCollectionHumanNames
Definition: EmDQM.h:158
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_manualConf_token
Definition: EmDQM.h:226
GreaterByPt< reco::Particle > pTComparator_
Definition: EmDQM.h:214
std::vector< MonitorElement * > phigens
Definition: EmDQM.h:212
unsigned int verbosity_
Definition: EmDQM.h:102
double genEtaAcc_
Definition: EmDQM.h:103
void endJob()
Definition: EmDQM.cc:1059
std::vector< int > theHLTOutputTypes
Definition: EmDQM.h:160
unsigned int reqNum
Definition: EmDQM.h:166
edm::ParameterSet makePSetForEtFilter(const std::string &)
Definition: EmDQM.cc:1253
edm::ParameterSet makePSetForPixelMatchFilter(const std::string &)
Definition: EmDQM.cc:1287
unsigned int minEtForEtaEffPlot_
Definition: EmDQM.h:111
edm::EDGetTokenT< edm::TriggerResults > hltResults_token
Definition: EmDQM.h:220
double etaMax_
Definition: EmDQM.h:108
std::vector< std::pair< double, double > > plotBounds
Definition: EmDQM.h:163
std::vector< MonitorElement * > etgens
Definition: EmDQM.h:210
std::vector< bool > plotiso
Definition: EmDQM.h:161