CMS 3D CMS Logo

EmDQM.cc
Go to the documentation of this file.
1 // Header file for this //
5 
6 using namespace ROOT::Math::VectorUtil;
7 
9 // Constructor //
11 EmDQM::EmDQM(const edm::ParameterSet &pset_) : pset(pset_) {
12  // are we running in automatic configuration mode with the HLTConfigProvider
13  // or with a per path python config file
14  autoConfMode_ = pset.getUntrackedParameter<bool>("autoConfMode", false);
15 
16  // set global parameters
17  triggerObject_ = pset_.getParameter<edm::InputTag>("triggerobject");
18  verbosity_ = pset_.getUntrackedParameter<unsigned int>("verbosity", 0);
19  genEtaAcc_ = pset.getParameter<double>("genEtaAcc");
20  genEtAcc_ = pset.getParameter<double>("genEtAcc");
21  ptMax_ = pset.getUntrackedParameter<double>("PtMax", 1000.);
22  ptMin_ = pset.getUntrackedParameter<double>("PtMin", 0.);
23  etaMax_ = pset.getUntrackedParameter<double>("EtaMax", 2.7);
24  phiMax_ = pset.getUntrackedParameter<double>("PhiMax", 3.15);
25  nbins_ = pset.getUntrackedParameter<unsigned int>("Nbins", 40);
26  eta2DMax_ = pset.getUntrackedParameter<double>("Eta2DMax", 2.8);
27  phi2DMax_ = pset.getUntrackedParameter<double>("Phi2DMax", 3.2);
28  nbins2D_ = pset.getUntrackedParameter<unsigned int>("Nbins2D", 16);
29  minEtForEtaEffPlot_ = pset.getUntrackedParameter<unsigned int>("minEtForEtaEffPlot", 15);
30  useHumanReadableHistTitles_ = pset.getUntrackedParameter<bool>("useHumanReadableHistTitles", false);
31  mcMatchedOnly_ = pset.getUntrackedParameter<bool>("mcMatchedOnly", true);
32  noPhiPlots_ = pset.getUntrackedParameter<bool>("noPhiPlots", true);
33  noIsolationPlots_ = pset.getUntrackedParameter<bool>("noIsolationPlots", true);
34 
35  if (!autoConfMode_) {
36  paramSets.push_back(pset);
37  isData_ = false;
38  } else {
39  isData_ = pset.getParameter<bool>("isData");
40  }
41 
47 
48  // consumes
49  genParticles_token = consumes<edm::View<reco::Candidate>>(edm::InputTag("genParticles"));
50  triggerObject_token = consumes<trigger::TriggerEventWithRefs>(triggerObject_);
51  hltResults_token = consumes<edm::TriggerResults>(edm::InputTag("TriggerResults", "", triggerObject_.process()));
52  if (autoConfMode_) {
53  gencutColl_fidWenu_token = mayConsume<edm::View<reco::Candidate>>(edm::InputTag("fiducialWenu"));
54  gencutColl_fidZee_token = mayConsume<edm::View<reco::Candidate>>(edm::InputTag("fiducialZee"));
55  gencutColl_fidTripleEle_token = mayConsume<edm::View<reco::Candidate>>(edm::InputTag("fiducialTripleEle"));
56  gencutColl_fidGammaJet_token = mayConsume<edm::View<reco::Candidate>>(edm::InputTag("fiducialGammaJet"));
57  gencutColl_fidDiGamma_token = mayConsume<edm::View<reco::Candidate>>(edm::InputTag("fiducialDiGamma"));
58  } else {
60  consumes<edm::View<reco::Candidate>>(pset.getParameter<edm::InputTag>("cutcollection"));
61  }
62 }
63 
64 void EmDQM::dqmBeginRun(edm::Run const &iRun, edm::EventSetup const &iSetup) {
65  bool changed(true);
66  if (hltConfig_.init(iRun, iSetup, triggerObject_.process(), changed)) {
67  // if init returns TRUE, initialisation has succeeded!
68 
69  if (autoConfMode_) {
70  if (verbosity_ >= OUTPUT_ALL) {
71  // Output general information on the menu
72  edm::LogPrint("EmDQM") << "inited=" << hltConfig_.inited();
73  edm::LogPrint("EmDQM") << "changed=" << hltConfig_.changed();
74  edm::LogPrint("EmDQM") << "processName=" << hltConfig_.processName();
75  edm::LogPrint("EmDQM") << "tableName=" << hltConfig_.tableName();
76  edm::LogPrint("EmDQM") << "size=" << hltConfig_.size();
77  edm::LogInfo("EmDQM") << "The following filter types are not analyzed: \n"
78  << "\tHLTGlobalSumsMET\n"
79  << "\tHLTHtMhtFilter\n"
80  << "\tHLTMhtFilter\n"
81  << "\tHLTJetTag\n"
82  << "\tHLT1CaloJet\n"
83  << "\tHLT1CaloMET\n"
84  << "\tHLT1CaloBJet\n"
85  << "\tHLT1Tau\n"
86  << "\tHLT1PFTau\n"
87  << "\tPFTauSelector\n"
88  << "\tHLT1PFJet\n"
89  << "\tHLTPFJetCollectionsFilter\n"
90  << "\tHLTPFJetCollectionsVBFFilter\n"
91  << "\tHLTPFJetTag\n"
92  << "\tEtMinCaloJetSelector\n"
93  << "\tEtMinPFJetSelector\n"
94  << "\tLargestEtCaloJetSelector\n"
95  << "\tLargestEtPFJetSelector\n"
96  << "\tHLTEgammaTriggerFilterObjectWrapper\n"
97  << "\tHLTEgammaDoubleLegCombFilter\n"
98  << "\tHLT2ElectronTau\n"
99  << "\tHLT2ElectronMET\n"
100  << "\tHLT2ElectronPFTau\n"
101  << "\tHLTPMMassFilter\n"
102  << "\tHLTHcalTowerFilter\n"
103  << "\tHLT1Photon\n"
104  << "\tHLTRFilter\n"
105  << "\tHLTRHemisphere\n"
106  << "\tHLTElectronPFMTFilter\n"
107  << "\tPrimaryVertexObjectFilter\n"
108  << "\tHLTEgammaAllCombMassFilter\n"
109  << "\tHLTMuon*\n";
110  }
111 
112  // All electron and photon paths
113  std::vector<std::vector<std::string>> egammaPaths = findEgammaPaths();
114  // std::cout << "Found " << egammaPaths[TYPE_SINGLE_ELE].size() << "
115  // single electron paths" << std::endl; std::cout << "Found " <<
116  // egammaPaths[TYPE_DOUBLE_ELE].size() << " double electron paths" <<
117  // std::endl; std::cout << "Found " << egammaPaths[TYPE_TRIPLE_ELE].size()
118  // << " triple electron paths" << std::endl; std::cout << "Found " <<
119  // egammaPaths[TYPE_SINGLE_PHOTON].size() << " single photon paths" <<
120  // std::endl; std::cout << "Found " <<
121  // egammaPaths[TYPE_DOUBLE_PHOTON].size() << " double photon paths" <<
122  // std::endl;
123 
124  std::vector<std::string> filterModules;
125 
126  for (unsigned int j = 0; j < egammaPaths.size(); j++) {
127  if (verbosity_ >= OUTPUT_ALL) {
128  switch (j) {
129  case TYPE_SINGLE_ELE:
130  edm::LogPrint("EmDQM") << "////////////////////////////////////////"
131  "/\nSingle electron paths: ";
132  break;
133  case TYPE_DOUBLE_ELE:
134  edm::LogPrint("EmDQM") << "////////////////////////////////////////"
135  "/\nDouble electron paths: ";
136  break;
137  case TYPE_TRIPLE_ELE:
138  edm::LogPrint("EmDQM") << "////////////////////////////////////////"
139  "/\nTriple electron paths: ";
140  break;
141  case TYPE_SINGLE_PHOTON:
142  edm::LogPrint("EmDQM") << "////////////////////////////////////////"
143  "/\nSingle photon paths: ";
144  break;
145  case TYPE_DOUBLE_PHOTON:
146  edm::LogPrint("EmDQM") << "////////////////////////////////////////"
147  "/\nDouble photon paths: ";
148  break;
149  }
150  }
151 
152  for (unsigned int i = 0; i < egammaPaths.at(j).size(); i++) {
153  // get pathname of this trigger
154  const std::string pathName = egammaPaths.at(j).at(i);
155  if (verbosity_ >= OUTPUT_ALL)
156  edm::LogPrint("EmDQM") << "Path: " << pathName;
157 
158  // get filters of the current path
159  filterModules = getFilterModules(pathName);
160 
161  //--------------------
162  edm::ParameterSet paramSet;
163 
164  paramSet.addUntrackedParameter("pathIndex", hltConfig_.triggerIndex(pathName));
165  paramSet.addParameter("@module_label", hltConfig_.removeVersion(pathName) + "_DQM");
166  // paramSet.addParameter("@module_label", pathName + "_DQM");
167 
168  // plotting parameters (untracked because they don't affect the
169  // physics)
170  double genEtMin = getPrimaryEtCut(pathName);
171  if (genEtMin >= 0) {
172  paramSet.addUntrackedParameter("genEtMin", genEtMin);
173  } else {
175  edm::LogWarning("EmDQM") << "Pathname: '" << pathName
176  << "': Unable to determine a minimum Et. Will not include "
177  "this path in the validation.";
178  continue;
179  }
180 
181  // set the x axis of the et plots to some reasonable value based
182  // on the primary et cut determined from the path name
183  double ptMax = ptMax_;
184  double ptMin = ptMin_;
185  if (ptMax < (1.2 * genEtMin)) {
186  paramSet.addUntrackedParameter<double>("PtMax", (10 * ceil(0.12 * genEtMin)));
187  paramSet.addUntrackedParameter<double>("PtMin", (10 * ceil(0.12 * genEtMin) - ptMax + ptMin));
188  } else {
189  paramSet.addUntrackedParameter<double>("PtMax", ptMax);
190  paramSet.addUntrackedParameter<double>("PtMin", ptMin);
191  }
192 
193  // preselction cuts
194  switch (j) {
195  case TYPE_SINGLE_ELE:
196  paramSet.addParameter<unsigned>("reqNum", 1);
197  paramSet.addParameter<int>("pdgGen", 11);
198  paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialWenu"));
199  paramSet.addParameter<int>("cutnum", 1);
200  break;
201  case TYPE_DOUBLE_ELE:
202  paramSet.addParameter<unsigned>("reqNum", 2);
203  paramSet.addParameter<int>("pdgGen", 11);
204  paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialZee"));
205  paramSet.addParameter<int>("cutnum", 2);
206  break;
207  case TYPE_TRIPLE_ELE:
208  paramSet.addParameter<unsigned>("reqNum", 3);
209  paramSet.addParameter<int>("pdgGen", 11);
210  paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialTripleEle"));
211  paramSet.addParameter<int>("cutnum", 3);
212  break;
213  case TYPE_SINGLE_PHOTON:
214  paramSet.addParameter<unsigned>("reqNum", 1);
215  paramSet.addParameter<int>("pdgGen", 22);
216  paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialGammaJet"));
217  paramSet.addParameter<int>("cutnum", 1);
218  break;
219  case TYPE_DOUBLE_PHOTON:
220  paramSet.addParameter<unsigned>("reqNum", 2);
221  paramSet.addParameter<int>("pdgGen", 22);
222  paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialDiGamma"));
223  paramSet.addParameter<int>("cutnum", 2);
224  }
225  //--------------------
226 
227  // TODO: extend this
228  if (isData_)
229  paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("gsfElectrons"));
230 
231  std::vector<edm::ParameterSet> filterVPSet;
232  edm::ParameterSet filterPSet;
233  std::string moduleLabel;
234 
235  // loop over filtermodules of current trigger path
236  for (std::vector<std::string>::iterator filter = filterModules.begin(); filter != filterModules.end();
237  ++filter) {
238  std::string moduleType = hltConfig_.modulePSet(*filter).getParameter<std::string>("@module_type");
239  moduleLabel = hltConfig_.modulePSet(*filter).getParameter<std::string>("@module_label");
240 
241  // first check if it is a filter we are not interrested in
242  if (moduleType == "Pythia6GeneratorFilter" || moduleType == "HLTTriggerTypeFilter" ||
243  moduleType == "HLTLevel1Activity" || moduleType == "HLTPrescaler" || moduleType == "HLTBool")
244  continue;
245 
246  // now check for the known filter types
247  if (moduleType == "HLTLevel1GTSeed") {
248  filterPSet = makePSetForL1SeedFilter(moduleLabel);
249  } else if (moduleType == "HLTEgammaL1MatchFilterRegional") {
250  filterPSet = makePSetForL1SeedToSuperClusterMatchFilter(moduleLabel);
251  } else if (moduleType == "HLTEgammaEtFilter") {
252  filterPSet = makePSetForEtFilter(moduleLabel);
253  } else if (moduleType == "HLTElectronOneOEMinusOneOPFilterRegional") {
254  filterPSet = makePSetForOneOEMinusOneOPFilter(moduleLabel);
255  } else if (moduleType == "HLTElectronPixelMatchFilter") {
256  filterPSet = makePSetForPixelMatchFilter(moduleLabel);
257  } else if (moduleType == "HLTEgammaGenericFilter") {
258  filterPSet = makePSetForEgammaGenericFilter(moduleLabel);
259  } else if (moduleType == "HLTEgammaGenericQuadraticFilter") {
260  filterPSet = makePSetForEgammaGenericQuadraticFilter(moduleLabel);
261  } else if (moduleType == "HLTElectronGenericFilter") {
262  filterPSet = makePSetForElectronGenericFilter(moduleLabel);
263  } else if (moduleType == "HLTEgammaDoubleEtDeltaPhiFilter") {
264  filterPSet = makePSetForEgammaDoubleEtDeltaPhiFilter(moduleLabel);
265  } else if (moduleType == "HLTGlobalSumsMET" || moduleType == "HLTHtMhtFilter" ||
266  moduleType == "HLTMhtFilter" || moduleType == "HLTJetTag" || moduleType == "HLT1CaloJet" ||
267  moduleType == "HLT1CaloMET" || moduleType == "HLT1CaloBJet" || moduleType == "HLT1Tau" ||
268  moduleType == "HLT1PFTau" || moduleType == "PFTauSelector" || moduleType == "HLT1PFJet" ||
269  moduleType == "HLTPFJetCollectionsFilter" || moduleType == "HLTPFJetCollectionsVBFFilter" ||
270  moduleType == "HLTPFJetTag" || moduleType == "EtMinCaloJetSelector" ||
271  moduleType == "EtMinPFJetSelector" || moduleType == "LargestEtCaloJetSelector" ||
272  moduleType == "LargestEtPFJetSelector" ||
273  moduleType == "HLTEgammaTriggerFilterObjectWrapper" // 'fake' filter
274  || moduleType == "HLTEgammaDoubleLegCombFilter" // filter does not put
275  // anything in
276  // TriggerEventWithRefs
277  || moduleType == "HLT2ElectronMET" || moduleType == "HLT2ElectronTau" ||
278  moduleType == "HLT2ElectronPFTau" || moduleType == "HLTPMMassFilter" ||
279  moduleType == "HLTHcalTowerFilter" || moduleType == "HLT1Photon" || moduleType == "HLTRFilter" ||
280  moduleType == "HLTRHemisphere" || moduleType == "HLTElectronPFMTFilter" ||
281  moduleType == "PrimaryVertexObjectFilter" || moduleType == "HLTEgammaAllCombMassFilter" ||
282  moduleType.find("HLTMuon") != std::string::npos)
283  continue;
284  else {
286  edm::LogWarning("EmDQM") << "No parameter set for filter '" << moduleLabel << "' with filter type '"
287  << moduleType << "' added. Module will not be analyzed.";
288  continue;
289  }
290 
291  // something went wrong when the parameter set is empty.
292  if (!filterPSet.empty()) {
293  if (!hltConfig_.modulePSet(moduleLabel).exists("saveTags")) {
294  // make sure that 'theHLTOutputTypes' before an unseeded filter
295  // in a photon path is set to trigger::TriggerPhoton this is
296  // coupled to the parameter 'saveTag = true'
297  if (moduleLabel.find("Unseeded") != std::string::npos &&
298  (j == TYPE_DOUBLE_PHOTON || j == TYPE_SINGLE_PHOTON)) {
299  filterVPSet.back().addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);
300  }
301  }
302  // if ncandcut is -1 (when parsing for the number of particles in
303  // the name of the L1seed filter fails), fall back to setting
304  // ncandcut to the number of particles needed for the given path.
305  if (filterPSet.getParameter<int>("ncandcut") < 0) {
306  edm::LogPrint("EmDQM") << "No number of candidates for filter " << moduleLabel << " found. Set to "
307  << paramSet.getParameter<int>("cutnum") << ", determined from path name.";
308  filterPSet.addParameter<int>("ncandcut", paramSet.getParameter<int>("cutnum"));
309  } else if (filterPSet.getParameter<int>("ncandcut") > paramSet.getParameter<int>("cutnum")) {
310  edm::LogInfo("EmDQM") << "Changed required number of candidates from "
311  << paramSet.getParameter<int>("cutnum") << " to "
312  << filterPSet.getParameter<int>("ncandcut") << " for filter " << moduleLabel;
313  paramSet.addParameter<int>("cutnum", filterPSet.getParameter<int>("ncandcut"));
314  paramSet.addParameter<unsigned>("reqNum", (unsigned)filterPSet.getParameter<int>("ncandcut"));
315  }
316 
317  filterVPSet.push_back(filterPSet);
318  } else
319  break;
320 
321  } // end loop over filter modules of current trigger path
322 
323  // do not include this path when an empty filterPSet is detected.
324  if (!filterPSet.empty()) {
325  std::string lastModuleName = filterPSet.getParameter<edm::InputTag>("HLTCollectionLabels").label();
326  if (!hltConfig_.modulePSet(lastModuleName).exists("saveTags")) {
327  // make sure that 'theHLTOutputTypes' of the last filter of a
328  // photon path is set to trigger::TriggerPhoton this is coupled to
329  // the parameter 'saveTag = true'
330  if ((j == TYPE_SINGLE_PHOTON || j == TYPE_DOUBLE_PHOTON) && pathName.rfind("Ele") == std::string::npos) {
331  filterVPSet.back().addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);
332  }
333  }
334  paramSet.addParameter<std::vector<edm::ParameterSet>>("filters", filterVPSet);
335  } else {
336  if (verbosity_ >= OUTPUT_ALL)
337  edm::LogPrint("EmDQM") << "Will not include this path in the validation due to "
338  "errors while generating the parameter set.";
339  continue;
340  }
341 
342  // dump generated parameter set
343  // std::cout << paramSet.dump() << std::endl;
344 
345  paramSets.push_back(paramSet);
346  } // loop over all paths of this analysis type
347 
348  } // loop over analysis types (single ele etc.)
349  }
350 
353 
355  // loop over all the trigger path parameter sets
357  for (std::vector<edm::ParameterSet>::iterator psetIt = paramSets.begin(); psetIt != paramSets.end(); ++psetIt) {
360  }
361 
362  if (changed) {
363  // The HLT config has actually changed wrt the previous Run, hence rebook
364  // your histograms or do anything else dependent on the revised HLT config
365  }
366  } else {
367  // if init returns FALSE, initialisation has NOT succeeded, which indicates
368  // a problem with the file and/or code and needs to be investigated!
369  if (verbosity_ >= OUTPUT_ERRORS)
370  edm::LogError("EmDQM") << " HLT config extraction failure with process name '" << triggerObject_.process()
371  << "'.";
372  // In this case, all access methods will return empty values!
373  }
374 }
375 
376 void EmDQM::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &iRun, edm::EventSetup const &iSetup) {
378  // loop over all the trigger path parameter sets
380  for (std::vector<edm::ParameterSet>::iterator psetIt = paramSets.begin(); psetIt != paramSets.end(); ++psetIt) {
381  SetVarsFromPSet(psetIt);
382 
383  iBooker.setCurrentFolder(dirname_);
384 
386  // Set up Histogram of Effiency vs Step. //
387  // theHLTCollectionLabels is a vector of InputTags //
388  // from the configuration file. //
390  // Et & eta distributions
391  std::vector<MonitorElement *> etahist;
392  std::vector<MonitorElement *> phihist;
393  std::vector<MonitorElement *> ethist;
394  std::vector<MonitorElement *> etahistmatch;
395  std::vector<MonitorElement *> phihistmatch;
396  std::vector<MonitorElement *> ethistmatch;
397  std::vector<MonitorElement *> histEtOfHltObjMatchToGen;
398  std::vector<MonitorElement *> histEtaOfHltObjMatchToGen;
399  std::vector<MonitorElement *> histPhiOfHltObjMatchToGen;
400  std::vector<MonitorElement *> etaphihist;
401  std::vector<MonitorElement *> etaphihistmatch;
402  std::vector<MonitorElement *> histEtaPhiOfHltObjMatchToGen;
403  // Plots of efficiency per step
405  MonitorElement *totalmatch;
406  // generator histograms
407  MonitorElement *etgen;
408  MonitorElement *etagen;
409  MonitorElement *phigen;
410  MonitorElement *etaphigen;
411 
412  std::string histName = "total_eff";
413  std::string histTitle = "total events passing";
414  if (!mcMatchedOnly_) {
415  // This plot will have bins equal to 2+(number of
416  // HLTCollectionLabels in the config file)
417  total = iBooker.book1D(
418  histName.c_str(), histTitle.c_str(), numOfHLTCollectionLabels + 2, 0, numOfHLTCollectionLabels + 2);
419  total->setBinLabel(numOfHLTCollectionLabels + 1, "Total");
420  total->setBinLabel(numOfHLTCollectionLabels + 2, "Gen");
421  for (unsigned int u = 0; u < numOfHLTCollectionLabels; u++) {
422  total->setBinLabel(u + 1, theHLTCollectionLabels[u].label());
423  }
424  }
425 
426  histName = "total_eff_MC_matched";
427  histTitle = "total events passing (mc matched)";
428  totalmatch = iBooker.book1D(
429  histName.c_str(), histTitle.c_str(), numOfHLTCollectionLabels + 2, 0, numOfHLTCollectionLabels + 2);
430  totalmatch->setBinLabel(numOfHLTCollectionLabels + 1, "Total");
431  totalmatch->setBinLabel(numOfHLTCollectionLabels + 2, "Gen");
432  for (unsigned int u = 0; u < numOfHLTCollectionLabels; u++) {
433  totalmatch->setBinLabel(u + 1, theHLTCollectionLabels[u].label());
434  }
435 
436  MonitorElement *tmphisto;
437  // MonitorElement* tmpiso;
438 
440  // Set up generator-level histograms //
442  std::string pdgIdString;
443  switch (pdgGen) {
444  case 11:
445  pdgIdString = "Electron";
446  break;
447  case 22:
448  pdgIdString = "Photon";
449  break;
450  default:
451  pdgIdString = "Particle";
452  }
453 
454  histName = "gen_et";
455  histTitle = "E_{T} of " + pdgIdString + "s";
456  etgen = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, plotPtMin, plotPtMax);
457  histName = "gen_eta";
458  histTitle = "#eta of " + pdgIdString + "s ";
459  etagen = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, -etaMax_, etaMax_);
460  histName = "gen_phi";
461  histTitle = "#phi of " + pdgIdString + "s ";
462  if (!noPhiPlots_)
463  phigen = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, -phiMax_, phiMax_);
464  histName = "gen_etaphi";
465  histTitle = "#eta-#phi of " + pdgIdString + "s ";
466  etaphigen = iBooker.book2D(
467  histName.c_str(), histTitle.c_str(), nbins2D_ - 2, -eta2DMax_, eta2DMax_, nbins2D_, -phi2DMax_, phi2DMax_);
469  // Set up histograms of HLT objects //
471  // Determine what strings to use for histogram titles
472  std::vector<std::string> HltHistTitle;
473  if (theHLTCollectionHumanNames.size() == numOfHLTCollectionLabels && useHumanReadableHistTitles_) {
474  HltHistTitle = theHLTCollectionHumanNames;
475  } else {
476  for (unsigned int i = 0; i < numOfHLTCollectionLabels; i++) {
477  HltHistTitle.push_back(theHLTCollectionLabels[i].label());
478  }
479  }
480 
481  for (unsigned int i = 0; i < numOfHLTCollectionLabels; i++) {
482  if (!mcMatchedOnly_) {
483  // Et distribution of HLT objects passing filter i
484  histName = theHLTCollectionLabels[i].label() + "et_all";
485  histTitle = HltHistTitle[i] + " Et (ALL)";
486  tmphisto = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, plotPtMin, plotPtMax);
487  ethist.push_back(tmphisto);
488 
489  // Eta distribution of HLT objects passing filter i
490  histName = theHLTCollectionLabels[i].label() + "eta_all";
491  histTitle = HltHistTitle[i] + " #eta (ALL)";
492  tmphisto = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, -etaMax_, etaMax_);
493  etahist.push_back(tmphisto);
494 
495  if (!noPhiPlots_) {
496  // Phi distribution of HLT objects passing filter i
497  histName = theHLTCollectionLabels[i].label() + "phi_all";
498  histTitle = HltHistTitle[i] + " #phi (ALL)";
499  tmphisto = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, -phiMax_, phiMax_);
500  phihist.push_back(tmphisto);
501  }
502 
503  histName = theHLTCollectionLabels[i].label() + "etaphi_all";
504  histTitle = HltHistTitle[i] + " #eta-#phi (ALL)";
505  tmphisto = iBooker.book2D(
506  histName.c_str(), histTitle.c_str(), nbins2D_ - 2, -eta2DMax_, eta2DMax_, nbins2D_, -phi2DMax_, phi2DMax_);
507  etaphihist.push_back(tmphisto);
508 
509  // Et distribution of HLT object that is closest delta-R match to sorted
510  // gen particle(s)
511  histName = theHLTCollectionLabels[i].label() + "et";
512  histTitle = HltHistTitle[i] + " Et";
513  tmphisto = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, plotPtMin, plotPtMax);
514  histEtOfHltObjMatchToGen.push_back(tmphisto);
515 
516  // eta distribution of HLT object that is closest delta-R match to
517  // sorted gen particle(s)
518  histName = theHLTCollectionLabels[i].label() + "eta";
519  histTitle = HltHistTitle[i] + " eta";
520  tmphisto = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, -etaMax_, etaMax_);
521  histEtaOfHltObjMatchToGen.push_back(tmphisto);
522 
523  if (!noPhiPlots_) {
524  // phi distribution of HLT object that is closest delta-R match to
525  // sorted gen particle(s)
526  histName = theHLTCollectionLabels[i].label() + "phi";
527  histTitle = HltHistTitle[i] + " phi";
528  tmphisto = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, -phiMax_, phiMax_);
529  histPhiOfHltObjMatchToGen.push_back(tmphisto);
530  }
531 
532  histName = theHLTCollectionLabels[i].label() + "etaphi";
533  histTitle = HltHistTitle[i] + " eta-phi";
534  tmphisto = iBooker.book2D(
535  histName.c_str(), histTitle.c_str(), nbins2D_ - 2, -eta2DMax_, eta2DMax_, nbins2D_, -phi2DMax_, phi2DMax_);
536  histEtaPhiOfHltObjMatchToGen.push_back(tmphisto);
537  }
538 
539  // Et distribution of gen object matching HLT object passing filter i
540  histName = theHLTCollectionLabels[i].label() + "et_MC_matched";
541  histTitle = HltHistTitle[i] + " Et (MC matched)";
542  tmphisto = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, plotPtMin, plotPtMax);
543  ethistmatch.push_back(tmphisto);
544 
545  // Eta distribution of gen object matching HLT object passing filter i
546  histName = theHLTCollectionLabels[i].label() + "eta_MC_matched";
547  histTitle = HltHistTitle[i] + " #eta (MC matched)";
548  tmphisto = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, -etaMax_, etaMax_);
549  etahistmatch.push_back(tmphisto);
550 
551  if (!noPhiPlots_) {
552  // Phi distribution of gen object matching HLT object passing filter i
553  histName = theHLTCollectionLabels[i].label() + "phi_MC_matched";
554  histTitle = HltHistTitle[i] + " #phi (MC matched)";
555  tmphisto = iBooker.book1D(histName.c_str(), histTitle.c_str(), nbins_, -phiMax_, phiMax_);
556  phihistmatch.push_back(tmphisto);
557  }
558 
559  histName = theHLTCollectionLabels[i].label() + "etaphi_MC_matched";
560  histTitle = HltHistTitle[i] + " #eta-#phi (MC matched)";
561  tmphisto = iBooker.book2D(
562  histName.c_str(), histTitle.c_str(), nbins2D_ - 2, -eta2DMax_, eta2DMax_, nbins2D_, -phi2DMax_, phi2DMax_);
563  etaphihistmatch.push_back(tmphisto);
564  }
565 
566  // Et & eta distributions
567  etahists.push_back(etahist);
568  phihists.push_back(phihist);
569  ethists.push_back(ethist);
570  etahistmatchs.push_back(etahistmatch);
571  phihistmatchs.push_back(phihistmatch);
572  ethistmatchs.push_back(ethistmatch);
573  histEtOfHltObjMatchToGens.push_back(histEtOfHltObjMatchToGen);
574  histEtaOfHltObjMatchToGens.push_back(histEtaOfHltObjMatchToGen);
575  histPhiOfHltObjMatchToGens.push_back(histPhiOfHltObjMatchToGen);
576  etaphihists.push_back(etaphihist);
577  etaphihistmatchs.push_back(etaphihistmatch);
578  histEtaPhiOfHltObjMatchToGens.push_back(histEtaPhiOfHltObjMatchToGen);
579  // commented out because uses data not included in HTLDEBUG and uses
580  // Isolation distributions
581  // etahistisos.push_back(etahistiso);
582  // phihistisos.push_back(phihistiso);
583  // ethistisos.push_back(ethistiso);
584  // etahistisomatchs.push_back(etahistisomatch);
585  // phihistisomatchs.push_back(phihistisomatch);
586  // ethistisomatchs.push_back(ethistisomatch);
587  // histEtIsoOfHltObjMatchToGens.push_back(histEtIsoOfHltObjMatchToGen);
588  // histEtaIsoOfHltObjMatchToGens.push_back(histEtaIsoOfHltObjMatchToGen);
589  // histPhiIsoOfHltObjMatchToGens.push_back(histPhiIsoOfHltObjMatchToGen);
590 
591  totals.push_back(total);
592  totalmatchs.push_back(totalmatch);
593  etgens.push_back(etgen);
594  etagens.push_back(etagen);
595  phigens.push_back(phigen);
596  etaphigens.push_back(etaphigen);
597  }
598 }
599 
601 // Destructor //
605 
608  // Decide if this was an event of interest. //
609  // Did the highest energy particles happen //
610  // to have |eta| < 2.5 ? Then continue. //
613  event.getByToken(genParticles_token, genParticles);
614  if (!genParticles.isValid()) {
616  edm::LogWarning("EmDQM") << "genParticles invalid.";
617  return false;
618  }
619 
620  std::vector<reco::LeafCandidate> allSortedGenParticles;
621 
622  for (edm::View<reco::Candidate>::const_iterator currentGenParticle = genParticles->begin();
623  currentGenParticle != genParticles->end();
624  currentGenParticle++) {
625  // TODO: do we need to check the states here again ?
626  // in principle, there should collections produced with the python
627  // configuration (other than 'genParticles') which fulfill these criteria
628  if (!(abs((*currentGenParticle).pdgId()) == pdgGen && (*currentGenParticle).status() == 1 &&
629  (*currentGenParticle).et() > 2.0))
630  continue;
631 
632  reco::LeafCandidate tmpcand(*(currentGenParticle));
633 
634  if (tmpcand.et() < plotEtMin)
635  continue;
636 
637  allSortedGenParticles.push_back(tmpcand);
638  }
639 
640  std::sort(allSortedGenParticles.begin(), allSortedGenParticles.end(), pTGenComparator_);
641 
642  // return false if not enough particles found
643  if (allSortedGenParticles.size() < gencut_)
644  return false;
645 
646  // additional check (this might be legacy code and we need to check
647  // whether this should not be removed ?)
648 
649  // We now have a sorted collection of all generated particles
650  // with pdgId = pdgGen.
651  // Loop over them to see if the top gen particles have eta within acceptance
652  // bool keepEvent = true;
653  for (unsigned int i = 0; i < gencut_; i++) {
654  bool inECALgap = fabs(allSortedGenParticles[i].eta()) > 1.4442 && fabs(allSortedGenParticles[i].eta()) < 1.556;
655  if ((fabs(allSortedGenParticles[i].eta()) > genEtaAcc_) || inECALgap) {
656  // edm::LogWarning("EmDQM") << "Throwing event away. Gen particle with
657  // pdgId="<< allSortedGenParticles[i].pdgId() <<"; et="<<
658  // allSortedGenParticles[i].et() <<"; and eta="<<
659  // allSortedGenParticles[i].eta() <<" beyond acceptance.";
660  return false;
661  }
662  }
663 
664  // all tests passed
665  return true;
666 }
668 
670  // note that this code is very similar to the one in
671  // checkGeneratedParticlesRequirement(..) and hopefully can be merged with it
672  // at some point in the future
673 
674  edm::Handle<edm::View<reco::Candidate>> referenceParticles;
675  // get the right data according to the trigger path currently looked at
676  if (autoConfMode_) {
677  switch (reqNum) {
678  case 1:
679  if (pdgGen == 11)
680  event.getByToken(gencutColl_fidWenu_token, referenceParticles);
681  else
682  event.getByToken(gencutColl_fidGammaJet_token, referenceParticles);
683  break;
684  case 2:
685  if (pdgGen == 11)
686  event.getByToken(gencutColl_fidZee_token, referenceParticles);
687  else
688  event.getByToken(gencutColl_fidDiGamma_token, referenceParticles);
689  break;
690  case 3:
691  event.getByToken(gencutColl_fidTripleEle_token, referenceParticles);
692  break;
693  }
694  } else {
695  event.getByToken(gencutColl_manualConf_token, referenceParticles);
696  }
697  if (!referenceParticles.isValid()) {
699  edm::LogWarning("EmDQM") << "referenceParticles invalid.";
700  return false;
701  }
702 
703  std::vector<const reco::Candidate *> allSortedReferenceParticles;
704 
705  for (edm::View<reco::Candidate>::const_iterator currentReferenceParticle = referenceParticles->begin();
706  currentReferenceParticle != referenceParticles->end();
707  currentReferenceParticle++) {
708  if (currentReferenceParticle->et() <= 2.0)
709  continue;
710 
711  // Note that for determining the overall efficiency,
712  // we should only allow
713  //
714  // HOWEVER: for turn-on curves, we need to let
715  // more electrons pass
716  if (currentReferenceParticle->et() < plotEtMin)
717  continue;
718 
719  // TODO: instead of filling a new vector we could simply count here...
720  allSortedReferenceParticles.push_back(&(*currentReferenceParticle));
721  }
722 
723  // std::sort(allSortedReferenceParticles.begin(),
724  // allSortedReferenceParticles.end(),pTComparator_);
725 
726  // return false if not enough particles found
727  return allSortedReferenceParticles.size() >= gencut_;
728 }
729 
731 // method called to for each event //
734  // loop over all the trigger path parameter sets
735  unsigned int vPos = 0;
736  for (std::vector<edm::ParameterSet>::iterator psetIt = paramSets.begin(); psetIt != paramSets.end();
737  ++psetIt, ++vPos) {
738  SetVarsFromPSet(psetIt);
739  // get the set forthe current path
742 
744  // Check if there's enough gen particles //
745  // of interest //
747  // get the right data according to the trigger path currently looked at
749  if (autoConfMode_) {
750  switch (reqNum) {
751  case 1:
752  if (pdgGen == 11)
753  event.getByToken(gencutColl_fidWenu_token, cutCounter);
754  else
755  event.getByToken(gencutColl_fidGammaJet_token, cutCounter);
756  break;
757  case 2:
758  if (pdgGen == 11)
759  event.getByToken(gencutColl_fidZee_token, cutCounter);
760  else
761  event.getByToken(gencutColl_fidDiGamma_token, cutCounter);
762  break;
763  case 3:
764  event.getByToken(gencutColl_fidTripleEle_token, cutCounter);
765  break;
766  }
767  } else {
768  event.getByToken(gencutColl_manualConf_token, cutCounter);
769  }
770  if (cutCounter->size() < (unsigned int)gencut_) {
771  // edm::LogWarning("EmDQM") << "Less than "<< gencut_ <<" gen particles
772  // with pdgId=" << pdgGen;
773  continue;
774  }
775 
776  // fill L1 and HLT info
777  // get objects possed by each filter
779  event.getByToken(triggerObject_token, triggerObj);
780  if (!triggerObj.isValid()) {
782  edm::LogWarning("EmDQM") << "parameter triggerobject (" << triggerObject_
783  << ") does not corresond to a valid TriggerEventWithRefs product. "
784  "Please check especially the process name (e.g. when running "
785  "over reprocessed datasets)";
786  continue;
787  }
788 
789  // Were enough high energy gen particles found?
790  if (event.isRealData()) {
791  // running validation on data.
792  // TODO: we should check that the entire
793  // run is on the same type (all data or
794  // all MC). Otherwise one gets
795  // uninterpretable results...
796  if (!checkRecoParticlesRequirement(event))
797  continue;
798  } else { // MC
799  // if no, throw event away
801  continue;
802  }
803 
804  // It was an event worth keeping. Continue.
805 
807  // Fill the bin labeled "Total" //
808  // This will be the number of events looked at. //
810  if (!mcMatchedOnly_)
811  totals.at(vPos)->Fill(numOfHLTCollectionLabels + 0.5);
812  totalmatchs.at(vPos)->Fill(numOfHLTCollectionLabels + 0.5);
813 
815  // Fill generator info //
817  // the gencut_ highest Et generator objects of the preselected type are our
818  // matches
819 
820  std::vector<reco::Particle> sortedGen;
821  for (edm::View<reco::Candidate>::const_iterator genpart = cutCounter->begin(); genpart != cutCounter->end();
822  genpart++) {
823  reco::Particle tmpcand(genpart->charge(), genpart->p4(), genpart->vertex(), genpart->pdgId(), genpart->status());
824  if (tmpcand.et() >= plotEtMin) {
825  sortedGen.push_back(tmpcand);
826  }
827  }
828  std::sort(sortedGen.begin(), sortedGen.end(), pTComparator_);
829 
830  // Now the collection of gen particles is sorted by pt.
831  // So, remove all particles from the collection so that we
832  // only have the top "1 thru gencut_" particles in it
833  if (sortedGen.size() < gencut_) {
834  continue;
835  }
836  sortedGen.erase(sortedGen.begin() + gencut_, sortedGen.end());
837 
838  for (unsigned int i = 0; i < gencut_; i++) {
839  etgens.at(vPos)->Fill(sortedGen[i].et()); // validity has been implicitily checked by the
840  // cut on gencut_ above
841  if (sortedGen[i].et() > minEtForEtaEffPlot_) {
842  etagens.at(vPos)->Fill(sortedGen[i].eta());
843  if (!noPhiPlots_)
844  phigens.at(vPos)->Fill(sortedGen[i].phi());
845  etaphigens.at(vPos)->Fill(sortedGen[i].eta(), sortedGen[i].phi());
846  }
847  } // END of loop over Generated particles
848  if (gencut_ >= reqNum && !mcMatchedOnly_)
849  totals.at(vPos)->Fill(numOfHLTCollectionLabels +
850  1.5); // this isn't really needed anymore keep for backward comp.
851  if (gencut_ >= reqNum)
852  totalmatchs.at(vPos)->Fill(numOfHLTCollectionLabels +
853  1.5); // this isn't really needed anymore keep for backward comp.
854 
855  bool accepted = true; // flags that the event has been accepted by all filters before
857  event.getByToken(hltResults_token, hltResults);
859  // Loop over filter modules //
861  for (unsigned int n = 0; n < numOfHLTCollectionLabels; n++) {
862  // check that there are not less sortedGen particles than nCandCut
863  // requires for this filter
864  if (sortedGen.size() < nCandCuts.at(n)) {
865  if (verbosity_ >= OUTPUT_ERRORS)
866  edm::LogError("EmDQM") << "There are less generated particles than the module '"
867  << theHLTCollectionLabels[n].label() << "' requires.";
868  continue;
869  }
870  std::vector<reco::Particle> sortedGenForFilter(sortedGen);
871  sortedGenForFilter.erase(sortedGenForFilter.begin() + nCandCuts.at(n), sortedGenForFilter.end());
872 
873  // Fill only if this filter was run.
874  if (pathIndex != 0 &&
876  break;
877  // These numbers are from the Parameter Set, such as:
878  // theHLTOutputTypes = cms.uint32(100)
879  switch (theHLTOutputTypes[n]) {
880  case trigger::TriggerL1NoIsoEG: // Non-isolated Level 1
881  histoFillerL1NonIso->fillHistos(triggerObj, event, vPos, n, sortedGenForFilter, accepted);
882  break;
883  case trigger::TriggerL1IsoEG: // Isolated Level 1
884  histoFillerL1Iso->fillHistos(triggerObj, event, vPos, n, sortedGenForFilter, accepted);
885  break;
886  case trigger::TriggerPhoton: // Photon
887  histoFillerPho->fillHistos(triggerObj, event, vPos, n, sortedGenForFilter, accepted);
888  break;
889  case trigger::TriggerElectron: // Electron
890  histoFillerEle->fillHistos(triggerObj, event, vPos, n, sortedGenForFilter, accepted);
891  break;
892  case trigger::TriggerCluster: // TriggerCluster
893  histoFillerClu->fillHistos(triggerObj, event, vPos, n, sortedGenForFilter, accepted);
894  break;
895  default:
896  throw(cms::Exception("Release Validation Error") << "HLT output type not implemented: theHLTOutputTypes[n]");
897  }
898  } // END of loop over filter modules
899 
900  // earse the dummy and fill with real set
903  }
904 }
905 
907 // fillHistos //
908 // Called by analyze method. //
910 template <class T>
912  const edm::Event &iEvent,
913  unsigned int vPos,
914  unsigned int n,
915  std::vector<reco::Particle> &sortedGen,
916  bool &accepted) {
917  std::vector<edm::Ref<T>> recoecalcands;
918  if ((triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]) >= triggerObj->size())) { // only process if available
919  dqm->hltCollectionLabelsMissed.insert(dqm->theHLTCollectionLabels[n].encode());
920  accepted = false;
921  return;
922  }
923 
924  dqm->hltCollectionLabelsFound.insert(dqm->theHLTCollectionLabels[n].encode());
925 
927  // Retrieve saved filter objects //
929  triggerObj->getObjects(
930  triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]), dqm->theHLTOutputTypes[n], recoecalcands);
931  // Danger: special case, L1 non-isolated
932  // needs to be merged with L1 iso
933  if (dqm->theHLTOutputTypes[n] == trigger::TriggerL1NoIsoEG) {
934  std::vector<edm::Ref<T>> isocands;
935  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]), trigger::TriggerL1IsoEG, isocands);
936  if (!isocands.empty()) {
937  for (unsigned int i = 0; i < isocands.size(); i++)
938  recoecalcands.push_back(isocands[i]);
939  }
940  } // END of if theHLTOutputTypes == 82
941 
942  if (recoecalcands.empty()) { // stop if no object passed the previous filter
943  accepted = false;
944  return;
945  }
946 
947  // if (recoecalcands.size() >= reqNum )
948  if (recoecalcands.size() >= dqm->nCandCuts.at(n) && !dqm->mcMatchedOnly_)
949  dqm->totals.at(vPos)->Fill(n + 0.5);
950 
952  // check for validity //
953  // prevents crash in CMSSW_3_1_0_pre6 //
955  for (unsigned int j = 0; j < recoecalcands.size(); j++) {
956  if (!(recoecalcands.at(j).isAvailable())) {
957  if (dqm->verbosity_ >= dqm->OUTPUT_ERRORS)
958  edm::LogError("EmDQMInvalidRefs") << "Event content inconsistent: TriggerEventWithRefs contains "
959  "invalid Refs. Invalid refs for: "
960  << dqm->theHLTCollectionLabels[n].label()
961  << ". The collection that this module uses may has been dropped in "
962  "the event.";
963  return;
964  }
965  }
966 
967  if (!dqm->mcMatchedOnly_) {
969  // Loop over the Generated Particles, and find the //
970  // closest HLT object match. //
972  // for (unsigned int i=0; i < gencut_; i++) {
973  for (unsigned int i = 0; i < dqm->nCandCuts.at(n); i++) {
974  math::XYZVector currentGenParticleMomentum = sortedGen[i].momentum();
975 
976  float closestDeltaR = 0.5;
977  int closestEcalCandIndex = -1;
978  for (unsigned int j = 0; j < recoecalcands.size(); j++) {
979  float deltaR = DeltaR(recoecalcands[j]->momentum(), currentGenParticleMomentum);
980 
981  if (deltaR < closestDeltaR) {
982  closestDeltaR = deltaR;
983  closestEcalCandIndex = j;
984  }
985  }
986 
987  // If an HLT object was found within some delta-R
988  // of this gen particle, store it in a histogram
989  if (closestEcalCandIndex >= 0) {
990  dqm->histEtOfHltObjMatchToGens.at(vPos).at(n)->Fill(recoecalcands[closestEcalCandIndex]->et());
991  dqm->histEtaOfHltObjMatchToGens.at(vPos).at(n)->Fill(recoecalcands[closestEcalCandIndex]->eta());
992  if (!dqm->noPhiPlots_)
993  dqm->histPhiOfHltObjMatchToGens.at(vPos).at(n)->Fill(recoecalcands[closestEcalCandIndex]->phi());
994  dqm->histEtaPhiOfHltObjMatchToGens.at(vPos).at(n)->Fill(recoecalcands[closestEcalCandIndex]->eta(),
995  recoecalcands[closestEcalCandIndex]->phi());
996  } // END of if closestEcalCandIndex >= 0
997  }
998 
1000  // Loop over all HLT objects in this filter step, and //
1001  // fill histograms. //
1003  // bool foundAllMatches = false;
1004  // unsigned int numOfHLTobjectsMatched = 0;
1005  for (unsigned int i = 0; i < recoecalcands.size(); i++) {
1007  // float closestGenParticleDr = 99.0;
1008  // for(unsigned int j =0; j < gencut_; j++) {
1009  // math::XYZVector currentGenParticle = sortedGen[j].momentum();
1010 
1011  // double currentDeltaR =
1012  // DeltaR(recoecalcands[i]->momentum(),currentGenParticle); if (
1013  // currentDeltaR < closestGenParticleDr ) {
1014  // closestGenParticleDr = currentDeltaR;
1015  // }
1016  //}
1019  // if ( !(fabs(closestGenParticleDr < 0.3)) ) continue;
1020 
1021  // numOfHLTobjectsMatched++;
1022  // if (numOfHLTobjectsMatched >= gencut_) foundAllMatches=true;
1023 
1024  // Fill HLT object histograms
1025  dqm->ethists.at(vPos).at(n)->Fill(recoecalcands[i]->et());
1026  dqm->etahists.at(vPos).at(n)->Fill(recoecalcands[i]->eta());
1027  if (!dqm->noPhiPlots_)
1028  dqm->phihists.at(vPos).at(n)->Fill(recoecalcands[i]->phi());
1029  dqm->etaphihists.at(vPos).at(n)->Fill(recoecalcands[i]->eta(), recoecalcands[i]->phi());
1030  }
1031  }
1032 
1034  // Fill mc matched objects into histograms //
1036  unsigned int matchedMcParts = 0;
1037  float mindist = 0.3;
1038  if (n == 0)
1039  mindist = 0.5; // low L1-resolution => allow wider matching
1040  for (unsigned int i = 0; i < dqm->nCandCuts.at(n); ++i) {
1041  // match generator candidate
1042  bool matchThis = false;
1043  math::XYZVector candDir = sortedGen[i].momentum();
1044  // unsigned int closest = 0;
1045  double closestDr = 1000.;
1046  for (unsigned int trigOb = 0; trigOb < recoecalcands.size(); ++trigOb) {
1047  double dr = DeltaR(recoecalcands[trigOb]->momentum(), candDir);
1048  if (dr < closestDr) {
1049  closestDr = dr;
1050  // closest = trigOb;
1051  }
1052  if (closestDr > mindist) { // it's not really a "match" if it's that far away
1053  // closest = -1;
1054  } else {
1055  matchedMcParts++;
1056  matchThis = true;
1057  }
1058  }
1059  if (!matchThis) {
1060  accepted = false;
1061  continue; // only plot matched candidates
1062  }
1063  // fill coordinates of mc particle matching trigger object
1064  dqm->ethistmatchs.at(vPos).at(n)->Fill(sortedGen[i].et());
1065  if (sortedGen[i].et() > dqm->minEtForEtaEffPlot_) {
1066  dqm->etahistmatchs.at(vPos).at(n)->Fill(sortedGen[i].eta());
1067  if (!dqm->noPhiPlots_)
1068  dqm->phihistmatchs.at(vPos).at(n)->Fill(sortedGen[i].phi());
1069  dqm->etaphihistmatchs.at(vPos).at(n)->Fill(sortedGen[i].eta(), sortedGen[i].phi());
1070  }
1071  }
1072  // fill total mc matched efficiency
1073 
1074  if (matchedMcParts >= dqm->nCandCuts.at(n) && accepted == true)
1075  dqm->totalmatchs.at(vPos)->Fill(n + 0.5);
1076 }
1077 
1078 void EmDQM::endRun(edm::Run const &iRun, edm::EventSetup const &iSetup) {
1079  // loop over all the trigger path parameter sets
1080  unsigned int vPos = 0;
1081  for (std::vector<edm::ParameterSet>::iterator psetIt = paramSets.begin(); psetIt != paramSets.end();
1082  ++psetIt, ++vPos) {
1083  SetVarsFromPSet(psetIt);
1084 
1085  // print information about hltCollectionLabels which were not found
1086  // (but only those which were never found)
1087 
1088  // check which ones were never found
1089  std::vector<std::string> labelsNeverFound;
1090 
1091  for (edm::InputTag const &tag : hltCollectionLabelsMissedPerPath.at(vPos)) {
1092  if ((hltCollectionLabelsFoundPerPath.at(vPos)).count(tag.encode()) == 0)
1093  // never found
1094  labelsNeverFound.push_back(tag.encode());
1095 
1096  } // loop over all tags which were missed at least once
1097 
1098  if (labelsNeverFound.empty())
1099  continue;
1100 
1101  std::sort(labelsNeverFound.begin(), labelsNeverFound.end());
1102 
1103  // there was at least one label which was never found
1104  // (note that this could also be because the corresponding
1105  // trigger path slowly fades out to zero efficiency)
1106  if (verbosity_ >= OUTPUT_WARNINGS)
1107  edm::LogWarning("EmDQM") << "There were some HLTCollectionLabels which were never found:";
1108 
1109  for (auto const &tag : labelsNeverFound) {
1110  if (verbosity_ >= OUTPUT_ALL)
1111  edm::LogPrint("EmDQM") << " " << tag;
1112  }
1113  }
1114 }
1115 
1116 // returns count of non-overlapping occurrences of 'sub' in 'str'
1118  if (sub.length() == 0)
1119  return 0;
1120  int count = 0;
1121  for (size_t offset = str.find(sub); offset != std::string::npos; offset = str.find(sub, offset + sub.length())) {
1122  ++count;
1123  }
1124  return count;
1125 }
1126 
1127 //----------------------------------------------------------------------
1128 // find egamma trigger paths from trigger name
1129 std::vector<std::vector<std::string>> EmDQM::findEgammaPaths() {
1130  std::vector<std::vector<std::string>> Paths(5);
1131  // Loop over all paths in the menu
1132  for (unsigned int i = 0; i < hltConfig_.size(); i++) {
1134 
1135  // Find electron and photon paths and classify them
1136  if (int(path.find("HLT_")) == 0) { // Path should start with 'HLT_'
1137 
1138  int scCount = countSubstring(path, "_SC");
1139  int eleCount = countSubstring(path, "Ele");
1140  int doubleEleCount = countSubstring(path, "DoubleEle");
1141  int doubleSCCount = countSubstring(path, "DiSC");
1142  int tripleEleCount = countSubstring(path, "TripleEle");
1143  int photonCount = countSubstring(path, "hoton");
1144  int doublePhotonCount = countSubstring(path, "DoublePhoton") + countSubstring(path, "Diphoton");
1145 
1146  int totEleCount = 2 * tripleEleCount + doubleEleCount + eleCount + scCount + 2 * doubleSCCount;
1147  int totPhotonCount = doublePhotonCount + photonCount;
1148 
1149  if (totEleCount + totPhotonCount < 1)
1150  continue;
1151  switch (totEleCount) {
1152  case 1:
1153  Paths[TYPE_SINGLE_ELE].push_back(path);
1154  // std::cout << "Electron \t" << path << std::endl;
1155  break;
1156  case 2:
1157  Paths[TYPE_DOUBLE_ELE].push_back(path);
1158  // std::cout << "DoubleElectron \t" << path << std::endl;
1159  break;
1160  case 3:
1161  Paths[TYPE_TRIPLE_ELE].push_back(path);
1162  // std::cout << "TripleElectron \t" << path << std::endl;
1163  break;
1164  }
1165 
1166  switch (totPhotonCount) {
1167  case 1:
1168  Paths[TYPE_SINGLE_PHOTON].push_back(path);
1169  // std::cout << "Photon \t\t" << path << std::endl;
1170  break;
1171  case 2:
1172  Paths[TYPE_DOUBLE_PHOTON].push_back(path);
1173  // std::cout << "DoublePhoton \t" << path << std::endl;
1174  break;
1175  }
1176  }
1177  // std::cout << i << " triggerName: " << path << " containing " <<
1178  // hltConfig_.size(i) << " modules."<< std::endl;
1179  }
1180  return Paths;
1181 }
1182 
1183 //----------------------------------------------------------------------
1184 // get the names of filters of a given path
1185 std::vector<std::string> EmDQM::getFilterModules(const std::string &path) {
1186  std::vector<std::string> filters;
1187 
1188  // std::cout << "Pathname: " << path << std::endl;
1189 
1190  // Loop over all modules in the path
1191  for (unsigned int i = 0; i < hltConfig_.size(path); i++) {
1193  std::string moduleType = hltConfig_.moduleType(module);
1194  std::string moduleEDMType = hltConfig_.moduleEDMType(module);
1195 
1196  // Find filters
1197  if (moduleEDMType == "EDFilter" ||
1198  moduleType.find("Filter") != std::string::npos) { // older samples may not have EDMType data
1199  // included
1200  filters.push_back(module);
1201  // std::cout << i << " moduleLabel: " << module << " moduleType: "
1202  // << moduleType << " moduleEDMType: " << moduleEDMType << std::endl;
1203  }
1204  }
1205  return filters;
1206 }
1207 
1208 //----------------------------------------------------------------------
1209 // get the primary Et cut from the trigger name
1211  double minEt = -1;
1212 
1213  boost::regex reg("^HLT_.*?(Ele|hoton|EG|SC)([[:digit:]]+).*");
1214 
1215  boost::smatch what;
1216  if (boost::regex_match(path, what, reg, boost::match_extra)) {
1217  minEt = boost::lexical_cast<double>(what[2]);
1218  }
1219 
1220  return minEt;
1221 }
1222 
1223 //----------------------------------------------------------------------
1224 
1226  // generates a PSet to analyze the behaviour of an L1 seed.
1227  //
1228  // moduleName is the name of the HLT module which filters
1229  // on the L1 seed.
1230  edm::ParameterSet retPSet;
1231 
1232  retPSet.addParameter<std::vector<double>>("PlotBounds", std::vector<double>(2, 0.0));
1233  // retPSet.addParameter<edm::InputTag>("HLTCollectionLabels",
1234  // edm::InputTag(moduleName, "", processName_));
1235  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1236  retPSet.addParameter<std::vector<edm::InputTag>>("IsoCollections",
1237  std::vector<edm::InputTag>(1, std::string("none")));
1238  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerL1NoIsoEG);
1239 
1240  // as HLTLevel1GTSeed has no parameter ncandcut we determine the value from
1241  // the name of the filter
1242 
1243  int orCount = countSubstring(moduleName, "OR") + countSubstring(moduleName, "Or");
1244  int egCount = countSubstring(moduleName, "EG");
1245  int dEgCount = countSubstring(moduleName, "DoubleEG");
1246  int tEgCount = countSubstring(moduleName, "TripleEG");
1247 
1248  int candCount = 2 * tEgCount + dEgCount + egCount;
1249  // if L1 is and OR of triggers try the assumption that all of them are similar
1250  // first and if not take the lowest number. If this is not successful, let the
1251  // path name decide
1252  if (orCount > 0 && candCount > 0) {
1253  if (egCount % (orCount + 1) == 0 && dEgCount % (orCount + 1) == 0 && tEgCount % (orCount + 1) == 0)
1254  candCount /= (orCount + 1);
1255  else if (egCount - dEgCount - tEgCount > 0)
1256  candCount = 1; // at least one singleEG present
1257  else if (dEgCount > 0)
1258  candCount = 2; // at least one doubleEG and no singleEG present
1259  else if (tEgCount > 0)
1260  candCount = 3; // only tripleEG present
1261  else
1262  candCount = -1;
1263  }
1264 
1265  switch (candCount) {
1266  case 0:
1267  retPSet.addParameter<int>("ncandcut", 0);
1268  break;
1269  case 1:
1270  retPSet.addParameter<int>("ncandcut", 1);
1271  break;
1272  case 2:
1273  retPSet.addParameter<int>("ncandcut", 2);
1274  break;
1275  case 3:
1276  retPSet.addParameter<int>("ncandcut", 3);
1277  break;
1278  default:
1279  retPSet.addParameter<int>("ncandcut", -1);
1280  }
1281 
1282  return retPSet;
1283 }
1284 
1285 //----------------------------------------------------------------------
1286 
1288  // generates a PSet to analyze the behaviour of L1 to supercluster match
1289  // filter.
1290  //
1291  // moduleName is the name of the HLT module which requires the match
1292  // between supercluster and L1 seed.
1293  //
1294  edm::ParameterSet retPSet;
1295 
1296  retPSet.addParameter<std::vector<double>>("PlotBounds", std::vector<double>(2, 0.0));
1297  // retPSet.addParameter<edm::InputTag>("HLTCollectionLabels",
1298  // edm::InputTag(moduleName, "", processName_));
1299  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1300  retPSet.addParameter<std::vector<edm::InputTag>>("IsoCollections",
1301  std::vector<edm::InputTag>(1, std::string("none")));
1302  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1303  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1304 
1305  return retPSet;
1306 }
1307 
1308 //----------------------------------------------------------------------
1309 
1311  edm::ParameterSet retPSet;
1312 
1313  retPSet.addParameter<std::vector<double>>("PlotBounds", std::vector<double>(2, 0.0));
1314  // retPSet.addParameter<edm::InputTag>("HLTCollectionLabels",
1315  // edm::InputTag(moduleName, "", processName_));
1316  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1317  retPSet.addParameter<std::vector<edm::InputTag>>("IsoCollections",
1318  std::vector<edm::InputTag>(1, std::string("none")));
1319  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1320  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1321 
1322  return retPSet;
1323 }
1324 
1325 //----------------------------------------------------------------------
1326 
1328  edm::ParameterSet retPSet;
1329 
1330  retPSet.addParameter<std::vector<double>>("PlotBounds", std::vector<double>(2, 0.0));
1331  // retPSet.addParameter<edm::InputTag>("HLTCollectionLabels",
1332  // edm::InputTag(moduleName, "", processName_));
1333  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1334  retPSet.addParameter<std::vector<edm::InputTag>>("IsoCollections",
1335  std::vector<edm::InputTag>(1, std::string("none")));
1336  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerElectron);
1337  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1338 
1339  return retPSet;
1340 }
1341 
1342 //----------------------------------------------------------------------
1343 
1345  edm::ParameterSet retPSet;
1346 
1347  retPSet.addParameter<std::vector<double>>("PlotBounds", std::vector<double>(2, 0.0));
1348  // retPSet.addParameter<edm::InputTag>("HLTCollectionLabels",
1349  // edm::InputTag(moduleName, "", processName_));
1350  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1351  retPSet.addParameter<std::vector<edm::InputTag>>("IsoCollections",
1352  std::vector<edm::InputTag>(1, std::string("none")));
1353  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1354  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1355 
1356  return retPSet;
1357 }
1358 
1359 //----------------------------------------------------------------------
1360 
1362  edm::ParameterSet retPSet;
1363 
1364  retPSet.addParameter<std::vector<double>>("PlotBounds", std::vector<double>(2, 0.0));
1365  // retPSet.addParameter<edm::InputTag>("HLTCollectionLabels",
1366  // edm::InputTag(moduleName, "", processName_));
1367  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1368  retPSet.addParameter<std::vector<edm::InputTag>>("IsoCollections",
1369  std::vector<edm::InputTag>(1, std::string("none")));
1370  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1371  retPSet.addParameter<int>("ncandcut", 2);
1372 
1373  return retPSet;
1374 }
1375 
1376 //----------------------------------------------------------------------
1377 
1379  edm::ParameterSet retPSet;
1380 
1381  // example usages of HLTEgammaGenericFilter are:
1382  // R9 shape filter
1383  // hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolR9ShapeFilter
1384  // cluster shape filter
1385  // hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolClusterShapeFilter
1386  // Ecal isolation filter
1387  // hltL1NonIsoHLTNonIsoSingleElectronEt17TIghterEleIdIsolEcalIsolFilter H/E
1388  // filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHEFilter
1389  // HCAL isolation filter
1390  // hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHcalIsolFilter
1391 
1392  // infer the type of filter by the type of the producer which
1393  // generates the collection used to cut on this
1394  edm::InputTag varTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("varTag");
1395  // edm::InputTag nonIsoTag =
1396  // hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("");
1397  // std::cout
1398  // << "varTag.label " << varTag.label() << " nonIsoTag.label " <<
1399  // nonIsoTag.label() << std::endl;
1400 
1401  std::string inputType = hltConfig_.moduleType(varTag.label());
1402  // std::cout << "inputType " << inputType << " moduleName " << moduleName <<
1403  // std::endl;
1404 
1405  //--------------------
1406  // sanity check: non-isolated path should be produced by the
1407  // same type of module
1408 
1409  // first check that the non-iso tag is non-empty
1410  // if (nonIsoTag.label().empty()) {
1411  // edm::LogError("EmDQM") << "nonIsoTag of HLTEgammaGenericFilter '" <<
1412  // moduleName << "' is empty."; return retPSet;
1413  //}
1414  // if (inputType != hltConfig_.moduleType(nonIsoTag.label())) {
1415  // edm::LogError("EmDQM") << "C++ Type of varTag '" << inputType << "' and
1416  // nonIsoTag '" << hltConfig_.moduleType(nonIsoTag.label()) << "' are not the
1417  // same for HLTEgammaGenericFilter '" << moduleName << "'."; return retPSet;
1418  //}
1419  //--------------------
1420 
1421  // parameter saveTag determines the output type
1422  if (hltConfig_.saveTags(moduleName))
1423  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);
1424  else
1425  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1426 
1427  std::vector<edm::InputTag> isoCollections;
1428  isoCollections.push_back(varTag);
1429  // if (!nonIsoTag.label().empty())
1430  // isoCollections.push_back(nonIsoTag);
1431 
1432  //--------------------
1433  // the following cases seem to have identical PSets ?
1434  //--------------------
1435 
1436  if (inputType == "EgammaHLTR9Producer" || // R9 shape
1437  inputType == "EgammaHLTR9IDProducer" || // R9 ID
1438  inputType == "EgammaHLTClusterShapeProducer" || // cluster shape
1439  inputType == "EgammaHLTEcalRecIsolationProducer" || // ecal isolation
1440  inputType == "EgammaHLTHcalIsolationProducersRegional" || // HCAL isolation and HE
1441  inputType == "EgammaHLTGsfTrackVarProducer" || // GSF track deta and dphi filter
1442  inputType == "EgammaHLTBcHcalIsolationProducersRegional" || // HCAL isolation and
1443  // HE
1444  inputType == "EgammaHLTEcalPFClusterIsolationProducer" || // ECAL PF isolation
1445  // filter
1446  inputType == "EgammaHLTHcalPFClusterIsolationProducer" || // HCAL PF isolation
1447  // filter
1448  inputType == "EgammaHLTElectronTrackIsolationProducers" // Track isolation filter
1449  ) {
1450  retPSet.addParameter<std::vector<double>>("PlotBounds", std::vector<double>(2, 0.0));
1451  // retPSet.addParameter<edm::InputTag>("HLTCollectionLabels",
1452  // edm::InputTag(moduleName, "", processName_));
1453  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1454  retPSet.addParameter<std::vector<edm::InputTag>>("IsoCollections", isoCollections);
1455  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1456 
1457  return retPSet;
1458  }
1459 
1460  if (verbosity_ >= OUTPUT_ERRORS)
1461  edm::LogError("EmDQM") << "Can't determine what the HLTEgammaGenericFilter '" << moduleName
1462  << "' should do: uses a collection produced by a module of C++ type '" << inputType << "'.";
1463  return edm::ParameterSet();
1464 }
1465 
1466 //----------------------------------------------------------------------
1467 
1469  edm::ParameterSet retPSet;
1470 
1471  // example usages of HLTEgammaGenericFilter are:
1472  // R9 shape filter
1473  // hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolR9ShapeFilter
1474  // cluster shape filter
1475  // hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolClusterShapeFilter
1476  // Ecal isolation filter
1477  // hltL1NonIsoHLTNonIsoSingleElectronEt17TIghterEleIdIsolEcalIsolFilter H/E
1478  // filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHEFilter
1479  // HCAL isolation filter
1480  // hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHcalIsolFilter
1481 
1482  // infer the type of filter by the type of the producer which
1483  // generates the collection used to cut on this
1484  edm::InputTag varTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("varTag");
1485  // edm::InputTag nonIsoTag =
1486  // hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("nonIsoTag");
1487  // std::cout << "varTag.label " << varTag.label() << " nonIsoTag.label " <<
1488  // nonIsoTag.label() << std::endl;
1489 
1490  std::string inputType = hltConfig_.moduleType(varTag.label());
1491  // std::cout << "inputType " << inputType << " moduleName " << moduleName <<
1492  // std::endl;
1493 
1494  //--------------------
1495  // sanity check: non-isolated path should be produced by the
1496  // same type of module
1497 
1498  // first check that the non-iso tag is non-empty
1499  // if (nonIsoTag.label().empty()) {
1500  // edm::LogError("EmDQM") << "nonIsoTag of HLTEgammaGenericFilter '" <<
1501  // moduleName << "' is empty."; return retPSet;
1502  //}
1503  // if (inputType != hltConfig_.moduleType(nonIsoTag.label())) {
1504  // edm::LogError("EmDQM") << "C++ Type of varTag '" << inputType << "' and
1505  // nonIsoTag '" << hltConfig_.moduleType(nonIsoTag.label()) << "' are not the
1506  // same for HLTEgammaGenericFilter '" << moduleName << "'."; return retPSet;
1507  //}
1508  //--------------------
1509 
1510  // parameter saveTag determines the output type
1511  if (hltConfig_.saveTags(moduleName))
1512  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);
1513  else
1514  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1515 
1516  std::vector<edm::InputTag> isoCollections;
1517  isoCollections.push_back(varTag);
1518  // if (!nonIsoTag.label().empty())
1519  // isoCollections.push_back(nonIsoTag);
1520 
1521  //--------------------
1522  // the following cases seem to have identical PSets ?
1523  //--------------------
1524 
1525  if (inputType == "EgammaHLTR9Producer" || // R9 shape
1526  inputType == "EgammaHLTR9IDProducer" || // R9 ID
1527  inputType == "EgammaHLTClusterShapeProducer" || // cluster shape
1528  inputType == "EgammaHLTEcalRecIsolationProducer" || // ecal isolation
1529  inputType == "EgammaHLTHcalIsolationProducersRegional" || // HCAL isolation and HE
1530  inputType == "EgammaHLTBcHcalIsolationProducersRegional" || // HCAL isolation and
1531  // HE
1532  inputType == "EgammaHLTEcalPFClusterIsolationProducer" || // ECAL PF isolation
1533  // filter
1534  inputType == "EgammaHLTHcalPFClusterIsolationProducer" || // HCAL PF isolation
1535  // filter
1536  inputType == "EgammaHLTPhotonTrackIsolationProducersRegional" // Photon track
1537  // isolation
1538  ) {
1539  retPSet.addParameter<std::vector<double>>("PlotBounds", std::vector<double>(2, 0.0));
1540  // retPSet.addParameter<edm::InputTag>("HLTCollectionLabels",
1541  // edm::InputTag(moduleName, "", processName_));
1542  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1543  retPSet.addParameter<std::vector<edm::InputTag>>("IsoCollections", isoCollections);
1544  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1545 
1546  return retPSet;
1547  }
1548 
1549  if (verbosity_ >= OUTPUT_ERRORS)
1550  edm::LogError("EmDQM") << "Can't determine what the HLTEgammaGenericQuadraticFilter '" << moduleName
1551  << "' should do: uses a collection produced by a module of C++ type '" << inputType << "'.";
1552  return edm::ParameterSet();
1553 }
1554 
1555 //----------------------------------------------------------------------
1556 
1558  edm::ParameterSet retPSet;
1559 
1560  // example usages of HLTElectronGenericFilter are:
1561  //
1562  // deta filter
1563  // hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDetaFilter dphi
1564  // filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDphiFilter
1565  // track isolation
1566  // hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolTrackIsolFilter
1567 
1568  // infer the type of filter by the type of the producer which
1569  // generates the collection used to cut on this
1570  edm::InputTag varTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("varTag");
1571  // edm::InputTag nonIsoTag =
1572  // hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("nonIsoTag");
1573  // std::cout << "varTag.label " << varTag.label() << " nonIsoTag.label " <<
1574  // nonIsoTag.label() << std::endl;
1575 
1576  std::string inputType = hltConfig_.moduleType(varTag.label());
1577  // std::cout << "inputType iso " << inputType << " inputType noniso " <<
1578  // hltConfig_.moduleType(nonIsoTag.label()) << " moduleName " << moduleName <<
1579  // std::endl;
1580 
1581  //--------------------
1582  // sanity check: non-isolated path should be produced by the
1583  // same type of module
1584  // if (nonIsoTag.label().empty()) {
1585  // edm::LogError("EmDQM") << "nonIsoTag of HLTElectronGenericFilter '" <<
1586  // moduleName << "' is empty."; return retPSet;
1587  //}
1588  // if (inputType != hltConfig_.moduleType(nonIsoTag.label())) {
1589  // edm::LogError("EmDQM") << "C++ Type of varTag '" << inputType << "' and
1590  // nonIsoTag '" << hltConfig_.moduleType(nonIsoTag.label()) << "' are not the
1591  // same for HLTElectronGenericFilter '" << moduleName << "'."; return
1592  // retPSet;
1593  //}
1594  //--------------------
1595 
1596  // the type of object to look for seems to be the
1597  // same for all uses of HLTEgammaGenericFilter
1598  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerElectron);
1599 
1600  std::vector<edm::InputTag> isoCollections;
1601  isoCollections.push_back(varTag);
1602  // if (!nonIsoTag.label().empty())
1603  // isoCollections.push_back(nonIsoTag);
1604 
1605  //--------------------
1606  // the following cases seem to have identical PSets ?
1607  //--------------------
1608 
1609  // note that whether deta or dphi is used is determined from
1610  // the product instance (not the module label)
1611  if (inputType == "EgammaHLTElectronDetaDphiProducer" || // deta and dphi filter
1612  inputType == "EgammaHLTElectronTrackIsolationProducers" // track isolation
1613  ) {
1614  retPSet.addParameter<std::vector<double>>("PlotBounds", std::vector<double>(2, 0.0));
1615  // retPSet.addParameter<edm::InputTag>("HLTCollectionLabels",
1616  // edm::InputTag(moduleName, "", processName_));
1617  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1618  retPSet.addParameter<std::vector<edm::InputTag>>("IsoCollections", isoCollections);
1619  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1620 
1621  return retPSet;
1622  }
1623 
1624  if (verbosity_ >= OUTPUT_ERRORS)
1625  edm::LogError("EmDQM") << "Can't determine what the HLTElectronGenericFilter '" << moduleName
1626  << "' should do: uses a collection produced by a module of C++ type '" << inputType << "'.";
1627  return edm::ParameterSet();
1628 }
1629 
1630 //----------------------------------------------------------------------
1631 
1632 void EmDQM::SetVarsFromPSet(std::vector<edm::ParameterSet>::iterator psetIt) {
1633  dirname_ = "HLT/HLTEgammaValidation/" + psetIt->getParameter<std::string>("@module_label");
1634 
1635  pathIndex = psetIt->getUntrackedParameter<unsigned int>("pathIndex", 0);
1636  // parameters for generator study
1637  reqNum = psetIt->getParameter<unsigned int>("reqNum");
1638  pdgGen = psetIt->getParameter<int>("pdgGen");
1639  // plotting parameters (untracked because they don't affect the physics)
1640  plotEtMin = psetIt->getUntrackedParameter<double>("genEtMin", 0.);
1641  plotPtMin = psetIt->getUntrackedParameter<double>("PtMin", 0.);
1642  plotPtMax = psetIt->getUntrackedParameter<double>("PtMax", 1000.);
1643 
1644  // preselction cuts
1645  gencutCollection_ = psetIt->getParameter<edm::InputTag>("cutcollection");
1646  gencut_ = psetIt->getParameter<int>("cutnum");
1647 
1649  // Read in the Vector of Parameter Sets. //
1650  // Information for each filter-step //
1652  std::vector<edm::ParameterSet> filters = psetIt->getParameter<std::vector<edm::ParameterSet>>("filters");
1653 
1654  // empty vectors of parameters from previous paths
1655  theHLTCollectionLabels.clear();
1656  theHLTOutputTypes.clear();
1658  plotBounds.clear();
1659  isoNames.clear();
1660  plotiso.clear();
1661  nCandCuts.clear();
1662 
1663  int i = 0;
1664  for (std::vector<edm::ParameterSet>::iterator filterconf = filters.begin(); filterconf != filters.end();
1665  filterconf++) {
1666  theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
1667  theHLTOutputTypes.push_back(filterconf->getParameter<int>("theHLTOutputTypes"));
1668  // Grab the human-readable name, if it is not specified, use the Collection
1669  // Label
1670  theHLTCollectionHumanNames.push_back(
1671  filterconf->getUntrackedParameter<std::string>("HLTCollectionHumanName", theHLTCollectionLabels[i].label()));
1672 
1673  std::vector<double> bounds = filterconf->getParameter<std::vector<double>>("PlotBounds");
1674  // If the size of plot "bounds" vector != 2, abort
1675  assert(bounds.size() == 2);
1676  plotBounds.push_back(std::pair<double, double>(bounds[0], bounds[1]));
1677  isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag>>("IsoCollections"));
1678 
1679  // for (unsigned int i=0; i<isoNames.back().size(); i++) {
1680  // switch(theHLTOutputTypes.back()) {
1681  // case trigger::TriggerL1NoIsoEG:
1682  // histoFillerL1NonIso->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<l1extra::L1EmParticleCollection
1683  // , float>>>(isoNames.back()[i])); break;
1684  // case trigger::TriggerL1IsoEG: // Isolated Level 1
1685  // histoFillerL1Iso->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<l1extra::L1EmParticleCollection
1686  // , float>>>(isoNames.back()[i])); break;
1687  // case trigger::TriggerPhoton: // Photon
1688  // histoFillerPho->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<reco::RecoEcalCandidateCollection
1689  // , float>>>(isoNames.back()[i])); break;
1690  // case trigger::TriggerElectron: // Electron
1691  // histoFillerEle->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<reco::ElectronCollection
1692  // , float>>>(isoNames.back()[i])); break;
1693  // case trigger::TriggerCluster: // TriggerCluster
1694  // histoFillerClu->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<reco::RecoEcalCandidateCollection
1695  // , float>>>(isoNames.back()[i])); break;
1696  // default:
1697  // throw(cms::Exception("Release Validation Error") << "HLT output type
1698  // not implemented: theHLTOutputTypes[n]" );
1699  // }
1700  //}
1701 
1702  // If the size of the isoNames vector is not greater than zero, abort
1703  assert(!isoNames.back().empty());
1704  if (isoNames.back().at(0).label() == "none") {
1705  plotiso.push_back(false);
1706  } else {
1707  if (!noIsolationPlots_)
1708  plotiso.push_back(true);
1709  else
1710  plotiso.push_back(false);
1711  }
1712  nCandCuts.push_back(filterconf->getParameter<int>("ncandcut"));
1713  i++;
1714  } // END of loop over parameter sets
1715 
1716  // Record number of HLTCollectionLabels
1718 }
1719 
1720 //----------------------------------------------------------------------
1721 
unsigned int size() const
number of trigger paths in trigger table
edm::ParameterSet makePSetForEgammaGenericFilter(const std::string &)
Definition: EmDQM.cc:1378
~EmDQM() override
Destructor.
Definition: EmDQM.cc:603
double ptMax_
Definition: EmDQM.h:107
std::vector< std::vector< MonitorElement * > > etaphihists
Definition: EmDQM.h:210
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:191
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet makePSetForEgammaGenericQuadraticFilter(const std::string &)
Definition: EmDQM.cc:1468
bool saveTags(const std::string &module) const
Is module an L3 filter (ie, tracked saveTags=true)
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidZee_token
Definition: EmDQM.h:230
std::vector< MonitorElement * > etgens
Definition: EmDQM.h:217
void fillHistos(edm::Handle< trigger::TriggerEventWithRefs > &, const edm::Event &, unsigned int, unsigned int, std::vector< reco::Particle > &, bool &)
Definition: EmDQM.cc:911
edm::EDGetTokenT< edm::View< reco::Candidate > > genParticles_token
Definition: EmDQM.h:226
std::vector< MonitorElement * > totalmatchs
Definition: EmDQM.h:215
const std::string moduleType(const std::string &module) const
C++ class name of module.
std::vector< std::vector< std::string > > findEgammaPaths()
Definition: EmDQM.cc:1129
bool checkRecoParticlesRequirement(const edm::Event &event)
Definition: EmDQM.cc:669
const std::string & triggerName(unsigned int triggerIndex) const
unsigned int numOfHLTCollectionLabels
Definition: EmDQM.h:161
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: EmDQM.cc:1078
std::string dirname_
Definition: EmDQM.h:89
std::vector< std::pair< double, double > > plotBounds
Definition: EmDQM.h:167
std::vector< std::set< std::string > > hltCollectionLabelsMissedPerPath
Definition: EmDQM.h:194
bool noPhiPlots_
Definition: EmDQM.h:118
std::vector< std::vector< MonitorElement * > > etahistmatchs
Definition: EmDQM.h:204
static const unsigned OUTPUT_ALL
Definition: EmDQM.h:249
int pdgGen
Definition: EmDQM.h:171
std::vector< std::vector< MonitorElement * > > histEtaPhiOfHltObjMatchToGens
Definition: EmDQM.h:212
std::set< std::string > hltCollectionLabelsFound
Definition: EmDQM.h:191
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: EmDQM.cc:64
void analyze(const edm::Event &event, const edm::EventSetup &) override
Definition: EmDQM.cc:733
std::vector< std::set< std::string > > hltCollectionLabelsFoundPerPath
Definition: EmDQM.h:190
double phiMax_
Definition: EmDQM.h:110
std::vector< MonitorElement * > etagens
Definition: EmDQM.h:218
std::vector< MonitorElement * > etaphigens
Definition: EmDQM.h:220
bool exists(std::string const &parameterName) const
checks if a parameter exists
HLTConfigProvider hltConfig_
The instance of the HLTConfigProvider as a data member.
Definition: EmDQM.h:136
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
const std::string moduleEDMType(const std::string &module) const
C++ base class name of module.
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
std::vector< std::vector< MonitorElement * > > histPhiOfHltObjMatchToGens
Definition: EmDQM.h:209
edm::ParameterSet makePSetForOneOEMinusOneOPFilter(const std::string &)
Definition: EmDQM.cc:1327
const std::string & tableName() const
HLT ConfDB table name.
static const unsigned TYPE_DOUBLE_PHOTON
Definition: EmDQM.h:242
const edm::ParameterSet & modulePSet(const std::string &module) const
ParameterSet of module.
edm::ParameterSet makePSetForElectronGenericFilter(const std::string &)
Definition: EmDQM.cc:1557
HistoFiller< reco::ElectronCollection > * histoFillerEle
Definition: EmDQM.h:91
double plotEtMin
Definition: EmDQM.h:173
Definition: EmDQM.h:67
bool isRealData() const
Definition: EventBase.h:62
std::vector< std::vector< MonitorElement * > > phihists
Definition: EmDQM.h:202
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
bool changed() const
changed?
static const unsigned OUTPUT_ERRORS
Definition: EmDQM.h:247
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidWenu_token
Definition: EmDQM.h:229
const std::string & moduleLabel(unsigned int trigger, unsigned int module) const
static const std::string removeVersion(const std::string &trigger)
GreaterByPt< reco::GenParticle > pTGenComparator_
Definition: EmDQM.h:223
bool inited() const
Accessors (const methods)
std::vector< std::vector< edm::InputTag > > isoNames
Definition: EmDQM.h:166
edm::ParameterSet makePSetForL1SeedFilter(const std::string &)
Definition: EmDQM.cc:1225
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
std::vector< std::string > getFilterModules(const std::string &)
Definition: EmDQM.cc:1185
char const * label
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQM.h:160
HistoFiller< l1extra::L1EmParticleCollection > * histoFillerL1Iso
Definition: EmDQM.h:95
int iEvent
Definition: GenABIO.cc:224
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
unsigned int moduleIndex(unsigned int trigger, const std::string &module) const
slot position of module on trigger path (0 to size-1)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HistoFiller< l1extra::L1EmParticleCollection > * histoFillerL1NonIso
Definition: EmDQM.h:93
unsigned int gencut_
Definition: EmDQM.h:187
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::vector< unsigned int > nCandCuts
Definition: EmDQM.h:168
HistoFiller< reco::RecoEcalCandidateCollection > * histoFillerPho
Definition: EmDQM.h:94
edm::InputTag triggerObject_
Definition: EmDQM.h:102
static const unsigned OUTPUT_WARNINGS
Definition: EmDQM.h:248
double et() const final
transverse energy
std::vector< MonitorElement * > totals
Definition: EmDQM.h:214
double plotPtMax
Definition: EmDQM.h:175
bool noIsolationPlots_
Definition: EmDQM.h:119
unsigned int index(const unsigned int i) const
Get index (slot position) of module giving the decision of the ith path.
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:125
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidGammaJet_token
Definition: EmDQM.h:232
std::set< std::string > hltCollectionLabelsMissed
Definition: EmDQM.h:195
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
void SetVarsFromPSet(std::vector< edm::ParameterSet >::iterator)
Definition: EmDQM.cc:1632
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::ParameterSet & pset
Definition: EmDQM.h:100
double plotPtMin
Definition: EmDQM.h:174
edm::InputTag gencutCollection_
Definition: EmDQM.h:183
edm::ParameterSet makePSetForEgammaDoubleEtDeltaPhiFilter(const std::string &)
Definition: EmDQM.cc:1361
unsigned int nbins_
Definition: EmDQM.h:111
bool isValid() const
Definition: HandleBase.h:74
EmDQM(const edm::ParameterSet &pset)
Constructor.
Definition: EmDQM.cc:11
bool isData_
Definition: EmDQM.h:106
const std::string & processName() const
process name
std::vector< std::vector< MonitorElement * > > ethistmatchs
Definition: EmDQM.h:206
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
double eta2DMax_
Definition: EmDQM.h:112
static const unsigned TYPE_SINGLE_PHOTON
Definition: EmDQM.h:241
std::vector< std::vector< MonitorElement * > > etaphihistmatchs
Definition: EmDQM.h:211
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidDiGamma_token
Definition: EmDQM.h:233
std::vector< std::vector< MonitorElement * > > histEtaOfHltObjMatchToGens
Definition: EmDQM.h:208
std::vector< std::vector< MonitorElement * > > phihistmatchs
Definition: EmDQM.h:205
double ptMin_
Definition: EmDQM.h:108
bool checkGeneratedParticlesRequirement(const edm::Event &event)
Definition: EmDQM.cc:606
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
std::vector< MonitorElement * > phigens
Definition: EmDQM.h:219
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:182
std::vector< edm::ParameterSet > paramSets
Definition: EmDQM.h:157
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidTripleEle_token
Definition: EmDQM.h:231
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type
unsigned int nbins2D_
Definition: EmDQM.h:114
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
bool accepted(std::vector< std::string_view > const &, std::string_view)
int countSubstring(const std::string &, const std::string &)
Definition: EmDQM.cc:1117
double genEtAcc_
Definition: EmDQM.h:105
size_type size() const
number of filters
bool autoConfMode_
Definition: EmDQM.h:98
et
define resolution functions of each parameter
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
static const unsigned TYPE_SINGLE_ELE
Definition: EmDQM.h:239
double getPrimaryEtCut(const std::string &)
Definition: EmDQM.cc:1210
edm::ParameterSet makePSetForL1SeedToSuperClusterMatchFilter(const std::string &)
Definition: EmDQM.cc:1287
unsigned int pathIndex
Definition: EmDQM.h:159
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
bool useHumanReadableHistTitles_
Definition: EmDQM.h:116
edm::EDGetTokenT< trigger::TriggerEventWithRefs > triggerObject_token
Definition: EmDQM.h:227
static const unsigned TYPE_DOUBLE_ELE
Definition: EmDQM.h:240
HistoFiller< reco::RecoEcalCandidateCollection > * histoFillerClu
Definition: EmDQM.h:92
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: EmDQM.cc:376
static const unsigned TYPE_TRIPLE_ELE
Definition: EmDQM.h:243
bool mcMatchedOnly_
Definition: EmDQM.h:117
std::vector< std::vector< MonitorElement * > > histEtOfHltObjMatchToGens
Definition: EmDQM.h:207
std::vector< std::string > theHLTCollectionHumanNames
Definition: EmDQM.h:162
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_manualConf_token
Definition: EmDQM.h:234
GreaterByPt< reco::Particle > pTComparator_
Definition: EmDQM.h:222
unsigned int verbosity_
Definition: EmDQM.h:103
double genEtaAcc_
Definition: EmDQM.h:104
#define str(s)
std::vector< int > theHLTOutputTypes
Definition: EmDQM.h:164
double phi2DMax_
Definition: EmDQM.h:113
Definition: vlib.h:208
unsigned int reqNum
Definition: EmDQM.h:170
edm::ParameterSet makePSetForEtFilter(const std::string &)
Definition: EmDQM.cc:1310
edm::ParameterSet makePSetForPixelMatchFilter(const std::string &)
Definition: EmDQM.cc:1344
unsigned int minEtForEtaEffPlot_
Definition: EmDQM.h:115
std::vector< std::vector< MonitorElement * > > etahists
Definition: EmDQM.h:201
edm::EDGetTokenT< edm::TriggerResults > hltResults_token
Definition: EmDQM.h:228
double etaMax_
Definition: EmDQM.h:109
Definition: event.py:1
Definition: Run.h:45
std::vector< std::vector< MonitorElement * > > ethists
Definition: EmDQM.h:203
std::vector< bool > plotiso
Definition: EmDQM.h:165