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, std::vector< float > &dxys)
 
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 > _parametersDxy
 
std::vector< double > _parametersEta
 
std::vector< double > _parametersPhi
 
std::vector< double > _parametersTurnOn
 
std::vector< double > _parametersTurnOnSumEt
 

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 20 of file HLTExoticaPlotter.cc.

References LogDebug.

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

Definition at line 36 of file HLTExoticaPlotter.cc.

37 {
38 }

Member Function Documentation

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

Definition at line 107 of file HLTExoticaPlotter.cc.

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

112 {
113  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::analyze()";
114  if (!isPassTrigger) {
115  return;
116  }
117 
118  std::map<unsigned int, int> countobjects;
119  // Initializing the count of the used object
120  for (std::set<unsigned int>::iterator co = _objectsType.begin();
121  co != _objectsType.end(); ++co) {
122  countobjects[*co] = 0;
123  }
124 
125  int counttotal = 0;
126 
127  // 3 : pt1, pt2, pt3
128  const int totalobjectssize3 = 3 * countobjects.size();
129  // Fill the histos if pass the trigger (just the two with higher pt)
130  for (size_t j = 0; j < matches.size(); ++j) {
131  // Is this object owned by this trigger? If not we are not interested...
132  if (_objectsType.find(matches[j].pdgId()) == _objectsType.end()) {
133  continue;
134  }
135 
136  const unsigned int objType = matches[j].pdgId();
137  const std::string objTypeStr = EVTColContainer::getTypeString(objType);
138 
139  float pt = matches[j].pt();
140  float eta = matches[j].eta();
141  float phi = matches[j].phi();
142 
143  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
144  this->fillHist(isPassTrigger, source, objTypeStr, "Eta", eta);
145  this->fillHist(isPassTrigger, source, objTypeStr, "Phi", phi);
146  }
147  else if( source!="gen" ) {
148  if(theSumEt[objType]>=0 && countobjects[objType] == 0) {
149  this->fillHist(isPassTrigger, source, objTypeStr, "SumEt", theSumEt[objType]);
150  }
151  }
152 
153  if ( dxys.size() && (objType == EVTColContainer::ELEC || objType == EVTColContainer::MUON ) )
154  this->fillHist(isPassTrigger, source, objTypeStr, "Dxy", dxys[j] );
155 
156  if (countobjects[objType] == 0) {
157  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) || source!="gen" ) {
158  this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt1", pt);
159  }
160  // Filled the high pt ...
161  ++(countobjects[objType]);
162  ++counttotal;
163  }
164  else if (countobjects[objType] == 1) {
165  if( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
166  this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt2", pt);
167  }
168  // Filled the second high pt ...
169  ++(countobjects[objType]);
170  ++counttotal;
171  }
172  else if (countobjects[objType] == 2) {
173  if( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
174  this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt3", pt);
175  }
176  // Filled the third highest pt ...
177  ++(countobjects[objType]);
178  ++counttotal;
179  }
180  else {
181  if (counttotal == totalobjectssize3) {
182  break;
183  }
184  }
185 
186  } // end loop over matches
187 }
#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 41 of file HLTExoticaPlotter.cc.

42 {
43 }
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 190 of file HLTExoticaPlotter.cc.

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

Referenced by plotterBookHistos().

194 {
195  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::bookHist()";
196  std::string sourceUpper = source;
197  sourceUpper[0] = std::toupper(sourceUpper[0]);
198  std::string name = source + objType + variable + "_" + _hltPath;
199  TH1F * h = 0;
200 
201  if (variable.find("SumEt") != std::string::npos) {
202  std::string title = "Sum ET of " + sourceUpper + " " + objType;
203  const size_t nBins = _parametersTurnOnSumEt.size() - 1;
204  float * edges = new float[nBins + 1];
205  for (size_t i = 0; i < nBins + 1; i++) {
206  edges[i] = _parametersTurnOnSumEt[i];
207  }
208  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
209  delete[] edges;
210  }
211  else if (variable.find("Dxy") != std::string::npos) {
212  std::string title = "Dxy " + sourceUpper + " " + objType;
213  int nBins = _parametersDxy[0];
214  double min = _parametersDxy[1];
215  double max = _parametersDxy[2];
216  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
217  }
218  else if (variable.find("MaxPt") != std::string::npos) {
219  std::string desc = (variable == "MaxPt1") ? "Leading" :
220  (variable == "MaxPt2") ? "Next-to-Leading" : "Next-to-next-to-Leading";
221  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType + " "
222  "where event pass the " + _hltPath;
223  const size_t nBins = _parametersTurnOn.size() - 1;
224  float * edges = new float[nBins + 1];
225  for (size_t i = 0; i < nBins + 1; i++) {
226  edges[i] = _parametersTurnOn[i];
227  }
228  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
229  delete [] edges;
230  }
231 
232  else {
233  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
234  std::string title = symbol + " of " + sourceUpper + " " + objType + " " +
235  "where event pass the " + _hltPath;
236  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
237 
238  int nBins = (int)params[0];
239  double min = params[1];
240  double max = params[2];
241  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
242  }
243 
244  h->Sumw2();
245  _elements[name] = iBooker.book1D(name, h);
246  // LogDebug("ExoticaValidation") << " booked histo with name " << name << "\n"
247  // << " at location " << (unsigned long int)_elements[name];
248  delete h;
249 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::vector< double > _parametersDxy
dictionary edges
std::vector< double > _parametersTurnOnSumEt
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 251 of file HLTExoticaPlotter.cc.

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

Referenced by analyze().

256 {
257  std::string sourceUpper = source;
258  sourceUpper[0] = toupper(sourceUpper[0]);
259  std::string name = source + objType + variable + "_" + _hltPath;
260 
261  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " " << value;
262  _elements[name]->Fill(value);
263  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " worked";
264 }
#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 57 of file HLTExoticaPlotter.h.

References _hltPath.

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

Definition at line 47 of file HLTExoticaPlotter.cc.

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

50 {
51  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::plotterBookHistos()";
52  for (std::set<unsigned int>::iterator it = _objectsType.begin();
53  it != _objectsType.end(); ++it) {
54  std::vector<std::string> sources(2);
55  sources[0] = "gen";
56  sources[1] = "rec";
57 
58  const std::string objTypeStr = EVTColContainer::getTypeString(*it);
59 
60  for (size_t i = 0; i < sources.size(); i++) {
61  std::string source = sources[i];
62 
63  if ( source == "gen" ) {
64  if ( TString(objTypeStr).Contains("MET") ||
65  TString(objTypeStr).Contains("MHT") ||
66  TString(objTypeStr).Contains("Jet") ) {
67  continue;
68  } else {
69  bookHist(iBooker, source, objTypeStr, "MaxPt1");
70  bookHist(iBooker, source, objTypeStr, "MaxPt2");
71  bookHist(iBooker, source, objTypeStr, "MaxPt3");
72  bookHist(iBooker, source, objTypeStr, "Eta");
73  bookHist(iBooker, source, objTypeStr, "Phi");
74 
75  // If the target is electron or muon,
76  // we will add Dxy plots.
77  if ( *it == EVTColContainer::ELEC ||
78  *it == EVTColContainer::MUON ) {
79  bookHist(iBooker, source, objTypeStr, "Dxy");
80  }
81  }
82  } else { // reco
83  if ( TString(objTypeStr).Contains("MET") ||
84  TString(objTypeStr).Contains("MHT") ) {
85  bookHist(iBooker, source, objTypeStr, "MaxPt1");
86  bookHist(iBooker, source, objTypeStr, "SumEt");
87  } else {
88  bookHist(iBooker, source, objTypeStr, "MaxPt1");
89  bookHist(iBooker, source, objTypeStr, "MaxPt2");
90  bookHist(iBooker, source, objTypeStr, "MaxPt3");
91  bookHist(iBooker, source, objTypeStr, "Eta");
92  bookHist(iBooker, source, objTypeStr, "Phi");
93 
94  // If the target is electron or muon,
95  // we will add Dxy plots.
96  if ( *it == EVTColContainer::ELEC ||
97  *it == EVTColContainer::MUON ) {
98  bookHist(iBooker, source, objTypeStr, "Dxy");
99  }
100  }
101  }
102 
103  }
104  }
105 }
#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 81 of file HLTExoticaPlotter.h.

Referenced by bookHist(), and fillHist().

std::string HLTExoticaPlotter::_hltPath
private

Definition at line 68 of file HLTExoticaPlotter.h.

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

std::string HLTExoticaPlotter::_hltProcessName
private

Definition at line 69 of file HLTExoticaPlotter.h.

unsigned int HLTExoticaPlotter::_nObjects
private

Definition at line 73 of file HLTExoticaPlotter.h.

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

Definition at line 71 of file HLTExoticaPlotter.h.

Referenced by analyze(), and plotterBookHistos().

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

Definition at line 79 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 75 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 76 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 77 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 78 of file HLTExoticaPlotter.h.

Referenced by bookHist().