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

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  :
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  _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 115 of file HLTExoticaPlotter.cc.

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

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

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

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

Referenced by analyze().

267 {
268  std::string sourceUpper = source;
269  sourceUpper[0] = toupper(sourceUpper[0]);
270  std::string name = source + objType + variable + "_" + _hltPath;
271 
272  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " " << value;
273  _elements[name]->Fill(value);
274  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " worked";
275 }
#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 55 of file HLTExoticaPlotter.cc.

References _drop_pt2, _drop_pt3, _objectsType, bookHist(), EVTColContainer::ELEC, EVTColContainer::getTypeString(), i, LogDebug, EVTColContainer::MUON, 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  bookHist(iBooker, source, objTypeStr, "Dxy");
88  }
89  }
90  } else { // reco
91  if ( TString(objTypeStr).Contains("MET") ||
92  TString(objTypeStr).Contains("MHT") ) {
93  bookHist(iBooker, source, objTypeStr, "MaxPt1");
94  bookHist(iBooker, source, objTypeStr, "SumEt");
95  } else {
96  bookHist(iBooker, source, objTypeStr, "MaxPt1");
97  if (!_drop_pt2) bookHist(iBooker, source, objTypeStr, "MaxPt2");
98  if (!_drop_pt3) bookHist(iBooker, source, objTypeStr, "MaxPt3");
99  bookHist(iBooker, source, objTypeStr, "Eta");
100  bookHist(iBooker, source, objTypeStr, "Phi");
101 
102  // If the target is electron or muon,
103  // we will add Dxy plots.
104  if ( *it == EVTColContainer::ELEC ||
105  *it == EVTColContainer::MUON ) {
106  bookHist(iBooker, source, objTypeStr, "Dxy");
107  }
108  }
109  }
110 
111  }
112  }
113 }
#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

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().