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 << " <= 0, using default value 0.348 instead";
11  widthEta = 0.348;
12  }
13  return binsEta/2*widthEta;
14  }
15 }
16 
17 HLTTauDQML1Plotter::HLTTauDQML1Plotter(const edm::ParameterSet& ps, edm::ConsumesCollector&& cc, int phibins, double maxpt, double maxhighpt, bool ref, double dr, const std::string& dqmBaseFolder):
18  HLTTauDQMPlotter(ps, dqmBaseFolder),
19  doRefAnalysis_(ref),
20  matchDeltaR_(dr),
21  maxPt_(maxpt),
22  maxHighPt_(maxhighpt),
23  binsEt_(ps.getUntrackedParameter<int>("EtHistoBins", 25)),
24  binsEta_(ps.getUntrackedParameter<int>("EtaHistoBins", 14)),
25  binsPhi_(phibins),
26  maxEta_(getMaxEta(binsEta_, ps.getUntrackedParameter<double>("EtaHistoBinWidth", 0.348)))
27 {
28  if(!configValid_)
29  return;
30 
31  //Process PSet
34 
37  l1ETMMin_ = ps.getUntrackedParameter<double>("L1ETMMin");
38 
39  configValid_ = true;
40 }
41 
43  if(!configValid_)
44  return;
45 
46  // The L1 phi plot is asymmetric around 0 because of the discrete nature of L1 phi
47  constexpr float pi = 3.1416f;
48  constexpr float phiShift = pi/18; // half of 2pi/18 bin
49  constexpr float minPhi = -pi+phiShift;
50  constexpr float maxPhi = pi+phiShift;
51 
52  constexpr int BUFMAX = 256;
53  char buffer[BUFMAX] = "";
54 
55  //Create the histograms
56  iBooker.setCurrentFolder(triggerTag());
57 
58  l1tauEt_ = iBooker.book1D("L1TauEt","L1 #tau E_{T};L1 #tau E_{T};entries",binsEt_,0,maxPt_);
59  l1tauEta_ = iBooker.book1D("L1TauEta","L1 #tau #eta;L1 #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
60  l1tauPhi_ = iBooker.book1D("L1TauPhi","L1 #tau #phi;L1 #tau #phi;entries",binsPhi_,minPhi,maxPhi);
61 
62  l1isotauEt_ = iBooker.book1D("L1IsoTauEt","L1 isolated #tau E_{T};L1 #tau E_{T};entries",binsEt_,0,maxPt_);
63  l1isotauEta_ = iBooker.book1D("L1IsoTauEta","L1 isolated #tau #eta;L1 #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
64  l1isotauPhi_ = iBooker.book1D("L1IsoTauPhi","L1 isolated #tau #phi;L1 #tau #phi;entries",binsPhi_,minPhi,maxPhi);
65 
66  l1etmEt_ = iBooker.book1D("L1ETM","L1 ETM E_{T};L1 ETM E_{T};entries",binsEt_,0,maxPt_);
67  l1etmPhi_ = iBooker.book1D("L1ETMPhi","L1 ETM #phi;L1 ETM #phi;entries",binsPhi_,minPhi,maxPhi);
68 
69  snprintf(buffer, BUFMAX, "L1 leading #tau E_{T};L1 #tau E_{T};entries");
70  firstTauEt_ = iBooker.book1D("L1LeadTauEt", buffer, binsEt_, 0, maxPt_);
71  snprintf(buffer, BUFMAX, "L1 leading #tau #eta;L1 #tau #eta;entries");
72  firstTauEta_ = iBooker.book1D("L1LeadTauEta", buffer, binsEta_, -maxEta_, maxEta_);
73  snprintf(buffer, BUFMAX, "L1 leading #tau #phi;L1 #tau #phi;entries");
74  firstTauPhi_ = iBooker.book1D("L1LeadTauPhi", buffer, binsPhi_, minPhi, maxPhi);
75 
76  snprintf(buffer, BUFMAX, "L1 second-leading #tau E_{T};L1 #tau E_{T};entries");
77  secondTauEt_ = iBooker.book1D("L1SecondTauEt", buffer, binsEt_, 0, maxPt_);
78  snprintf(buffer, BUFMAX, "L1 second-leading #tau #eta;L1 #tau #eta;entries");
79  secondTauEta_ = iBooker.book1D("L1SecondTauEta", buffer, binsEta_, -maxEta_, maxEta_);
80  snprintf(buffer, BUFMAX, "L1 second-leading #tau #phi;L1 #tau #phi;entries");
81  secondTauPhi_ = iBooker.book1D("L1SecondTauPhi", buffer, binsPhi_, minPhi, maxPhi);
82 
83  snprintf(buffer, BUFMAX, "L1 leading isolated #tau E_{T};L1 #tau E_{T};entries");
84  firstIsoTauEt_ = iBooker.book1D("L1LeadIsoTauEt", buffer, binsEt_, 0, maxPt_);
85  snprintf(buffer, BUFMAX, "L1 leading isolated #tau #eta;L1 #tau #eta;entries");
86  firstIsoTauEta_ = iBooker.book1D("L1LeadIsoTauEta", buffer, binsEta_, -maxEta_, maxEta_);
87  snprintf(buffer, BUFMAX, "L1 leading isolated #tau #phi;L1 #tau #phi;entries");
88  firstIsoTauPhi_ = iBooker.book1D("L1LeadIsoTauPhi", buffer, binsPhi_, minPhi, maxPhi);
89 
90  snprintf(buffer, BUFMAX, "L1 second-leading isolated #tau E_{T};L1 #tau E_{T};entries");
91  secondIsoTauEt_ = iBooker.book1D("L1SecondIsoTauEt", buffer, binsEt_, 0, maxPt_);
92  snprintf(buffer, BUFMAX, "L1 second-leading isolated #tau #eta;L1 #tau #eta;entries");
93  secondIsoTauEta_ = iBooker.book1D("L1SecondIsoTauEta", buffer, binsEta_, -maxEta_, maxEta_);
94  snprintf(buffer, BUFMAX, "L1 second-leading isolated #tau #phi;L1 #tau #phi;entries");
95  secondIsoTauPhi_ = iBooker.book1D("L1SecondIsoTauPhi", buffer, binsPhi_, minPhi, maxPhi);
96 
97  if (doRefAnalysis_) {
98  l1tauEtRes_ = iBooker.book1D("L1TauEtResol","L1 #tau E_{T} resolution;[L1 #tau E_{T}-Ref #tau E_{T}]/Ref #tau E_{T};entries",60,-1,4);
99  l1isotauEtRes_ = iBooker.book1D("L1IsoTauEtResol","L1 isolated #tau E_{T} resolution;[L1 #tau E_{T}-Ref #tau E_{T}]/Ref #tau E_{T};entries",60,-1,4);
100 
101  iBooker.setCurrentFolder(triggerTag()+"/helpers");
102 
103  l1tauEtEffNum_ = iBooker.book1D("L1TauEtEffNum","L1 #tau E_{T} Efficiency;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
104  l1tauHighEtEffNum_ = iBooker.book1D("L1TauHighEtEffNum","L1 #tau E_{T} Efficiency (high E_{T});Ref #tau E_{T};entries",binsEt_,0,maxHighPt_);
105 
106  l1tauEtEffDenom_ = iBooker.book1D("L1TauEtEffDenom","L1 #tau E_{T} Denominator;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
107  l1tauHighEtEffDenom_ = iBooker.book1D("L1TauHighEtEffDenom","L1 #tau E_{T} Denominator (high E_{T});Ref #tau E_{T};Efficiency",binsEt_,0,maxHighPt_);
108 
109  l1tauEtaEffNum_ = iBooker.book1D("L1TauEtaEffNum","L1 #tau #eta Efficiency;Ref #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
110  l1tauEtaEffDenom_ = iBooker.book1D("L1TauEtaEffDenom","L1 #tau #eta Denominator;Ref #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
111 
112  l1tauPhiEffNum_ = iBooker.book1D("L1TauPhiEffNum","L1 #tau #phi Efficiency;Ref #tau #phi;entries",binsPhi_,minPhi,maxPhi);
113  l1tauPhiEffDenom_ = iBooker.book1D("L1TauPhiEffDenom","L1 #tau #phi Denominator;Ref #tau #phi;Efficiency",binsPhi_,minPhi,maxPhi);
114 
115  l1isotauEtEffNum_ = iBooker.book1D("L1IsoTauEtEffNum","L1 isolated #tau E_{T} Efficiency;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
116  l1isotauEtEffDenom_ = iBooker.book1D("L1IsoTauEtEffDenom","L1 isolated #tau E_{T} Denominator;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
117 
118  l1isotauEtaEffNum_ = iBooker.book1D("L1IsoTauEtaEffNum","L1 isolated #tau #eta Efficiency;Ref #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
119  l1isotauEtaEffDenom_ = iBooker.book1D("L1IsoTauEtaEffDenom","L1 isolated #tau #eta Denominator;Ref #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
120 
121  l1isotauPhiEffNum_ = iBooker.book1D("L1IsoTauPhiEffNum","L1 isolated #tau #phi Efficiency;Ref #tau #phi;entries",binsPhi_,minPhi,maxPhi);
122  l1isotauPhiEffDenom_ = iBooker.book1D("L1IsoTauPhiEffDenom","L1 isolated #tau #phi Denominator;Ref #tau #phi;Efficiency",binsPhi_,minPhi,maxPhi);
123 
124  l1etmEtEffNum_ = iBooker.book1D("L1ETMEtEffNum", "L1 ETM Efficiency;Ref MET;entries",binsEt_, 0, maxPt_);
125  l1etmEtEffDenom_ = iBooker.book1D("L1ETMEtEffDenom","L1 ETM Denominator;Ref MET;entries",binsEt_,0,maxPt_);
126  }
127 }
128 
129 
131 
132 //
133 // member functions
134 //
135 
137  if ( doRefAnalysis_ ) {
138  //Tau reference
139  for (auto const & tau : refC.taus) {
140  l1tauEtEffDenom_->Fill(tau.pt());
142 
143  l1tauEtaEffDenom_->Fill(tau.eta());
144 
145  l1tauPhiEffDenom_->Fill(tau.phi());
146 
148  l1isotauEtaEffDenom_->Fill(tau.eta());
149  l1isotauPhiEffDenom_->Fill(tau.phi());
150  }
151  if(!refC.met.empty()) l1etmEtEffDenom_->Fill(refC.met[0].pt());
152  }
153 
154  //Analyze L1 Objects (Tau+Jets)
156  iEvent.getByToken(l1stage2TausToken_, taus);
157 
159  iEvent.getByToken(l1stage2SumsToken_, sums);
160 
161  LVColl pathTaus;
162  LVColl pathIsoTaus;
163 
164  //Set Variables for the threshold plot
165  LVColl l1taus;
166  LVColl l1isotaus;
167  LVColl l1met;
168 
169  if(taus.isValid()) {
170  for(auto const & i : *taus) {
171  l1taus.push_back(i.p4());
172  if(i.hwIso() > 0) l1isotaus.push_back(i.p4());
173  if(!doRefAnalysis_) {
174  l1tauEt_->Fill(i.et());
175  l1tauEta_->Fill(i.eta());
176  l1tauPhi_->Fill(i.phi());
177  pathTaus.push_back(i.p4());
178 
179  l1isotauEt_->Fill(i.et());
180  l1isotauEta_->Fill(i.eta());
181  l1isotauPhi_->Fill(i.phi());
182  if(i.hwIso() > 0) pathIsoTaus.push_back(i.p4());
183  }
184  }
185  }
186  else {
187  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 tau collection " << l1stage2Taus_.encode();
188  }
189 
190  if(sums.isValid() && sums.product()->size() > 0) {
191  if(!doRefAnalysis_) {
192  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
193  for (auto it=sums->begin(ibx); it!=sums->end(ibx); it++) {
194  auto type = static_cast<int>( it->getType() );
196  }
197  }
198  }
199  }
200  else {
201  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 met collection " << l1stage2Sums_.encode();
202  }
203 
204  //Now do the efficiency matching
205  if ( doRefAnalysis_ ) {
206  for (auto const & tau : refC.taus) {
207  std::pair<bool,LV> m = match(tau,l1taus,matchDeltaR_);
208  if ( m.first ) {
209  l1tauEt_->Fill(m.second.pt());
210  l1tauEta_->Fill(m.second.eta());
211  l1tauPhi_->Fill(m.second.phi());
212 
213  l1tauEtEffNum_->Fill(tau.pt());
214  l1tauHighEtEffNum_->Fill(tau.pt());
215  l1tauEtaEffNum_->Fill(tau.eta());
216  l1tauPhiEffNum_->Fill(tau.phi());
217 
218  l1tauEtRes_->Fill((m.second.pt()-tau.pt())/tau.pt());
219 
220  pathTaus.push_back(m.second);
221  }
222  m = match(tau,l1isotaus,matchDeltaR_);
223  if ( m.first ) {
224  l1isotauEt_->Fill(m.second.pt());
225  l1isotauEta_->Fill(m.second.eta());
226  l1isotauPhi_->Fill(m.second.phi());
227 
228  l1isotauEtEffNum_->Fill(tau.pt());
229  l1isotauEtaEffNum_->Fill(tau.eta());
230  l1isotauPhiEffNum_->Fill(tau.phi());
231 
232  l1isotauEtRes_->Fill((m.second.pt()-tau.pt())/tau.pt());
233 
234  pathIsoTaus.push_back(m.second);
235  }
236 
237  }
238 
239  if(sums.isValid() && sums.product()->size() > 0) {
240  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
241  for (auto it=sums->begin(ibx); it!=sums->end(ibx); it++) {
242  auto type = static_cast<int>( it->getType() );
244  l1etmEt_->Fill(it->et());
245  l1etmPhi_->Fill(it->phi());
246 
247  if( it->et() > l1ETMMin_){
248  l1etmEtEffNum_->Fill(it->et());
249  }
250  }
251  }
252  }
253  }
254  }
255 
256  //Fill the Threshold Monitoring
257  if(pathTaus.size() > 1) std::sort(pathTaus.begin(), pathTaus.end(), [](const LV& a, const LV& b) { return a.pt() > b.pt(); });
258  if ( !pathTaus.empty() ) {
259  firstTauEt_->Fill(pathTaus[0].pt());
260  firstTauEta_->Fill(pathTaus[0].eta());
261  firstTauPhi_->Fill(pathTaus[0].phi());
262  }
263  if ( pathTaus.size() > 1 ) {
264  secondTauEt_->Fill(pathTaus[1].pt());
265  secondTauEta_->Fill(pathTaus[1].eta());
266  secondTauPhi_->Fill(pathTaus[1].phi());
267  }
268  if(pathIsoTaus.size() > 1) std::sort(pathIsoTaus.begin(), pathIsoTaus.end(), [](const LV& a, const LV& b) { return a.pt() > b.pt(); });
269  if ( !pathIsoTaus.empty() ) {
270  firstIsoTauEt_->Fill(pathIsoTaus[0].pt());
271  firstIsoTauEta_->Fill(pathIsoTaus[0].eta());
272  firstIsoTauPhi_->Fill(pathIsoTaus[0].phi());
273  }
274  if ( pathIsoTaus.size() > 1 ) {
275  secondIsoTauEt_->Fill(pathIsoTaus[1].pt());
276  secondIsoTauEta_->Fill(pathIsoTaus[1].eta());
277  secondIsoTauPhi_->Fill(pathIsoTaus[1].phi());
278  }
279 }
const_iterator end(int bx) const
type
Definition: HCALResponse.h:21
MonitorElement * secondIsoTauPhi_
T getUntrackedParameter(std::string const &, T const &) const
const double matchDeltaR_
unsigned size(int bx) const
MonitorElement * l1isotauEtEffDenom_
MonitorElement * secondTauEta_
std::vector< LV > taus
void bookHistograms(DQMStore::IBooker &iBooker)
MonitorElement * l1isotauEta_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
MonitorElement * firstTauPhi_
math::XYZTLorentzVectorD LV
MonitorElement * l1etmEtEffNum_
MonitorElement * l1isotauPhiEffNum_
MonitorElement * l1isotauEt_
const std::string & triggerTag() const
MonitorElement * firstIsoTauPhi_
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const HLTTauDQMOfflineObjects &refC)
MonitorElement * secondIsoTauEt_
MonitorElement * firstTauEta_
std::string encode() const
Definition: InputTag.cc:166
#define constexpr
MonitorElement * l1tauEt_
MonitorElement * l1isotauEtaEffDenom_
MonitorElement * l1isotauPhiEffDenom_
MonitorElement * secondTauEt_
MonitorElement * l1tauEtEffDenom_
void Fill(long long x)
const Double_t pi
MonitorElement * secondIsoTauEta_
int iEvent
Definition: GenABIO.cc:230
MonitorElement * l1tauEtaEffNum_
MonitorElement * firstTauEt_
MonitorElement * l1tauHighEtEffDenom_
edm::EDGetTokenT< l1t::TauBxCollection > l1stage2TausToken_
MonitorElement * l1etmEt_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
edm::InputTag l1stage2Taus_
MonitorElement * l1tauEtEffNum_
MonitorElement * l1tauPhi_
bool isValid() const
Definition: HandleBase.h:74
std::vector< LV > met
MonitorElement * l1tauEta_
MonitorElement * l1isotauPhi_
int getFirstBX() const
MonitorElement * l1isotauEtaEffNum_
std::vector< LV > LVColl
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
MonitorElement * secondTauPhi_
T const * product() const
Definition: Handle.h:81
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:120
MonitorElement * firstIsoTauEta_
MonitorElement * l1isotauEtEffNum_
MonitorElement * l1tauEtaEffDenom_
MonitorElement * l1tauEtRes_
double a
Definition: hdecay.h:121
int getLastBX() const
std::pair< bool, LV > match(const LV &, const LVColl &, double)
MonitorElement * l1isotauEtRes_
MonitorElement * l1etmEtEffDenom_
MonitorElement * l1etmPhi_
MonitorElement * firstIsoTauEt_
const_iterator begin(int bx) const
edm::InputTag l1stage2Sums_
MonitorElement * l1tauPhiEffNum_
MonitorElement * l1tauHighEtEffNum_
edm::EDGetTokenT< l1t::EtSumBxCollection > l1stage2SumsToken_