CMS 3D CMS Logo

HLTTauDQML1Plotter.cc
Go to the documentation of this file.
2 
4 
5 #include <cstring>
6 
7 namespace {
8  double getMaxEta(int binsEta, double widthEta) {
9  if (widthEta <= 0.0) {
10  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::HLTTauDQML1Plotter: EtaHistoBinWidth = " << widthEta
11  << " <= 0, using default value 0.348 instead";
12  widthEta = 0.348;
13  }
14  return binsEta / 2 * widthEta;
15  }
16 } // namespace
17 
20  int phibins,
21  double maxpt,
22  double maxhighpt,
23  bool ref,
24  double dr,
25  const std::string& dqmBaseFolder)
26  : HLTTauDQMPlotter(ps, dqmBaseFolder),
27  doRefAnalysis_(ref),
28  matchDeltaR_(dr),
29  maxPt_(maxpt),
30  maxHighPt_(maxhighpt),
31  binsEt_(ps.getUntrackedParameter<int>("EtHistoBins", 25)),
32  binsEta_(ps.getUntrackedParameter<int>("EtaHistoBins", 14)),
33  binsPhi_(phibins),
34  maxEta_(getMaxEta(binsEta_, ps.getUntrackedParameter<double>("EtaHistoBinWidth", 0.348))) {
35  if (!configValid_)
36  return;
37 
38  //Process PSet
41 
44  l1ETMMin_ = ps.getUntrackedParameter<double>("L1ETMMin");
45 
46  configValid_ = true;
47 }
48 
50  if (!configValid_)
51  return;
52 
53  // The L1 phi plot is asymmetric around 0 because of the discrete nature of L1 phi
54  constexpr float pi = 3.1416f;
55  constexpr float phiShift = pi / 18; // half of 2pi/18 bin
56  constexpr float minPhi = -pi + phiShift;
57  constexpr float maxPhi = pi + phiShift;
58 
59  constexpr int BUFMAX = 256;
60  char buffer[BUFMAX] = "";
61 
62  //Create the histograms
63  iBooker.setCurrentFolder(triggerTag());
64 
65  l1tauEt_ = iWrapper.book1D(iBooker, "L1TauEt", "L1 #tau E_{T};L1 #tau E_{T};entries", binsEt_, 0, maxPt_, kVital);
66  l1tauEta_ = iWrapper.book1D(iBooker, "L1TauEta", "L1 #tau #eta;L1 #tau #eta;entries", binsEta_, -maxEta_, maxEta_);
67  l1tauPhi_ = iWrapper.book1D(iBooker, "L1TauPhi", "L1 #tau #phi;L1 #tau #phi;entries", binsPhi_, minPhi, maxPhi);
68 
69  l1isotauEt_ = iWrapper.book1D(
70  iBooker, "L1IsoTauEt", "L1 isolated #tau E_{T};L1 #tau E_{T};entries", binsEt_, 0, maxPt_, kVital);
71  l1isotauEta_ = iWrapper.book1D(
72  iBooker, "L1IsoTauEta", "L1 isolated #tau #eta;L1 #tau #eta;entries", binsEta_, -maxEta_, maxEta_);
73  l1isotauPhi_ =
74  iWrapper.book1D(iBooker, "L1IsoTauPhi", "L1 isolated #tau #phi;L1 #tau #phi;entries", binsPhi_, minPhi, maxPhi);
75 
76  l1etmEt_ = iWrapper.book1D(iBooker, "L1ETM", "L1 ETM E_{T};L1 ETM E_{T};entries", binsEt_, 0, maxPt_, kVital);
77  l1etmPhi_ = iWrapper.book1D(iBooker, "L1ETMPhi", "L1 ETM #phi;L1 ETM #phi;entries", binsPhi_, minPhi, maxPhi);
78 
79  snprintf(buffer, BUFMAX, "L1 leading #tau E_{T};L1 #tau E_{T};entries");
80  firstTauEt_ = iWrapper.book1D(iBooker, "L1LeadTauEt", buffer, binsEt_, 0, maxPt_, kVital);
81  snprintf(buffer, BUFMAX, "L1 leading #tau #eta;L1 #tau #eta;entries");
82  firstTauEta_ = iWrapper.book1D(iBooker, "L1LeadTauEta", buffer, binsEta_, -maxEta_, maxEta_);
83  snprintf(buffer, BUFMAX, "L1 leading #tau #phi;L1 #tau #phi;entries");
84  firstTauPhi_ = iWrapper.book1D(iBooker, "L1LeadTauPhi", buffer, binsPhi_, minPhi, maxPhi);
85 
86  snprintf(buffer, BUFMAX, "L1 second-leading #tau E_{T};L1 #tau E_{T};entries");
87  secondTauEt_ = iWrapper.book1D(iBooker, "L1SecondTauEt", buffer, binsEt_, 0, maxPt_, kVital);
88  snprintf(buffer, BUFMAX, "L1 second-leading #tau #eta;L1 #tau #eta;entries");
89  secondTauEta_ = iWrapper.book1D(iBooker, "L1SecondTauEta", buffer, binsEta_, -maxEta_, maxEta_);
90  snprintf(buffer, BUFMAX, "L1 second-leading #tau #phi;L1 #tau #phi;entries");
91  secondTauPhi_ = iWrapper.book1D(iBooker, "L1SecondTauPhi", buffer, binsPhi_, minPhi, maxPhi);
92 
93  snprintf(buffer, BUFMAX, "L1 leading isolated #tau E_{T};L1 #tau E_{T};entries");
94  firstIsoTauEt_ = iWrapper.book1D(iBooker, "L1LeadIsoTauEt", buffer, binsEt_, 0, maxPt_, kVital);
95  snprintf(buffer, BUFMAX, "L1 leading isolated #tau #eta;L1 #tau #eta;entries");
96  firstIsoTauEta_ = iWrapper.book1D(iBooker, "L1LeadIsoTauEta", buffer, binsEta_, -maxEta_, maxEta_);
97  snprintf(buffer, BUFMAX, "L1 leading isolated #tau #phi;L1 #tau #phi;entries");
98  firstIsoTauPhi_ = iWrapper.book1D(iBooker, "L1LeadIsoTauPhi", buffer, binsPhi_, minPhi, maxPhi);
99 
100  snprintf(buffer, BUFMAX, "L1 second-leading isolated #tau E_{T};L1 #tau E_{T};entries");
101  secondIsoTauEt_ = iWrapper.book1D(iBooker, "L1SecondIsoTauEt", buffer, binsEt_, 0, maxPt_, kVital);
102  snprintf(buffer, BUFMAX, "L1 second-leading isolated #tau #eta;L1 #tau #eta;entries");
103  secondIsoTauEta_ = iWrapper.book1D(iBooker, "L1SecondIsoTauEta", buffer, binsEta_, -maxEta_, maxEta_);
104  snprintf(buffer, BUFMAX, "L1 second-leading isolated #tau #phi;L1 #tau #phi;entries");
105  secondIsoTauPhi_ = iWrapper.book1D(iBooker, "L1SecondIsoTauPhi", buffer, binsPhi_, minPhi, maxPhi);
106 
107  if (doRefAnalysis_) {
108  l1tauEtRes_ = iWrapper.book1D(iBooker,
109  "L1TauEtResol",
110  "L1 #tau E_{T} resolution;[L1 #tau E_{T}-Ref #tau E_{T}]/Ref #tau E_{T};entries",
111  60,
112  -1,
113  4,
114  kVital);
116  iWrapper.book1D(iBooker,
117  "L1IsoTauEtResol",
118  "L1 isolated #tau E_{T} resolution;[L1 #tau E_{T}-Ref #tau E_{T}]/Ref #tau E_{T};entries",
119  60,
120  -1,
121  4,
122  kVital);
123 
124  iBooker.setCurrentFolder(triggerTag() + "/helpers");
125 
126  l1tauEtEffNum_ = iWrapper.book1D(
127  iBooker, "L1TauEtEffNum", "L1 #tau E_{T} Efficiency;Ref #tau E_{T};entries", binsEt_, 0, maxPt_, kVital);
128  l1tauHighEtEffNum_ = iWrapper.book1D(iBooker,
129  "L1TauHighEtEffNum",
130  "L1 #tau E_{T} Efficiency (high E_{T});Ref #tau E_{T};entries",
131  binsEt_,
132  0,
133  maxHighPt_,
134  kVital);
135 
136  l1tauEtEffDenom_ = iWrapper.book1D(
137  iBooker, "L1TauEtEffDenom", "L1 #tau E_{T} Denominator;Ref #tau E_{T};entries", binsEt_, 0, maxPt_, kVital);
138  l1tauHighEtEffDenom_ = iWrapper.book1D(iBooker,
139  "L1TauHighEtEffDenom",
140  "L1 #tau E_{T} Denominator (high E_{T});Ref #tau E_{T};Efficiency",
141  binsEt_,
142  0,
143  maxHighPt_,
144  kVital);
145 
146  l1tauEtaEffNum_ = iWrapper.book1D(
147  iBooker, "L1TauEtaEffNum", "L1 #tau #eta Efficiency;Ref #tau #eta;entries", binsEta_, -maxEta_, maxEta_);
148  l1tauEtaEffDenom_ = iWrapper.book1D(
149  iBooker, "L1TauEtaEffDenom", "L1 #tau #eta Denominator;Ref #tau #eta;entries", binsEta_, -maxEta_, maxEta_);
150 
151  l1tauPhiEffNum_ = iWrapper.book1D(
152  iBooker, "L1TauPhiEffNum", "L1 #tau #phi Efficiency;Ref #tau #phi;entries", binsPhi_, minPhi, maxPhi);
153  l1tauPhiEffDenom_ = iWrapper.book1D(
154  iBooker, "L1TauPhiEffDenom", "L1 #tau #phi Denominator;Ref #tau #phi;Efficiency", binsPhi_, minPhi, maxPhi);
155 
156  l1isotauEtEffNum_ = iWrapper.book1D(iBooker,
157  "L1IsoTauEtEffNum",
158  "L1 isolated #tau E_{T} Efficiency;Ref #tau E_{T};entries",
159  binsEt_,
160  0,
161  maxPt_,
162  kVital);
163  l1isotauEtEffDenom_ = iWrapper.book1D(iBooker,
164  "L1IsoTauEtEffDenom",
165  "L1 isolated #tau E_{T} Denominator;Ref #tau E_{T};entries",
166  binsEt_,
167  0,
168  maxPt_,
169  kVital);
170 
171  l1isotauEtaEffNum_ = iWrapper.book1D(iBooker,
172  "L1IsoTauEtaEffNum",
173  "L1 isolated #tau #eta Efficiency;Ref #tau #eta;entries",
174  binsEta_,
175  -maxEta_,
176  maxEta_);
177  l1isotauEtaEffDenom_ = iWrapper.book1D(iBooker,
178  "L1IsoTauEtaEffDenom",
179  "L1 isolated #tau #eta Denominator;Ref #tau #eta;entries",
180  binsEta_,
181  -maxEta_,
182  maxEta_);
183 
184  l1isotauPhiEffNum_ = iWrapper.book1D(iBooker,
185  "L1IsoTauPhiEffNum",
186  "L1 isolated #tau #phi Efficiency;Ref #tau #phi;entries",
187  binsPhi_,
188  minPhi,
189  maxPhi);
190  l1isotauPhiEffDenom_ = iWrapper.book1D(iBooker,
191  "L1IsoTauPhiEffDenom",
192  "L1 isolated #tau #phi Denominator;Ref #tau #phi;Efficiency",
193  binsPhi_,
194  minPhi,
195  maxPhi);
196 
198  iWrapper.book1D(iBooker, "L1ETMEtEffNum", "L1 ETM Efficiency;Ref MET;entries", binsEt_, 0, maxPt_, kVital);
200  iWrapper.book1D(iBooker, "L1ETMEtEffDenom", "L1 ETM Denominator;Ref MET;entries", binsEt_, 0, maxPt_, kVital);
201  }
202 }
203 
205 
206 //
207 // member functions
208 //
209 
211  const edm::EventSetup& iSetup,
212  const HLTTauDQMOfflineObjects& refC) {
213  if (doRefAnalysis_) {
214  //Tau reference
215  for (auto const& tau : refC.taus) {
216  if (l1tauEtEffDenom_)
217  l1tauEtEffDenom_->Fill(tau.pt());
220 
221  if (l1tauEtaEffDenom_)
222  l1tauEtaEffDenom_->Fill(tau.eta());
223 
224  if (l1tauPhiEffDenom_)
225  l1tauPhiEffDenom_->Fill(tau.phi());
226 
230  l1isotauEtaEffDenom_->Fill(tau.eta());
232  l1isotauPhiEffDenom_->Fill(tau.phi());
233  }
234  if (!refC.met.empty())
235  if (l1etmEtEffDenom_)
236  l1etmEtEffDenom_->Fill(refC.met[0].pt());
237  }
238 
239  //Analyze L1 Objects (Tau+Jets)
241  iEvent.getByToken(l1stage2TausToken_, taus);
242 
244  iEvent.getByToken(l1stage2SumsToken_, sums);
245 
246  LVColl pathTaus;
247  LVColl pathIsoTaus;
248 
249  //Set Variables for the threshold plot
250  LVColl l1taus;
251  LVColl l1isotaus;
252  LVColl l1met;
253 
254  if (taus.isValid()) {
255  for (auto const& i : *taus) {
256  l1taus.push_back(i.p4());
257  if (i.hwIso() > 0)
258  l1isotaus.push_back(i.p4());
259  if (!doRefAnalysis_) {
260  if (l1tauEt_)
261  l1tauEt_->Fill(i.et());
262  if (l1tauEta_)
263  l1tauEta_->Fill(i.eta());
264  if (l1tauPhi_)
265  l1tauPhi_->Fill(i.phi());
266  pathTaus.push_back(i.p4());
267 
268  if (l1isotauEt_)
269  l1isotauEt_->Fill(i.et());
270  if (l1isotauEta_)
271  l1isotauEta_->Fill(i.eta());
272  if (l1isotauPhi_)
273  l1isotauPhi_->Fill(i.phi());
274  if (i.hwIso() > 0)
275  pathIsoTaus.push_back(i.p4());
276  }
277  }
278  } else {
279  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 tau collection "
280  << l1stage2Taus_.encode();
281  }
282 
283  if (sums.isValid() && sums.product()->size() > 0) {
284  if (!doRefAnalysis_) {
285  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
286  for (auto it = sums->begin(ibx); it != sums->end(ibx); it++) {
287  auto type = static_cast<int>(it->getType());
289  if (l1etmEt_)
290  l1etmEt_->Fill(it->et());
291  }
292  }
293  }
294  } else {
295  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 met collection "
296  << l1stage2Sums_.encode();
297  }
298 
299  //Now do the efficiency matching
300  if (doRefAnalysis_) {
301  for (auto const& tau : refC.taus) {
302  std::pair<bool, LV> m = match(tau, l1taus, matchDeltaR_);
303  if (m.first) {
304  if (l1tauEt_)
305  l1tauEt_->Fill(m.second.pt());
306  if (l1tauEta_)
307  l1tauEta_->Fill(m.second.eta());
308  if (l1tauPhi_)
309  l1tauPhi_->Fill(m.second.phi());
310 
311  if (l1tauEtEffNum_)
312  l1tauEtEffNum_->Fill(tau.pt());
313  if (l1tauHighEtEffNum_)
314  l1tauHighEtEffNum_->Fill(tau.pt());
315  if (l1tauEtaEffNum_)
316  l1tauEtaEffNum_->Fill(tau.eta());
317  if (l1tauPhiEffNum_)
318  l1tauPhiEffNum_->Fill(tau.phi());
319 
320  if (l1tauEtRes_)
321  l1tauEtRes_->Fill((m.second.pt() - tau.pt()) / tau.pt());
322 
323  pathTaus.push_back(m.second);
324  }
325  m = match(tau, l1isotaus, matchDeltaR_);
326  if (m.first) {
327  if (l1isotauEt_)
328  l1isotauEt_->Fill(m.second.pt());
329  if (l1isotauEta_)
330  l1isotauEta_->Fill(m.second.eta());
331  if (l1isotauPhi_)
332  l1isotauPhi_->Fill(m.second.phi());
333 
334  if (l1isotauEtEffNum_)
335  l1isotauEtEffNum_->Fill(tau.pt());
336  if (l1isotauEtaEffNum_)
337  l1isotauEtaEffNum_->Fill(tau.eta());
338  if (l1isotauPhiEffNum_)
339  l1isotauPhiEffNum_->Fill(tau.phi());
340 
341  if (l1isotauEtRes_)
342  l1isotauEtRes_->Fill((m.second.pt() - tau.pt()) / tau.pt());
343 
344  pathIsoTaus.push_back(m.second);
345  }
346  }
347 
348  if (sums.isValid() && sums.product()->size() > 0) {
349  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
350  for (auto it = sums->begin(ibx); it != sums->end(ibx); it++) {
351  auto type = static_cast<int>(it->getType());
353  if (l1etmEt_)
354  l1etmEt_->Fill(it->et());
355  if (l1etmPhi_)
356  l1etmPhi_->Fill(it->phi());
357 
358  if (it->et() > l1ETMMin_) {
359  if (l1etmEtEffNum_)
360  l1etmEtEffNum_->Fill(it->et());
361  }
362  }
363  }
364  }
365  }
366  }
367 
368  //Fill the Threshold Monitoring
369  if (pathTaus.size() > 1)
370  std::sort(pathTaus.begin(), pathTaus.end(), [](const LV& a, const LV& b) { return a.pt() > b.pt(); });
371  if (!pathTaus.empty()) {
372  if (firstTauEt_)
373  firstTauEt_->Fill(pathTaus[0].pt());
374  if (firstTauEta_)
375  firstTauEta_->Fill(pathTaus[0].eta());
376  if (firstTauPhi_)
377  firstTauPhi_->Fill(pathTaus[0].phi());
378  }
379  if (pathTaus.size() > 1) {
380  if (secondTauEt_)
381  secondTauEt_->Fill(pathTaus[1].pt());
382  if (secondTauEta_)
383  secondTauEta_->Fill(pathTaus[1].eta());
384  if (secondTauPhi_)
385  secondTauPhi_->Fill(pathTaus[1].phi());
386  }
387  if (pathIsoTaus.size() > 1)
388  std::sort(pathIsoTaus.begin(), pathIsoTaus.end(), [](const LV& a, const LV& b) { return a.pt() > b.pt(); });
389  if (!pathIsoTaus.empty()) {
390  if (firstIsoTauEt_)
391  firstIsoTauEt_->Fill(pathIsoTaus[0].pt());
392  if (firstIsoTauEta_)
393  firstIsoTauEta_->Fill(pathIsoTaus[0].eta());
394  if (firstIsoTauPhi_)
395  firstIsoTauPhi_->Fill(pathIsoTaus[0].phi());
396  }
397  if (pathIsoTaus.size() > 1) {
398  if (secondIsoTauEt_)
399  secondIsoTauEt_->Fill(pathIsoTaus[1].pt());
400  if (secondIsoTauEta_)
401  secondIsoTauEta_->Fill(pathIsoTaus[1].eta());
402  if (secondIsoTauPhi_)
403  secondIsoTauPhi_->Fill(pathIsoTaus[1].phi());
404  }
405 }
int getLastBX() const
MonitorElement * secondIsoTauPhi_
int getFirstBX() const
const double matchDeltaR_
MonitorElement * l1isotauEtEffDenom_
MonitorElement * secondTauEta_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
std::vector< LV > taus
MonitorElement * l1isotauEta_
void bookHistograms(HistoWrapper &iWrapper, DQMStore::IBooker &iBooker)
MonitorElement * firstTauPhi_
std::string encode() const
Definition: InputTag.cc:159
math::XYZTLorentzVectorD LV
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
MonitorElement * l1etmEtEffNum_
T const * product() const
Definition: Handle.h:70
MonitorElement * l1isotauPhiEffNum_
MonitorElement * l1isotauEt_
MonitorElement * firstIsoTauPhi_
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const HLTTauDQMOfflineObjects &refC)
MonitorElement * secondIsoTauEt_
MonitorElement * firstTauEta_
MonitorElement * l1tauEt_
MonitorElement * l1isotauEtaEffDenom_
MonitorElement * l1isotauPhiEffDenom_
MonitorElement * secondTauEt_
MonitorElement * l1tauEtEffDenom_
const Double_t pi
const_iterator begin(int bx) const
unsigned size(int bx) const
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
MonitorElement * secondIsoTauEta_
int iEvent
Definition: GenABIO.cc:224
MonitorElement * l1tauEtaEffNum_
MonitorElement * firstTauEt_
MonitorElement * l1tauHighEtEffDenom_
edm::EDGetTokenT< l1t::TauBxCollection > l1stage2TausToken_
MonitorElement * l1etmEt_
edm::InputTag l1stage2Taus_
MonitorElement * l1tauEtEffNum_
MonitorElement * l1tauPhi_
MonitorElement * book1D(DQMStore::IBooker &iBooker, TString const &name, TString const &title, int const nchX, double const lowX, double const highX, int level=kEverything)
Definition: HistoWrapper.cc:17
std::vector< LV > met
MonitorElement * l1tauEta_
MonitorElement * l1isotauPhi_
MonitorElement * l1isotauEtaEffNum_
std::vector< LV > LVColl
MonitorElement * secondTauPhi_
MonitorElement * l1tauPhiEffDenom_
HLTTauDQML1Plotter(const edm::ParameterSet &, edm::ConsumesCollector &&cc, int phibins, double maxpt, double maxhighpt, bool ref, double dr, const std::string &dqmBaseFolder)
double b
Definition: hdecay.h:118
MonitorElement * firstIsoTauEta_
bool isValid() const
Definition: HandleBase.h:70
MonitorElement * l1isotauEtEffNum_
MonitorElement * l1tauEtaEffDenom_
MonitorElement * l1tauEtRes_
const_iterator end(int bx) const
double a
Definition: hdecay.h:119
Log< level::Warning, false > LogWarning
std::pair< bool, LV > match(const LV &, const LVColl &, double)
MonitorElement * l1isotauEtRes_
MonitorElement * l1etmEtEffDenom_
MonitorElement * l1etmPhi_
MonitorElement * firstIsoTauEt_
const std::string & triggerTag() const
edm::InputTag l1stage2Sums_
MonitorElement * l1tauPhiEffNum_
MonitorElement * l1tauHighEtEffNum_
edm::EDGetTokenT< l1t::EtSumBxCollection > l1stage2SumsToken_