CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTExoticaPlotter.cc
Go to the documentation of this file.
1 
8 
12 
13 #include "TPRegexp.h"
14 
15 
16 #include<set>
17 #include<cctype>
18 
20  const std::string & hltPath,
21  const std::vector<unsigned int> & objectsType) :
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 }
32 
34 {
35 }
36 
37 
39 {
40 }
41 
42 
43 
45  const edm::Run & iRun,
46  const edm::EventSetup & iSetup)
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  bookHist(iBooker, source, objTypeStr, "Eta");
60  bookHist(iBooker, source, objTypeStr, "Phi");
61  bookHist(iBooker, source, objTypeStr, "MaxPt1");
62  bookHist(iBooker, source, objTypeStr, "MaxPt2");
63  bookHist(iBooker, source, objTypeStr, "SumEt");
64  }
65  }
66 }
67 
68 void HLTExoticaPlotter::analyze(const bool & isPassTrigger,
69  const std::string & source,
70  const std::vector<reco::LeafCandidate> & matches)
71 {
72  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::analyze()";
73  if (!isPassTrigger) {
74  return;
75  }
76 
77  std::map<unsigned int, int> countobjects;
78  // Initializing the count of the used object
79  for (std::set<unsigned int>::iterator co = _objectsType.begin();
80  co != _objectsType.end(); ++co) {
81  countobjects[*co] = 0;
82  }
83 
84  int counttotal = 0;
85  const int totalobjectssize2 = 2 * countobjects.size();
86  // Fill the histos if pass the trigger (just the two with higher pt)
87  for (size_t j = 0; j < matches.size(); ++j) {
88  // Is this object owned by this trigger? If not we are not interested...
89  if (_objectsType.find(matches[j].pdgId()) == _objectsType.end()) {
90  continue;
91  }
92 
93  const unsigned int objType = matches[j].pdgId();
94  const std::string objTypeStr = EVTColContainer::getTypeString(objType);
95 
96  float pt = matches[j].pt();
97  float eta = matches[j].eta();
98  float phi = matches[j].phi();
99  float sumEt = 0;//matches[j].sumEt;
100  this->fillHist(isPassTrigger, source, objTypeStr, "Eta", eta);
101  this->fillHist(isPassTrigger, source, objTypeStr, "Phi", phi);
102  this->fillHist(isPassTrigger, source, objTypeStr, "SumEt", sumEt);
103 
104  if (countobjects[objType] == 0) {
105  this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt1", pt);
106  // Filled the high pt ...
107  ++(countobjects[objType]);
108  ++counttotal;
109  } else if (countobjects[objType] == 1) {
110  this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt2", pt);
111  // Filled the second high pt ...
112  ++(countobjects[objType]);
113  ++counttotal;
114  } else {
115  if (counttotal == totalobjectssize2) {
116  break;
117  }
118  }
119  }
120 }
121 
122 
124  const std::string & source,
125  const std::string & objType,
126  const std::string & variable)
127 {
128  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::bookHist()";
129  std::string sourceUpper = source;
130  sourceUpper[0] = std::toupper(sourceUpper[0]);
131  std::string name = source + objType + variable + "_" + _hltPath;
132  TH1F * h = 0;
133 
134  if (variable.find("SumEt") != std::string::npos) {
135  std::string title = "Sum ET of " + sourceUpper + " " + objType;
136  const size_t nBins = _parametersTurnOn.size() - 1;
137  float * edges = new float[nBins + 1];
138  for (size_t i = 0; i < nBins + 1; i++) {
139  edges[i] = _parametersTurnOn[i];
140  }
141  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
142  delete[] edges;
143  }
144  else if (variable.find("MaxPt") != std::string::npos) {
145  std::string desc = (variable == "MaxPt1") ? "Leading" : "Next-to-Leading";
146  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType + " "
147  "where event pass the " + _hltPath;
148  const size_t nBins = _parametersTurnOn.size() - 1;
149  float * edges = new float[nBins + 1];
150  for (size_t i = 0; i < nBins + 1; i++) {
151  edges[i] = _parametersTurnOn[i];
152  }
153  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
154  delete [] edges;
155  } else {
156  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
157  std::string title = symbol + " of " + sourceUpper + " " + objType + " " +
158  "where event pass the " + _hltPath;
159  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
160 
161  int nBins = (int)params[0];
162  double min = params[1];
163  double max = params[2];
164  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
165  }
166  h->Sumw2();
167  _elements[name] = iBooker.book1D(name, h);
168  // LogDebug("ExoticaValidation") << " booked histo with name " << name << "\n"
169  // << " at location " << (unsigned long int)_elements[name];
170  delete h;
171 }
172 
173 void HLTExoticaPlotter::fillHist(const bool & passTrigger,
174  const std::string & source,
175  const std::string & objType,
176  const std::string & variable,
177  const float & value)
178 {
179  std::string sourceUpper = source;
180  sourceUpper[0] = toupper(sourceUpper[0]);
181  std::string name = source + objType + variable + "_" + _hltPath;
182 
183  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " " << value;
184  _elements[name]->Fill(value);
185  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " worked";
186 }
187 
188 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
void plotterBookHistos(DQMStore::IBooker &iBooker, const edm::Run &iRun, const edm::EventSetup &iSetup)
void analyze(const bool &isPassTrigger, const std::string &source, const std::vector< reco::LeafCandidate > &matches)
std::set< unsigned int > _objectsType
T eta() const
dictionary edges
HLTExoticaPlotter(const edm::ParameterSet &pset, const std::string &hltPath, const std::vector< unsigned int > &objectsType)
std::vector< double > _parametersEta
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
int j
Definition: DBlmapReader.cc:9
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
#define end
Definition: vmac.h:37
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< double > _parametersTurnOn
void fillHist(const bool &passTrigger, const std::string &source, const std::string &objType, const std::string &var, const float &value)
std::vector< double > _parametersPhi
void bookHist(DQMStore::IBooker &iBooker, const std::string &source, const std::string &objType, const std::string &variable)
#define begin
Definition: vmac.h:30
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
static std::string const source
Definition: EdmProvDump.cc:43
tuple size
Write out results.
Definition: Run.h:41
std::map< std::string, MonitorElement * > _elements
Definition: DDAxes.h:10