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