CMS 3D CMS Logo

HLTHiggsPlotter.cc
Go to the documentation of this file.
1 
11 
13 
17 
18 #include "TPRegexp.h"
19 
20 #include <set>
21 #include <cctype>
22 
24  const std::string &hltPath,
25  const std::vector<unsigned int> &objectsType,
26  const unsigned int &NptPlots,
27  const std::vector<double> &NminOneCuts)
28  : _hltPath(hltPath),
29  _hltProcessName(pset.getParameter<std::string>("hltProcessName")),
30  _objectsType(std::set<unsigned int>(objectsType.begin(), objectsType.end())),
31  _nObjects(objectsType.size()),
32  _parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
33  _parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
34  _parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn")),
35  _NptPlots(NptPlots),
36  _NminOneCuts(NminOneCuts) {
37  for (std::set<unsigned int>::iterator it = _objectsType.begin(); it != _objectsType.end(); ++it) {
38  // Some parameters extracted from the .py
40  _cutMinPt[*it] = pset.getParameter<double>(std::string(objStr + "_cutMinPt").c_str());
41  _cutMaxEta[*it] = pset.getParameter<double>(std::string(objStr + "_cutMaxEta").c_str());
42  }
43 }
44 
46 
48 
49 void HLTHiggsPlotter::beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) {}
50 
51 void HLTHiggsPlotter::bookHistograms(DQMStore::IBooker &ibooker, const bool &useNminOneCuts) {
52  for (std::set<unsigned int>::iterator it = _objectsType.begin(); it != _objectsType.end(); ++it) {
53  std::vector<std::string> sources(2);
54  sources[0] = "gen";
55  sources[1] = "rec";
56  TString maxPt;
57 
58  const std::string objTypeStr = EVTColContainer::getTypeString(*it);
59 
60  for (size_t i = 0; i < sources.size(); i++) {
62 
63  if (useNminOneCuts && *it == EVTColContainer::PFJET) {
64  if (source == "gen")
65  continue;
66  else {
67  // N-1 jet plots (dEtaqq, mqq, dPhibb, CSV1, maxCSV_jets, maxCSV_E, PFMET, pt1, pt2, pt3, pt4)
68  if (_NminOneCuts[0])
69  bookHist(source, objTypeStr, "dEtaqq", ibooker);
70  if (_NminOneCuts[1])
71  bookHist(source, objTypeStr, "mqq", ibooker);
72  if (_NminOneCuts[2])
73  bookHist(source, objTypeStr, "dPhibb", ibooker);
74  if (_NminOneCuts[3]) {
75  if (_NminOneCuts[6])
76  bookHist(source, objTypeStr, "maxCSV", ibooker);
77  else
78  bookHist(source, objTypeStr, "CSV1", ibooker);
79  }
80  if (_NminOneCuts[4])
81  bookHist(source, objTypeStr, "CSV2", ibooker);
82  if (_NminOneCuts[5])
83  bookHist(source, objTypeStr, "CSV3", ibooker);
84  }
85  }
86 
87  bookHist(source, objTypeStr, "Eta", ibooker);
88  bookHist(source, objTypeStr, "Phi", ibooker);
89  for (unsigned int i = 0; i < _NptPlots; i++) {
90  maxPt = "MaxPt";
91  maxPt += i + 1;
92  bookHist(source, objTypeStr, maxPt.Data(), ibooker);
93  }
94  }
95  }
96 }
97 
98 void HLTHiggsPlotter::analyze(const bool &isPassTrigger,
99  const std::string &source,
100  const std::vector<MatchStruct> &matches,
101  const unsigned int &minCandidates) {
102  if (!isPassTrigger) {
103  return;
104  }
105  std::map<unsigned int, int> countobjects;
106  // Initializing the count of the used object
107  for (std::set<unsigned int>::iterator co = _objectsType.begin(); co != _objectsType.end(); ++co) {
108  countobjects[*co] = 0;
109  }
110 
111  int counttotal = 0;
112  const int totalobjectssize2 = _NptPlots * countobjects.size();
113  // Fill the histos if pass the trigger (just the two with higher pt)
114  for (size_t j = 0; j < matches.size(); ++j) {
115  // Is this object owned by this trigger? If not we are not interested...
116  if (_objectsType.find(matches[j].objType) == _objectsType.end()) {
117  continue;
118  }
119 
120  const unsigned int objType = matches[j].objType;
122 
123  float pt = matches[j].pt;
124  float eta = matches[j].eta;
125  float phi = matches[j].phi;
126 
127  TString maxPt;
128  if ((unsigned)countobjects[objType] < _NptPlots) {
129  maxPt = "MaxPt";
130  maxPt += (countobjects[objType] + 1);
131  this->fillHist(isPassTrigger, source, objTypeStr, maxPt.Data(), pt);
132  // Filled the high pt ...
133  ++(countobjects[objType]);
134  ++counttotal;
135  } else {
136  if ((unsigned)countobjects[objType] < minCandidates) { // To get correct results for HZZ
137  ++(countobjects[objType]);
138  ++counttotal;
139  } else
140  continue; // Otherwise too many entries in Eta and Phi distributions
141  }
142 
143  this->fillHist(isPassTrigger, source, objTypeStr, "Eta", eta);
144  this->fillHist(isPassTrigger, source, objTypeStr, "Phi", phi);
145 
146  if (counttotal == totalobjectssize2) {
147  break;
148  }
149  }
150 }
151 
152 void HLTHiggsPlotter::analyze(const bool &isPassTrigger,
153  const std::string &source,
154  const std::vector<MatchStruct> &matches,
155  std::map<std::string, bool> &nMinOne,
156  const float &dEtaqq,
157  const float &mqq,
158  const float &dPhibb,
159  const float &CSV1,
160  const float &CSV2,
161  const float &CSV3,
162  const bool &passAllCuts) {
163  if (!isPassTrigger) {
164  return;
165  }
166  std::map<unsigned int, int> countobjects;
167  // Initializing the count of the used object
168  for (std::set<unsigned int>::iterator co = _objectsType.begin(); co != _objectsType.end(); ++co) {
169  if (!(*co == EVTColContainer::PFJET && source == "gen")) // genJets are not there
170  countobjects[*co] = 0;
171  }
172 
173  int counttotal = 0;
174  const int totalobjectssize2 = _NptPlots * countobjects.size();
175  // Fill the histos if pass the trigger (just the two with higher pt)
176  for (size_t j = 0; j < matches.size(); ++j) {
177  // Is this object owned by this trigger? If not we are not interested...
178  if (_objectsType.find(matches[j].objType) == _objectsType.end()) {
179  continue;
180  }
181 
182  const unsigned int objType = matches[j].objType;
184 
185  float pt = matches[j].pt;
186  float eta = matches[j].eta;
187  float phi = matches[j].phi;
188 
189  // PFMET N-1 cut
190  if (objType == EVTColContainer::PFMET && _NminOneCuts[8] && !nMinOne["PFMET"])
191  continue;
192 
193  TString maxPt;
194  if ((unsigned)(countobjects)[objType] < _NptPlots) {
195  maxPt = "MaxPt";
196  maxPt += (countobjects[objType] + 1);
197  if (objType != EVTColContainer::PFJET || nMinOne[maxPt.Data()]) {
198  this->fillHist(isPassTrigger, source, objTypeStr, maxPt.Data(), pt);
199  }
200  ++(countobjects[objType]);
201  ++counttotal;
202  } else
203  continue; // if not needed (minCandidates == _NptPlots if _useNminOneCuts
204  if (objType != EVTColContainer::PFJET || passAllCuts) {
205  this->fillHist(isPassTrigger, source, objTypeStr, "Eta", eta);
206  this->fillHist(isPassTrigger, source, objTypeStr, "Phi", phi);
207  }
208 
209  if (counttotal == totalobjectssize2) {
210  break;
211  }
212  }
213  if (source == "rec" && _objectsType.find(EVTColContainer::PFJET) != _objectsType.end()) {
214  if (_NminOneCuts[0] && nMinOne["dEtaqq"]) {
215  this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "dEtaqq", dEtaqq);
216  }
217  if (_NminOneCuts[1] && nMinOne["mqq"]) {
218  this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "mqq", mqq);
219  }
220  if (_NminOneCuts[2] && nMinOne["dPhibb"]) {
221  this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "dPhibb", dPhibb);
222  }
223  if (_NminOneCuts[3]) {
224  std::string nameCSVplot = "CSV1";
225  if (_NminOneCuts[6])
226  nameCSVplot = "maxCSV";
227  if (nMinOne[nameCSVplot])
228  this->fillHist(
229  isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), nameCSVplot, CSV1);
230  }
231  if (_NminOneCuts[4] && nMinOne["CSV2"]) {
232  this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "CSV2", CSV2);
233  }
234  if (_NminOneCuts[5] && nMinOne["CSV3"]) {
235  this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "CSV3", CSV3);
236  }
237  }
238 }
239 
241  const std::string &objType,
242  const std::string &variable,
243  DQMStore::IBooker &ibooker) {
244  std::string sourceUpper = source;
245  sourceUpper[0] = std::toupper(sourceUpper[0]);
247  TH1F *h = nullptr;
248 
249  if (variable.find("MaxPt") != std::string::npos) {
251  if (variable == "MaxPt1")
252  desc = "Leading";
253  else if (variable == "MaxPt2")
254  desc = "Next-to-Leading";
255  else
256  desc = variable.substr(5, 6) + "th Leading";
257  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType +
258  " "
259  "where event pass the " +
260  _hltPath;
261  const size_t nBinsStandard = _parametersTurnOn.size() - 1;
262  size_t nBins = nBinsStandard;
263  float *edges = new float[nBinsStandard + 1];
264  for (size_t i = 0; i < nBinsStandard + 1; i++) {
266  }
267 
269  if (objType == jetObj) {
270  const size_t nBinsJets = 25;
271  nBins = nBinsJets;
272  delete[] edges;
273  edges = new float[nBinsJets + 1];
274  for (size_t i = 0; i < nBinsJets + 1; i++) {
275  edges[i] = i * 10;
276  }
277  }
279  const size_t nBinsJets = 30;
280  nBins = nBinsJets;
281  delete[] edges;
282  edges = new float[nBinsJets + 1];
283  for (size_t i = 0; i < nBinsJets + 1; i++) {
284  edges[i] = i * 10;
285  }
286  }
287  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
288  delete[] edges;
289  } else {
290  if (variable == "dEtaqq") {
291  std::string title = "#Delta #eta_{qq} of " + sourceUpper + " " + objType;
292  int nBins = 20;
293  double min = 0;
294  double max = 4.8;
295  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
296  } else if (variable == "mqq") {
297  std::string title = "m_{qq} of " + sourceUpper + " " + objType;
298  int nBins = 20;
299  double min = 0;
300  double max = 1000;
301  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
302  } else if (variable == "dPhibb") {
303  std::string title = "#Delta #phi_{bb} of " + sourceUpper + " " + objType;
304  int nBins = 10;
305  double min = 0;
306  double max = 3.1416;
307  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
308  } else if (variable == "CSV1") {
309  std::string title = "CSV1 of " + sourceUpper + " " + objType;
310  int nBins = 20;
311  double min = 0;
312  double max = 1;
313  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
314  } else if (variable == "CSV2") {
315  std::string title = "CSV2 of " + sourceUpper + " " + objType;
316  int nBins = 20;
317  double min = 0;
318  double max = 1;
319  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
320  } else if (variable == "CSV3") {
321  std::string title = "CSV3 of " + sourceUpper + " " + objType;
322  int nBins = 20;
323  double min = 0;
324  double max = 1;
325  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
326  } else if (variable == "maxCSV") {
327  std::string title = "max CSV of " + sourceUpper + " " + objType;
328  int nBins = 20;
329  double min = 0;
330  double max = 1;
331  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
332  } else {
333  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
334  std::string title = symbol + " of " + sourceUpper + " " + objType + " " + "where event pass the " + _hltPath;
335  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
336 
337  int nBins = (int)params[0];
338  double min = params[1];
339  double max = params[2];
340  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
341  }
342  }
343  h->Sumw2();
344  _elements[name] = ibooker.book1D(name.c_str(), h);
345  delete h;
346 }
347 
348 void HLTHiggsPlotter::fillHist(const bool &passTrigger,
349  const std::string &source,
350  const std::string &objType,
351  const std::string &variable,
352  const float &value) {
353  std::string sourceUpper = source;
354  sourceUpper[0] = toupper(sourceUpper[0]);
356 
357  _elements[name]->Fill(value);
358 }
EVTColContainer::getTypeString
const static std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
Definition: EVTColContainer.cc:232
Handle.h
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
Muon.h
MessageLogger.h
HLTHiggsPlotter::_elements
std::map< std::string, MonitorElement * > _elements
Definition: HLTHiggsPlotter.h:110
HLTHiggsPlotter.h
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::Run
Definition: Run.h:45
min
T min(T a, T b)
Definition: MathUtil.h:58
HLTHiggsPlotter::HLTHiggsPlotter
HLTHiggsPlotter(const edm::ParameterSet &pset, const std::string &hltPath, const std::vector< unsigned int > &objectsType, const unsigned int &minCandidates, const std::vector< double > &NminOneCuts)
Definition: HLTHiggsPlotter.cc:23
TriggerEvent.h
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
TriggerAnalyzer.hltPath
hltPath
Definition: TriggerAnalyzer.py:62
oniaPATMuonsWithTrigger_cff.matches
matches
Definition: oniaPATMuonsWithTrigger_cff.py:77
EVTColContainer::PFJET
Definition: EVTColContainer.cc:61
CalibrationSummaryClient_cfi.sources
sources
Definition: CalibrationSummaryClient_cfi.py:23
HLTHiggsSubAnalysis.h
HLTHiggsPlotter::_NminOneCuts
std::vector< double > _NminOneCuts
Definition: HLTHiggsPlotter.h:108
HLTHiggsPlotter::bookHist
void bookHist(const std::string &source, const std::string &objType, const std::string &variable, DQMStore::IBooker &)
Definition: HLTHiggsPlotter.cc:240
HLTHiggsPlotter::_objectsType
std::set< unsigned int > _objectsType
Definition: HLTHiggsPlotter.h:91
CandMatchMap.h
HLTHiggsPlotter::_hltPath
std::string _hltPath
Definition: HLTHiggsPlotter.h:87
HLTHiggsPlotter::bookHistograms
void bookHistograms(DQMStore::IBooker &, const bool &)
Definition: HLTHiggsPlotter.cc:51
MuonErrorMatrixAnalyzer_cfi.maxPt
maxPt
Definition: MuonErrorMatrixAnalyzer_cfi.py:19
EVTColContainer::PFMET
Definition: EVTColContainer.cc:54
cms::cuda::co
__host__ __device__ VT * co
Definition: prefixScan.h:47
Service.h
PVValHelper::eta
Definition: PVValidationHelpers.h:70
MuonFwd.h
HLTHiggsPlotter::_NptPlots
unsigned int _NptPlots
Definition: HLTHiggsPlotter.h:105
mps_fire.end
end
Definition: mps_fire.py:242
HLTHiggsPlotter::_cutMinPt
std::map< unsigned int, double > _cutMinPt
Definition: HLTHiggsPlotter.h:99
source
static const std::string source
Definition: EdmProvDump.cc:47
seedmultiplicitymonitor_newtracking_cfi.nBins
nBins
Definition: seedmultiplicitymonitor_newtracking_cfi.py:8
h
HLTHiggsPlotter::beginJob
void beginJob()
Definition: HLTHiggsPlotter.cc:47
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTHiggsPlotter::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: HLTHiggsPlotter.cc:49
electrons_cff.objType
objType
Definition: electrons_cff.py:520
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
HLTHiggsPlotter::_parametersPhi
std::vector< double > _parametersPhi
Definition: HLTHiggsPlotter.h:96
createfilelist.int
int
Definition: createfilelist.py:10
value
Definition: value.py:1
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
HLTHiggsPlotter::_parametersTurnOn
std::vector< double > _parametersTurnOn
Definition: HLTHiggsPlotter.h:97
edm::EventSetup
Definition: EventSetup.h:58
HLTHiggsPlotter::~HLTHiggsPlotter
~HLTHiggsPlotter()
Definition: HLTHiggsPlotter.cc:45
hltExoticaCaloHT_cff.minCandidates
minCandidates
Definition: hltExoticaCaloHT_cff.py:23
SelectiveReadoutTask_cfi.edges
edges
Definition: SelectiveReadoutTask_cfi.py:107
DDAxes::phi
HLTHiggsPlotter::_parametersEta
std::vector< double > _parametersEta
Definition: HLTHiggsPlotter.h:95
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
taus_updatedMVAIds_cff.variable
variable
Definition: taus_updatedMVAIds_cff.py:33
std
Definition: JetResolutionObject.h:76
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EVTColContainer.cc
HLTHiggsPlotter::analyze
void analyze(const bool &isPassTrigger, const std::string &source, const std::vector< MatchStruct > &matches, const unsigned int &minCandidates)
Definition: HLTHiggsPlotter.cc:98
dqm::implementation::IBooker
Definition: DQMStore.h:43
HLTHiggsPlotter::_cutMaxEta
std::map< unsigned int, double > _cutMaxEta
Definition: HLTHiggsPlotter.h:100
HLTHiggsPlotter::fillHist
void fillHist(const bool &passTrigger, const std::string &source, const std::string &objType, const std::string &var, const float &value)
Definition: HLTHiggsPlotter.cc:348
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hltHiggsPostProcessors_cff.NminOneCuts
NminOneCuts
Definition: hltHiggsPostProcessors_cff.py:131
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443