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  // 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", "", "SIM"));
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) filterPSet.addParameter<int>("ncandcut", paramSet.getParameter<int>("cutnum"));
328  else if (filterPSet.getParameter<int>("ncandcut") > paramSet.getParameter<int>("cutnum")) {
329  paramSet.addParameter<int>("cutnum", filterPSet.getParameter<int>("ncandcut"));
330  paramSet.addParameter<unsigned>("reqNum", (unsigned)filterPSet.getParameter<int>("ncandcut"));
331  }
332 
333  filterVPSet.push_back(filterPSet);
334  }
335  else
336  break;
337 
338  } // end loop over filter modules of current trigger path
339 
340  // do not include this path when an empty filterPSet is detected.
341  if (!filterPSet.empty()) {
342  std::string lastModuleName = filterPSet.getParameter<edm::InputTag>("HLTCollectionLabels").label();
343  if (!hltConfig_.modulePSet(lastModuleName).exists("saveTags")) {
344  // make sure that 'theHLTOutputTypes' of the last filter of a photon path is set to trigger::TriggerPhoton
345  // this is coupled to the parameter 'saveTag = true'
346  if ((j == TYPE_SINGLE_PHOTON || j == TYPE_DOUBLE_PHOTON) && pathName.rfind("Ele") == std::string::npos) {
347  filterVPSet.back().addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);
348  }
349  }
350  paramSet.addParameter<std::vector<edm::ParameterSet> >("filters", filterVPSet);
351  }
352  else {
353  if (verbosity_ >= OUTPUT_ALL)
354  edm::LogPrint("EmDQM") << "Will not include this path in the validation due to errors while generating the parameter set.";
355  continue;
356  }
357 
358  // dump generated parameter set
359  //std::cout << paramSet.dump() << std::endl;
360 
361  paramSets.push_back(paramSet);
362  } // loop over all paths of this analysis type
363 
364  } // loop over analysis types (single ele etc.)
365  }
366 
369 
371  // loop over all the trigger path parameter sets
373  for (std::vector<edm::ParameterSet>::iterator psetIt = paramSets.begin(); psetIt != paramSets.end(); ++psetIt) {
376  }
377 
378  if (changed) {
379  // The HLT config has actually changed wrt the previous Run, hence rebook your
380  // histograms or do anything else dependent on the revised HLT config
381  }
382  } else {
383  // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
384  // with the file and/or code and needs to be investigated!
385  if (verbosity_ >= OUTPUT_ERRORS)
386  edm::LogError("EmDQM") << " HLT config extraction failure with process name '" << triggerObject_.process() << "'.";
387  // In this case, all access methods will return empty values!
388  }
389 }
390 
391 void
393 {
395  // loop over all the trigger path parameter sets
397  for (std::vector<edm::ParameterSet>::iterator psetIt = paramSets.begin(); psetIt != paramSets.end(); ++psetIt) {
398  SetVarsFromPSet(psetIt);
399 
400  iBooker.setCurrentFolder(dirname_);
401 
403  // Set up Histogram of Effiency vs Step. //
404  // theHLTCollectionLabels is a vector of InputTags //
405  // from the configuration file. //
407  // Et & eta distributions
408  std::vector<MonitorElement*> etahist;
409  std::vector<MonitorElement*> phihist;
410  std::vector<MonitorElement*> ethist;
411  std::vector<MonitorElement*> etahistmatch;
412  std::vector<MonitorElement*> phihistmatch;
413  std::vector<MonitorElement*> ethistmatch;
414  std::vector<MonitorElement*> histEtOfHltObjMatchToGen;
415  std::vector<MonitorElement*> histEtaOfHltObjMatchToGen;
416  std::vector<MonitorElement*> histPhiOfHltObjMatchToGen;
417  // Plots of efficiency per step
419  MonitorElement* totalmatch;
420  //generator histograms
421  MonitorElement* etgen;
422  MonitorElement* etagen;
423  MonitorElement* phigen;
424 
425  std::string histName="total_eff";
426  std::string histTitle = "total events passing";
427  if (!mcMatchedOnly_) {
428  // This plot will have bins equal to 2+(number of
429  // HLTCollectionLabels in the config file)
430  total = iBooker.book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
431  total->setBinLabel(numOfHLTCollectionLabels+1,"Total");
432  total->setBinLabel(numOfHLTCollectionLabels+2,"Gen");
433  for (unsigned int u=0; u<numOfHLTCollectionLabels; u++) {
434  total->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());
435  }
436  }
437 
438  histName="total_eff_MC_matched";
439  histTitle="total events passing (mc matched)";
440  totalmatch = iBooker.book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
441  totalmatch->setBinLabel(numOfHLTCollectionLabels+1,"Total");
442  totalmatch->setBinLabel(numOfHLTCollectionLabels+2,"Gen");
443  for (unsigned int u=0; u<numOfHLTCollectionLabels; u++) {
444  totalmatch->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());
445  }
446 
447  MonitorElement* tmphisto;
448  //MonitorElement* tmpiso;
449 
451  // Set up generator-level histograms //
453  std::string pdgIdString;
454  switch(pdgGen) {
455  case 11:
456  pdgIdString="Electron";break;
457  case 22:
458  pdgIdString="Photon";break;
459  default:
460  pdgIdString="Particle";
461  }
462 
463  histName = "gen_et";
464  histTitle= "E_{T} of " + pdgIdString + "s" ;
465  etgen = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,plotPtMin,plotPtMax);
466  histName = "gen_eta";
467  histTitle= "#eta of "+ pdgIdString +"s " ;
468  etagen = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,-etaMax_, etaMax_);
469  histName = "gen_phi";
470  histTitle= "#phi of "+ pdgIdString +"s " ;
471  if (!noPhiPlots_) phigen = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,-phiMax_, phiMax_);
472 
474  // Set up histograms of HLT objects //
476  // Determine what strings to use for histogram titles
477  std::vector<std::string> HltHistTitle;
478  if ( theHLTCollectionHumanNames.size() == numOfHLTCollectionLabels && useHumanReadableHistTitles_ ) {
479  HltHistTitle = theHLTCollectionHumanNames;
480  } else {
481  for (unsigned int i =0; i < numOfHLTCollectionLabels; i++) {
482  HltHistTitle.push_back(theHLTCollectionLabels[i].label());
483  }
484  }
485 
486  for(unsigned int i = 0; i< numOfHLTCollectionLabels ; i++){
487  if (!mcMatchedOnly_) {
488  // Et distribution of HLT objects passing filter i
489  histName = theHLTCollectionLabels[i].label()+"et_all";
490  histTitle = HltHistTitle[i]+" Et (ALL)";
491  tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,plotPtMin,plotPtMax);
492  ethist.push_back(tmphisto);
493 
494  // Eta distribution of HLT objects passing filter i
495  histName = theHLTCollectionLabels[i].label()+"eta_all";
496  histTitle = HltHistTitle[i]+" #eta (ALL)";
497  tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,-etaMax_, etaMax_);
498  etahist.push_back(tmphisto);
499 
500  if (!noPhiPlots_) {
501  // Phi distribution of HLT objects passing filter i
502  histName = theHLTCollectionLabels[i].label()+"phi_all";
503  histTitle = HltHistTitle[i]+" #phi (ALL)";
504  tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,-phiMax_, phiMax_);
505  phihist.push_back(tmphisto);
506  }
507 
508 
509  // Et distribution of HLT object that is closest delta-R match to sorted gen particle(s)
510  histName = theHLTCollectionLabels[i].label()+"et";
511  histTitle = HltHistTitle[i]+" Et";
512  tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,plotPtMin,plotPtMax);
513  histEtOfHltObjMatchToGen.push_back(tmphisto);
514 
515  // eta distribution of HLT object that is closest delta-R match to sorted gen particle(s)
516  histName = theHLTCollectionLabels[i].label()+"eta";
517  histTitle = HltHistTitle[i]+" eta";
518  tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,-etaMax_, etaMax_);
519  histEtaOfHltObjMatchToGen.push_back(tmphisto);
520 
521  if (!noPhiPlots_) {
522  // phi distribution of HLT object that is closest delta-R match to sorted gen particle(s)
523  histName = theHLTCollectionLabels[i].label()+"phi";
524  histTitle = HltHistTitle[i]+" phi";
525  tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,-phiMax_, phiMax_);
526  histPhiOfHltObjMatchToGen.push_back(tmphisto);
527  }
528  }
529 
530  // Et distribution of gen object matching HLT object passing filter i
531  histName = theHLTCollectionLabels[i].label()+"et_MC_matched";
532  histTitle = HltHistTitle[i]+" Et (MC matched)";
533  tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,plotPtMin,plotPtMax);
534  ethistmatch.push_back(tmphisto);
535 
536  // Eta distribution of gen object matching HLT object passing filter i
537  histName = theHLTCollectionLabels[i].label()+"eta_MC_matched";
538  histTitle = HltHistTitle[i]+" #eta (MC matched)";
539  tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,-etaMax_, etaMax_);
540  etahistmatch.push_back(tmphisto);
541 
542  if (!noPhiPlots_) {
543  // Phi distribution of gen object matching HLT object passing filter i
544  histName = theHLTCollectionLabels[i].label()+"phi_MC_matched";
545  histTitle = HltHistTitle[i]+" #phi (MC matched)";
546  tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),nbins_,-phiMax_, phiMax_);
547  phihistmatch.push_back(tmphisto);
548  }
549  }
550 
551  // Et & eta distributions
552  etahists.push_back(etahist);
553  phihists.push_back(phihist);
554  ethists.push_back(ethist);
555  etahistmatchs.push_back(etahistmatch);
556  phihistmatchs.push_back(phihistmatch);
557  ethistmatchs.push_back(ethistmatch);
558  histEtOfHltObjMatchToGens.push_back(histEtOfHltObjMatchToGen);
559  histEtaOfHltObjMatchToGens.push_back(histEtaOfHltObjMatchToGen);
560  histPhiOfHltObjMatchToGens.push_back(histPhiOfHltObjMatchToGen);
561  // commented out because uses data not included in HTLDEBUG and uses
562  // Isolation distributions
563  //etahistisos.push_back(etahistiso);
564  //phihistisos.push_back(phihistiso);
565  //ethistisos.push_back(ethistiso);
566  //etahistisomatchs.push_back(etahistisomatch);
567  //phihistisomatchs.push_back(phihistisomatch);
568  //ethistisomatchs.push_back(ethistisomatch);
569  //histEtIsoOfHltObjMatchToGens.push_back(histEtIsoOfHltObjMatchToGen);
570  //histEtaIsoOfHltObjMatchToGens.push_back(histEtaIsoOfHltObjMatchToGen);
571  //histPhiIsoOfHltObjMatchToGens.push_back(histPhiIsoOfHltObjMatchToGen);
572 
573  totals.push_back(total);
574  totalmatchs.push_back(totalmatch);
575  etgens.push_back(etgen);
576  etagens.push_back(etagen);
577  phigens.push_back(phigen);
578  }
579 }
580 
582 // Destructor //
585 }
587 
589 {
591  // Decide if this was an event of interest. //
592  // Did the highest energy particles happen //
593  // to have |eta| < 2.5 ? Then continue. //
596  event.getByToken(genParticles_token, genParticles);
597  if(!genParticles.isValid()) {
599  edm::LogWarning("EmDQM") << "genParticles invalid.";
600  return false;
601  }
602 
603  std::vector<reco::LeafCandidate> allSortedGenParticles;
604 
605  for(edm::View<reco::Candidate>::const_iterator currentGenParticle = genParticles->begin(); currentGenParticle != genParticles->end(); currentGenParticle++){
606 
607  // TODO: do we need to check the states here again ?
608  // in principle, there should collections produced with the python configuration
609  // (other than 'genParticles') which fulfill these criteria
610  if ( !( abs((*currentGenParticle).pdgId())==pdgGen && (*currentGenParticle).status()==1 && (*currentGenParticle).et() > 2.0) ) continue;
611 
612  reco::LeafCandidate tmpcand( *(currentGenParticle) );
613 
614  if (tmpcand.et() < plotEtMin) continue;
615 
616  allSortedGenParticles.push_back(tmpcand);
617  }
618 
619  std::sort(allSortedGenParticles.begin(), allSortedGenParticles.end(),pTGenComparator_);
620 
621  // return false if not enough particles found
622  if (allSortedGenParticles.size() < gencut_)
623  return false;
624 
625  // additional check (this might be legacy code and we need to check
626  // whether this should not be removed ?)
627 
628  // We now have a sorted collection of all generated particles
629  // with pdgId = pdgGen.
630  // Loop over them to see if the top gen particles have eta within acceptance
631  // bool keepEvent = true;
632  for (unsigned int i = 0 ; i < gencut_ ; i++ ) {
633  bool inECALgap = fabs(allSortedGenParticles[i].eta()) > 1.4442 && fabs(allSortedGenParticles[i].eta()) < 1.556;
634  if ( (fabs(allSortedGenParticles[i].eta()) > genEtaAcc_) || inECALgap ) {
635  //edm::LogWarning("EmDQM") << "Throwing event away. Gen particle with pdgId="<< allSortedGenParticles[i].pdgId() <<"; et="<< allSortedGenParticles[i].et() <<"; and eta="<< allSortedGenParticles[i].eta() <<" beyond acceptance.";
636  return false;
637  }
638  }
639 
640  // all tests passed
641  return true;
642 }
644 
646 {
647  // note that this code is very similar to the one in checkGeneratedParticlesRequirement(..)
648  // and hopefully can be merged with it at some point in the future
649 
650  edm::Handle< edm::View<reco::Candidate> > referenceParticles;
651  // get the right data according to the trigger path currently looked at
652  if (autoConfMode_) {
653  switch(reqNum) {
654  case 1:
655  if (pdgGen == 11) event.getByToken(gencutColl_fidWenu_token, referenceParticles);
656  else event.getByToken(gencutColl_fidGammaJet_token, referenceParticles);
657  break;
658  case 2:
659  if (pdgGen == 11) event.getByToken(gencutColl_fidZee_token, referenceParticles);
660  else event.getByToken(gencutColl_fidDiGamma_token, referenceParticles);
661  break;
662  case 3:
663  event.getByToken(gencutColl_fidTripleEle_token, referenceParticles);
664  break;
665  }
666  } else {
667  event.getByToken(gencutColl_manualConf_token, referenceParticles);
668  }
669  if(!referenceParticles.isValid()) {
671  edm::LogWarning("EmDQM") << "referenceParticles invalid.";
672  return false;
673  }
674 
675  std::vector<const reco::Candidate *> allSortedReferenceParticles;
676 
677  for(edm::View<reco::Candidate>::const_iterator currentReferenceParticle = referenceParticles->begin();
678  currentReferenceParticle != referenceParticles->end();
679  currentReferenceParticle++)
680  {
681  if ( currentReferenceParticle->et() <= 2.0)
682  continue;
683 
684  // Note that for determining the overall efficiency,
685  // we should only allow
686  //
687  // HOWEVER: for turn-on curves, we need to let
688  // more electrons pass
689  if (currentReferenceParticle->et() < plotEtMin)
690  continue;
691 
692  // TODO: instead of filling a new vector we could simply count here...
693  allSortedReferenceParticles.push_back(&(*currentReferenceParticle));
694  }
695 
696  // std::sort(allSortedReferenceParticles.begin(), allSortedReferenceParticles.end(),pTComparator_);
697 
698  // return false if not enough particles found
699  return allSortedReferenceParticles.size() >= gencut_;
700 }
701 
703 // method called to for each event //
705 void
707 {
708  // loop over all the trigger path parameter sets
709  unsigned int vPos = 0;
710  for (std::vector<edm::ParameterSet>::iterator psetIt = paramSets.begin(); psetIt != paramSets.end(); ++psetIt, ++vPos) {
711  SetVarsFromPSet(psetIt);
712  // get the set forthe current path
715 
717  // Check if there's enough gen particles //
718  // of interest //
720  // get the right data according to the trigger path currently looked at
722  if (autoConfMode_) {
723  switch(reqNum) {
724  case 1:
725  if (pdgGen == 11) event.getByToken(gencutColl_fidWenu_token, cutCounter);
726  else event.getByToken(gencutColl_fidGammaJet_token, cutCounter);
727  break;
728  case 2:
729  if (pdgGen == 11) event.getByToken(gencutColl_fidZee_token, cutCounter);
730  else event.getByToken(gencutColl_fidDiGamma_token, cutCounter);
731  break;
732  case 3:
733  event.getByToken(gencutColl_fidTripleEle_token, cutCounter);
734  break;
735  }
736  } else {
737  event.getByToken(gencutColl_manualConf_token, cutCounter);
738  }
739  if (cutCounter->size() < (unsigned int)gencut_) {
740  //edm::LogWarning("EmDQM") << "Less than "<< gencut_ <<" gen particles with pdgId=" << pdgGen;
741  continue;
742  }
743 
744  // fill L1 and HLT info
745  // get objects possed by each filter
747  event.getByToken(triggerObject_token,triggerObj);
748  if(!triggerObj.isValid()) {
750  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)";
751  continue;
752  }
753 
754  // Were enough high energy gen particles found?
755  if (event.isRealData()) {
756  // running validation on data.
757  // TODO: we should check that the entire
758  // run is on the same type (all data or
759  // all MC). Otherwise one gets
760  // uninterpretable results...
761  if (!checkRecoParticlesRequirement(event))
762  continue;
763  }
764  else { // MC
765  // if no, throw event away
767  continue;
768  }
769 
770  // It was an event worth keeping. Continue.
771 
773  // Fill the bin labeled "Total" //
774  // This will be the number of events looked at. //
776  if (!mcMatchedOnly_) totals.at(vPos)->Fill(numOfHLTCollectionLabels+0.5);
777  totalmatchs.at(vPos)->Fill(numOfHLTCollectionLabels+0.5);
778 
780  // Fill generator info //
782  // the gencut_ highest Et generator objects of the preselected type are our matches
783 
784  std::vector<reco::Particle> sortedGen;
785  for(edm::View<reco::Candidate>::const_iterator genpart = cutCounter->begin(); genpart != cutCounter->end();genpart++){
786  reco::Particle tmpcand( genpart->charge(), genpart->p4(), genpart->vertex(),genpart->pdgId(),genpart->status() );
787  if (tmpcand.et() >= plotEtMin) {
788  sortedGen.push_back(tmpcand);
789  }
790  }
791  std::sort(sortedGen.begin(),sortedGen.end(),pTComparator_ );
792 
793  // Now the collection of gen particles is sorted by pt.
794  // So, remove all particles from the collection so that we
795  // only have the top "1 thru gencut_" particles in it
796  if (sortedGen.size() < gencut_){
797  continue;
798  }
799  sortedGen.erase(sortedGen.begin()+gencut_,sortedGen.end());
800 
801  for (unsigned int i = 0 ; i < gencut_ ; i++ ) {
802  etgens.at(vPos)->Fill( sortedGen[i].et() ); //validity has been implicitily checked by the cut on gencut_ above
803  if (sortedGen[i].et() > minEtForEtaEffPlot_) {
804  etagens.at(vPos)->Fill( sortedGen[i].eta() );
805  if (!noPhiPlots_) phigens.at(vPos)->Fill( sortedGen[i].phi() );
806  }
807  } // END of loop over Generated particles
808  if (gencut_ >= reqNum && !mcMatchedOnly_) totals.at(vPos)->Fill(numOfHLTCollectionLabels+1.5); // this isn't really needed anymore keep for backward comp.
809  if (gencut_ >= reqNum) totalmatchs.at(vPos)->Fill(numOfHLTCollectionLabels+1.5); // this isn't really needed anymore keep for backward comp.
810 
811  bool accepted = true; // flags that the event has been accepted by all filters before
813  event.getByToken(hltResults_token, hltResults);
815  // Loop over filter modules //
817  for(unsigned int n=0; n < numOfHLTCollectionLabels ; n++) {
818  // check that there are not less sortedGen particles than nCandCut requires for this filter
819  if (sortedGen.size() < nCandCuts.at(n)) {
820  if (verbosity_ >= OUTPUT_ERRORS)
821  edm::LogError("EmDQM") << "There are less generated particles than the module '" << theHLTCollectionLabels[n].label() << "' requires.";
822  continue;
823  }
824  std::vector<reco::Particle> sortedGenForFilter(sortedGen);
825  sortedGenForFilter.erase(sortedGenForFilter.begin() + nCandCuts.at(n), sortedGenForFilter.end());
826 
827  // Fill only if this filter was run.
828  if (pathIndex != 0 && hltConfig_.moduleIndex(pathIndex, theHLTCollectionLabels[n].label()) > hltResults->index(pathIndex)) break;
829  // These numbers are from the Parameter Set, such as:
830  // theHLTOutputTypes = cms.uint32(100)
831  switch(theHLTOutputTypes[n])
832  {
833  case trigger::TriggerL1NoIsoEG: // Non-isolated Level 1
834  histoFillerL1NonIso->fillHistos(triggerObj,event,vPos,n,sortedGenForFilter,accepted);
835  break;
836  case trigger::TriggerL1IsoEG: // Isolated Level 1
837  histoFillerL1Iso->fillHistos(triggerObj,event,vPos,n,sortedGenForFilter,accepted);
838  break;
839  case trigger::TriggerPhoton: // Photon
840  histoFillerPho->fillHistos(triggerObj,event,vPos,n,sortedGenForFilter,accepted);
841  break;
842  case trigger::TriggerElectron: // Electron
843  histoFillerEle->fillHistos(triggerObj,event,vPos,n,sortedGenForFilter,accepted);
844  break;
845  case trigger::TriggerCluster: // TriggerCluster
846  histoFillerClu->fillHistos(triggerObj,event,vPos,n,sortedGenForFilter,accepted);
847  break;
848  default:
849  throw(cms::Exception("Release Validation Error") << "HLT output type not implemented: theHLTOutputTypes[n]" );
850  }
851  } // END of loop over filter modules
852 
853  // earse the dummy and fill with real set
856  }
857 }
858 
860 // fillHistos //
861 // Called by analyze method. //
863 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)
864 {
865  std::vector<edm::Ref<T> > recoecalcands;
866  if ( ( triggerObj->filterIndex(dqm->theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if available
867  dqm->hltCollectionLabelsMissed.insert(dqm->theHLTCollectionLabels[n].encode());
868  accepted = false;
869  return;
870  }
871 
872  dqm->hltCollectionLabelsFound.insert(dqm->theHLTCollectionLabels[n].encode());
873 
875  // Retrieve saved filter objects //
877  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),dqm->theHLTOutputTypes[n],recoecalcands);
878  //Danger: special case, L1 non-isolated
879  // needs to be merged with L1 iso
881  std::vector<edm::Ref<T> > isocands;
882  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),trigger::TriggerL1IsoEG,isocands);
883  if (isocands.size()>0)
884  {
885  for (unsigned int i=0; i < isocands.size(); i++)
886  recoecalcands.push_back(isocands[i]);
887  }
888  } // END of if theHLTOutputTypes == 82
889 
890 
891  if (recoecalcands.size() < 1){ // stop if no object passed the previous filter
892  accepted = false;
893  return;
894  }
895 
896  //if (recoecalcands.size() >= reqNum )
897  if (recoecalcands.size() >= dqm->nCandCuts.at(n) && !dqm->mcMatchedOnly_)
898  dqm->totals.at(vPos)->Fill(n+0.5);
899 
901  // check for validity //
902  // prevents crash in CMSSW_3_1_0_pre6 //
904  for (unsigned int j=0; j<recoecalcands.size(); j++){
905  if(!( recoecalcands.at(j).isAvailable())){
906  if (dqm->verbosity_ >= dqm->OUTPUT_ERRORS)
907  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.";
908  return;
909  }
910  }
911 
912  if (!dqm->mcMatchedOnly_) {
914  // Loop over the Generated Particles, and find the //
915  // closest HLT object match. //
917  //for (unsigned int i=0; i < gencut_; i++) {
918  for (unsigned int i=0; i < dqm->nCandCuts.at(n); i++) {
919  math::XYZVector currentGenParticleMomentum = sortedGen[i].momentum();
920 
921  float closestDeltaR = 0.5;
922  int closestEcalCandIndex = -1;
923  for (unsigned int j=0; j<recoecalcands.size(); j++) {
924  float deltaR = DeltaR(recoecalcands[j]->momentum(),currentGenParticleMomentum);
925 
926  if (deltaR < closestDeltaR) {
927  closestDeltaR = deltaR;
928  closestEcalCandIndex = j;
929  }
930  }
931 
932  // If an HLT object was found within some delta-R
933  // of this gen particle, store it in a histogram
934  if ( closestEcalCandIndex >= 0 ) {
935  dqm->histEtOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->et() );
936  dqm->histEtaOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->eta() );
937  if (!dqm->noPhiPlots_) dqm->histPhiOfHltObjMatchToGens.at(vPos).at(n)->Fill( recoecalcands[closestEcalCandIndex]->phi() );
938 
939  } // END of if closestEcalCandIndex >= 0
940  }
941 
943  // Loop over all HLT objects in this filter step, and //
944  // fill histograms. //
946  // bool foundAllMatches = false;
947  // unsigned int numOfHLTobjectsMatched = 0;
948  for (unsigned int i=0; i<recoecalcands.size(); i++) {
950  //float closestGenParticleDr = 99.0;
951  //for(unsigned int j =0; j < gencut_; j++) {
952  // math::XYZVector currentGenParticle = sortedGen[j].momentum();
953 
954  // double currentDeltaR = DeltaR(recoecalcands[i]->momentum(),currentGenParticle);
955  // if ( currentDeltaR < closestGenParticleDr ) {
956  // closestGenParticleDr = currentDeltaR;
957  // }
958  //}
960  //if ( !(fabs(closestGenParticleDr < 0.3)) ) continue;
961 
962  //numOfHLTobjectsMatched++;
963  //if (numOfHLTobjectsMatched >= gencut_) foundAllMatches=true;
964 
965  // Fill HLT object histograms
966  dqm->ethists.at(vPos).at(n) ->Fill(recoecalcands[i]->et() );
967  dqm->etahists.at(vPos).at(n)->Fill(recoecalcands[i]->eta() );
968  if (!dqm->noPhiPlots_) dqm->phihists.at(vPos).at(n)->Fill(recoecalcands[i]->phi() );
969 
970  }
971  }
972 
974  // Fill mc matched objects into histograms //
976  unsigned int matchedMcParts = 0;
977  float mindist=0.3;
978  if(n==0) mindist=0.5; //low L1-resolution => allow wider matching
979  for(unsigned int i =0; i < dqm->nCandCuts.at(n); ++i){
980  //match generator candidate
981  bool matchThis= false;
982  math::XYZVector candDir=sortedGen[i].momentum();
983  //unsigned int closest = 0;
984  double closestDr = 1000.;
985  for(unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); ++trigOb){
986  double dr = DeltaR(recoecalcands[trigOb]->momentum(),candDir);
987  if (dr < closestDr) {
988  closestDr = dr;
989  //closest = trigOb;
990  }
991  if (closestDr > mindist) { // it's not really a "match" if it's that far away
992  //closest = -1;
993  } else {
994  matchedMcParts++;
995  matchThis = true;
996  }
997  }
998  if ( !matchThis ) {
999  accepted = false;
1000  continue; // only plot matched candidates
1001  }
1002  // fill coordinates of mc particle matching trigger object
1003  dqm->ethistmatchs.at(vPos).at(n) ->Fill( sortedGen[i].et() );
1004  if (sortedGen[i].et() > dqm->minEtForEtaEffPlot_) {
1005  dqm->etahistmatchs.at(vPos).at(n)->Fill( sortedGen[i].eta() );
1006  if (!dqm->noPhiPlots_) dqm->phihistmatchs.at(vPos).at(n)->Fill( sortedGen[i].phi() );
1007  }
1008  }
1009  // fill total mc matched efficiency
1010 
1011  if (matchedMcParts >= dqm->nCandCuts.at(n) && accepted == true)
1012  dqm->totalmatchs.at(vPos)->Fill(n+0.5);
1013 }
1014 
1015 void
1016 EmDQM::endRun(edm::Run const &iRun, edm::EventSetup const &iSetup)
1017 {
1018  // loop over all the trigger path parameter sets
1019  unsigned int vPos = 0;
1020  for (std::vector<edm::ParameterSet>::iterator psetIt = paramSets.begin(); psetIt != paramSets.end(); ++psetIt, ++vPos) {
1021  SetVarsFromPSet(psetIt);
1022 
1023  // print information about hltCollectionLabels which were not found
1024  // (but only those which were never found)
1025 
1026  // check which ones were never found
1027  std::vector<std::string> labelsNeverFound;
1028 
1029  BOOST_FOREACH(const edm::InputTag &tag, hltCollectionLabelsMissedPerPath.at(vPos))
1030  {
1031  if ((hltCollectionLabelsFoundPerPath.at(vPos)).count(tag.encode()) == 0)
1032  // never found
1033  labelsNeverFound.push_back(tag.encode());
1034 
1035  } // loop over all tags which were missed at least once
1036 
1037  if (labelsNeverFound.empty())
1038  continue;
1039 
1040  std::sort(labelsNeverFound.begin(), labelsNeverFound.end());
1041 
1042  // there was at least one label which was never found
1043  // (note that this could also be because the corresponding
1044  // trigger path slowly fades out to zero efficiency)
1045  if (verbosity_ >= OUTPUT_WARNINGS)
1046  edm::LogWarning("EmDQM") << "There were some HLTCollectionLabels which were never found:";
1047 
1048  BOOST_FOREACH(const edm::InputTag &tag, labelsNeverFound)
1049  {
1050  if (verbosity_ >= OUTPUT_ALL)
1051  edm::LogPrint("EmDQM") << " " << tag;
1052  }
1053  }
1054 }
1055 
1057 // method called once each job just after ending the event loop //
1060 {
1061 
1062 }
1063 
1064 // returns count of non-overlapping occurrences of 'sub' in 'str'
1065 int
1067 {
1068  if (sub.length() == 0) return 0;
1069  int count = 0;
1070  for (size_t offset = str.find(sub); offset != std::string::npos;
1071  offset = str.find(sub, offset + sub.length()))
1072  {
1073  ++count;
1074  }
1075  return count;
1076 }
1077 
1078 //----------------------------------------------------------------------
1079 // find egamma trigger paths from trigger name
1080 std::vector<std::vector<std::string> >
1082 {
1083  std::vector<std::vector<std::string> > Paths(5);
1084  // Loop over all paths in the menu
1085  for (unsigned int i=0; i<hltConfig_.size(); i++) {
1086 
1088 
1089  // Find electron and photon paths and classify them
1090  if (int(path.find("HLT_")) == 0) { // Path should start with 'HLT_'
1091 
1092  int scCount = countSubstring(path, "_SC");
1093  int eleCount = countSubstring(path, "Ele");
1094  int doubleEleCount = countSubstring(path, "DoubleEle");
1095  int tripleEleCount = countSubstring(path, "TripleEle");
1096  int photonCount = countSubstring(path, "Photon");
1097  int doublePhotonCount = countSubstring(path, "DoublePhoton");
1098 
1099  int totEleCount = 2*tripleEleCount + doubleEleCount + eleCount + scCount;
1100  int totPhotonCount = doublePhotonCount + photonCount;
1101 
1102  if (totEleCount + totPhotonCount < 1) continue;
1103  switch (totEleCount) {
1104  case 1:
1105  Paths[TYPE_SINGLE_ELE].push_back(path);
1106  //std::cout << "Electron \t" << path << std::endl;
1107  break;
1108  case 2:
1109  Paths[TYPE_DOUBLE_ELE].push_back(path);
1110  //std::cout << "DoubleElectron \t" << path << std::endl;
1111  break;
1112  case 3:
1113  Paths[TYPE_TRIPLE_ELE].push_back(path);
1114  //std::cout << "TripleElectron \t" << path << std::endl;
1115  break;
1116  }
1117 
1118  switch (totPhotonCount) {
1119  case 1:
1120  Paths[TYPE_SINGLE_PHOTON].push_back(path);
1121  //std::cout << "Photon \t\t" << path << std::endl;
1122  break;
1123  case 2:
1124  Paths[TYPE_DOUBLE_PHOTON].push_back(path);
1125  //std::cout << "DoublePhoton \t" << path << std::endl;
1126  break;
1127  }
1128  }
1129  //std::cout << i << " triggerName: " << path << " containing " << hltConfig_.size(i) << " modules."<< std::endl;
1130  }
1131  return Paths;
1132 }
1133 
1134 //----------------------------------------------------------------------
1135 // get the names of filters of a given path
1136 std::vector<std::string>
1138 {
1139  std::vector<std::string> filters;
1140 
1141  //std::cout << "Pathname: " << path << std::endl;
1142 
1143  // Loop over all modules in the path
1144  for (unsigned int i=0; i<hltConfig_.size(path); i++) {
1145 
1147  std::string moduleType = hltConfig_.moduleType(module);
1148  std::string moduleEDMType = hltConfig_.moduleEDMType(module);
1149 
1150  // Find filters
1151  if (moduleEDMType == "EDFilter" || moduleType.find("Filter") != std::string::npos) { // older samples may not have EDMType data included
1152  filters.push_back(module);
1153  //std::cout << i << " moduleLabel: " << module << " moduleType: " << moduleType << " moduleEDMType: " << moduleEDMType << std::endl;
1154  }
1155  }
1156  return filters;
1157 }
1158 
1159 //----------------------------------------------------------------------
1160 // get the primary Et cut from the trigger name
1161 double
1163 {
1164  double minEt = -1;
1165 
1166  boost::regex reg("^HLT_.*?(Ele|Photon|EG|SC)([[:digit:]]+).*");
1167 
1168  boost::smatch what;
1169  if (boost::regex_match(path, what, reg, boost::match_extra))
1170  {
1171  minEt = boost::lexical_cast<double>(what[2]);
1172  }
1173 
1174  return minEt;
1175 }
1176 
1177 //----------------------------------------------------------------------
1178 
1181 {
1182  // generates a PSet to analyze the behaviour of an L1 seed.
1183  //
1184  // moduleName is the name of the HLT module which filters
1185  // on the L1 seed.
1186  edm::ParameterSet retPSet;
1187 
1188  retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
1189  //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
1190  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1191  retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
1192  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerL1NoIsoEG);
1193 
1194  // as HLTLevel1GTSeed has no parameter ncandcut we determine the value from the name of the filter
1195 
1196  int orCount = countSubstring(moduleName, "OR");
1197  int egCount = countSubstring(moduleName, "EG");
1198  int dEgCount = countSubstring(moduleName, "DoubleEG");
1199  int tEgCount = countSubstring(moduleName, "TripleEG");
1200 
1201  int candCount = 2*tEgCount + dEgCount + egCount;
1202  // if L1 is and OR of triggers try the assumption that all of them are similar first and, if not successful, let the path name decide
1203  if (orCount > 0 && candCount > 0) {
1204  if (egCount % (orCount+1) == 0 && dEgCount % (orCount+1) == 0 && tEgCount % (orCount+1) == 0) candCount /= (orCount+1);
1205  else candCount = -1;
1206  }
1207 
1208  switch (candCount) {
1209  case 0:
1210  retPSet.addParameter<int>("ncandcut", 0);
1211  break;
1212  case 1:
1213  retPSet.addParameter<int>("ncandcut", 1);
1214  break;
1215  case 2:
1216  retPSet.addParameter<int>("ncandcut", 2);
1217  break;
1218  case 3:
1219  retPSet.addParameter<int>("ncandcut", 3);
1220  break;
1221  default:
1222  retPSet.addParameter<int>("ncandcut", -1);
1223  }
1224 
1225  return retPSet;
1226 }
1227 
1228 //----------------------------------------------------------------------
1229 
1232 {
1233  // generates a PSet to analyze the behaviour of L1 to supercluster match filter.
1234  //
1235  // moduleName is the name of the HLT module which requires the match
1236  // between supercluster and L1 seed.
1237  //
1238  edm::ParameterSet retPSet;
1239 
1240  retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
1241  //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
1242  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1243  retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
1244  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1245  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1246 
1247  return retPSet;
1248 }
1249 
1250 //----------------------------------------------------------------------
1251 
1254 {
1255  edm::ParameterSet retPSet;
1256 
1257  retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
1258  //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
1259  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1260  retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
1261  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1262  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1263 
1264  return retPSet;
1265 }
1266 
1267 //----------------------------------------------------------------------
1268 
1271 {
1272  edm::ParameterSet retPSet;
1273 
1274  retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
1275  //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
1276  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1277  retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
1278  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerElectron);
1279  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1280 
1281  return retPSet;
1282 }
1283 
1284 //----------------------------------------------------------------------
1285 
1288 {
1289  edm::ParameterSet retPSet;
1290 
1291  retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
1292  //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
1293  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1294  retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
1295  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1296  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1297 
1298  return retPSet;
1299 }
1300 
1301 //----------------------------------------------------------------------
1302 
1305 {
1306  edm::ParameterSet retPSet;
1307 
1308  retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
1309  //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
1310  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1311  retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
1312  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1313  retPSet.addParameter<int>("ncandcut", 2);
1314 
1315  return retPSet;
1316 }
1317 
1318 //----------------------------------------------------------------------
1319 
1322 {
1323  edm::ParameterSet retPSet;
1324 
1325  // example usages of HLTEgammaGenericFilter are:
1326  // R9 shape filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolR9ShapeFilter
1327  // cluster shape filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolClusterShapeFilter
1328  // Ecal isolation filter hltL1NonIsoHLTNonIsoSingleElectronEt17TIghterEleIdIsolEcalIsolFilter
1329  // H/E filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHEFilter
1330  // HCAL isolation filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHcalIsolFilter
1331 
1332  // infer the type of filter by the type of the producer which
1333  // generates the collection used to cut on this
1334  edm::InputTag isoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("isoTag");
1335  edm::InputTag nonIsoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("nonIsoTag");
1336  //std::cout << "isoTag.label " << isoTag.label() << " nonIsoTag.label " << nonIsoTag.label() << std::endl;
1337 
1338  std::string inputType = hltConfig_.moduleType(isoTag.label());
1339  //std::cout << "inputType " << inputType << " moduleName " << moduleName << std::endl;
1340 
1341  //--------------------
1342  // sanity check: non-isolated path should be produced by the
1343  // same type of module
1344 
1345  // first check that the non-iso tag is non-empty
1346  //if (nonIsoTag.label().empty()) {
1347  // edm::LogError("EmDQM") << "nonIsoTag of HLTEgammaGenericFilter '" << moduleName << "' is empty.";
1348  // return retPSet;
1349  //}
1350  //if (inputType != hltConfig_.moduleType(nonIsoTag.label())) {
1351  // edm::LogError("EmDQM") << "C++ Type of isoTag '" << inputType << "' and nonIsoTag '" << hltConfig_.moduleType(nonIsoTag.label()) << "' are not the same for HLTEgammaGenericFilter '" << moduleName << "'.";
1352  // return retPSet;
1353  //}
1354  //--------------------
1355 
1356  // parameter saveTag determines the output type
1357  if (hltConfig_.saveTags(moduleName))
1358  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);
1359  else
1360  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1361 
1362  std::vector<edm::InputTag> isoCollections;
1363  isoCollections.push_back(isoTag);
1364  if (!nonIsoTag.label().empty())
1365  isoCollections.push_back(nonIsoTag);
1366 
1367  //--------------------
1368  // the following cases seem to have identical PSets ?
1369  //--------------------
1370 
1371  if (inputType == "EgammaHLTR9Producer" || // R9 shape
1372  inputType == "EgammaHLTR9IDProducer" || // R9 ID
1373  inputType == "EgammaHLTClusterShapeProducer" || // cluster shape
1374  inputType == "EgammaHLTEcalRecIsolationProducer" || // ecal isolation
1375  inputType == "EgammaHLTHcalIsolationProducersRegional" || // HCAL isolation and HE
1376  inputType == "EgammaHLTGsfTrackVarProducer" // GSF track deta and dphi filter
1377  ) {
1378  retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
1379  //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
1380  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1381  retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", isoCollections);
1382  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1383 
1384  return retPSet;
1385  }
1386 
1387  if (verbosity_ >= OUTPUT_ERRORS)
1388  edm::LogError("EmDQM") << "Can't determine what the HLTEgammaGenericFilter '" << moduleName << "' should do: uses a collection produced by a module of C++ type '" << inputType << "'.";
1389  return edm::ParameterSet();
1390 }
1391 
1392 //----------------------------------------------------------------------
1393 
1396 {
1397  edm::ParameterSet retPSet;
1398 
1399  // example usages of HLTEgammaGenericFilter are:
1400  // R9 shape filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolR9ShapeFilter
1401  // cluster shape filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolClusterShapeFilter
1402  // Ecal isolation filter hltL1NonIsoHLTNonIsoSingleElectronEt17TIghterEleIdIsolEcalIsolFilter
1403  // H/E filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHEFilter
1404  // HCAL isolation filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHcalIsolFilter
1405 
1406  // infer the type of filter by the type of the producer which
1407  // generates the collection used to cut on this
1408  edm::InputTag isoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("isoTag");
1409  edm::InputTag nonIsoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("nonIsoTag");
1410  //std::cout << "isoTag.label " << isoTag.label() << " nonIsoTag.label " << nonIsoTag.label() << std::endl;
1411 
1412  std::string inputType = hltConfig_.moduleType(isoTag.label());
1413  //std::cout << "inputType " << inputType << " moduleName " << moduleName << std::endl;
1414 
1415  //--------------------
1416  // sanity check: non-isolated path should be produced by the
1417  // same type of module
1418 
1419  // first check that the non-iso tag is non-empty
1420  //if (nonIsoTag.label().empty()) {
1421  // edm::LogError("EmDQM") << "nonIsoTag of HLTEgammaGenericFilter '" << moduleName << "' is empty.";
1422  // return retPSet;
1423  //}
1424  //if (inputType != hltConfig_.moduleType(nonIsoTag.label())) {
1425  // edm::LogError("EmDQM") << "C++ Type of isoTag '" << inputType << "' and nonIsoTag '" << hltConfig_.moduleType(nonIsoTag.label()) << "' are not the same for HLTEgammaGenericFilter '" << moduleName << "'.";
1426  // return retPSet;
1427  //}
1428  //--------------------
1429 
1430  // parameter saveTag determines the output type
1431  if (hltConfig_.saveTags(moduleName))
1432  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);
1433  else
1434  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
1435 
1436  std::vector<edm::InputTag> isoCollections;
1437  isoCollections.push_back(isoTag);
1438  if (!nonIsoTag.label().empty())
1439  isoCollections.push_back(nonIsoTag);
1440 
1441  //--------------------
1442  // the following cases seem to have identical PSets ?
1443  //--------------------
1444 
1445  if (inputType == "EgammaHLTR9Producer" || // R9 shape
1446  inputType == "EgammaHLTR9IDProducer" || // R9 ID
1447  inputType == "EgammaHLTClusterShapeProducer" || // cluster shape
1448  inputType == "EgammaHLTEcalRecIsolationProducer" || // ecal isolation
1449  inputType == "EgammaHLTHcalIsolationProducersRegional" || // HCAL isolation and HE
1450  inputType == "EgammaHLTPhotonTrackIsolationProducersRegional" // Photon track isolation
1451  ) {
1452  retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
1453  //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
1454  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1455  retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", isoCollections);
1456  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1457 
1458  return retPSet;
1459  }
1460 
1461  if (verbosity_ >= OUTPUT_ERRORS)
1462  edm::LogError("EmDQM") << "Can't determine what the HLTEgammaGenericQuadraticFilter '" << moduleName << "' should do: uses a collection produced by a module of C++ type '" << inputType << "'.";
1463  return edm::ParameterSet();
1464 }
1465 
1466 //----------------------------------------------------------------------
1467 
1470 {
1471  edm::ParameterSet retPSet;
1472 
1473  // example usages of HLTElectronGenericFilter are:
1474  //
1475  // deta filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDetaFilter
1476  // dphi filter hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDphiFilter
1477  // track isolation hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolTrackIsolFilter
1478 
1479  // infer the type of filter by the type of the producer which
1480  // generates the collection used to cut on this
1481  edm::InputTag isoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("isoTag");
1482  edm::InputTag nonIsoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("nonIsoTag");
1483  //std::cout << "isoTag.label " << isoTag.label() << " nonIsoTag.label " << nonIsoTag.label() << std::endl;
1484 
1485  std::string inputType = hltConfig_.moduleType(isoTag.label());
1486  //std::cout << "inputType iso " << inputType << " inputType noniso " << hltConfig_.moduleType(nonIsoTag.label()) << " moduleName " << moduleName << std::endl;
1487 
1488  //--------------------
1489  // sanity check: non-isolated path should be produced by the
1490  // same type of module
1491  //if (nonIsoTag.label().empty()) {
1492  // edm::LogError("EmDQM") << "nonIsoTag of HLTElectronGenericFilter '" << moduleName << "' is empty.";
1493  // return retPSet;
1494  //}
1495  //if (inputType != hltConfig_.moduleType(nonIsoTag.label())) {
1496  // edm::LogError("EmDQM") << "C++ Type of isoTag '" << inputType << "' and nonIsoTag '" << hltConfig_.moduleType(nonIsoTag.label()) << "' are not the same for HLTElectronGenericFilter '" << moduleName << "'.";
1497  // return retPSet;
1498  //}
1499  //--------------------
1500 
1501  // the type of object to look for seems to be the
1502  // same for all uses of HLTEgammaGenericFilter
1503  retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerElectron);
1504 
1505  std::vector<edm::InputTag> isoCollections;
1506  isoCollections.push_back(isoTag);
1507  if (!nonIsoTag.label().empty())
1508  isoCollections.push_back(nonIsoTag);
1509 
1510  //--------------------
1511  // the following cases seem to have identical PSets ?
1512  //--------------------
1513 
1514  // note that whether deta or dphi is used is determined from
1515  // the product instance (not the module label)
1516  if (inputType == "EgammaHLTElectronDetaDphiProducer" || // deta and dphi filter
1517  inputType == "EgammaHLTElectronTrackIsolationProducers" // track isolation
1518  ) {
1519  retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
1520  //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
1521  retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
1522  retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", isoCollections);
1523  retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
1524 
1525  return retPSet;
1526  }
1527 
1528  if (verbosity_ >= OUTPUT_ERRORS)
1529  edm::LogError("EmDQM") << "Can't determine what the HLTElectronGenericFilter '" << moduleName << "' should do: uses a collection produced by a module of C++ type '" << inputType << "'.";
1530  return edm::ParameterSet();
1531 }
1532 
1533 //----------------------------------------------------------------------
1534 
1535 void EmDQM::SetVarsFromPSet(std::vector<edm::ParameterSet>::iterator psetIt)
1536 {
1537  dirname_="HLT/HLTEgammaValidation/"+psetIt->getParameter<std::string>("@module_label");
1538 
1539  pathIndex = psetIt->getUntrackedParameter<unsigned int>("pathIndex", 0);
1540  // parameters for generator study
1541  reqNum = psetIt->getParameter<unsigned int>("reqNum");
1542  pdgGen = psetIt->getParameter<int>("pdgGen");
1543  // plotting parameters (untracked because they don't affect the physics)
1544  plotEtMin = psetIt->getUntrackedParameter<double>("genEtMin",0.);
1545  plotPtMin = psetIt->getUntrackedParameter<double>("PtMin",0.);
1546  plotPtMax = psetIt->getUntrackedParameter<double>("PtMax",1000.);
1547 
1548  //preselction cuts
1549  gencutCollection_= psetIt->getParameter<edm::InputTag>("cutcollection");
1550  gencut_ = psetIt->getParameter<int>("cutnum");
1551 
1553  // Read in the Vector of Parameter Sets. //
1554  // Information for each filter-step //
1556  std::vector<edm::ParameterSet> filters =
1557  psetIt->getParameter<std::vector<edm::ParameterSet> >("filters");
1558 
1559  // empty vectors of parameters from previous paths
1560  theHLTCollectionLabels.clear();
1561  theHLTOutputTypes.clear();
1563  plotBounds.clear();
1564  isoNames.clear();
1565  plotiso.clear();
1566  nCandCuts.clear();
1567 
1568  int i = 0;
1569  for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++)
1570  {
1571 
1572  theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
1573  theHLTOutputTypes.push_back(filterconf->getParameter<int>("theHLTOutputTypes"));
1574  // Grab the human-readable name, if it is not specified, use the Collection Label
1575  theHLTCollectionHumanNames.push_back(filterconf->getUntrackedParameter<std::string>("HLTCollectionHumanName",theHLTCollectionLabels[i].label()));
1576 
1577  std::vector<double> bounds = filterconf->getParameter<std::vector<double> >("PlotBounds");
1578  // If the size of plot "bounds" vector != 2, abort
1579  assert(bounds.size() == 2);
1580  plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1]));
1581  isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >("IsoCollections"));
1582 
1583  //for (unsigned int i=0; i<isoNames.back().size(); i++) {
1584  // switch(theHLTOutputTypes.back()) {
1585  // case trigger::TriggerL1NoIsoEG:
1586  // histoFillerL1NonIso->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<l1extra::L1EmParticleCollection , float>>>(isoNames.back()[i]));
1587  // break;
1588  // case trigger::TriggerL1IsoEG: // Isolated Level 1
1589  // histoFillerL1Iso->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<l1extra::L1EmParticleCollection , float>>>(isoNames.back()[i]));
1590  // break;
1591  // case trigger::TriggerPhoton: // Photon
1592  // histoFillerPho->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<reco::RecoEcalCandidateCollection , float>>>(isoNames.back()[i]));
1593  // break;
1594  // case trigger::TriggerElectron: // Electron
1595  // histoFillerEle->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<reco::ElectronCollection , float>>>(isoNames.back()[i]));
1596  // break;
1597  // case trigger::TriggerCluster: // TriggerCluster
1598  // histoFillerClu->isoNameTokens_.push_back(consumes<edm::AssociationMap<edm::OneToValue<reco::RecoEcalCandidateCollection , float>>>(isoNames.back()[i]));
1599  // break;
1600  // default:
1601  // throw(cms::Exception("Release Validation Error") << "HLT output type not implemented: theHLTOutputTypes[n]" );
1602  // }
1603  //}
1604 
1605  // If the size of the isoNames vector is not greater than zero, abort
1606  assert(isoNames.back().size()>0);
1607  if (isoNames.back().at(0).label()=="none") {
1608  plotiso.push_back(false);
1609  } else {
1610  if (!noIsolationPlots_) plotiso.push_back(true);
1611  else plotiso.push_back(false);
1612  }
1613  nCandCuts.push_back(filterconf->getParameter<int>("ncandcut"));
1614  i++;
1615  } // END of loop over parameter sets
1616 
1617  // Record number of HLTCollectionLabels
1619 }
1620 
1621 //----------------------------------------------------------------------
1622 
unsigned int size() const
number of trigger paths in trigger table
edm::ParameterSet makePSetForEgammaGenericFilter(const std::string &)
Definition: EmDQM.cc:1321
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: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:1395
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
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:863
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:1081
bool checkRecoParticlesRequirement(const edm::Event &event)
Definition: EmDQM.cc:645
const std::string & triggerName(unsigned int triggerIndex) const
~EmDQM()
Destructor.
Definition: EmDQM.cc:584
unsigned int numOfHLTCollectionLabels
Definition: EmDQM.h:157
std::vector< std::vector< MonitorElement * > > phihists
Definition: EmDQM.h:198
std::string dirname_
Definition: EmDQM.h:88
Definition: deltaR.h:79
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
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.
std::vector< int > theHLTOutputTypes
Definition: EmDQMReco.h:110
edm::ParameterSet makePSetForOneOEMinusOneOPFilter(const std::string &)
Definition: EmDQM.cc:1270
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.
T eta() const
edm::ParameterSet makePSetForElectronGenericFilter(const std::string &)
Definition: EmDQM.cc:1469
HistoFiller< reco::ElectronCollection > * histoFillerEle
Definition: EmDQM.h:90
double plotEtMin
Definition: EmDQM.h:169
Definition: EmDQM.h:63
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: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:1180
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:1137
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
tuple path
else: Piece not in the list, fine.
std::vector< unsigned int > nCandCuts
Definition: EmDQM.h:164
HistoFiller< reco::RecoEcalCandidateCollection > * histoFillerPho
Definition: EmDQM.h:93
edm::InputTag triggerObject_
Definition: EmDQM.h:101
void endRun(edm::Run const &, edm::EventSetup const &)
Definition: EmDQM.cc:1016
static const unsigned OUTPUT_WARNINGS
Definition: EmDQM.h:240
double plotPtMax
Definition: EmDQM.h:171
bool noIsolationPlots_
Definition: EmDQM.h:115
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:142
void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
Definition: EmDQM.cc:72
EmDQMReco * dqm
Definition: EmDQMReco.h:40
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:113
void SetVarsFromPSet(std::vector< edm::ParameterSet >::iterator)
Definition: EmDQM.cc:1535
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
const edm::ParameterSet & pset
Definition: EmDQM.h:99
double plotPtMin
Definition: EmDQM.h:170
edm::InputTag gencutCollection_
Definition: EmDQM.h:179
edm::ParameterSet makePSetForEgammaDoubleEtDeltaPhiFilter(const std::string &)
Definition: EmDQM.cc:1304
unsigned int nbins_
Definition: EmDQM.h:110
unsigned int offset(bool)
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:201
EmDQM(const edm::ParameterSet &pset)
Constructor.
Definition: EmDQM.cc:12
bool isData_
Definition: EmDQM.h:105
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:233
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidDiGamma_token
Definition: EmDQM.h:225
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
double ptMin_
Definition: EmDQM.h:107
bool checkGeneratedParticlesRequirement(const edm::Event &event)
Definition: EmDQM.cc:588
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:153
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_fidTripleEle_token
Definition: EmDQM.h:223
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:1066
void analyze(const edm::Event &event, const edm::EventSetup &)
Definition: EmDQM.cc:706
double genEtAcc_
Definition: EmDQM.h:104
bool autoConfMode_
Definition: EmDQM.h:97
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQMReco.h:103
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:231
double getPrimaryEtCut(const std::string &)
Definition: EmDQM.cc:1162
edm::ParameterSet makePSetForL1SeedToSuperClusterMatchFilter(const std::string &)
Definition: EmDQM.cc:1231
unsigned int pathIndex
Definition: EmDQM.h:155
bool useHumanReadableHistTitles_
Definition: EmDQM.h:112
edm::EDGetTokenT< trigger::TriggerEventWithRefs > triggerObject_token
Definition: EmDQM.h:219
std::vector< MonitorElement * > totalmatchs
Definition: EmDQM.h:208
static const unsigned TYPE_DOUBLE_ELE
Definition: EmDQM.h:232
HistoFiller< reco::RecoEcalCandidateCollection > * histoFillerClu
Definition: EmDQM.h:91
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: EmDQM.cc:392
static const unsigned TYPE_TRIPLE_ELE
Definition: EmDQM.h:235
bool mcMatchedOnly_
Definition: EmDQM.h:113
std::vector< std::string > theHLTCollectionHumanNames
Definition: EmDQM.h:158
edm::EDGetTokenT< edm::View< reco::Candidate > > gencutColl_manualConf_token
Definition: EmDQM.h:226
GreaterByPt< reco::Particle > pTComparator_
Definition: EmDQM.h:214
std::vector< MonitorElement * > phigens
Definition: EmDQM.h:212
unsigned int verbosity_
Definition: EmDQM.h:102
double genEtaAcc_
Definition: EmDQM.h:103
void endJob()
Definition: EmDQM.cc:1059
std::vector< int > theHLTOutputTypes
Definition: EmDQM.h:160
Definition: vlib.h:208
unsigned int reqNum
Definition: EmDQM.h:166
edm::ParameterSet makePSetForEtFilter(const std::string &)
Definition: EmDQM.cc:1253
edm::ParameterSet makePSetForPixelMatchFilter(const std::string &)
Definition: EmDQM.cc:1287
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
unsigned int minEtForEtaEffPlot_
Definition: EmDQM.h:111
edm::EDGetTokenT< edm::TriggerResults > hltResults_token
Definition: EmDQM.h:220
double etaMax_
Definition: EmDQM.h:108
Definition: Run.h:41
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
Definition: DDAxes.h:10