CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTHiggsPlotter.cc
Go to the documentation of this file.
1 
12 
14 
18 
19 #include "TPRegexp.h"
20 
21 
22 #include<set>
23 #include<cctype>
24 
26  const std::string & hltPath,
27  const std::vector<unsigned int> & objectsType,
28  DQMStore * dbe) :
29  _hltPath(hltPath),
30  _hltProcessName(pset.getParameter<std::string>("hltProcessName")),
31  _objectsType(std::set<unsigned int>(objectsType.begin(),objectsType.end())),
32  _nObjects(objectsType.size()),
33  _parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
34  _parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
35  _parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn")),
36  _dbe(dbe)
37 {
38  for(std::set<unsigned int>::iterator it = _objectsType.begin();
39  it != _objectsType.end(); ++it)
40  {
41  // Some parameters extracted from the .py
43  _cutMinPt[*it] = pset.getParameter<double>( std::string(objStr+"_cutMinPt").c_str() );
44  _cutMaxEta[*it] = pset.getParameter<double>( std::string(objStr+"_cutMaxEta").c_str() );
45  }
46 }
47 
49 {
50 }
51 
52 
54 {
55 }
56 
57 
58 
60  const edm::EventSetup & iSetup)
61 {
62  for (std::set<unsigned int>::iterator it = _objectsType.begin();
63  it != _objectsType.end(); ++it)
64  {
65  std::vector<std::string> sources(2);
66  sources[0] = "gen";
67  sources[1] = "rec";
68 
69  const std::string objTypeStr = EVTColContainer::getTypeString(*it);
70 
71  for (size_t i = 0; i < sources.size(); i++)
72  {
73  std::string source = sources[i];
74  bookHist(source, objTypeStr, "Eta");
75  bookHist(source, objTypeStr, "Phi");
76  bookHist(source, objTypeStr, "MaxPt1");
77  bookHist(source, objTypeStr, "MaxPt2");
78  }
79  }
80 }
81 
82 void HLTHiggsPlotter::analyze(const bool & isPassTrigger,
83  const std::string & source,
84  const std::vector<MatchStruct> & matches)
85 {
86  if ( !isPassTrigger )
87  {
88  return;
89  }
90  std::map<unsigned int,int> countobjects;
91  // Initializing the count of the used object
92  for(std::set<unsigned int>::iterator co = _objectsType.begin();
93  co != _objectsType.end(); ++co)
94  {
95  countobjects[*co] = 0;
96  }
97 
98  int counttotal = 0;
99  const int totalobjectssize2 = 2*countobjects.size();
100  // Fill the histos if pass the trigger (just the two with higher pt)
101  for (size_t j = 0; j < matches.size(); ++j)
102  {
103  // Is this object owned by this trigger? If not we are not interested...
104  if ( _objectsType.find( matches[j].objType) == _objectsType.end() )
105  {
106  continue;
107  }
108 
109  const unsigned int objType = matches[j].objType;
110  const std::string objTypeStr = EVTColContainer::getTypeString(matches[j].objType);
111 
112  float pt = matches[j].pt;
113  float eta = matches[j].eta;
114  float phi = matches[j].phi;
115  this->fillHist(isPassTrigger,source,objTypeStr,"Eta",eta);
116  this->fillHist(isPassTrigger,source,objTypeStr,"Phi",phi);
117  if ( countobjects[objType] == 0 )
118  {
119  this->fillHist(isPassTrigger,source,objTypeStr,"MaxPt1",pt);
120  // Filled the high pt ...
121  ++(countobjects[objType]);
122  ++counttotal;
123  }
124  else if ( countobjects[objType] == 1 )
125  {
126  this->fillHist(isPassTrigger,source,objTypeStr,"MaxPt2",pt);
127  // Filled the second high pt ...
128  ++(countobjects[objType]);
129  ++counttotal;
130  }
131  else
132  {
133  if ( counttotal == totalobjectssize2 )
134  {
135  break;
136  }
137  }
138  }
139 }
140 
141 
143  const std::string & objType,
144  const std::string & variable)
145 {
146  std::string sourceUpper = source;
147  sourceUpper[0] = std::toupper(sourceUpper[0]);
148  std::string name = source + objType + variable + "_" + _hltPath;
149  TH1F * h = 0;
150 
151  if (variable.find("MaxPt") != std::string::npos)
152  {
153  std::string desc = (variable == "MaxPt1") ? "Leading" : "Next-to-Leading";
154  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType + " "
155  "where event pass the "+ _hltPath;
156  const size_t nBins = _parametersTurnOn.size() - 1;
157  float * edges = new float[nBins + 1];
158  for(size_t i = 0; i < nBins + 1; i++)
159  {
160  edges[i] = _parametersTurnOn[i];
161  }
162  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
163  delete [] edges;
164  }
165  else
166  {
167  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
168  std::string title = symbol + " of " + sourceUpper + " " + objType + " "+
169  "where event pass the "+ _hltPath;
170  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
171 
172  int nBins = (int)params[0];
173  double min = params[1];
174  double max = params[2];
175  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
176  }
177  h->Sumw2();
178  _elements[name] = _dbe->book1D(name, h);
179  delete h;
180 }
181 
182 void HLTHiggsPlotter::fillHist(const bool & passTrigger,
183  const std::string & source,
184  const std::string & objType,
185  const std::string & variable,
186  const float & value )
187 {
188  std::string sourceUpper = source;
189  sourceUpper[0] = toupper(sourceUpper[0]);
190  std::string name = source + objType + variable + "_" + _hltPath;
191 
192  _elements[name]->Fill(value);
193 }
194 
195 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
static std::string getTypeString(const unsigned int &objtype)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:873
std::vector< double > _parametersPhi
T eta() const
dictionary edges
std::set< unsigned int > _objectsType
std::map< std::string, MonitorElement * > _elements
HLTHiggsPlotter(const edm::ParameterSet &pset, const std::string &hltPath, const std::vector< unsigned int > &objectsType, DQMStore *dbe)
std::string _hltPath
const T & max(const T &a, const T &b)
std::map< unsigned int, double > _cutMinPt
int j
Definition: DBlmapReader.cc:9
std::vector< double > _parametersTurnOn
#define end
Definition: vmac.h:37
void fillHist(const bool &passTrigger, const std::string &source, const std::string &objType, const std::string &var, const float &value)
std::vector< double > _parametersEta
void beginRun(const edm::Run &, const edm::EventSetup &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void analyze(const bool &isPassTrigger, const std::string &source, const std::vector< MatchStruct > &matches)
#define begin
Definition: vmac.h:30
std::map< unsigned int, double > _cutMaxEta
void bookHist(const std::string &source, const std::string &objType, const std::string &variable)
static std::string const source
Definition: EdmProvDump.cc:43
tuple size
Write out results.
Definition: Run.h:41
Definition: DDAxes.h:10