CMS 3D CMS Logo

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