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
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  l1etmEt_ = iBooker.book1D("L1ETM","L1 ETM E_{T};L1 ETM E_{T};entries",binsEt_,0,maxPt_);
63  l1etmPhi_ = iBooker.book1D("L1ETMPhi","L1 ETM #phi;L1 ETM #phi;entries",binsPhi_,minPhi,maxPhi);
64 
65  snprintf(buffer, BUFMAX, "L1 leading (#tau OR central jet E_{T} > %.1f) E_{T};L1 (#tau or central jet) E_{T};entries", l1JetMinEt_);
66  firstTauEt_ = iBooker.book1D("L1LeadTauEt", buffer, binsEt_, 0, maxPt_);
67  snprintf(buffer, BUFMAX, "L1 leading (#tau OR central jet E_{T} > %.1f) #eta;L1 (#tau or central jet) #eta;entries", l1JetMinEt_);
68  firstTauEta_ = iBooker.book1D("L1LeadTauEta", buffer, binsEta_, -maxEta_, maxEta_);
69  snprintf(buffer, BUFMAX, "L1 leading (#tau OR central jet E_{T} > %.1f) #phi;L1 (#tau or central jet) #phi;entries", l1JetMinEt_);
70  firstTauPhi_ = iBooker.book1D("L1LeadTauPhi", buffer, binsPhi_, minPhi, maxPhi);
71 
72  snprintf(buffer, BUFMAX, "L1 second-leading (#tau OR central jet E_{T} > %.1f) E_{T};L1 (#tau or central jet) E_{T};entries", l1JetMinEt_);
73  secondTauEt_ = iBooker.book1D("L1SecondTauEt", buffer, binsEt_, 0, maxPt_);
74  snprintf(buffer, BUFMAX, "L1 second-leading (#tau OR central jet E_{T} > %.1f) #eta;L1 (#tau or central jet) #eta;entries", l1JetMinEt_);
75  secondTauEta_ = iBooker.book1D("L1SecondTauEta", buffer, binsEta_, -maxEta_, maxEta_);
76  snprintf(buffer, BUFMAX, "L1 second-leading (#tau OR central jet E_{T} > %.1f) #phi;L1 (#tau or central jet) #phi;entries", l1JetMinEt_);
77  secondTauPhi_ = iBooker.book1D("L1SecondTauPhi", buffer, binsPhi_, minPhi, maxPhi);
78 
79  if (doRefAnalysis_) {
80  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);
81 
82  iBooker.setCurrentFolder(triggerTag()+"/helpers");
83 
84  l1tauEtEffNum_ = iBooker.book1D("L1TauEtEffNum","L1 #tau E_{T} Efficiency;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
85  l1tauHighEtEffNum_ = iBooker.book1D("L1TauHighEtEffNum","L1 #tau E_{T} Efficiency (high E_{T});Ref #tau E_{T};entries",binsEt_,0,maxHighPt_);
86 
87  l1tauEtEffDenom_ = iBooker.book1D("L1TauEtEffDenom","L1 #tau E_{T} Denominator;Ref #tau E_{T};entries",binsEt_,0,maxPt_);
88  l1tauHighEtEffDenom_ = iBooker.book1D("L1TauHighEtEffDenom","L1 #tau E_{T} Denominator (high E_{T});Ref #tau E_{T};Efficiency",binsEt_,0,maxHighPt_);
89 
90  l1tauEtaEffNum_ = iBooker.book1D("L1TauEtaEffNum","L1 #tau #eta Efficiency;Ref #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
91  l1tauEtaEffDenom_ = iBooker.book1D("L1TauEtaEffDenom","L1 #tau #eta Denominator;Ref #tau #eta;entries",binsEta_,-maxEta_,maxEta_);
92 
93  l1tauPhiEffNum_ = iBooker.book1D("L1TauPhiEffNum","L1 #tau #phi Efficiency;Ref #tau #phi;entries",binsPhi_,minPhi,maxPhi);
94  l1tauPhiEffDenom_ = iBooker.book1D("L1TauPhiEffDenom","L1 #tau #phi Denominator;Ref #tau #phi;Efficiency",binsPhi_,minPhi,maxPhi);
95 
96  l1etmEtEffNum_ = iBooker.book1D("L1ETMEtEffNum", "L1 ETM Efficiency;Ref MET;entries",binsEt_, 0, maxPt_);
97  l1etmEtEffDenom_ = iBooker.book1D("L1ETMEtEffDenom","L1 ETM Denominator;Ref MET;entries",binsEt_,0,maxPt_);
98  }
99 }
100 
101 
103 }
104 
105 //
106 // member functions
107 //
108 
110  if ( doRefAnalysis_ ) {
111  //Tau reference
112  for ( LVColl::const_iterator iter = refC.taus.begin(); iter != refC.taus.end(); ++iter ) {
113  l1tauEtEffDenom_->Fill(iter->pt());
114  l1tauHighEtEffDenom_->Fill(iter->pt());
115 
116  l1tauEtaEffDenom_->Fill(iter->eta());
117 
118  l1tauPhiEffDenom_->Fill(iter->phi());
119  }
120  if(refC.met.size() > 0) l1etmEtEffDenom_->Fill(refC.met[0].pt());
121  }
122 
123  //Analyze L1 Objects (Tau+Jets)
125  iEvent.getByToken(l1stage2TausToken_, taus);
126 
128  iEvent.getByToken(l1stage2SumsToken_, sums);
129 
130  LVColl pathTaus;
131 
132  //Set Variables for the threshold plot
133  LVColl l1taus;
134  LVColl l1met;
135 
136  if(taus.isValid()) {
137  for(l1t::TauBxCollection::const_iterator i = taus->begin(); i != taus->end(); ++i) {
138  l1taus.push_back(i->p4());
139  if(!doRefAnalysis_) {
140  l1tauEt_->Fill(i->et());
141  l1tauEta_->Fill(i->eta());
142  l1tauPhi_->Fill(i->phi());
143  pathTaus.push_back(i->p4());
144  }
145  }
146  }
147  else {
148  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 tau collection " << l1stage2Taus_.encode();
149  }
150 
151  if(sums.isValid() && sums.product()->size() > 0) {
152  if(!doRefAnalysis_) {
153  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
154  for (l1t::EtSumBxCollection::const_iterator it=sums->begin(ibx); it!=sums->end(ibx); it++) {
155  int type = static_cast<int>( it->getType() );
156  if(type == l1t::EtSum::EtSumType::kMissingEt) l1etmEt_->Fill(it->et());
157  }
158  }
159  }
160  }
161  else {
162  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQML1Plotter::analyze: unable to read L1 met collection " << l1stage2Sums_.encode();
163  }
164 
165  //Now do the efficiency matching
166  if ( doRefAnalysis_ ) {
167  for ( LVColl::const_iterator i = refC.taus.begin(); i != refC.taus.end(); ++i ) {
168  std::pair<bool,LV> m = match(*i,l1taus,matchDeltaR_);
169  if ( m.first ) {
170  l1tauEt_->Fill(m.second.pt());
171  l1tauEta_->Fill(m.second.eta());
172  l1tauPhi_->Fill(m.second.phi());
173 
174  l1tauEtEffNum_->Fill(i->pt());
175  l1tauHighEtEffNum_->Fill(i->pt());
176  l1tauEtaEffNum_->Fill(i->eta());
177  l1tauPhiEffNum_->Fill(i->phi());
178 
179  l1tauEtRes_->Fill((m.second.pt()-i->pt())/i->pt());
180 
181  pathTaus.push_back(m.second);
182  }
183  }
184 
185  if(sums.isValid() && sums.product()->size() > 0) {
186  for (int ibx = sums->getFirstBX(); ibx <= sums->getLastBX(); ++ibx) {
187  for (l1t::EtSumBxCollection::const_iterator it=sums->begin(ibx); it!=sums->end(ibx); it++) {
188  int type = static_cast<int>( it->getType() );
190  l1etmEt_->Fill(it->et());
191  l1etmPhi_->Fill(it->phi());
192 
193  if( it->et() > l1ETMMin_){
194  l1etmEtEffNum_->Fill(it->et());
195  }
196  }
197  }
198  }
199  }
200  }
201 
202  //Fill the Threshold Monitoring
203  if(pathTaus.size() > 1) std::sort(pathTaus.begin(), pathTaus.end(), [](const LV& a, const LV& b) { return a.pt() > b.pt(); });
204  if ( pathTaus.size() > 0 ) {
205  firstTauEt_->Fill(pathTaus[0].pt());
206  firstTauEta_->Fill(pathTaus[0].eta());
207  firstTauPhi_->Fill(pathTaus[0].phi());
208  }
209  if ( pathTaus.size() > 1 ) {
210  secondTauEt_->Fill(pathTaus[1].pt());
211  secondTauEta_->Fill(pathTaus[1].eta());
212  secondTauPhi_->Fill(pathTaus[1].phi());
213  }
214 }
type
Definition: HCALResponse.h:21
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
const double matchDeltaR_
MonitorElement * secondTauEta_
std::vector< LV > taus
void bookHistograms(DQMStore::IBooker &iBooker)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
MonitorElement * firstTauPhi_
MonitorElement * l1etmEtEffNum_
const std::string & triggerTag() const
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const HLTTauDQMOfflineObjects &refC)
MonitorElement * firstTauEta_
std::string encode() const
Definition: InputTag.cc:164
#define constexpr
MonitorElement * l1tauEt_
MonitorElement * secondTauEt_
MonitorElement * l1tauEtEffDenom_
void Fill(long long x)
const Double_t pi
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:75
std::vector< LV > met
MonitorElement * l1tauEta_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
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 * l1tauEtaEffDenom_
MonitorElement * l1tauEtRes_
double a
Definition: hdecay.h:121
std::pair< bool, LV > match(const LV &, const LVColl &, double)
MonitorElement * l1etmEtEffDenom_
MonitorElement * l1etmPhi_
edm::InputTag l1stage2Sums_
MonitorElement * l1tauPhiEffNum_
MonitorElement * l1tauHighEtEffNum_
edm::EDGetTokenT< l1t::EtSumBxCollection > l1stage2SumsToken_
std::vector< Tau >::const_iterator const_iterator
Definition: BXVector.h:20