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