CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HLTHiggsPlotter Class Reference

#include <HLTHiggsPlotter.h>

Public Member Functions

void analyze (const bool &isPassTrigger, const std::string &source, const std::vector< MatchStruct > &matches, const unsigned int &minCandidates)
 
void analyze (const bool &isPassTrigger, const std::string &source, const std::vector< MatchStruct > &matches, std::map< std::string, bool > &nMinOne, const float &dEtaqq, const float &mqq, const float &dPhibb, const float &CSV1, const float &CSV2, const float &CSV3, const bool &passAllCuts)
 
void beginJob ()
 
void beginRun (const edm::Run &, const edm::EventSetup &)
 
void bookHistograms (DQMStore::IBooker &, const bool &)
 
const std::string gethltpath () const
 
 HLTHiggsPlotter (const edm::ParameterSet &pset, const std::string &hltPath, const std::vector< unsigned int > &objectsType, const unsigned int &minCandidates, const std::vector< double > &NminOneCuts)
 
 ~HLTHiggsPlotter ()
 

Private Member Functions

void bookHist (const std::string &source, const std::string &objType, const std::string &variable, DQMStore::IBooker &)
 
void fillHist (const bool &passTrigger, const std::string &source, const std::string &objType, const std::string &var, const float &value)
 

Private Attributes

std::map< unsigned int, double > _cutMaxEta
 
std::map< unsigned int, double > _cutMinPt
 
std::map< unsigned int,
unsigned int > 
_cutMotherId
 
std::map< unsigned int,
std::vector< double > > 
_cutsDr
 
std::map< std::string,
MonitorElement * > 
_elements
 
std::string _hltPath
 
std::string _hltProcessName
 
std::vector< double > _NminOneCuts
 
unsigned int _nObjects
 
unsigned int _NptPlots
 
std::set< unsigned int > _objectsType
 
std::vector< double > _parametersEta
 
std::vector< double > _parametersPhi
 
std::vector< double > _parametersTurnOn
 

Detailed Description

Generate histograms for trigger efficiencies Higgs related Documentation available on the CMS TWiki: https://twiki.cern.ch/twiki/bin/view/CMS/HiggsWGHLTValidate

Author
J. Duarte Campderros (based and adapted on J. Klukas, M. Vander Donckt and J. Alcaraz code from the HLTriggerOffline/Muon package)
J. Klukas, M. Vander Donckt, J. Alcaraz

Definition at line 47 of file HLTHiggsPlotter.h.

Constructor & Destructor Documentation

HLTHiggsPlotter::HLTHiggsPlotter ( const edm::ParameterSet pset,
const std::string &  hltPath,
const std::vector< unsigned int > &  objectsType,
const unsigned int &  minCandidates,
const std::vector< double > &  NminOneCuts 
)

Definition at line 25 of file HLTHiggsPlotter.cc.

References _cutMaxEta, _cutMinPt, _objectsType, edm::ParameterSet::getParameter(), EVTColContainer::getTypeString(), and AlCaHLTBitMon_QueryRunRegistry::string.

29  :
30  _hltPath(hltPath),
31  _hltProcessName(pset.getParameter<std::string>("hltProcessName")),
32  _objectsType(std::set<unsigned int>(objectsType.begin(),objectsType.end())),
33  _nObjects(objectsType.size()),
34  _parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
35  _parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
36  _parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn")),
37  _NptPlots(NptPlots),
39 {
40  for(std::set<unsigned int>::iterator it = _objectsType.begin();
41  it != _objectsType.end(); ++it)
42  {
43  // Some parameters extracted from the .py
45  _cutMinPt[*it] = pset.getParameter<double>( std::string(objStr+"_cutMinPt").c_str() );
46  _cutMaxEta[*it] = pset.getParameter<double>( std::string(objStr+"_cutMaxEta").c_str() );
47  }
48 }
T getParameter(std::string const &) const
unsigned int _NptPlots
std::string _hltProcessName
std::vector< double > _parametersPhi
std::set< unsigned int > _objectsType
std::string _hltPath
std::map< unsigned int, double > _cutMinPt
std::vector< double > _parametersTurnOn
std::vector< double > _parametersEta
unsigned int _nObjects
std::map< unsigned int, double > _cutMaxEta
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
std::vector< double > _NminOneCuts
HLTHiggsPlotter::~HLTHiggsPlotter ( )

Definition at line 50 of file HLTHiggsPlotter.cc.

51 {
52 }

Member Function Documentation

void HLTHiggsPlotter::analyze ( const bool &  isPassTrigger,
const std::string &  source,
const std::vector< MatchStruct > &  matches,
const unsigned int &  minCandidates 
)

Definition at line 111 of file HLTHiggsPlotter.cc.

References _NptPlots, _objectsType, eta, fillHist(), EVTColContainer::getTypeString(), j, phi, EnergyCorrector::pt, and AlCaHLTBitMon_QueryRunRegistry::string.

116 {
117  if ( !isPassTrigger )
118  {
119  return;
120  }
121  std::map<unsigned int,int> countobjects;
122  // Initializing the count of the used object
123  for(std::set<unsigned int>::iterator co = _objectsType.begin();
124  co != _objectsType.end(); ++co)
125  {
126  countobjects[*co] = 0;
127  }
128 
129  int counttotal = 0;
130  const int totalobjectssize2 = _NptPlots*countobjects.size();
131  // Fill the histos if pass the trigger (just the two with higher pt)
132  for (size_t j = 0; j < matches.size(); ++j)
133  {
134  // Is this object owned by this trigger? If not we are not interested...
135  if ( _objectsType.find( matches[j].objType) == _objectsType.end() )
136  {
137  continue;
138  }
139 
140  const unsigned int objType = matches[j].objType;
141  const std::string objTypeStr = EVTColContainer::getTypeString(matches[j].objType);
142 
143  float pt = matches[j].pt;
144  float eta = matches[j].eta;
145  float phi = matches[j].phi;
146 
147  TString maxPt;
148  if( (unsigned)countobjects[objType] < _NptPlots )
149  {
150  maxPt = "MaxPt";
151  maxPt += (countobjects[objType]+1);
152  this->fillHist(isPassTrigger,source,objTypeStr,maxPt.Data(),pt);
153  // Filled the high pt ...
154  ++(countobjects[objType]);
155  ++counttotal;
156  }
157  else {
158  if( (unsigned)countobjects[objType] < minCandidates ) { // To get correct results for HZZ
159  ++(countobjects[objType]);
160  ++counttotal;
161  }
162  else continue; // Otherwise too many entries in Eta and Phi distributions
163  }
164 
165  this->fillHist(isPassTrigger,source,objTypeStr,"Eta",eta);
166  this->fillHist(isPassTrigger,source,objTypeStr,"Phi",phi);
167 
168  if ( counttotal == totalobjectssize2 )
169  {
170  break;
171  }
172  }
173 }
unsigned int _NptPlots
std::set< unsigned int > _objectsType
int j
Definition: DBlmapReader.cc:9
void fillHist(const bool &passTrigger, const std::string &source, const std::string &objType, const std::string &var, const float &value)
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
static std::string const source
Definition: EdmProvDump.cc:43
void HLTHiggsPlotter::analyze ( const bool &  isPassTrigger,
const std::string &  source,
const std::vector< MatchStruct > &  matches,
std::map< std::string, bool > &  nMinOne,
const float &  dEtaqq,
const float &  mqq,
const float &  dPhibb,
const float &  CSV1,
const float &  CSV2,
const float &  CSV3,
const bool &  passAllCuts 
)

Definition at line 175 of file HLTHiggsPlotter.cc.

References _NminOneCuts, _NptPlots, _objectsType, eta, fillHist(), EVTColContainer::getTypeString(), j, EVTColContainer::PFJET, EVTColContainer::PFMET, phi, EnergyCorrector::pt, and AlCaHLTBitMon_QueryRunRegistry::string.

177 {
178  if ( !isPassTrigger )
179  {
180  return;
181  }
182  std::map<unsigned int,int> countobjects;
183  // Initializing the count of the used object
184  for(std::set<unsigned int>::iterator co = _objectsType.begin();
185  co != _objectsType.end(); ++co)
186  {
187  if( !(*co == EVTColContainer::PFJET && source == "gen") ) // genJets are not there
188  countobjects[*co] = 0;
189  }
190 
191  int counttotal = 0;
192  const int totalobjectssize2 = _NptPlots*countobjects.size();
193  // Fill the histos if pass the trigger (just the two with higher pt)
194  for (size_t j = 0; j < matches.size(); ++j)
195  {
196  // Is this object owned by this trigger? If not we are not interested...
197  if ( _objectsType.find( matches[j].objType) == _objectsType.end() )
198  {
199  continue;
200  }
201 
202  const unsigned int objType = matches[j].objType;
203  const std::string objTypeStr = EVTColContainer::getTypeString(matches[j].objType);
204 
205  float pt = matches[j].pt;
206  float eta = matches[j].eta;
207  float phi = matches[j].phi;
208 
209  // PFMET N-1 cut
210  if( objType == EVTColContainer::PFMET && _NminOneCuts[8] && ! nMinOne["PFMET"] ) continue;
211 
212  TString maxPt;
213  if( (unsigned)(countobjects)[objType] < _NptPlots )
214  {
215  maxPt = "MaxPt";
216  maxPt += (countobjects[objType]+1);
217  if( objType != EVTColContainer::PFJET || nMinOne[maxPt.Data()] ) {
218  this->fillHist(isPassTrigger,source,objTypeStr,maxPt.Data(),pt);
219  }
220  ++(countobjects[objType]);
221  ++counttotal;
222  }
223  else continue; // if not needed (minCandidates == _NptPlots if _useNminOneCuts
224  if( objType != EVTColContainer::PFJET || passAllCuts ) {
225  this->fillHist(isPassTrigger,source,objTypeStr,"Eta",eta);
226  this->fillHist(isPassTrigger,source,objTypeStr,"Phi",phi);
227  }
228 
229  if ( counttotal == totalobjectssize2 )
230  {
231  break;
232  }
233  }
234  if( source == "rec" && _objectsType.find(EVTColContainer::PFJET) != _objectsType.end()) {
235  if( _NminOneCuts[0] && nMinOne["dEtaqq"] ) {
236  this->fillHist(isPassTrigger,source,EVTColContainer::getTypeString(EVTColContainer::PFJET),"dEtaqq",dEtaqq);
237  }
238  if( _NminOneCuts[1] && nMinOne["mqq"] ) {
240  }
241  if( _NminOneCuts[2] && nMinOne["dPhibb"] ) {
242  this->fillHist(isPassTrigger,source,EVTColContainer::getTypeString(EVTColContainer::PFJET),"dPhibb",dPhibb);
243  }
244  if( _NminOneCuts[3] ) {
245  std::string nameCSVplot = "CSV1";
246  if ( _NminOneCuts[6] ) nameCSVplot = "maxCSV";
247  if ( nMinOne[nameCSVplot] ) this->fillHist(isPassTrigger,source,EVTColContainer::getTypeString(EVTColContainer::PFJET),nameCSVplot,CSV1);
248  }
249  if( _NminOneCuts[4] && nMinOne["CSV2"] ) {
250  this->fillHist(isPassTrigger,source,EVTColContainer::getTypeString(EVTColContainer::PFJET),"CSV2",CSV2);
251  }
252  if( _NminOneCuts[5] && nMinOne["CSV3"] ) {
253  this->fillHist(isPassTrigger,source,EVTColContainer::getTypeString(EVTColContainer::PFJET),"CSV3",CSV3);
254  }
255  }
256 }
unsigned int _NptPlots
std::set< unsigned int > _objectsType
int j
Definition: DBlmapReader.cc:9
void fillHist(const bool &passTrigger, const std::string &source, const std::string &objType, const std::string &var, const float &value)
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
static std::string const source
Definition: EdmProvDump.cc:43
std::vector< double > _NminOneCuts
void HLTHiggsPlotter::beginJob ( void  )

Definition at line 55 of file HLTHiggsPlotter.cc.

56 {
57 }
void HLTHiggsPlotter::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 61 of file HLTHiggsPlotter.cc.

63 {
64 
65 }
void HLTHiggsPlotter::bookHist ( const std::string &  source,
const std::string &  objType,
const std::string &  variable,
DQMStore::IBooker ibooker 
)
private

Definition at line 258 of file HLTHiggsPlotter.cc.

References _elements, _hltPath, _parametersEta, _parametersPhi, _parametersTurnOn, DQMStore::IBooker::book1D(), EVTColContainer::getTypeString(), h, i, bookConverter::max, min(), mergeVDriftHistosByStation::name, EVTColContainer::PFJET, EVTColContainer::PFMET, source, AlCaHLTBitMon_QueryRunRegistry::string, and SiPixelPhase1TrackClusters_cfi::title.

Referenced by bookHistograms().

262 {
263  std::string sourceUpper = source;
264  sourceUpper[0] = std::toupper(sourceUpper[0]);
265  std::string name = source + objType + variable + "_" + _hltPath;
266  TH1F * h = 0;
267 
268  if (variable.find("MaxPt") != std::string::npos)
269  {
270  std::string desc;
271  if (variable == "MaxPt1") desc = "Leading";
272  else if (variable == "MaxPt2") desc = "Next-to-Leading";
273  else desc = variable.substr(5,6) + "th Leading";
274  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType + " "
275  "where event pass the "+ _hltPath;
276  const size_t nBinsStandard = _parametersTurnOn.size() - 1;
277  size_t nBins = nBinsStandard;
278  float * edges = new float[nBinsStandard + 1];
279  for(size_t i = 0; i < nBinsStandard + 1; i++)
280  {
281  edges[i] = _parametersTurnOn[i];
282  }
283 
285  if( objType == jetObj ) {
286  const size_t nBinsJets = 25;
287  nBins = nBinsJets;
288  delete [] edges;
289  edges = new float[nBinsJets+1];
290  for(size_t i = 0; i < nBinsJets + 1; i++)
291  {
292  edges[i] = i*10;
293  }
294  }
296  const size_t nBinsJets = 30;
297  nBins = nBinsJets;
298  delete [] edges;
299  edges = new float[nBinsJets+1];
300  for(size_t i = 0; i < nBinsJets + 1; i++)
301  {
302  edges[i] = i*10;
303  }
304  }
305  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
306  delete [] edges;
307  }
308  else
309  {
310  if( variable == "dEtaqq" ){
311  std::string title = "#Delta #eta_{qq} of " + sourceUpper + " " + objType;
312  int nBins = 20;
313  double min = 0;
314  double max = 4.8;
315  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
316  }
317  else if ( variable == "mqq" ){
318  std::string title = "m_{qq} of " + sourceUpper + " " + objType;
319  int nBins = 20;
320  double min = 0;
321  double max = 1000;
322  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
323  }
324  else if ( variable == "dPhibb" ){
325  std::string title = "#Delta #phi_{bb} of " + sourceUpper + " " + objType;
326  int nBins = 10;
327  double min = 0;
328  double max = 3.1416;
329  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
330  }
331  else if ( variable == "CSV1" ){
332  std::string title = "CSV1 of " + sourceUpper + " " + objType;
333  int nBins = 20;
334  double min = 0;
335  double max = 1;
336  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
337  }
338  else if ( variable == "CSV2" ){
339  std::string title = "CSV2 of " + sourceUpper + " " + objType;
340  int nBins = 20;
341  double min = 0;
342  double max = 1;
343  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
344  }
345  else if ( variable == "CSV3" ){
346  std::string title = "CSV3 of " + sourceUpper + " " + objType;
347  int nBins = 20;
348  double min = 0;
349  double max = 1;
350  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
351  }
352  else if ( variable == "maxCSV" ){
353  std::string title = "max CSV of " + sourceUpper + " " + objType;
354  int nBins = 20;
355  double min = 0;
356  double max = 1;
357  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
358  }
359  else
360  {
361  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
362  std::string title = symbol + " of " + sourceUpper + " " + objType + " "+
363  "where event pass the "+ _hltPath;
364  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
365 
366  int nBins = (int)params[0];
367  double min = params[1];
368  double max = params[2];
369  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
370  }
371  }
372  h->Sumw2();
373  _elements[name] = ibooker.book1D(name.c_str(), h);
374  delete h;
375 }
int i
Definition: DBlmapReader.cc:9
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::vector< double > _parametersPhi
std::map< std::string, MonitorElement * > _elements
std::string _hltPath
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::vector< double > _parametersTurnOn
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< double > _parametersEta
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
static std::string const source
Definition: EdmProvDump.cc:43
void HLTHiggsPlotter::bookHistograms ( DQMStore::IBooker ibooker,
const bool &  useNminOneCuts 
)

Definition at line 67 of file HLTHiggsPlotter.cc.

References _NminOneCuts, _NptPlots, _objectsType, bookHist(), EVTColContainer::getTypeString(), i, EVTColContainer::PFJET, source, and AlCaHLTBitMon_QueryRunRegistry::string.

68 {
69  for (std::set<unsigned int>::iterator it = _objectsType.begin();
70  it != _objectsType.end(); ++it)
71  {
72  std::vector<std::string> sources(2);
73  sources[0] = "gen";
74  sources[1] = "rec";
75  TString maxPt;
76 
77  const std::string objTypeStr = EVTColContainer::getTypeString(*it);
78 
79  for (size_t i = 0; i < sources.size(); i++)
80  {
81  std::string source = sources[i];
82 
83  if( useNminOneCuts && *it == EVTColContainer::PFJET) {
84  if( source == "gen" ) continue;
85  else {
86  // N-1 jet plots (dEtaqq, mqq, dPhibb, CSV1, maxCSV_jets, maxCSV_E, PFMET, pt1, pt2, pt3, pt4)
87  if( _NminOneCuts[0] ) bookHist(source, objTypeStr, "dEtaqq", ibooker);
88  if( _NminOneCuts[1] ) bookHist(source, objTypeStr, "mqq", ibooker);
89  if( _NminOneCuts[2] ) bookHist(source, objTypeStr, "dPhibb", ibooker);
90  if( _NminOneCuts[3] ) {
91  if ( _NminOneCuts[6] ) bookHist(source, objTypeStr, "maxCSV", ibooker);
92  else bookHist(source, objTypeStr, "CSV1", ibooker);
93  }
94  if( _NminOneCuts[4] ) bookHist(source, objTypeStr, "CSV2", ibooker);
95  if( _NminOneCuts[5] ) bookHist(source, objTypeStr, "CSV3", ibooker);
96  }
97  }
98 
99  bookHist(source, objTypeStr, "Eta", ibooker);
100  bookHist(source, objTypeStr, "Phi", ibooker);
101  for( unsigned int i=0; i < _NptPlots; i++ )
102  {
103  maxPt = "MaxPt";
104  maxPt += i+1;
105  bookHist(source, objTypeStr, maxPt.Data(), ibooker);
106  }
107  }
108  }
109 }
int i
Definition: DBlmapReader.cc:9
unsigned int _NptPlots
std::set< unsigned int > _objectsType
void bookHist(const std::string &source, const std::string &objType, const std::string &variable, DQMStore::IBooker &)
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
static std::string const source
Definition: EdmProvDump.cc:43
std::vector< double > _NminOneCuts
void HLTHiggsPlotter::fillHist ( const bool &  passTrigger,
const std::string &  source,
const std::string &  objType,
const std::string &  var,
const float &  value 
)
private

Definition at line 377 of file HLTHiggsPlotter.cc.

References _elements, _hltPath, mergeVDriftHistosByStation::name, source, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

382 {
383  std::string sourceUpper = source;
384  sourceUpper[0] = toupper(sourceUpper[0]);
385  std::string name = source + objType + variable + "_" + _hltPath;
386 
387  _elements[name]->Fill(value);
388 }
std::map< std::string, MonitorElement * > _elements
std::string _hltPath
static std::string const source
Definition: EdmProvDump.cc:43
const std::string HLTHiggsPlotter::gethltpath ( ) const
inline

Definition at line 64 of file HLTHiggsPlotter.h.

References _hltPath.

64 { return _hltPath; }
std::string _hltPath

Member Data Documentation

std::map<unsigned int,double> HLTHiggsPlotter::_cutMaxEta
private

Definition at line 85 of file HLTHiggsPlotter.h.

Referenced by HLTHiggsPlotter().

std::map<unsigned int,double> HLTHiggsPlotter::_cutMinPt
private

Definition at line 84 of file HLTHiggsPlotter.h.

Referenced by HLTHiggsPlotter().

std::map<unsigned int,unsigned int> HLTHiggsPlotter::_cutMotherId
private

Definition at line 86 of file HLTHiggsPlotter.h.

std::map<unsigned int,std::vector<double> > HLTHiggsPlotter::_cutsDr
private

Definition at line 87 of file HLTHiggsPlotter.h.

std::map<std::string, MonitorElement *> HLTHiggsPlotter::_elements
private

Definition at line 95 of file HLTHiggsPlotter.h.

Referenced by bookHist(), and fillHist().

std::string HLTHiggsPlotter::_hltPath
private

Definition at line 72 of file HLTHiggsPlotter.h.

Referenced by bookHist(), fillHist(), and gethltpath().

std::string HLTHiggsPlotter::_hltProcessName
private

Definition at line 74 of file HLTHiggsPlotter.h.

std::vector<double> HLTHiggsPlotter::_NminOneCuts
private

Definition at line 93 of file HLTHiggsPlotter.h.

Referenced by analyze(), and bookHistograms().

unsigned int HLTHiggsPlotter::_nObjects
private

Definition at line 78 of file HLTHiggsPlotter.h.

unsigned int HLTHiggsPlotter::_NptPlots
private

Definition at line 90 of file HLTHiggsPlotter.h.

Referenced by analyze(), and bookHistograms().

std::set<unsigned int> HLTHiggsPlotter::_objectsType
private

Definition at line 76 of file HLTHiggsPlotter.h.

Referenced by analyze(), bookHistograms(), and HLTHiggsPlotter().

std::vector<double> HLTHiggsPlotter::_parametersEta
private

Definition at line 80 of file HLTHiggsPlotter.h.

Referenced by bookHist().

std::vector<double> HLTHiggsPlotter::_parametersPhi
private

Definition at line 81 of file HLTHiggsPlotter.h.

Referenced by bookHist().

std::vector<double> HLTHiggsPlotter::_parametersTurnOn
private

Definition at line 82 of file HLTHiggsPlotter.h.

Referenced by bookHist().