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
HLTExoticaPlotter Class Reference

#include <HLTExoticaPlotter.h>

Public Member Functions

void analyze (const bool &isPassTrigger, const std::string &source, const std::vector< reco::LeafCandidate > &matches, std::map< int, double > theSumEt)
 
void beginJob ()
 
void beginRun (const edm::Run &, const edm::EventSetup &)
 
const std::string gethltpath () const
 
 HLTExoticaPlotter (const edm::ParameterSet &pset, const std::string &hltPath, const std::vector< unsigned int > &objectsType)
 
void plotterBookHistos (DQMStore::IBooker &iBooker, const edm::Run &iRun, const edm::EventSetup &iSetup)
 
 ~HLTExoticaPlotter ()
 

Private Member Functions

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

Private Attributes

std::map< std::string,
MonitorElement * > 
_elements
 
std::string _hltPath
 
std::string _hltProcessName
 
unsigned int _nObjects
 
std::set< unsigned int > _objectsType
 
std::vector< double > _parametersEta
 
std::vector< double > _parametersPhi
 
std::vector< double > _parametersTurnOn
 

Detailed Description

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

Author
Thiago R. Fernandez Perez Tomei Based and adapted from: J. Duarte Campderros code from HLTriggerOffline/Higgs J. Klukas, M. Vander Donckt and J. Alcaraz code from the HLTriggerOffline/Muon package.

Definition at line 44 of file HLTExoticaPlotter.h.

Constructor & Destructor Documentation

HLTExoticaPlotter::HLTExoticaPlotter ( const edm::ParameterSet pset,
const std::string &  hltPath,
const std::vector< unsigned int > &  objectsType 
)

Definition at line 19 of file HLTExoticaPlotter.cc.

References LogDebug.

21  :
22  _hltPath(hltPath),
23  _hltProcessName(pset.getParameter<std::string>("hltProcessName")),
24  _objectsType(std::set<unsigned int>(objectsType.begin(), objectsType.end())),
25  _nObjects(objectsType.size()),
26  _parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
27  _parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
28  _parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn"))
29 {
30  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::constructor()";
31 }
#define LogDebug(id)
T getParameter(std::string const &) const
std::set< unsigned int > _objectsType
std::vector< double > _parametersEta
std::string _hltProcessName
std::vector< double > _parametersTurnOn
std::vector< double > _parametersPhi
unsigned int _nObjects
HLTExoticaPlotter::~HLTExoticaPlotter ( )

Definition at line 33 of file HLTExoticaPlotter.cc.

34 {
35 }

Member Function Documentation

void HLTExoticaPlotter::analyze ( const bool &  isPassTrigger,
const std::string &  source,
const std::vector< reco::LeafCandidate > &  matches,
std::map< int, double >  theSumEt 
)

Definition at line 88 of file HLTExoticaPlotter.cc.

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

92 {
93  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::analyze()";
94  if (!isPassTrigger) {
95  return;
96  }
97 
98  std::map<unsigned int, int> countobjects;
99  // Initializing the count of the used object
100  for (std::set<unsigned int>::iterator co = _objectsType.begin();
101  co != _objectsType.end(); ++co) {
102  countobjects[*co] = 0;
103  }
104 
105  int counttotal = 0;
106  const int totalobjectssize2 = 2 * countobjects.size();
107  // Fill the histos if pass the trigger (just the two with higher pt)
108  for (size_t j = 0; j < matches.size(); ++j) {
109  // Is this object owned by this trigger? If not we are not interested...
110  if (_objectsType.find(matches[j].pdgId()) == _objectsType.end()) {
111  continue;
112  }
113 
114  const unsigned int objType = matches[j].pdgId();
115  const std::string objTypeStr = EVTColContainer::getTypeString(objType);
116 
117  float pt = matches[j].pt();
118  float eta = matches[j].eta();
119  float phi = matches[j].phi();
120 
121  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
122  this->fillHist(isPassTrigger, source, objTypeStr, "Eta", eta);
123  this->fillHist(isPassTrigger, source, objTypeStr, "Phi", phi);
124  }
125  else if( source!="gen" ) {
126  if(theSumEt[objType]>=0 && countobjects[objType] == 0) {
127  this->fillHist(isPassTrigger, source, objTypeStr, "SumEt", theSumEt[objType]);
128  }
129  }
130 
131  if (countobjects[objType] == 0) {
132  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) || source!="gen" ) {
133  this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt1", pt);
134  }
135  // Filled the high pt ...
136  ++(countobjects[objType]);
137  ++counttotal;
138  }
139  else if (countobjects[objType] == 1) {
140  if( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
141  this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt2", pt);
142  }
143  // Filled the second high pt ...
144  ++(countobjects[objType]);
145  ++counttotal;
146  }
147  else {
148  if (counttotal == totalobjectssize2) {
149  break;
150  }
151  }
152 
153  } // end loop over matches
154 }
#define LogDebug(id)
std::set< unsigned int > _objectsType
T eta() const
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:42
Definition: DDAxes.h:10
void HLTExoticaPlotter::beginJob ( void  )

Definition at line 38 of file HLTExoticaPlotter.cc.

39 {
40 }
void HLTExoticaPlotter::beginRun ( const edm::Run ,
const edm::EventSetup  
)
void HLTExoticaPlotter::bookHist ( DQMStore::IBooker iBooker,
const std::string &  source,
const std::string &  objType,
const std::string &  variable 
)
private

Definition at line 157 of file HLTExoticaPlotter.cc.

References _elements, _hltPath, _parametersEta, _parametersPhi, _parametersTurnOn, DQMStore::IBooker::book1D(), prof2calltree::edges, h, i, LogDebug, bookConverter::max, min(), mergeVDriftHistosByStation::name, source, AlCaHLTBitMon_QueryRunRegistry::string, and indexGen::title.

Referenced by plotterBookHistos().

161 {
162  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::bookHist()";
163  std::string sourceUpper = source;
164  sourceUpper[0] = std::toupper(sourceUpper[0]);
165  std::string name = source + objType + variable + "_" + _hltPath;
166  TH1F * h = 0;
167 
168  if (variable.find("SumEt") != std::string::npos) {
169  std::string title = "Sum ET of " + sourceUpper + " " + objType;
170  const size_t nBins = _parametersTurnOn.size() - 1;
171  float * edges = new float[nBins + 1];
172  for (size_t i = 0; i < nBins + 1; i++) {
173  edges[i] = _parametersTurnOn[i];
174  }
175  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
176  delete[] edges;
177  }
178 
179  else if (variable.find("MaxPt") != std::string::npos) {
180  std::string desc = (variable == "MaxPt1") ? "Leading" : "Next-to-Leading";
181  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType + " "
182  "where event pass the " + _hltPath;
183  const size_t nBins = _parametersTurnOn.size() - 1;
184  float * edges = new float[nBins + 1];
185  for (size_t i = 0; i < nBins + 1; i++) {
186  edges[i] = _parametersTurnOn[i];
187  }
188  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
189  delete [] edges;
190  }
191 
192  else {
193  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
194  std::string title = symbol + " of " + sourceUpper + " " + objType + " " +
195  "where event pass the " + _hltPath;
196  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
197 
198  int nBins = (int)params[0];
199  double min = params[1];
200  double max = params[2];
201  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
202  }
203 
204  h->Sumw2();
205  _elements[name] = iBooker.book1D(name, h);
206  // LogDebug("ExoticaValidation") << " booked histo with name " << name << "\n"
207  // << " at location " << (unsigned long int)_elements[name];
208  delete h;
209 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
dictionary edges
std::vector< double > _parametersEta
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< double > _parametersTurnOn
std::vector< double > _parametersPhi
static std::string const source
Definition: EdmProvDump.cc:42
std::map< std::string, MonitorElement * > _elements
void HLTExoticaPlotter::fillHist ( const bool &  passTrigger,
const std::string &  source,
const std::string &  objType,
const std::string &  var,
const float &  value 
)
private

Definition at line 211 of file HLTExoticaPlotter.cc.

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

Referenced by analyze().

216 {
217  std::string sourceUpper = source;
218  sourceUpper[0] = toupper(sourceUpper[0]);
219  std::string name = source + objType + variable + "_" + _hltPath;
220 
221  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " " << value;
222  _elements[name]->Fill(value);
223  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " worked";
224 }
#define LogDebug(id)
static std::string const source
Definition: EdmProvDump.cc:42
std::map< std::string, MonitorElement * > _elements
const std::string HLTExoticaPlotter::gethltpath ( ) const
inline

Definition at line 56 of file HLTExoticaPlotter.h.

References _hltPath.

57  {
58  return _hltPath;
59  }
void HLTExoticaPlotter::plotterBookHistos ( DQMStore::IBooker iBooker,
const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 44 of file HLTExoticaPlotter.cc.

References _objectsType, bookHist(), EVTColContainer::getTypeString(), i, LogDebug, source, and AlCaHLTBitMon_QueryRunRegistry::string.

47 {
48  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::plotterBookHistos()";
49  for (std::set<unsigned int>::iterator it = _objectsType.begin();
50  it != _objectsType.end(); ++it) {
51  std::vector<std::string> sources(2);
52  sources[0] = "gen";
53  sources[1] = "rec";
54 
55  const std::string objTypeStr = EVTColContainer::getTypeString(*it);
56 
57  for (size_t i = 0; i < sources.size(); i++) {
58  std::string source = sources[i];
59 
60  if ( source == "gen" ) {
61  if ( TString(objTypeStr).Contains("MET") ||
62  TString(objTypeStr).Contains("MHT") ||
63  TString(objTypeStr).Contains("Jet") ) {
64  continue;
65  } else {
66  bookHist(iBooker, source, objTypeStr, "MaxPt1");
67  bookHist(iBooker, source, objTypeStr, "MaxPt2");
68  bookHist(iBooker, source, objTypeStr, "Eta");
69  bookHist(iBooker, source, objTypeStr, "Phi");
70  }
71  } else { // reco
72  if ( TString(objTypeStr).Contains("MET") ||
73  TString(objTypeStr).Contains("MHT") ) {
74  bookHist(iBooker, source, objTypeStr, "MaxPt1");
75  bookHist(iBooker, source, objTypeStr, "SumEt");
76  } else {
77  bookHist(iBooker, source, objTypeStr, "MaxPt1");
78  bookHist(iBooker, source, objTypeStr, "MaxPt2");
79  bookHist(iBooker, source, objTypeStr, "Eta");
80  bookHist(iBooker, source, objTypeStr, "Phi");
81  }
82  }
83 
84  }
85  }
86 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::set< unsigned int > _objectsType
void bookHist(DQMStore::IBooker &iBooker, const std::string &source, const std::string &objType, const std::string &variable)
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
static std::string const source
Definition: EdmProvDump.cc:42

Member Data Documentation

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

Definition at line 78 of file HLTExoticaPlotter.h.

Referenced by bookHist(), and fillHist().

std::string HLTExoticaPlotter::_hltPath
private

Definition at line 67 of file HLTExoticaPlotter.h.

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

std::string HLTExoticaPlotter::_hltProcessName
private

Definition at line 68 of file HLTExoticaPlotter.h.

unsigned int HLTExoticaPlotter::_nObjects
private

Definition at line 72 of file HLTExoticaPlotter.h.

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

Definition at line 70 of file HLTExoticaPlotter.h.

Referenced by analyze(), and plotterBookHistos().

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

Definition at line 74 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 75 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 76 of file HLTExoticaPlotter.h.

Referenced by bookHist().