CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
32  try {
37  l1JetMinEt_ = ps.getUntrackedParameter<double>("L1JetMinEt");
38  } catch ( cms::Exception &e ) {
39  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::HLTTauDQML1Plotter: " << e.what();
40  configValid_ = false;
41  return;
42  }
43  configValid_ = true;
44 }
45 
47  if(!configValid_)
48  return;
49 
51  if (store.isAvailable()) {
52  // The L1 phi plot is asymmetric around 0 because of the discrete nature of L1 phi
53  constexpr float pi = 3.1416f;
54  constexpr float phiShift = pi/18; // half of 2pi/18 bin
55  constexpr float minPhi = -pi+phiShift;
56  constexpr float maxPhi = pi+phiShift;
57 
58  constexpr int BUFMAX = 256;
59  char buffer[BUFMAX] = "";
60 
61  //Create the histograms
62  store->setCurrentFolder(triggerTag());
63  store->removeContents();
64 
65  l1tauEt_ = store->book1D("L1TauEt","L1 #tau E_{T};L1 #tau E_{T};entries",binsEt_,0,maxPt_);
66  l1tauEta_ = store->book1D("L1TauEta","L1 #tau #eta;L1 #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
67  l1tauPhi_ = store->book1D("L1TauPhi","L1 #tau #phi;L1 #tau #phi;entries",binsPhi_,minPhi,maxPhi);
68 
69  l1jetEt_ = store->book1D("L1JetEt","L1 central jet E_{T};L1 jet E_{T};entries",binsEt_,0,maxPt_);
70  snprintf(buffer, BUFMAX, "L1 central jet #eta (E_{T} > %.1f);L1 jet #eta;entries", l1JetMinEt_);
71  l1jetEta_ = store->book1D("L1JetEta", buffer, binsEta_, -maxEta_, maxEta_);
72  snprintf(buffer, BUFMAX, "L1 central jet #phi (E_{T} > %.1f);L1 jet #phi;entries", l1JetMinEt_);
73  l1jetPhi_ = store->book1D("L1JetPhi", buffer, binsPhi_, minPhi, maxPhi);
74 
75  snprintf(buffer, BUFMAX, "L1 leading (#tau OR central jet E_{T} > %.1f) E_{T};L1 (#tau or central jet) E_{T};entries", l1JetMinEt_);
76  firstTauEt_ = store->book1D("L1LeadTauEt", buffer, binsEt_, 0, maxPt_);
77  snprintf(buffer, BUFMAX, "L1 leading (#tau OR central jet E_{T} > %.1f) #eta;L1 (#tau or central jet) #eta;entries", l1JetMinEt_);
78  firstTauEta_ = store->book1D("L1LeadTauEta", buffer, binsEta_, -maxEta_, maxEta_);
79  snprintf(buffer, BUFMAX, "L1 leading (#tau OR central jet E_{T} > %.1f) #phi;L1 (#tau or central jet) #phi;entries", l1JetMinEt_);
80  firstTauPhi_ = store->book1D("L1LeadTauPhi", buffer, binsPhi_, minPhi, maxPhi);
81 
82  snprintf(buffer, BUFMAX, "L1 second-leading (#tau OR central jet E_{T} > %.1f) E_{T};L1 (#tau or central jet) E_{T};entries", l1JetMinEt_);
83  secondTauEt_ = store->book1D("L1SecondTauEt", buffer, binsEt_, 0, maxPt_);
84  snprintf(buffer, BUFMAX, "L1 second-leading (#tau OR central jet E_{T} > %.1f) #eta;L1 (#tau or central jet) #eta;entries", l1JetMinEt_);
85  secondTauEta_ = store->book1D("L1SecondTauEta", buffer, binsEta_, -maxEta_, maxEta_);
86  snprintf(buffer, BUFMAX, "L1 second-leading (#tau OR central jet E_{T} > %.1f) #phi;L1 (#tau or central jet) #phi;entries", l1JetMinEt_);
87  secondTauPhi_ = store->book1D("L1SecondTauPhi", buffer, binsPhi_, minPhi, maxPhi);
88 
89  if (doRefAnalysis_) {
90  l1tauEtRes_ = store->book1D("L1TauEtResol","L1 #tau E_{T} resolution;[L1 #tau E_{T}-Ref #tau E_{T}]/Ref #tau E_{T};entries",60,-1,4);
91  snprintf(buffer, BUFMAX, "L1 central jet E_{T} resolution (E_{T} > %.1f);[L1 jet E_{T}-Ref #tau E_{T}]/Ref #tau E_{T};entries", l1JetMinEt_);
92  l1jetEtRes_ = store->book1D("L1JetEtResol", buffer, 60, -1, 4);
93 
94  store->setCurrentFolder(triggerTag()+"/EfficiencyHelpers");
95  store->removeContents();
96 
97  l1tauEtEffNum_ = store->book1D("L1TauEtEffNum","L1 #tau E_{T} Efficiency;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
98  l1tauEtEffNum_->getTH1F()->Sumw2();
99  l1tauHighEtEffNum_ = store->book1D("L1TauHighEtEffNum","L1 #tau E_{T} Efficiency (high E_{T});Ref #tau E_{T};entries",binsEt_,0,maxHighPt_);
100  l1tauHighEtEffNum_->getTH1F()->Sumw2();
101 
102  l1tauEtEffDenom_ = store->book1D("L1TauEtEffDenom","L1 #tau E_{T} Denominator;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
103  l1tauEtEffDenom_->getTH1F()->Sumw2();
104  l1tauHighEtEffDenom_ = store->book1D("L1TauHighEtEffDenom","L1 #tau E_{T} Denominator (high E_{T});Ref #tau E_{T};entries",binsEt_,0,maxHighPt_);
105  l1tauHighEtEffDenom_->getTH1F()->Sumw2();
106 
107  l1tauEtaEffNum_ = store->book1D("L1TauEtaEffNum","L1 #tau #eta Efficiency;Ref #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
108  l1tauEtaEffNum_->getTH1F()->Sumw2();
109 
110  l1tauEtaEffDenom_ = store->book1D("L1TauEtaEffDenom","L1 #tau #eta Denominator;Ref #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
111  l1tauEtaEffDenom_->getTH1F()->Sumw2();
112 
113  l1tauPhiEffNum_ = store->book1D("L1TauPhiEffNum","L1 #tau #phi Efficiency;Ref #tau #phi;entries",binsPhi_,minPhi,maxPhi);
114  l1tauPhiEffNum_->getTH1F()->Sumw2();
115 
116  l1tauPhiEffDenom_ = store->book1D("L1TauPhiEffDenom","L1 #tau #phi Denominator;Ref #tau #phi;entries",binsPhi_,minPhi,maxPhi);
117  l1tauPhiEffDenom_->getTH1F()->Sumw2();
118 
119  l1jetEtEffNum_ = store->book1D("L1JetEtEffNum","L1 central jet E_{T} Efficiency;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
120  l1jetEtEffNum_->getTH1F()->Sumw2();
121  l1jetHighEtEffNum_ = store->book1D("L1JetHighEtEffNum","L1 central jet E_{T} Efficiency (high E_{T});Ref #tau E_{T};entries",binsEt_,0,maxHighPt_);
122  l1jetHighEtEffNum_->getTH1F()->Sumw2();
123 
124  l1jetEtEffDenom_ = store->book1D("L1JetEtEffDenom","L1 central jet E_{T} Denominator;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
125  l1jetEtEffDenom_->getTH1F()->Sumw2();
126  l1jetHighEtEffDenom_ = store->book1D("L1JetHighEtEffDenom","L1 central jet E_{T} Denominator (high E_{T});Ref #tau E_{T};entries",binsEt_,0,maxHighPt_);
127  l1jetHighEtEffDenom_->getTH1F()->Sumw2();
128 
129  snprintf(buffer, BUFMAX, "L1 central jet #eta Efficiency (E_{T} > %.1f);Ref #tau #eta;entries", l1JetMinEt_);
130  l1jetEtaEffNum_ = store->book1D("L1JetEtaEffNum", buffer, binsEta_, -maxEta_, maxEta_);
131  l1jetEtaEffNum_->getTH1F()->Sumw2();
132 
133  snprintf(buffer, BUFMAX, "L1 central jet #eta Denominator (E_{T} > %.1f);Ref #tau #eta;entries", l1JetMinEt_);
134  l1jetEtaEffDenom_ = store->book1D("L1JetEtaEffDenom", buffer, binsEta_, -maxEta_, maxEta_);
135  l1jetEtaEffDenom_->getTH1F()->Sumw2();
136 
137  snprintf(buffer, BUFMAX, "L1 central jet #phi Efficiency (E_{T} > %.1f);Ref #tau #eta;entries", l1JetMinEt_);
138  l1jetPhiEffNum_ = store->book1D("L1JetPhiEffNum", buffer, binsPhi_, minPhi, maxPhi);
139  l1jetPhiEffNum_->getTH1F()->Sumw2();
140 
141  snprintf(buffer, BUFMAX, "L1 central jet #phi Efficiency (E_{T} > %.1f);Ref #tau #eta;entries", l1JetMinEt_);
142  l1jetPhiEffDenom_ = store->book1D("L1JetPhiEffDenom", buffer, binsPhi_, minPhi, maxPhi);
143  l1jetPhiEffDenom_->getTH1F()->Sumw2();
144  }
145  runValid_ = true;
146  }
147  else {
148  runValid_ = false;
149  }
150 }
151 
152 
154 }
155 
156 //
157 // member functions
158 //
159 
161  if ( doRefAnalysis_ ) {
162  //Tau reference
163  for ( LVColl::const_iterator iter = refC.taus.begin(); iter != refC.taus.end(); ++iter ) {
164  l1tauEtEffDenom_->Fill(iter->pt());
165  l1jetEtEffDenom_->Fill(iter->pt());
166  l1tauHighEtEffDenom_->Fill(iter->pt());
167  l1jetHighEtEffDenom_->Fill(iter->pt());
168 
169  l1tauEtaEffDenom_->Fill(iter->eta());
170  l1jetEtaEffDenom_->Fill(iter->eta());
171 
172  l1tauPhiEffDenom_->Fill(iter->phi());
173  l1jetPhiEffDenom_->Fill(iter->phi());
174  }
175  }
176 
177  //Analyze L1 Objects (Tau+Jets)
180  iEvent.getByToken(l1ExtraTausToken_, taus);
181  iEvent.getByToken(l1ExtraJetsToken_, jets);
182 
183  LVColl pathTaus;
184 
185  //Set Variables for the threshold plot
186  LVColl l1taus;
187  LVColl l1jets;
188 
189  if(taus.isValid()) {
190  for(l1extra::L1JetParticleCollection::const_iterator i = taus->begin(); i != taus->end(); ++i) {
191  l1taus.push_back(i->p4());
192  if(!doRefAnalysis_) {
193  l1tauEt_->Fill(i->et());
194  l1tauEta_->Fill(i->eta());
195  l1tauPhi_->Fill(i->phi());
196  pathTaus.push_back(i->p4());
197  }
198  }
199  }
200  else {
201  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 tau collection " << l1ExtraTaus_.encode();
202  }
203 
204  if(jets.isValid()) {
205  for(l1extra::L1JetParticleCollection::const_iterator i = jets->begin(); i != jets->end(); ++i) {
206  l1jets.push_back(i->p4());
207  if(!doRefAnalysis_) {
208  l1jetEt_->Fill(i->et());
209  if(i->et() >= l1JetMinEt_) {
210  l1jetEta_->Fill(i->eta());
211  l1jetPhi_->Fill(i->phi());
212  pathTaus.push_back(i->p4());
213  }
214  }
215  }
216  }
217  else {
218  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 jet collection " << l1ExtraJets_.encode();
219  }
220 
221  //Now do the efficiency matching
222  if ( doRefAnalysis_ ) {
223  for ( LVColl::const_iterator i = refC.taus.begin(); i != refC.taus.end(); ++i ) {
224  std::pair<bool,LV> m = match(*i,l1taus,matchDeltaR_);
225  if ( m.first ) {
226  l1tauEt_->Fill(m.second.pt());
227  l1tauEta_->Fill(m.second.eta());
228  l1tauPhi_->Fill(m.second.phi());
229 
230  l1tauEtEffNum_->Fill(i->pt());
231  l1tauHighEtEffNum_->Fill(i->pt());
232  l1tauEtaEffNum_->Fill(i->eta());
233  l1tauPhiEffNum_->Fill(i->phi());
234 
235  l1tauEtRes_->Fill((m.second.pt()-i->pt())/i->pt());
236 
237  pathTaus.push_back(m.second);
238  }
239  }
240 
241  for ( LVColl::const_iterator i = refC.taus.begin(); i != refC.taus.end(); ++i ) {
242  std::pair<bool,LV> m = match(*i,l1jets,matchDeltaR_);
243  if ( m.first ) {
244  l1jetEt_->Fill(m.second.pt());
245  if(m.second.pt() >= l1JetMinEt_) {
246  l1jetEta_->Fill(m.second.eta());
247  l1jetPhi_->Fill(m.second.phi());
248 
249  l1jetEtEffNum_->Fill(i->pt());
250  l1jetHighEtEffNum_->Fill(i->pt());
251  l1jetEtaEffNum_->Fill(i->eta());
252  l1jetPhiEffNum_->Fill(i->phi());
253 
254  l1jetEtRes_->Fill((m.second.pt()-i->pt())/i->pt());
255 
256  pathTaus.push_back(m.second);
257  }
258  }
259  }
260  }
261 
262 
263  //Fill the Threshold Monitoring
264  if(pathTaus.size() > 1) std::sort(pathTaus.begin(), pathTaus.end(), [](const LV& a, const LV& b) { return a.pt() > b.pt(); });
265 
266  if ( pathTaus.size() > 0 ) {
267  firstTauEt_->Fill(pathTaus[0].pt());
268  firstTauEta_->Fill(pathTaus[0].eta());
269  firstTauPhi_->Fill(pathTaus[0].phi());
270  }
271  if ( pathTaus.size() > 1 ) {
272  secondTauEt_->Fill(pathTaus[1].pt());
273  secondTauEta_->Fill(pathTaus[1].eta());
274  secondTauPhi_->Fill(pathTaus[1].phi());
275  }
276 }
virtual char const * what() const
Definition: Exception.cc:141
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
const double matchDeltaR_
MonitorElement * l1jetEta_
edm::EDGetTokenT< l1extra::L1JetParticleCollection > l1ExtraJetsToken_
MonitorElement * secondTauEta_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
std::vector< LV > taus
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MonitorElement * firstTauPhi_
MonitorElement * l1jetEtEffNum_
MonitorElement * l1jetPhiEffDenom_
MonitorElement * l1jetHighEtEffDenom_
std::vector< L1JetParticle > L1JetParticleCollection
MonitorElement * l1jetEtaEffNum_
MonitorElement * l1jetHighEtEffNum_
const std::string & triggerTag() const
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const HLTTauDQMOfflineObjects &refC)
T eta() const
edm::EDGetTokenT< l1extra::L1JetParticleCollection > l1ExtraTausToken_
MonitorElement * firstTauEta_
std::string encode() const
Definition: InputTag.cc:164
MonitorElement * l1tauEt_
MonitorElement * secondTauEt_
MonitorElement * l1tauEtEffDenom_
void Fill(long long x)
MonitorElement * l1jetEtRes_
MonitorElement * l1jetPhiEffNum_
math::XYZTLorentzVectorD LV
int iEvent
Definition: GenABIO.cc:243
MonitorElement * l1tauEtaEffNum_
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2764
MonitorElement * firstTauEt_
MonitorElement * l1tauHighEtEffDenom_
std::vector< LV > LVColl
vector< PseudoJet > jets
MonitorElement * l1jetEtEffDenom_
bool isAvailable() const
Definition: Service.h:46
MonitorElement * l1tauEtEffNum_
MonitorElement * l1tauPhi_
edm::InputTag l1ExtraTaus_
bool isValid() const
Definition: HandleBase.h:76
MonitorElement * l1tauEta_
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)
TH1F * getTH1F(void) const
double b
Definition: hdecay.h:120
edm::InputTag l1ExtraJets_
MonitorElement * l1tauEtaEffDenom_
MonitorElement * l1tauEtRes_
MonitorElement * l1jetPhi_
double a
Definition: hdecay.h:121
MonitorElement * l1jetEt_
MonitorElement * l1jetEtaEffDenom_
double pi
std::pair< bool, LV > match(const LV &, const LVColl &, double)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
MonitorElement * l1tauPhiEffNum_
#define constexpr
MonitorElement * l1tauHighEtEffNum_
Definition: DDAxes.h:10