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 
60  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) || source!="gen" ) {
61  bookHist(iBooker, source, objTypeStr, "MaxPt1");
62  }
63 
64  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
65  bookHist(iBooker, source, objTypeStr, "Eta");
66  bookHist(iBooker, source, objTypeStr, "Phi");
67  bookHist(iBooker, source, objTypeStr, "MaxPt2");
68  }
69 
70  else if( source!="gen" ) {
71  bookHist(iBooker, source, objTypeStr, "SumEt");
72  }
73 
74  }
75  }
76 }
77 
78 void HLTExoticaPlotter::analyze(const bool & isPassTrigger,
79  const std::string & source,
80  const std::vector<reco::LeafCandidate> & matches,
81  std::map<int,double> theSumEt)
82 {
83  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::analyze()";
84  if (!isPassTrigger) {
85  return;
86  }
87 
88  std::map<unsigned int, int> countobjects;
89  // Initializing the count of the used object
90  for (std::set<unsigned int>::iterator co = _objectsType.begin();
91  co != _objectsType.end(); ++co) {
92  countobjects[*co] = 0;
93  }
94 
95  int counttotal = 0;
96  const int totalobjectssize2 = 2 * countobjects.size();
97  // Fill the histos if pass the trigger (just the two with higher pt)
98  for (size_t j = 0; j < matches.size(); ++j) {
99  // Is this object owned by this trigger? If not we are not interested...
100  if (_objectsType.find(matches[j].pdgId()) == _objectsType.end()) {
101  continue;
102  }
103 
104  const unsigned int objType = matches[j].pdgId();
105  const std::string objTypeStr = EVTColContainer::getTypeString(objType);
106 
107  float pt = matches[j].pt();
108  float eta = matches[j].eta();
109  float phi = matches[j].phi();
110 
111  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
112  this->fillHist(isPassTrigger, source, objTypeStr, "Eta", eta);
113  this->fillHist(isPassTrigger, source, objTypeStr, "Phi", phi);
114  }
115  else if( source!="gen" ) {
116  if(theSumEt[objType]>=0 && countobjects[objType] == 0) {
117  this->fillHist(isPassTrigger, source, objTypeStr, "SumEt", theSumEt[objType]);
118  }
119  }
120 
121  if (countobjects[objType] == 0) {
122  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) || source!="gen" ) {
123  this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt1", pt);
124  }
125  // Filled the high pt ...
126  ++(countobjects[objType]);
127  ++counttotal;
128  }
129  else if (countobjects[objType] == 1) {
130  if( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
131  this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt2", pt);
132  }
133  // Filled the second high pt ...
134  ++(countobjects[objType]);
135  ++counttotal;
136  }
137  else {
138  if (counttotal == totalobjectssize2) {
139  break;
140  }
141  }
142 
143  } // end loop over matches
144 }
145 
146 
148  const std::string & source,
149  const std::string & objType,
150  const std::string & variable)
151 {
152  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::bookHist()";
153  std::string sourceUpper = source;
154  sourceUpper[0] = std::toupper(sourceUpper[0]);
155  std::string name = source + objType + variable + "_" + _hltPath;
156  TH1F * h = 0;
157 
158  if (variable.find("SumEt") != std::string::npos) {
159  std::string title = "Sum ET of " + sourceUpper + " " + objType;
160  const size_t nBins = _parametersTurnOn.size() - 1;
161  float * edges = new float[nBins + 1];
162  for (size_t i = 0; i < nBins + 1; i++) {
163  edges[i] = _parametersTurnOn[i];
164  }
165  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
166  delete[] edges;
167  }
168 
169  else if (variable.find("MaxPt") != std::string::npos) {
170  std::string desc = (variable == "MaxPt1") ? "Leading" : "Next-to-Leading";
171  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType + " "
172  "where event pass the " + _hltPath;
173  const size_t nBins = _parametersTurnOn.size() - 1;
174  float * edges = new float[nBins + 1];
175  for (size_t i = 0; i < nBins + 1; i++) {
176  edges[i] = _parametersTurnOn[i];
177  }
178  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
179  delete [] edges;
180  }
181 
182  else {
183  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
184  std::string title = symbol + " of " + sourceUpper + " " + objType + " " +
185  "where event pass the " + _hltPath;
186  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
187 
188  int nBins = (int)params[0];
189  double min = params[1];
190  double max = params[2];
191  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
192  }
193 
194  h->Sumw2();
195  _elements[name] = iBooker.book1D(name, h);
196  // LogDebug("ExoticaValidation") << " booked histo with name " << name << "\n"
197  // << " at location " << (unsigned long int)_elements[name];
198  delete h;
199 }
200 
201 void HLTExoticaPlotter::fillHist(const bool & passTrigger,
202  const std::string & source,
203  const std::string & objType,
204  const std::string & variable,
205  const float & value)
206 {
207  std::string sourceUpper = source;
208  sourceUpper[0] = toupper(sourceUpper[0]);
209  std::string name = source + objType + variable + "_" + _hltPath;
210 
211  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " " << value;
212  _elements[name]->Fill(value);
213  LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::fillHist()" << name << " worked";
214 }
215 
216 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
void plotterBookHistos(DQMStore::IBooker &iBooker, const edm::Run &iRun, const edm::EventSetup &iSetup)
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:115
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)
void analyze(const bool &isPassTrigger, const std::string &source, const std::vector< reco::LeafCandidate > &matches, std::map< int, double > theSumEt)
#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