CMS 3D CMS Logo

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

bool _drop_pt2
 
bool _drop_pt3
 
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 19 of file HLTExoticaPlotter.cc.

References _drop_pt2, _drop_pt3, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), and LogDebug.

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  _parametersTurnOnSumEt(pset.getParameter<std::vector<double>>("parametersTurnOnSumEt")),
30  _parametersDxy(pset.getParameter<std::vector<double>>("parametersDxy")),
31  _drop_pt2(false),
32  _drop_pt3(false) {
33  if (pset.exists("dropPt2")) {
34  _drop_pt2 = pset.getParameter<bool>("dropPt2");
35  }
36  if (pset.exists("dropPt3")) {
37  _drop_pt3 = pset.getParameter<bool>("dropPt3");
38  }
39  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::constructor()";
40 }
#define LogDebug(id)
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
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 42 of file HLTExoticaPlotter.cc.

42 {}

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

References _drop_pt2, _drop_pt3, _objectsType, EVTColContainer::ELEC, PVValHelper::eta, fillHist(), EVTColContainer::getTypeString(), LogDebug, EVTColContainer::MUON, EVTColContainer::MUTRK, electrons_cff::objType, phi, EnergyCorrector::pt, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 44 of file HLTExoticaPlotter.cc.

44 {}
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 185 of file HLTExoticaPlotter.cc.

References _elements, _hltPath, _parametersDxy, _parametersEta, _parametersPhi, _parametersTurnOn, _parametersTurnOnSumEt, DQMStore::IBooker::book1D(), h, mps_fire::i, createfilelist::int, LogDebug, SiStripPI::max, min(), dataset::name, electrons_cff::objType, source, AlCaHLTBitMon_QueryRunRegistry::string, and fftjetcommon_cfi::title.

Referenced by gethltpath(), and plotterBookHistos().

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

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

Referenced by analyze(), and gethltpath().

250  {
251  std::string sourceUpper = source;
252  sourceUpper[0] = toupper(sourceUpper[0]);
254 
255  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " " << value;
256  _elements[name]->Fill(value);
257  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " worked";
258 }
#define LogDebug(id)
static std::string const source
Definition: EdmProvDump.cc:47
std::map< std::string, MonitorElement * > _elements
const std::string HLTExoticaPlotter::gethltpath ( ) const
inline
void HLTExoticaPlotter::plotterBookHistos ( DQMStore::IBooker iBooker,
const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 46 of file HLTExoticaPlotter.cc.

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

48  {
49  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::plotterBookHistos()";
50  for (std::set<unsigned int>::iterator it = _objectsType.begin(); 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") || TString(objTypeStr).Contains("MHT") ||
62  TString(objTypeStr).Contains("Jet")) {
63  continue;
64  } else {
65  bookHist(iBooker, source, objTypeStr, "MaxPt1");
66  if (!_drop_pt2)
67  bookHist(iBooker, source, objTypeStr, "MaxPt2");
68  if (!_drop_pt3)
69  bookHist(iBooker, source, objTypeStr, "MaxPt3");
70  bookHist(iBooker, source, objTypeStr, "Eta");
71  bookHist(iBooker, source, objTypeStr, "Phi");
72 
73  // If the target is electron or muon,
74  // we will add Dxy plots.
76  bookHist(iBooker, source, objTypeStr, "Dxy");
77  }
78  }
79  } else { // reco
80  if (TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT")) {
81  bookHist(iBooker, source, objTypeStr, "MaxPt1");
82  bookHist(iBooker, source, objTypeStr, "SumEt");
83  } else {
84  bookHist(iBooker, source, objTypeStr, "MaxPt1");
85  if (!_drop_pt2)
86  bookHist(iBooker, source, objTypeStr, "MaxPt2");
87  if (!_drop_pt3)
88  bookHist(iBooker, source, objTypeStr, "MaxPt3");
89  bookHist(iBooker, source, objTypeStr, "Eta");
90  bookHist(iBooker, source, objTypeStr, "Phi");
91 
92  // If the target is electron or muon,
93  // we will add Dxy plots.
95  bookHist(iBooker, source, objTypeStr, "Dxy");
96  }
97  }
98  }
99  }
100  }
101 }
#define LogDebug(id)
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:47

Member Data Documentation

bool HLTExoticaPlotter::_drop_pt2
private

Definition at line 86 of file HLTExoticaPlotter.h.

Referenced by analyze(), HLTExoticaPlotter(), and plotterBookHistos().

bool HLTExoticaPlotter::_drop_pt3
private

Definition at line 87 of file HLTExoticaPlotter.h.

Referenced by analyze(), HLTExoticaPlotter(), and plotterBookHistos().

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

Definition at line 89 of file HLTExoticaPlotter.h.

Referenced by bookHist(), and fillHist().

std::string HLTExoticaPlotter::_hltPath
private

Definition at line 72 of file HLTExoticaPlotter.h.

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

std::string HLTExoticaPlotter::_hltProcessName
private

Definition at line 73 of file HLTExoticaPlotter.h.

unsigned int HLTExoticaPlotter::_nObjects
private

Definition at line 77 of file HLTExoticaPlotter.h.

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

Definition at line 75 of file HLTExoticaPlotter.h.

Referenced by analyze(), and plotterBookHistos().

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

Definition at line 83 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 79 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 80 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 81 of file HLTExoticaPlotter.h.

Referenced by bookHist().

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

Definition at line 82 of file HLTExoticaPlotter.h.

Referenced by bookHist().