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 //
134 // member functions
135 //
136 
138  if ( doRefAnalysis_ ) {
139  //Tau reference
140  for ( LVColl::const_iterator iter = refC.taus.begin(); iter != refC.taus.end(); ++iter ) {
141  l1tauEtEffDenom_->Fill(iter->pt());
142  l1tauHighEtEffDenom_->Fill(iter->pt());
143 
144  l1tauEtaEffDenom_->Fill(iter->eta());
145 
146  l1tauPhiEffDenom_->Fill(iter->phi());
147 
148  l1isotauEtEffDenom_->Fill(iter->pt());
149  l1isotauEtaEffDenom_->Fill(iter->eta());
150  l1isotauPhiEffDenom_->Fill(iter->phi());
151  }
152  if(refC.met.size() > 0) l1etmEtEffDenom_->Fill(refC.met[0].pt());
153  }
154 
155  //Analyze L1 Objects (Tau+Jets)
157  iEvent.getByToken(l1stage2TausToken_, taus);
158 
160  iEvent.getByToken(l1stage2SumsToken_, sums);
161 
162  LVColl pathTaus;
163  LVColl pathIsoTaus;
164 
165  //Set Variables for the threshold plot
166  LVColl l1taus;
167  LVColl l1isotaus;
168  LVColl l1met;
169 
170  if(taus.isValid()) {
171  for(l1t::TauBxCollection::const_iterator i = taus->begin(); i != taus->end(); ++i) {
172  l1taus.push_back(i->p4());
173  if(i->hwIso() > 0) l1isotaus.push_back(i->p4());
174  if(!doRefAnalysis_) {
175  l1tauEt_->Fill(i->et());
176  l1tauEta_->Fill(i->eta());
177  l1tauPhi_->Fill(i->phi());
178  pathTaus.push_back(i->p4());
179 
180  l1isotauEt_->Fill(i->et());
181  l1isotauEta_->Fill(i->eta());
182  l1isotauPhi_->Fill(i->phi());
183  if(i->hwIso() > 0) pathIsoTaus.push_back(i->p4());
184  }
185  }
186  }
187  else {
188  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 tau collection " << l1stage2Taus_.encode();
189  }
190 
191  if(sums.isValid() && sums.product()->size() > 0) {
192  if(!doRefAnalysis_) {
193  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
194  for (l1t::EtSumBxCollection::const_iterator it=sums->begin(ibx); it!=sums->end(ibx); it++) {
195  int type = static_cast<int>( it->getType() );
196  if(type == l1t::EtSum::EtSumType::kMissingEt) l1etmEt_->Fill(it->et());
197  }
198  }
199  }
200  }
201  else {
202  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 met collection " << l1stage2Sums_.encode();
203  }
204 
205  //Now do the efficiency matching
206  if ( doRefAnalysis_ ) {
207  for ( LVColl::const_iterator i = refC.taus.begin(); i != refC.taus.end(); ++i ) {
208  std::pair<bool,LV> m = match(*i,l1taus,matchDeltaR_);
209  if ( m.first ) {
210  l1tauEt_->Fill(m.second.pt());
211  l1tauEta_->Fill(m.second.eta());
212  l1tauPhi_->Fill(m.second.phi());
213 
214  l1tauEtEffNum_->Fill(i->pt());
215  l1tauHighEtEffNum_->Fill(i->pt());
216  l1tauEtaEffNum_->Fill(i->eta());
217  l1tauPhiEffNum_->Fill(i->phi());
218 
219  l1tauEtRes_->Fill((m.second.pt()-i->pt())/i->pt());
220 
221  pathTaus.push_back(m.second);
222  }
223  m = match(*i,l1isotaus,matchDeltaR_);
224  if ( m.first ) {
225  l1isotauEt_->Fill(m.second.pt());
226  l1isotauEta_->Fill(m.second.eta());
227  l1isotauPhi_->Fill(m.second.phi());
228 
229  l1isotauEtEffNum_->Fill(i->pt());
230  l1isotauEtaEffNum_->Fill(i->eta());
231  l1isotauPhiEffNum_->Fill(i->phi());
232 
233  l1isotauEtRes_->Fill((m.second.pt()-i->pt())/i->pt());
234 
235  pathIsoTaus.push_back(m.second);
236  }
237 
238  }
239 
240  if(sums.isValid() && sums.product()->size() > 0) {
241  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
242  for (l1t::EtSumBxCollection::const_iterator it=sums->begin(ibx); it!=sums->end(ibx); it++) {
243  int type = static_cast<int>( it->getType() );
245  l1etmEt_->Fill(it->et());
246  l1etmPhi_->Fill(it->phi());
247 
248  if( it->et() > l1ETMMin_){
249  l1etmEtEffNum_->Fill(it->et());
250  }
251  }
252  }
253  }
254  }
255  }
256 
257  //Fill the Threshold Monitoring
258  if(pathTaus.size() > 1) std::sort(pathTaus.begin(), pathTaus.end(), [](const LV& a, const LV& b) { return a.pt() > b.pt(); });
259  if ( pathTaus.size() > 0 ) {
260  firstTauEt_->Fill(pathTaus[0].pt());
261  firstTauEta_->Fill(pathTaus[0].eta());
262  firstTauPhi_->Fill(pathTaus[0].phi());
263  }
264  if ( pathTaus.size() > 1 ) {
265  secondTauEt_->Fill(pathTaus[1].pt());
266  secondTauEta_->Fill(pathTaus[1].eta());
267  secondTauPhi_->Fill(pathTaus[1].phi());
268  }
269  if(pathIsoTaus.size() > 1) std::sort(pathIsoTaus.begin(), pathIsoTaus.end(), [](const LV& a, const LV& b) { return a.pt() > b.pt(); });
270  if ( pathIsoTaus.size() > 0 ) {
271  firstIsoTauEt_->Fill(pathIsoTaus[0].pt());
272  firstIsoTauEta_->Fill(pathIsoTaus[0].eta());
273  firstIsoTauPhi_->Fill(pathIsoTaus[0].phi());
274  }
275  if ( pathIsoTaus.size() > 1 ) {
276  secondIsoTauEt_->Fill(pathIsoTaus[1].pt());
277  secondIsoTauEta_->Fill(pathIsoTaus[1].eta());
278  secondIsoTauPhi_->Fill(pathIsoTaus[1].phi());
279  }
280 }
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:460
MonitorElement * firstTauPhi_
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_
math::XYZTLorentzVectorD LV
int iEvent
Definition: GenABIO.cc:230
MonitorElement * l1tauEtaEffNum_
MonitorElement * firstTauEt_
MonitorElement * l1tauHighEtEffDenom_
std::vector< LV > LVColl
edm::EDGetTokenT< l1t::TauBxCollection > l1stage2TausToken_
MonitorElement * l1etmEt_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
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_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
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_
minPhi
set NPt=0 and the vector of double for variable size binning
MonitorElement * l1tauHighEtEffNum_
edm::EDGetTokenT< l1t::EtSumBxCollection > l1stage2SumsToken_
std::vector< Tau >::const_iterator const_iterator
Definition: BXVector.h:20