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

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

22  :
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  _drop_pt2(false),
33  _drop_pt3(false)
34 {
35  if (pset.exists("dropPt2")) {
36  _drop_pt2 = pset.getParameter<bool>("dropPt2");
37  }
38  if (pset.exists("dropPt3")) {
39  _drop_pt3 = pset.getParameter<bool>("dropPt3");
40  }
41  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::constructor()";
42 }
#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 44 of file HLTExoticaPlotter.cc.

45 {
46 }

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 117 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.

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

Definition at line 49 of file HLTExoticaPlotter.cc.

50 {
51 }
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 203 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().

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

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

Referenced by analyze(), and gethltpath().

269 {
270  std::string sourceUpper = source;
271  sourceUpper[0] = toupper(sourceUpper[0]);
273 
274  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " " << value;
275  _elements[name]->Fill(value);
276  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " worked";
277 }
#define LogDebug(id)
static std::string const source
Definition: EdmProvDump.cc:43
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 55 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.

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

Member Data Documentation

bool HLTExoticaPlotter::_drop_pt2
private

Definition at line 82 of file HLTExoticaPlotter.h.

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

bool HLTExoticaPlotter::_drop_pt3
private

Definition at line 83 of file HLTExoticaPlotter.h.

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

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

Definition at line 85 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().