CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTHiggsSubAnalysis.cc
Go to the documentation of this file.
1 
7 
9 
13 
15 
16 #include "TPRegexp.h"
17 #include "TString.h"
18 
21 
24 
25 #include "TPRegexp.h"
26 #include "TRegexp.h"
27 #include "TString.h"
28 
29 #include<set>
30 #include<algorithm>
31 
33  const std::string & analysisname,
35  _pset(pset),
36  _analysisname(analysisname),
37  _minCandidates(0),
38  _HtJetPtMin(0),
39  _HtJetEtaMax(0),
40  _hltProcessName(pset.getParameter<std::string>("hltProcessName")),
41  _histDirectory(pset.getParameter<std::string>("histDirectory")),
42  _genParticleLabel(iC.consumes<reco::GenParticleCollection>(pset.getParameter<std::string>("genParticleLabel"))),
43  _genJetLabel(iC.consumes<reco::GenJetCollection>(pset.getParameter<std::string>("genJetLabel"))),
44  _recoHtJetLabel(iC.consumes<reco::PFJetCollection>(pset.getUntrackedParameter<std::string>("recoHtJetLabel","ak4PFJetsCHS"))),
45  _parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
46  _parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
47  _parametersPu(pset.getParameter<std::vector<double> >("parametersPu")),
48  _parametersHt(0),
49  _parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn")),
50  _trigResultsTag(iC.consumes<edm::TriggerResults>(edm::InputTag("TriggerResults","",_hltProcessName))),
51  _genJetSelector(0),
52  _recMuonSelector(0),
53  _recElecSelector(0),
54  _recCaloMETSelector(0),
55  _recPFMETSelector(0),
56  _recPFTauSelector(0),
57  _recPhotonSelector(0),
58  _recPFJetSelector(0),
59  _recTrackSelector(0),
60  _NminOneCuts(0),
61  _useNminOneCuts(0)
62 {
63  // Specific parameters for this analysis
64  edm::ParameterSet anpset = pset.getParameter<edm::ParameterSet>(analysisname);
65  // Collections labels (but genparticles already initialized)
66  // initializing _recLabels data member)
67  if( anpset.exists("parametersTurnOn") )
68  {
69  _parametersTurnOn = anpset.getParameter<std::vector<double> >("parametersTurnOn");
70  _pset.addParameter("parametersTurnOn",_parametersTurnOn);
71  }
72  this->bookobjects( anpset, iC );
73  // Generic objects: Initialization of cuts
74  for(std::map<unsigned int,std::string>::const_iterator it = _recLabels.begin();
75  it != _recLabels.end(); ++it)
76  {
77  const std::string objStr = EVTColContainer::getTypeString(it->first);
78  _genCut[it->first] = pset.getParameter<std::string>( objStr+"_genCut" );
79  _recCut[it->first] = pset.getParameter<std::string>( objStr+"_recCut" );
80  _cutMinPt[it->first] = pset.getParameter<double>( objStr+"_cutMinPt" );
81  _cutMaxEta[it->first] = pset.getParameter<double>( objStr+"_cutMaxEta" );
82  }
83  //--- Updating parameters if has to be modified for this particular specific analysis
84  for(std::map<unsigned int,std::string>::const_iterator it = _recLabels.begin();
85  it != _recLabels.end(); ++it)
86  {
87  const std::string objStr = EVTColContainer::getTypeString(it->first);
88  if(anpset.existsAs<std::string>( objStr+"_genCut", false))
89  {
90  _genCut[it->first] = anpset.getUntrackedParameter<std::string>( objStr+"_genCut" );
91  }
92  if(anpset.existsAs<std::string>( objStr+"_recCut", false))
93  {
94  _recCut[it->first] = anpset.getUntrackedParameter<std::string>( objStr+"_recCut" );
95  }
96  if(anpset.existsAs<double>( objStr+"_cutMinPt" , false) )
97  {
98  _cutMinPt[it->first] = anpset.getUntrackedParameter<double>( objStr+"_cutMinPt" );
99  }
100  if(anpset.existsAs<double>( objStr+"_cutMaxEta" ,false) )
101  {
102  _cutMaxEta[it->first] = anpset.getUntrackedParameter<double>( objStr+"_cutMaxEta" );
103  }
104  }
105  _hltPathsToCheck = anpset.getParameter<std::vector<std::string> >("hltPathsToCheck");
106  _minCandidates = anpset.getParameter<unsigned int>("minCandidates");
107 
108  std::vector<double> default_parametersHt;
109  default_parametersHt.push_back(100);
110  default_parametersHt.push_back(0);
111  default_parametersHt.push_back(1000);
112  _parametersHt = pset.getUntrackedParameter<std::vector<double> >("parametersHt",default_parametersHt);
113 
114  _HtJetPtMin = anpset.getUntrackedParameter<double>("HtJetPtMin", -1);
115  _HtJetEtaMax = anpset.getUntrackedParameter<double>("HtJetEtaMax", -1);
116 
117  if( _HtJetPtMin>0 && _HtJetEtaMax>0 ) _bookHtPlots = true;
118  else _bookHtPlots = false;
119 
120  if( pset.exists("pileUpInfoLabel") )
121  {
122  _puSummaryInfo = iC.consumes<std::vector< PileupSummaryInfo > >(pset.getParameter<std::string>("pileUpInfoLabel"));
123  }
124 
125  if( anpset.existsAs<std::vector<double>>( "NminOneCuts" , false) )
126  {
127  _NminOneCuts = anpset.getUntrackedParameter<std::vector<double> >("NminOneCuts");
128  if( _NminOneCuts.size() < 9 + _minCandidates ) {
129  edm::LogError("HiggsValidation") << "In HLTHiggsSubAnalysis::HLTHiggsSubAnalysis, "
130  << "Incoherence found in the python configuration file!!\nThe SubAnalysis '"
131  << _analysisname << "' has a vector NminOneCuts with size "
132  << _NminOneCuts.size() << ", while it needs to be at least of size "
133  << (9 + _minCandidates) << ".";
134  exit(-1);
135  }
136  for(std::vector<double>::const_iterator it = _NminOneCuts.begin(); it != _NminOneCuts.end(); ++it)
137  {
138  if( *it ) {
139  _useNminOneCuts = true;
140  break;
141  }
142  }
143  }
144 // NptPlots = ( _useNminOneCuts ? _minCandidates : 2 );
146 }
147 
149 {
150  for(std::map<unsigned int,StringCutObjectSelector<reco::GenParticle>* >::iterator it = _genSelectorMap.begin();
151  it != _genSelectorMap.end(); ++it)
152  {
153  delete it->second;
154  it->second =0;
155  }
156  delete _genJetSelector;
157  _genJetSelector =0;
158  delete _recMuonSelector;
159  _recMuonSelector =0;
160  delete _recElecSelector;
161  _recElecSelector =0;
162  delete _recPhotonSelector;
164  delete _recCaloMETSelector;
166  delete _recPFMETSelector;
168  delete _recPFTauSelector;
170  delete _recPFJetSelector;
172  delete _recTrackSelector;
174 }
175 
176 
178 {
179 }
180 
181 
182 
183 void HLTHiggsSubAnalysis::beginRun(const edm::Run & iRun, const edm::EventSetup & iSetup)
184 {
185  // Initialize the confighlt
186  bool changedConfig;
187  if(!_hltConfig.init(iRun,iSetup,_hltProcessName,changedConfig))
188  {
189  edm::LogError("HiggsValidations") << "HLTHiggsSubAnalysis::beginRun: "
190  << "Initializtion of HLTConfigProvider failed!!";
191  }
192 
193 
194  // Parse the input paths to get them if there are in the table
195  // and associate them the last filter of the path (in order to extract the
196  _hltPaths.clear();
197  for(size_t i = 0; i < _hltPathsToCheck.size(); ++i)
198  {
199  bool found = false;
200  TPRegexp pattern(_hltPathsToCheck[i]);
201  for(size_t j = 0 ; j < _hltConfig.triggerNames().size(); ++j)
202  {
203  std::string thetriggername = _hltConfig.triggerNames()[j];
204  if(TString(thetriggername).Contains(pattern))
205  {
206  _hltPaths.insert(thetriggername);
207  found = true;
208  }
209  }
210  if( ! found )
211  {
212  LogDebug("HiggsValidations") << "HLTHiggsSubAnalysis::beginRun, In "
213  << _analysisname << " subfolder NOT found the path: '"
214  << _hltPathsToCheck[i] << "*'" ;
215  }
216  }
217 
218  LogTrace("HiggsValidation") << "SubAnalysis: " << _analysisname
219  << "\nHLT Trigger Paths found >>>";
220  // Initialize the plotters (analysers for each trigger path)
221  _analyzers.clear();
222  for(std::set<std::string>::iterator iPath = _hltPaths.begin();
223  iPath != _hltPaths.end(); ++iPath)
224  {
225  // Avoiding the dependence of the version number for
226  // the trigger paths
227  std::string path = * iPath;
228  std::string shortpath = path;
229  if(path.rfind("_v") < path.length())
230  {
231  shortpath = path.substr(0, path.rfind("_v"));
232  }
233  _shortpath2long[shortpath] = path;
234 
235  // Objects needed by the HLT path
236  const std::vector<unsigned int> objsNeedHLT = this->getObjectsType(shortpath);
237  // Sanity check: the object needed by a trigger path should be
238  // introduced by the user via config python (_recLabels datamember)
239  std::vector<unsigned int> userInstantiate;
240  for(std::map<unsigned int,std::string>::iterator it = _recLabels.begin() ;
241  it != _recLabels.end(); ++it)
242  {
243  userInstantiate.push_back(it->first);
244  }
245  for(std::vector<unsigned int>::const_iterator it = objsNeedHLT.begin(); it != objsNeedHLT.end();
246  ++it)
247  {
248  if( std::find(userInstantiate.begin(),userInstantiate.end(), *it) ==
249  userInstantiate.end() )
250  {
251  edm::LogError("HiggsValidation") << "In HLTHiggsSubAnalysis::beginRun, "
252  << "Incoherence found in the python configuration file!!\nThe SubAnalysis '"
253  << _analysisname << "' has been asked to evaluate the trigger path '"
254  << shortpath << "' (found it in 'hltPathsToCheck') BUT this path"
255  << " needs a '" << EVTColContainer::getTypeString(*it)
256  << "' which has not been instantiate ('recVariableLabels'"
257  << ")" ;
258  exit(-1);
259  }
260  }
261  LogTrace("HiggsValidation") << " --- " << shortpath;
262 
263  // the hlt path, the objects (elec,muons,photons,...)
264  // needed to evaluate the path are the argumens of the plotter
265  HLTHiggsPlotter analyzer(_pset, shortpath,objsNeedHLT, NptPlots, _NminOneCuts);
266  _analyzers.push_back(analyzer);
267  }
268 }
269 
271 {
272  std::string baseDir = _histDirectory+"/"+_analysisname+"/";
273  ibooker.setCurrentFolder(baseDir);
274  // Book the gen/reco analysis-dependent histograms (denominators)
275  std::vector<std::string> sources(2);
276  sources[0] = "gen";
277  sources[1] = "rec";
278 
279  for(std::map<unsigned int,std::string>::const_iterator it = _recLabels.begin();
280  it != _recLabels.end(); ++it)
281  {
282  const std::string objStr = EVTColContainer::getTypeString(it->first);
283  TString maxPt;
284 
285  for(size_t i = 0; i < sources.size(); i++)
286  {
287  std::string source = sources[i];
288  if( _useNminOneCuts && it->first == EVTColContainer::PFJET) {
289  if( source == "gen" ) continue;
290  else {
291  // N-1 jet plots (dEtaqq, mqq, dPhibb, CSV1, maxCSV_jets, maxCSV_E, PFMET, pt1, pt2, pt3, pt4)
292  if( _NminOneCuts[0] ) bookHist(source, objStr, "dEtaqq", ibooker);
293  if( _NminOneCuts[1] ) bookHist(source, objStr, "mqq", ibooker);
294  if( _NminOneCuts[2] ) bookHist(source, objStr, "dPhibb", ibooker);
295  if( _NminOneCuts[3] ) {
296  if ( _NminOneCuts[6] ) bookHist(source, objStr, "maxCSV", ibooker);
297  else bookHist(source, objStr, "CSV1", ibooker);
298  }
299  if( _NminOneCuts[4] ) bookHist(source, objStr, "CSV2", ibooker);
300  if( _NminOneCuts[5] ) bookHist(source, objStr, "CSV3", ibooker);
301  }
302  }
303 
304  bookHist(source, objStr, "Eta", ibooker);
305  bookHist(source, objStr, "Phi", ibooker);
306  for( unsigned int i=0; i < NptPlots; i++ )
307  {
308  maxPt = "MaxPt";
309  maxPt += i+1;
310  bookHist(source, objStr, maxPt.Data(), ibooker);
311  }
312  }
313  }
314 
315  // Call the bookHistograms (which books all the path dependent histograms)
316  for(std::vector<HLTHiggsPlotter>::iterator it = _analyzers.begin();
317  it != _analyzers.end(); ++it)
318  {
319  it->bookHistograms(ibooker, _useNminOneCuts);
320  }
321  //booking the histograms for overall trigger efficiencies
322  for(size_t i = 0; i < sources.size(); i++)
323  {
324  std::string nameGlobalEfficiency = "SummaryPaths_"+_analysisname+"_"+sources[i];
325 
326  _elements[nameGlobalEfficiency] = ibooker.book1D(nameGlobalEfficiency.c_str(),nameGlobalEfficiency.c_str(),_hltPathsToCheck.size(), 0, _hltPathsToCheck.size());
327 
328  std::string nameGlobalEfficiencyPassing= nameGlobalEfficiency+"_passingHLT";
329  _elements[nameGlobalEfficiencyPassing] = ibooker.book1D(nameGlobalEfficiencyPassing.c_str(),nameGlobalEfficiencyPassing.c_str(),_hltPathsToCheck.size(), 0, _hltPathsToCheck.size());
330 
331  std::string titlePu = "nb of interations in the event";
332  std::string nameVtxPlot = "trueVtxDist_"+_analysisname+"_"+sources[i];
333  std::vector<double> paramsPu = _parametersPu;
334  int nBinsPu = (int)paramsPu[0];
335  double minPu = paramsPu[1];
336  double maxPu = paramsPu[2];
337 
338  std::string titleHt = "sum of jet pT in the event";
339  std::string nameHtPlot = "HtDist_"+_analysisname+"_"+sources[i];
340  std::vector<double> paramsHt = _parametersHt;
341  int nBinsHt = (int)paramsHt[0];
342  double minHt = paramsHt[1];
343  double maxHt = paramsHt[2];
344 
345  if( (! _useNminOneCuts) || sources[i] == "rec" ) _elements[nameVtxPlot] = ibooker.book1D(nameVtxPlot.c_str(), titlePu.c_str(), nBinsPu, minPu, maxPu);
346  if( _bookHtPlots ) _elements[nameHtPlot] = ibooker.book1D(nameHtPlot.c_str(), titleHt.c_str(), nBinsHt, minHt, maxHt);
347  for (size_t j = 0 ; j < _hltPathsToCheck.size() ; j++){
348  //declare the efficiency vs interaction plots
350  std::string shortpath = path;
351  if(path.rfind("_v") < path.length())
352  {
353  shortpath = path.substr(0, path.rfind("_v"));
354  }
355  std::string titlePassingPu = "nb of interations in the event passing path " + shortpath;
356  if( (! _useNminOneCuts) || sources[i] == "rec" ) _elements[nameVtxPlot+"_"+shortpath] = ibooker.book1D(nameVtxPlot+"_"+shortpath, titlePassingPu.c_str(), nBinsPu, minPu, maxPu);
357 
358  std::string titlePassingHt = "sum of jet pT in the event passing path " + shortpath;
359  if( _bookHtPlots ) _elements[nameHtPlot+"_"+shortpath] = ibooker.book1D(nameHtPlot+"_"+shortpath, titlePassingHt.c_str(), nBinsHt, minHt, maxHt);
360 
361  //fill the bin labels of the summary plot
362  _elements[nameGlobalEfficiency]->setBinLabel(j+1,shortpath);
363  _elements[nameGlobalEfficiencyPassing]->setBinLabel(j+1,shortpath);
364  }
365  }
366 }
367 
368 
369 
371  EVTColContainer * cols)
372 {
373  // Initialize the collection (the ones which hasn't been initialiazed yet)
374  this->initobjects(iEvent,cols);
375  // utility map
376  std::map<unsigned int,std::string> u2str;
377  u2str[GEN]="gen";
378  u2str[RECO]="rec";
379 
380  std::map<unsigned int,double> Htmap;
381  Htmap[GEN]=0.;
382  Htmap[RECO]=0.;
383 
385  iEvent.getByToken(_puSummaryInfo,puInfo);
386  int nbMCvtx = -1;
387  if (puInfo.isValid()) {
388  std::vector<PileupSummaryInfo>::const_iterator PVI;
389  for(PVI = puInfo->begin(); PVI != puInfo->end(); ++PVI) {
390  if(PVI->getBunchCrossing()==0){
391  nbMCvtx = PVI->getPU_NumInteractions();
392  break;
393  }
394  }
395  }
396 
397 
398  // Extract the match structure containing the gen/reco candidates (electron, muons,...)
399  // common to all the SubAnalysis
400  //---- Generation
401  // Make each good gen object into the base cand for a MatchStruct
402  std::vector<MatchStruct> * matches = new std::vector<MatchStruct>;
403 // bool alreadyMu = false;
404  for(std::map<unsigned int,std::string>::iterator it = _recLabels.begin();
405  it != _recLabels.end(); ++it)
406  {
407 
408  // Use genJets for jet matchstructs
409  if( it->first == EVTColContainer::PFJET)
410  {
411  // Skip genJets for N-1 plots
412  if( ! _useNminOneCuts )
413  {
414  // Initialize selectors when first event
415  if(!_genJetSelector)
416  {
418  }
419  for(size_t i = 0; i < cols->genJets->size(); ++i)
420  {
421  if(_genJetSelector->operator()(cols->genJets->at(i)))
422  {
423  matches->push_back(MatchStruct(&cols->genJets->at(i),it->first));
424  }
425  }
426  }
427  }
428  // Use genParticles
429  else
430  {
431  // Avoiding the TkMu and Mu case
432 /* if( alreadyMu )
433  {
434  continue;
435  }*/
436  // Initialize selectors when first event
437  if(!_genSelectorMap[it->first])
438  {
440  }
441 
442  for(size_t i = 0; i < cols->genParticles->size(); ++i)
443  {
444  if(_genSelectorMap[it->first]->operator()(cols->genParticles->at(i)))
445  {
446  matches->push_back(MatchStruct(&cols->genParticles->at(i),it->first));
447  }
448  }
449 /* if( it->first == EVTColContainer::MUON || it->first == EVTColContainer::TRACK )
450  {
451  alreadyMu = true;
452  }*/
453  }
454  }
455  // Sort the MatchStructs by pT for later filling of turn-on curve
456  std::sort(matches->begin(), matches->end(), matchesByDescendingPt());
457 
458  // Map to reference the source (gen/reco) with the recoCandidates
459  std::map<unsigned int,std::vector<MatchStruct> > sourceMatchMap; // To be a pointer to delete
460  // --- Storing the generating candidates
461  sourceMatchMap[GEN] = *matches;
462 
463  // Reuse the vector
464  matches->clear();
465  // --- same for RECO objects
466 
467  // Different treatment for jets (b-tag)
468  std::map<std::string,bool> nMinOne;
469  std::map<std::string,bool> jetCutResult;
470  float dEtaqq;
471  float mqq;
472  float dPhibb;
473  float CSV1;
474  float CSV2;
475  float CSV3;
476  bool passAllCuts = false;
477  if( _recLabels.find(EVTColContainer::PFJET) != _recLabels.end() ) {
478  // Initialize jet selector
480  // Initialize and insert pfJets
481  this->initAndInsertJets(iEvent, cols, matches);
482  // Make sure to skip events that don't have enough jets
483  if( matches->size() < NptPlots ) {
484  delete matches;
485  return;
486  }
487  // Cuts on multiple jet events (RECO)
488  if ( _useNminOneCuts ) {
489  this->passJetCuts(matches, jetCutResult, dEtaqq, mqq, dPhibb, CSV1, CSV2, CSV3);
490  }
491  }
492  // Extraction of the objects candidates
493  for(std::map<unsigned int,std::string>::iterator it = _recLabels.begin();
494  it != _recLabels.end(); ++it)
495  {
496  // Reco selectors (the function takes into account if it was instantiated
497  // before or not
498  this->InitSelector(it->first);
499  // -- Storing the matches
500  this->insertcandidates(it->first,cols,matches);
501  }
502 
503  // Sort the MatchStructs by pT for later filling of turn-on curve
504  std::sort(matches->begin(), matches->end(), matchesByDescendingPt());
505 
506  if ( _useNminOneCuts ) {
507  // Check non-jet N-1 Cuts
508  this->passOtherCuts(*matches,jetCutResult);
509 
510  // Make N-1 booleans from jetCutResults
511  for(std::map<std::string,bool>::const_iterator it = jetCutResult.begin(); it != jetCutResult.end(); ++it)
512  {
513  nMinOne[it->first] = true;
514  for(std::map<std::string,bool>::const_iterator it2 = jetCutResult.begin(); it2 != jetCutResult.end(); ++it2)
515  {
516  //ignore CSV2,CSV3 cut plotting CSV1
517  if( it->first=="CSV1" && it2->first=="CSV3") continue;
518  if( it->first=="CSV1" && it2->first=="CSV2") continue;
519 
520  //ignore CSV3 plotting cut CSV2
521  if( it->first=="CSV2" && it2->first=="CSV3") continue;
522 
523  if( it->first != it2->first && !(it2->second) ) {
524  nMinOne[it->first] = false;
525  break;
526  }
527  }
528  }
529  bool temp = false;
530  for(std::map<std::string,bool>::const_iterator it = nMinOne.begin(); it != nMinOne.end(); ++it)
531  {
532  if( temp && it->second ) {
533  passAllCuts = true;
534  break;
535  }
536  if( it->second ) temp = true;
537  }
538  }
539 
540  // --- Storing the reco candidates
541  sourceMatchMap[RECO] = *matches;
542  // --- All the objects are in place
543  delete matches;
544 
545  // -- Trigger Results
546  const edm::TriggerNames trigNames = iEvent.triggerNames(*(cols->triggerResults));
547 
548  if( _bookHtPlots ){
550  iEvent.getByToken(_recoHtJetLabel,recoJet);
551  if( recoJet.isValid() ){
552  for( reco::PFJetCollection::const_iterator iJet = recoJet->begin(); iJet != recoJet->end(); iJet++ ){
553  double pt = iJet->pt();
554  double eta = iJet->eta();
555  if( pt > _HtJetPtMin && fabs(eta) < _HtJetEtaMax ){
556  Htmap[RECO] += pt;
557  }
558  }
559  }
560 
562  iEvent.getByToken(_genJetLabel,genJet);
563  if( genJet.isValid() ){
564  for( reco::GenJetCollection::const_iterator iJet = genJet->begin(); iJet != genJet->end(); iJet++ ){
565  double pt = iJet->pt();
566  double eta = iJet->eta();
567  if( pt > _HtJetPtMin && fabs(eta) < _HtJetEtaMax ){
568  Htmap[GEN] += pt;
569  }
570  }
571  }
572  }
573 
574  // Filling the histograms if pass the minimum amount of candidates needed by the analysis:
575  // GEN + RECO CASE in the same loop
576  for(std::map<unsigned int,std::vector<MatchStruct> >::iterator it = sourceMatchMap.begin();
577  it != sourceMatchMap.end(); ++it)
578  {
579  // it->first: gen/reco it->second: matches (std::vector<MatchStruc>)
580  if( it->second.size() < _minCandidates ) // FIXME: A bug is potentially here: what about the mixed channels?
581  {
582  continue;
583  }
584 
585  // Filling the gen/reco objects (eff-denominators):
586  // Just the first two different ones, if there are more
587  std::map<unsigned int,int> * countobjects = new std::map<unsigned int,int>;
588  // Initializing the count of the used object
589  for(std::map<unsigned int,std::string>::iterator co = _recLabels.begin();
590  co != _recLabels.end(); ++co)
591  {
592  if( !(_useNminOneCuts && co->first == EVTColContainer::PFJET && it->first == GEN) ) // genJets are not there
593  countobjects->insert(std::pair<unsigned int,int>(co->first,0));
594  }
595  int counttotal = 0;
596  const int totalobjectssize2 = NptPlots*countobjects->size();
597  for(size_t j = 0; j < it->second.size(); ++j)
598  {
599  const unsigned int objType = it->second[j].objType;
600  const std::string objTypeStr = EVTColContainer::getTypeString(objType);
601 
602  float pt = (it->second)[j].pt;
603  float eta = (it->second)[j].eta;
604  float phi = (it->second)[j].phi;
605 
606  // PFMET N-1 cut
607  if( _useNminOneCuts && objType == EVTColContainer::PFMET && _NminOneCuts[8] && ! nMinOne["PFMET"] ) {
608  continue;
609  }
610 
611  TString maxPt;
612  if( (unsigned)(*countobjects)[objType] < NptPlots )
613  {
614  maxPt = "MaxPt";
615  maxPt += (*countobjects)[objType]+1;
616  if( _useNminOneCuts && objType == EVTColContainer::PFJET ) {
617  if( nMinOne[maxPt.Data()] )
618  {
619  this->fillHist(u2str[it->first],objTypeStr,maxPt.Data(),pt);
620  }
621  }
622  else {
623  this->fillHist(u2str[it->first],objTypeStr,maxPt.Data(),pt);
624  }
625  // Filled the high pt ...
626  ++((*countobjects)[objType]);
627  ++counttotal;
628  }
629  else {
630  if( (unsigned)(*countobjects)[objType] < _minCandidates ) { // To get correct results for HZZ
631  ++((*countobjects)[objType]);
632  ++counttotal;
633  }
634  else continue; // Otherwise too many entries in Eta and Phi distributions
635  }
636 
637  // Jet N-1 Cuts
638  if( _useNminOneCuts && objType == EVTColContainer::PFJET ) {
639  if( passAllCuts ) {
640  this->fillHist(u2str[it->first],objTypeStr,"Eta",eta);
641  this->fillHist(u2str[it->first],objTypeStr,"Phi",phi);
642  }
643  }
644  else {
645  this->fillHist(u2str[it->first],objTypeStr,"Eta",eta);
646  this->fillHist(u2str[it->first],objTypeStr,"Phi",phi);
647  }
648 
649  // Already the minimum two objects has been filled, get out...
650  if( counttotal == totalobjectssize2 )
651  {
652  break;
653  }
654  }
655  delete countobjects;
656 
657  if( _useNminOneCuts && it->first == RECO) {
658  if( _NminOneCuts[0] && nMinOne["dEtaqq"] ) {
659  this->fillHist(u2str[it->first],EVTColContainer::getTypeString(EVTColContainer::PFJET),"dEtaqq",dEtaqq);
660  }
661  if( _NminOneCuts[1] && nMinOne["mqq"] ) {
662  this->fillHist(u2str[it->first],EVTColContainer::getTypeString(EVTColContainer::PFJET),"mqq",mqq);
663  }
664  if( _NminOneCuts[2] && nMinOne["dPhibb"] ) {
665  this->fillHist(u2str[it->first],EVTColContainer::getTypeString(EVTColContainer::PFJET),"dPhibb",dPhibb);
666  }
667  if( _NminOneCuts[3] ) {
668  std::string nameCSVplot = "CSV1";
669  if ( _NminOneCuts[6] ) nameCSVplot = "maxCSV";
670  if ( nMinOne[nameCSVplot] ) this->fillHist(u2str[it->first],EVTColContainer::getTypeString(EVTColContainer::PFJET),nameCSVplot,CSV1);
671  }
672  if( _NminOneCuts[4] && nMinOne["CSV2"] ) {
673  this->fillHist(u2str[it->first],EVTColContainer::getTypeString(EVTColContainer::PFJET),"CSV2",CSV2);
674  }
675  if( _NminOneCuts[5] && nMinOne["CSV3"] ) {
676  this->fillHist(u2str[it->first],EVTColContainer::getTypeString(EVTColContainer::PFJET),"CSV3",CSV3);
677  }
678  }
679 
680  //fill the efficiency vs nb of interactions
681  std::string nameVtxPlot = "trueVtxDist_"+_analysisname+"_"+u2str[it->first];
682  if( (! _useNminOneCuts) || it->first == RECO ) _elements[nameVtxPlot]->Fill(nbMCvtx);
683 
684  //fill the efficiency vs sum pT of jets
685  std::string nameHtPlot = "HtDist_"+_analysisname+"_"+u2str[it->first];
686  if( _bookHtPlots ) _elements[nameHtPlot]->Fill(Htmap[it->first]);
687 
688 
689  // Calling to the plotters analysis (where the evaluation of the different trigger paths are done)
690  std::string SummaryName = "SummaryPaths_"+_analysisname+"_"+u2str[it->first];
691  const std::string source = u2str[it->first];
692  for(std::vector<HLTHiggsPlotter>::iterator an = _analyzers.begin();
693  an != _analyzers.end(); ++an)
694  {
695  const std::string hltPath = _shortpath2long[an->gethltpath()];
696  const std::string fillShortPath = an->gethltpath();
697  const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
698 
699  if( _useNminOneCuts ) {
700  an->analyze(ispassTrigger,source,it->second, nMinOne, dEtaqq, mqq, dPhibb, CSV1, CSV2, CSV3, passAllCuts);
701  }
702  else {
703  an->analyze(ispassTrigger,source,it->second, _minCandidates);
704  }
705 
706  int refOfThePath = -1;
707  for (size_t itePath = 0 ; itePath< _hltPathsToCheck.size() ; itePath++){
708  refOfThePath++;
709  if (TString(hltPath).Contains(_hltPathsToCheck[itePath])) break;
710  }
711  _elements[SummaryName]->Fill(refOfThePath);
712  if (ispassTrigger) {
713  _elements[SummaryName+"_passingHLT"]->Fill(refOfThePath,1);
714  if( (! _useNminOneCuts) || it->first == RECO ) _elements[nameVtxPlot+"_"+fillShortPath.c_str()]->Fill(nbMCvtx);
715  if( _bookHtPlots ) _elements[nameHtPlot+"_"+fillShortPath.c_str()]->Fill(Htmap[it->first]);
716  }
717  else {
718  _elements[SummaryName+"_passingHLT"]->Fill(refOfThePath,0);
719 
720  }
721  }
722  }
723 }
724 
725 // Return the objects (muons,electrons,photons,...) needed by a hlt path.
726 const std::vector<unsigned int> HLTHiggsSubAnalysis::getObjectsType(const std::string & hltPath) const
727 {
728  static const unsigned int objSize = 7;
729  static const unsigned int objtriggernames[] = {
733 // EVTColContainer::TRACK, // Note is tracker muon
738  };
739 
740  std::set<unsigned int> objsType;
741  // The object to deal has to be entered via the config .py
742  for(unsigned int i = 0; i < objSize; ++i)
743  {
744  std::string objTypeStr = EVTColContainer::getTypeString( objtriggernames[i] );
745  // Check if it is needed this object for this trigger
746  if( ! TString(hltPath).Contains(objTypeStr) )
747  {
748  if( (objtriggernames[i] == EVTColContainer::PFJET && TString(hltPath).Contains("WHbbBoost") ) || // fix for HLT_Ele27_WPLoose_Gsf_WHbbBoost_v
749  (objtriggernames[i] == EVTColContainer::PFJET && TString(hltPath).Contains("CSV") ) || // fix for ZnnHbb PFJET
750  (objtriggernames[i] == EVTColContainer::PFMET && TString(hltPath).Contains("MHT")) || // fix for ZnnHbb PFMET
751  (objtriggernames[i] == EVTColContainer::PHOTON && TString(hltPath).Contains("Diphoton")) )
752  {
753  objsType.insert(objtriggernames[i]); //case of the New Diphoton paths
754  }
755  continue;
756  }
757  if( ( objtriggernames[i] == EVTColContainer::CALOMET && (TString(hltPath).Contains("PFMET") || TString(hltPath).Contains("MHT") ) ) || // fix for PFMET
758  (objtriggernames[i] == EVTColContainer::PFJET && TString(hltPath).Contains("JetIdCleaned") && ! TString(hltPath).Contains(TRegexp("Jet[^I]"))) || // fix for Htaunu
759  (objtriggernames[i] == EVTColContainer::MUON && TString(hltPath).Contains("METNoMu")) ) // fix for VBFHToInv
760  {
761  continue;
762  }
763 
764  objsType.insert(objtriggernames[i]);
765  }
766 
767  return std::vector<unsigned int>(objsType.begin(),objsType.end());
768 }
769 
770 
771 // Booking the maps: recLabels and genParticle selectors
773 {
774  if( anpset.exists("recMuonLabel") )
775  {
776  _recLabels[EVTColContainer::MUON] = anpset.getParameter<std::string>("recMuonLabel");
779  }
780  if( anpset.exists("recElecLabel") )
781  {
782  _recLabels[EVTColContainer::ELEC] = anpset.getParameter<std::string>("recElecLabel");
785  }
786  if( anpset.exists("recPhotonLabel") )
787  {
788  _recLabels[EVTColContainer::PHOTON] = anpset.getParameter<std::string>("recPhotonLabel");
791  }
792  if( anpset.exists("recCaloMETLabel") )
793  {
794  _recLabels[EVTColContainer::CALOMET] = anpset.getParameter<std::string>("recCaloMETLabel");
797  }
798  if( anpset.exists("recPFMETLabel") )
799  {
800  _recLabels[EVTColContainer::PFMET] = anpset.getParameter<std::string>("recPFMETLabel");
803  }
804  if( anpset.exists("recPFTauLabel") )
805  {
806  _recLabels[EVTColContainer::PFTAU] = anpset.getParameter<std::string>("recPFTauLabel");
809  }
810  if( anpset.exists("recJetLabel") )
811  {
812  _recLabels[EVTColContainer::PFJET] = anpset.getParameter<std::string>("recJetLabel");
814  if( anpset.exists("jetTagLabel") )
816  _genJetSelector = 0;
817  }
818  /*if( anpset.exists("recTrackLabel") )
819  {
820  _recLabels[EVTColContainer::TRACK] = anpset.getParameter<std::string>("recTrackLabel");
821  _genSelectorMap[EVTColContainer::TRACK] = 0 ;
822  }*/
823 
824  if( _recLabels.size() < 1 )
825  {
826  edm::LogError("HiggsValidation") << "HLTHiggsSubAnalysis::bookobjects, "
827  << "Not included any object (recMuonLabel, recElecLabel, ...) "
828  << "in the analysis " << _analysisname;
829  return;
830  }
831 }
832 
834 {
835  /*if( col != 0 && col->isAllInit() )
836  {
837  // Already init, not needed to do nothing
838  return;
839  }*/
840  if( ! col->isCommonInit() )
841  {
842  // extract the trigger results (path info, pass,...)
844  iEvent.getByToken(_trigResultsTag,trigResults);
845  if( trigResults.isValid() )
846  {
847  col->triggerResults = trigResults.product();
848  }
849 
850  // GenParticle collection if is there (genJets only if there need to be jets)
852  iEvent.getByToken(_genParticleLabel,genPart);
853  if( genPart.isValid() )
854  {
855  col->genParticles = genPart.product();
856  }
857  }
858 
859  for(std::map<unsigned int,std::string>::iterator it = _recLabels.begin();
860  it != _recLabels.end(); ++it)
861  {
862  if( it->first == EVTColContainer::MUON )
863  {
865  iEvent.getByToken(_recLabelsMuon, theHandle);
866  col->set(theHandle.product());
867  }
868  else if( it->first == EVTColContainer::ELEC )
869  {
871  iEvent.getByToken(_recLabelsElec, theHandle);
872  col->set(theHandle.product());
873  }
874  else if( it->first == EVTColContainer::PHOTON )
875  {
877  iEvent.getByToken(_recLabelsPhoton, theHandle);
878  col->set(theHandle.product());
879  }
880  else if( it->first == EVTColContainer::CALOMET )
881  {
883  iEvent.getByToken(_recLabelsCaloMET, theHandle);
884  col->set(theHandle.product());
885  }
886  else if( it->first == EVTColContainer::PFMET )
887  {
889  iEvent.getByToken(_recLabelsPFMET, theHandle);
890  col->set(theHandle.product());
891  }
892  else if( it->first == EVTColContainer::PFTAU )
893  {
895  iEvent.getByToken(_recLabelsPFTau, theHandle);
896  col->set(theHandle.product());
897  }
898  // PFJets loaded in seperate function initAndInsertJets because they need to be combined with the btags using the Handle (not the product) and for ordering them seperately in the MatchStruct's
899  else if( it->first == EVTColContainer::PFJET )
900  {
901  if( ! _useNminOneCuts) {
902  // GenJet collection
904  iEvent.getByToken(_genJetLabel,genJet);
905  if( genJet.isValid() )
906  {
907  col->genJets = genJet.product();
908  }
909  }
910  }
911  else
912  {
913  edm::LogError("HiggsValidation") << "HLTHiggsSubAnalysis::initobjects "
914  << " NOT IMPLEMENTED (yet) ERROR: '" << it->second << "'";
915  //return; ??
916  }
917  }
918 }
919 
921  const std::string & objType, const std::string & variable, DQMStore::IBooker &ibooker)
922 {
923  std::string sourceUpper = source;
924  sourceUpper[0] = std::toupper(sourceUpper[0]);
925  std::string name = source + objType + variable ;
926  TH1F * h = 0;
927 
928  if(variable.find("MaxPt") != std::string::npos)
929  {
930  std::string desc;
931  if (variable == "MaxPt1") desc = "Leading";
932  else if (variable == "MaxPt2") desc = "Next-to-Leading";
933  else desc = variable.substr(5,6) + "th Leading";
934  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType;
935  const size_t nBinsStandard = _parametersTurnOn.size() - 1;
936  size_t nBins = nBinsStandard;
937  float * edges = new float[nBinsStandard + 1];
938  for(size_t i = 0; i < nBinsStandard + 1; i++)
939  {
940  edges[i] = _parametersTurnOn[i];
941  }
942 
944  if( objType == jetObj ) {
945  const size_t nBinsJets = 25;
946  nBins = nBinsJets;
947  delete [] edges;
948  edges = new float[nBinsJets+1];
949  for(size_t i = 0; i < nBinsJets + 1; i++)
950  {
951  edges[i] = i*10;
952  }
953  }
955  const size_t nBinsJets = 30;
956  nBins = nBinsJets;
957  delete [] edges;
958  edges = new float[nBinsJets+1];
959  for(size_t i = 0; i < nBinsJets + 1; i++)
960  {
961  edges[i] = i*10;
962  }
963  }
964  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
965  delete [] edges;
966  }
967  else if( variable == "dEtaqq" ){
968  std::string title = "#Delta #eta_{qq} of " + sourceUpper + " " + objType;
969  int nBins = 20;
970  double min = 0;
971  double max = 4.8;
972  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
973  }
974  else if ( variable == "mqq" ){
975  std::string title = "m_{qq} of " + sourceUpper + " " + objType;
976  int nBins = 20;
977  double min = 0;
978  double max = 1000;
979  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
980  }
981  else if ( variable == "dPhibb" ){
982  std::string title = "#Delta #phi_{bb} of " + sourceUpper + " " + objType;
983  int nBins = 10;
984  double min = 0;
985  double max = 3.1416;
986  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
987  }
988  else if ( variable == "CSV1" ){
989  std::string title = "CSV1 of " + sourceUpper + " " + objType;
990  int nBins = 20;
991  double min = 0;
992  double max = 1;
993  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
994  }
995  else if ( variable == "CSV2" ){
996  std::string title = "CSV2 of " + sourceUpper + " " + objType;
997  int nBins = 20;
998  double min = 0;
999  double max = 1;
1000  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1001  }
1002  else if ( variable == "CSV3" ){
1003  std::string title = "CSV3 of " + sourceUpper + " " + objType;
1004  int nBins = 20;
1005  double min = 0;
1006  double max = 1;
1007  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1008  }
1009  else if ( variable == "maxCSV" ){
1010  std::string title = "max CSV of " + sourceUpper + " " + objType;
1011  int nBins = 20;
1012  double min = 0;
1013  double max = 1;
1014  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1015  }
1016  else
1017  {
1018  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
1019  std::string title = symbol + " of " + sourceUpper + " " + objType;
1020  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
1021 
1022  int nBins = (int)params[0];
1023  double min = params[1];
1024  double max = params[2];
1025  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1026  }
1027  h->Sumw2();
1028  _elements[name] = ibooker.book1D(name, h);
1029  delete h;
1030 }
1031 
1033  const std::string & objType, const std::string & variable, const float & value )
1034 {
1035  std::string sourceUpper = source;
1036  sourceUpper[0] = toupper(sourceUpper[0]);
1037  std::string name = source + objType + variable ;
1038 
1039  _elements[name]->Fill(value);
1040 }
1041 
1042 
1043 
1044 // Initialize the selectors
1045 void HLTHiggsSubAnalysis::InitSelector(const unsigned int & objtype)
1046 {
1047  if( objtype == EVTColContainer::MUON && _recMuonSelector == 0 )
1048  {
1050  }
1051  else if( objtype == EVTColContainer::ELEC && _recElecSelector == 0)
1052  {
1054  }
1055  else if( objtype == EVTColContainer::PHOTON && _recPhotonSelector == 0)
1056  {
1058  }
1059  else if( objtype == EVTColContainer::CALOMET && _recCaloMETSelector == 0)
1060  {
1062  }
1063  else if( objtype == EVTColContainer::PFMET && _recPFMETSelector == 0)
1064  {
1066  }
1067  else if( objtype == EVTColContainer::PFTAU && _recPFTauSelector == 0 )
1068  {
1070  }
1071  else if( objtype == EVTColContainer::PFJET && _recPFJetSelector == 0 )
1072  {
1074  }
1075  /*else if( objtype == EVTColContainer::TRACK && _recTrackSelector == 0)
1076  {
1077  _recTrackSelector = new StringCutObjectSelector<reco::Track>(_recCut[objtype]);
1078  }*/
1079 /* else
1080  {
1081 FIXME: ERROR NO IMPLEMENTADO
1082  }*/
1083 }
1084 
1086  std::vector<MatchStruct> * matches)
1087 {
1089  iEvent.getByToken(_recLabelsPFJet, PFJetHandle);
1090  cols->set(PFJetHandle.product());
1091 
1093  if( _useNminOneCuts ) {
1094  iEvent.getByToken(_recTagPFJet, JetTagHandle);
1095  }
1096 
1097  for(reco::PFJetCollection::const_iterator it = PFJetHandle->begin();
1098  it != PFJetHandle->end(); ++it)
1099  {
1100  reco::PFJetRef jetRef(PFJetHandle, it - PFJetHandle->begin());
1101  reco::JetBaseRef jetBaseRef(jetRef);
1102 
1103  if(_recPFJetSelector->operator()(*it))
1104  {
1105  if( _useNminOneCuts)
1106  {
1107  float bTag = (*(JetTagHandle.product()))[jetBaseRef];
1108  matches->push_back(MatchStruct(&*it,EVTColContainer::PFJET, bTag));
1109  }
1110  else {
1111  matches->push_back(MatchStruct(&*it,EVTColContainer::PFJET));
1112  }
1113  }
1114  }
1115 }
1116 
1117 void HLTHiggsSubAnalysis::passJetCuts(std::vector<MatchStruct> * matches, std::map<std::string,bool> & jetCutResult, float & dEtaqq, float & mqq, float & dPhibb, float & CSV1, float & CSV2, float & CSV3)
1118 { //dEtaqq, mqq, dPhibb, CSV1, CSV2, CSV3, maxCSV_jets, maxCSV_E, PFMET, pt1, pt2, pt3, pt4
1119 
1120  // Perform pt cuts
1121  std::sort(matches->begin(), matches->end(), matchesByDescendingPt());
1122  TString maxPt;
1123  for( unsigned int i=0; i < NptPlots; i++ )
1124  {
1125  maxPt = "MaxPt";
1126  maxPt += i+1;
1127  if( (*matches)[i].pt > _NminOneCuts[9+i] ) jetCutResult[maxPt.Data()] = true;
1128  else jetCutResult[maxPt.Data()] = false;
1129  }
1130 
1131  unsigned int NbTag = ( (_NminOneCuts[0] || _NminOneCuts[1]) ? 4 : 8 );
1132  if( matches->size() < NbTag ) NbTag = matches->size();
1133  // Perform b-tag ordered cuts
1134  std::sort(matches->begin(), matches->begin()+NbTag, matchesByDescendingBtag());
1135 
1136  if( _NminOneCuts[0] ) {
1137  dEtaqq = fabs((*matches)[2].eta - (*matches)[3].eta);
1138  if( dEtaqq > _NminOneCuts[0] ) jetCutResult["dEtaqq"] = true;
1139  else jetCutResult["dEtaqq"] = false;
1140  }
1141 
1142  if( _NminOneCuts[1] ) {
1143  mqq = ((*matches)[2].lorentzVector + (*matches)[3].lorentzVector).M();
1144  if( mqq > _NminOneCuts[1] ) jetCutResult["mqq"] = true;
1145  else jetCutResult["mqq"] = false;
1146  }
1147 
1148  if( _NminOneCuts[2] ) {
1149  dPhibb = fmod(fabs((*matches)[0].phi - (*matches)[1].phi),3.1416);
1150  if( dPhibb < _NminOneCuts[2] ) jetCutResult["dPhibb"] = true;
1151  else jetCutResult["dPhibb"] = false;
1152  }
1153 
1154  if( _NminOneCuts[4] ) {
1155  CSV2 = (*matches)[1].bTag;
1156  std::string nameCSV2plot = "CSV2";
1157 
1158  if( CSV2 > _NminOneCuts[4] ) jetCutResult[nameCSV2plot] = true;
1159  else jetCutResult[nameCSV2plot] = false;
1160  }
1161 
1162  if( _NminOneCuts[5] ) {
1163  CSV3 = (*matches)[2].bTag;
1164  std::string nameCSV3plot = "CSV3";
1165 
1166  if( CSV3 > _NminOneCuts[5] ) jetCutResult[nameCSV3plot] = true;
1167  else jetCutResult[nameCSV3plot] = false;
1168  }
1169 
1170 
1171  if( _NminOneCuts[3] ) {
1172  CSV1 = (*matches)[0].bTag;
1173  std::string nameCSVplot = "CSV1";
1174  if ( _NminOneCuts[6] ) nameCSVplot = "maxCSV";
1175 
1176  if( CSV1 > _NminOneCuts[3] ) jetCutResult[nameCSVplot] = true;
1177  else jetCutResult[nameCSVplot] = false;
1178 
1179  // max(CSV)
1180  if( _NminOneCuts[6] ) {
1181  std::sort(matches->begin(), matches->end(), matchesByDescendingPt());
1182  CSV1 = (*matches)[0].bTag;
1183  unsigned int Njets = (unsigned int) _NminOneCuts[6];
1184  if ( _NminOneCuts[6] > matches->size()) Njets = matches->size();
1185  for(unsigned int i=1; i < (unsigned int) Njets ; ++i) {
1186  if( (*matches)[i].bTag > CSV1 && (*matches)[i].pt > _NminOneCuts[7] ) CSV1 = (*matches)[i].bTag;
1187  }
1188  }
1189  }
1190 }
1191 
1192 void HLTHiggsSubAnalysis::passOtherCuts(const std::vector<MatchStruct> & matches, std::map<std::string,bool> & jetCutResult){
1193  if( _NminOneCuts[8] ) {
1194  jetCutResult["PFMET"] = false;
1195  for(std::vector<MatchStruct>::const_iterator it = matches.begin(); it != matches.end(); ++it)
1196  {
1197  if( it->objType == EVTColContainer::PFMET ) {
1198  if( it->pt > _NminOneCuts[8] ) jetCutResult["PFMET"] = true;
1199  break;
1200  }
1201  }
1202  }
1203 }
1204 
1205 void HLTHiggsSubAnalysis::insertcandidates(const unsigned int & objType, const EVTColContainer * cols,
1206  std::vector<MatchStruct> * matches)
1207 {
1208  if( objType == EVTColContainer::MUON )
1209  {
1210  for(size_t i = 0; i < cols->muons->size(); i++)
1211  {
1212  if(_recMuonSelector->operator()(cols->muons->at(i)))
1213  {
1214  matches->push_back(MatchStruct(&cols->muons->at(i),objType));
1215  }
1216  }
1217  }
1218  else if( objType == EVTColContainer::ELEC )
1219  {
1220  for(size_t i = 0; i < cols->electrons->size(); i++)
1221  {
1222  if(_recElecSelector->operator()(cols->electrons->at(i)))
1223  {
1224  matches->push_back(MatchStruct(&cols->electrons->at(i),objType));
1225  }
1226  }
1227  }
1228  else if( objType == EVTColContainer::PHOTON )
1229  {
1230  for(size_t i = 0; i < cols->photons->size(); i++)
1231  {
1232  if(_recPhotonSelector->operator()(cols->photons->at(i)))
1233  {
1234  matches->push_back(MatchStruct(&cols->photons->at(i),objType));
1235  }
1236  }
1237  }
1238  else if( objType == EVTColContainer::CALOMET )
1239  {
1240  for(size_t i = 0; i < cols->caloMETs->size(); i++)
1241  {
1242  if(_recCaloMETSelector->operator()(cols->caloMETs->at(i)))
1243  {
1244  matches->push_back(MatchStruct(&cols->caloMETs->at(i),objType));
1245  }
1246  }
1247  }
1248  else if( objType == EVTColContainer::PFMET )
1249  {
1250  for(size_t i = 0; i < cols->pfMETs->size(); i++)
1251  {
1252  if(_recPFMETSelector->operator()(cols->pfMETs->at(i)))
1253  {
1254  matches->push_back(MatchStruct(&cols->pfMETs->at(i),objType));
1255  }
1256  }
1257  }
1258  else if( objType == EVTColContainer::PFTAU )
1259  {
1260  for(size_t i = 0; i < cols->pfTaus->size(); i++)
1261  {
1262  if(_recPFTauSelector->operator()(cols->pfTaus->at(i)))
1263  {
1264  matches->push_back(MatchStruct(&cols->pfTaus->at(i),objType));
1265  }
1266  }
1267  }
1268 // else if( objType == EVTColContainer::PFJET )
1269 // {
1270 // already inserted
1271 // }
1272  /*else if( objType == EVTColContainer::TRACK )
1273  {
1274  for(size_t i = 0; i < cols->tracks->size(); i++)
1275  {
1276  if(_recTrackSelector->operator()(cols->tracks->at(i)))
1277  {
1278  matches->push_back(MatchStruct(&cols->tracks->at(i),objType));
1279  }
1280  }
1281  }*/
1282  /*
1283  else FIXME: Control errores
1284  {
1285  }
1286  */
1287 }
#define LogDebug(id)
const std::vector< reco::Muon > * muons
std::vector< double > _parametersTurnOn
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void InitSelector(const unsigned int &objtype)
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:220
std::map< std::string, std::string > _shortpath2long
Relation between the short version of a path.
StringCutObjectSelector< reco::CaloMET > * _recCaloMETSelector
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
edm::EDGetTokenT< reco::PFMETCollection > _recLabelsPFMET
edm::EDGetTokenT< reco::PFJetCollection > _recLabelsPFJet
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
edm::EDGetTokenT< reco::GenParticleCollection > _genParticleLabel
void passJetCuts(std::vector< MatchStruct > *matches, std::map< std::string, bool > &jetCutResult, float &dEtaqq, float &mqq, float &dPhibb, float &CSV1, float &CSV2, float &CSV3)
std::map< unsigned int, std::string > _genCut
gen/rec objects cuts
void initobjects(const edm::Event &iEvent, EVTColContainer *col)
edm::EDGetTokenT< reco::PFJetCollection > _recoHtJetLabel
const std::vector< reco::CaloMET > * caloMETs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< reco::PFTauCollection > _recLabelsPFTau
unsigned int _minCandidates
The minimum number of reco/gen candidates needed by the analysis.
std::map< std::string, MonitorElement * > _elements
std::vector< double > _NminOneCuts
bool accept() const
Has at least one path accepted the event?
std::vector< GenJet > GenJetCollection
collection of GenJet objects
const std::vector< std::string > & triggerNames() const
names of trigger paths
edm::ParameterSet _pset
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::set< std::string > _hltPaths
the hlt paths found in the hltConfig
const reco::GenParticleCollection * genParticles
container with all the objects needed
StringCutObjectSelector< reco::PFMET > * _recPFMETSelector
edm::EDGetTokenT< reco::GenJetCollection > _genJetLabel
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
HLTConfigProvider _hltConfig
dictionary edges
edm::EDGetTokenT< reco::JetTagCollection > _recTagPFJet
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
const std::vector< reco::PFTau > * pfTaus
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
void bookHistograms(DQMStore::IBooker &)
std::vector< double > _parametersPu
edm::EDGetTokenT< reco::PhotonCollection > _recLabelsPhoton
edm::EDGetTokenT< reco::CaloMETCollection > _recLabelsCaloMET
StringCutObjectSelector< reco::Track > * _recTrackSelector
std::map< unsigned int, std::string > _recCut
void passOtherCuts(const std::vector< MatchStruct > &matches, std::map< std::string, bool > &jetCutResult)
std::map< unsigned int, StringCutObjectSelector< reco::GenParticle > * > _genSelectorMap
void set(const reco::MuonCollection *v)
Setter: multiple overloaded function.
int iEvent
Definition: GenABIO.cc:230
const reco::GenJetCollection * genJets
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
StringCutObjectSelector< reco::GenJet > * _genJetSelector
void initAndInsertJets(const edm::Event &iEvent, EVTColContainer *cols, std::vector< MatchStruct > *matches)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:144
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > _puSummaryInfo
std::vector< HLTHiggsPlotter > _analyzers
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
std::map< unsigned int, std::string > _recLabels
const std::vector< reco::Photon > * photons
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void analyze(const edm::Event &iEvent, const edm::EventSetup &iEventSetup, EVTColContainer *cols)
T min(T a, T b)
Definition: MathUtil.h:58
std::map< unsigned int, double > _cutMinPt
StringCutObjectSelector< reco::PFTau > * _recPFTauSelector
bool isValid() const
Definition: HandleBase.h:75
#define LogTrace(id)
void beginRun(const edm::Run &iRun, const edm::EventSetup &iEventSetup)
edm::EDGetTokenT< edm::TriggerResults > _trigResultsTag
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
void bookHist(const std::string &source, const std::string &objType, const std::string &variable, DQMStore::IBooker &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
std::vector< double > _parametersHt
edm::EDGetTokenT< reco::GsfElectronCollection > _recLabelsElec
HLTHiggsSubAnalysis(const edm::ParameterSet &pset, const std::string &analysisname, edm::ConsumesCollector &&iC)
T const * product() const
Definition: Handle.h:81
StringCutObjectSelector< reco::Muon > * _recMuonSelector
void fillHist(const std::string &source, const std::string &objType, const std::string &variable, const float &value)
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const std::vector< reco::GsfElectron > * electrons
Helper structure to order MatchStruct.
Definition: MatchStruct.cc:82
const std::vector< unsigned int > getObjectsType(const std::string &hltpath) const
Extract what objects need this analysis.
void insertcandidates(const unsigned int &objtype, const EVTColContainer *col, std::vector< MatchStruct > *matches)
std::vector< PFJet > PFJetCollection
collection of PFJet objects
edm::EDGetTokenT< reco::MuonCollection > _recLabelsMuon
std::vector< double > _parametersPhi
std::vector< std::string > _hltPathsToCheck
the hlt paths with regular expressions
std::vector< reco::PFMET > PFMETCollection
collection of PFMET objects
std::vector< double > _parametersEta
Some kinematical parameters.
std::map< unsigned int, double > _cutMaxEta
void bookobjects(const edm::ParameterSet &anpset, edm::ConsumesCollector &iC)
StringCutObjectSelector< reco::Photon > * _recPhotonSelector
const std::vector< reco::PFMET > * pfMETs
StringCutObjectSelector< reco::PFJet > * _recPFJetSelector
int col
Definition: cuy.py:1008
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
const edm::TriggerResults * triggerResults
static std::string const source
Definition: EdmProvDump.cc:42
StringCutObjectSelector< reco::GsfElectron > * _recElecSelector
Definition: Run.h:43