CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTauDQMPathPlotter.cc
Go to the documentation of this file.
5 
6 HLTTauDQMPathPlotter::HLTTauDQMPathPlotter(const edm::ParameterSet& pset, bool doRefAnalysis, const std::string& dqmBaseFolder,
7  const std::string& hltProcess, int ptbins, int etabins, int phibins,
8  double ptmax, double highptmax,
9  double l1MatchDr, double hltMatchDr):
10  HLTTauDQMPlotter(pset, dqmBaseFolder),
11  ptbins_(ptbins),
12  etabins_(etabins),
13  phibins_(phibins),
14  ptmax_(ptmax),
15  highptmax_(highptmax),
16  l1MatchDr_(l1MatchDr),
17  hltMatchDr_(hltMatchDr),
18  doRefAnalysis_(doRefAnalysis),
19  hltPath_(hltProcess, dqmFolder_, doRefAnalysis_)
20 {
21  if(!configValid_)
22  return;
23 
24  // Parse configuration
25  try {
26  hltPath_.initialize(pset);
27  } catch(cms::Exception& e) {
28  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQMPathPlotter::HLTTauDQMPathPlotter(): " << e.what();
29  configValid_ = false;
30  return;
31  }
32  configValid_ = true;
33 }
34 
36  if(!configValid_)
37  return;
38 
39  // Identify the correct HLT path
40  if(!HLTCP.inited()) {
41  edm::LogWarning("HLTTauDQMOffline") << "HLTTauDQMPathPlotter::beginRun(): HLTConfigProvider is not initialized!";
42  runValid_ = false;
43  return;
44  }
45 
46  // Search path candidates
47  runValid_ = hltPath_.beginRun(HLTCP);
48  if(!runValid_)
49  return;
50 
51  // Book histograms
53  if(store.isAvailable()) {
54  store->setCurrentFolder(triggerTag());
55  store->removeContents();
56 
57  hAcceptedEvents_ = store->book1D("EventsPerFilter", "Accepted Events per filter;;entries", hltPath_.filtersSize(), 0, hltPath_.filtersSize());
58  for(size_t i=0; i<hltPath_.filtersSize(); ++i) {
60  }
61 
62  hTrigTauEt_ = store->book1D("TrigTauEt", "Triggered #tau p_{T};#tau p_{T};entries", ptbins_, 0, ptmax_);
63  hTrigTauEta_ = store->book1D("TrigTauEta", "Triggered #tau #eta;#tau #eta;entries", etabins_, -2.5, 2.5);
64  hTrigTauPhi_ = store->book1D("TrigTauPhi", "Triggered #tau #phi;#tau #phi;entries", phibins_, -3.2, 3.2);
65 
66  // Efficiency helpers
67  if(doRefAnalysis_) {
68  store->setCurrentFolder(triggerTag()+"/helpers");
69  store->removeContents();
70  if(hltPath_.hasL2Taus()) {
71  hL2TrigTauEtEffNum_ = store->book1D("L2TrigTauEtEffNum", "L2 #tau p_{T} efficiency;Ref #tau p_{T};entries", ptbins_, 0, ptmax_);
72  hL2TrigTauEtEffDenom_ = store->book1D("L2TrigTauEtEffDenom", "L2 #tau p_{T} denominator;Ref #tau p_{T};entries", ptbins_, 0, ptmax_);
73  hL2TrigTauEtaEffNum_ = store->book1D("L2TrigTauEtaEffNum", "L2 #tau #eta efficiency;Ref #tau #eta;entries", etabins_, -2.5, 2.5);
74  hL2TrigTauEtaEffDenom_ = store->book1D("L2TrigTauEtaEffDenom", "L2 #tau #eta denominator;Ref #tau #eta;entries", etabins_, -2.5, 2.5);
75  hL2TrigTauPhiEffNum_ = store->book1D("L2TrigTauPhiEffNum", "L2 #tau #phi efficiency;Ref #tau #phi;entries", phibins_, -3.2, 3.2);
76  hL2TrigTauPhiEffDenom_ = store->book1D("L2TrigTauPhiEffDenom", "L2 #tau #phi denominator;Ref #tau #phi;entries", phibins_, -3.2, 3.2);
77  hL2TrigTauHighEtEffNum_ = store->book1D("L2TrigTauHighEtEffNum", "L2 #tau p_{T} efficiency (high p_{T})Ref #tau p_{T};entries", ptbins_, 0, highptmax_);
78  hL2TrigTauHighEtEffDenom_ = store->book1D("L2TrigTauHighEtEffDenom", "L2 #tau p_{T} denominator (high p_{T})Ref #tau p_{T};entries", ptbins_, 0, highptmax_);
79  }
80 
81  if(hltPath_.hasL3Taus()) {
82  hL3TrigTauEtEffNum_ = store->book1D("L3TrigTauEtEffNum", "L3 #tau p_{T} efficiency;Ref #tau p_{T};entries", ptbins_, 0, ptmax_);
83  hL3TrigTauEtEffDenom_ = store->book1D("L3TrigTauEtEffDenom", "L3 #tau p_{T} denominator;Ref #tau p_{T};entries", ptbins_, 0, ptmax_);
84  hL3TrigTauEtaEffNum_ = store->book1D("L3TrigTauEtaEffNum", "L3 #tau #eta efficiency;Ref #tau #eta;entries", etabins_, -2.5, 2.5);
85  hL3TrigTauEtaEffDenom_ = store->book1D("L3TrigTauEtaEffDenom", "L3 #tau #eta denominator;Ref #tau #eta;entries", etabins_, -2.5, 2.5);
86  hL3TrigTauPhiEffNum_ = store->book1D("L3TrigTauPhiEffNum", "L3 #tau #phi efficiency;Ref #tau #phi;entries", phibins_, -3.2, 3.2);
87  hL3TrigTauPhiEffDenom_ = store->book1D("L3TrigTauPhiEffDenom", "L3 #tau #phi denominator;Ref #tau #phi;entries", phibins_, -3.2, 3.2);
88  hL3TrigTauHighEtEffNum_ = store->book1D("L3TrigTauHighEtEffNum", "L3 #tau p_{T} efficiency (high p_{T});Ref #tau p_{T};entries", ptbins_, 0, highptmax_);
89  hL3TrigTauHighEtEffDenom_ = store->book1D("L3TrigTauHighEtEffDenom", "L3 #tau p_{T} denominator (high p_{T});Ref #tau p_{T};entries", ptbins_, 0, highptmax_);
90  }
91  store->setCurrentFolder(triggerTag());
92  }
93 
94  // Book di-object invariant mass histogram only for mu+tau, ele+tau, and di-tau paths
95  hMass_ = nullptr;
96  if(doRefAnalysis_) {
97  const int lastFilter = hltPath_.filtersSize()-1;
98  const int ntaus = hltPath_.getFilterNTaus(lastFilter);
99  const int neles = hltPath_.getFilterNElectrons(lastFilter);
100  const int nmus = hltPath_.getFilterNMuons(lastFilter);
101  if(ntaus+neles+nmus == 2) {
102  hMass_ = store->book1D("ReferenceMass", "Invariant mass of reference "+dqmFolder_+";Reference invariant mass;entries", 100, 0, 500);
103  }
104  }
105  runValid_ = true;
106  }
107  else
108  runValid_ = false;
109 }
110 
111 
113 
115 
116  std::vector<HLTTauDQMPath::Object> triggerObjs;
117  std::vector<HLTTauDQMPath::Object> matchedTriggerObjs;
118  HLTTauDQMOfflineObjects matchedOfflineObjs;
119 
120  // Events per filter
121  const int lastPassedFilter = hltPath_.lastPassedFilter(triggerResults);
122  int lastMatchedFilter = -1;
123  //std::cout << "Last passed filter " << lastPassedFilter << " " << (lastPassedFilter >= 0 ? hltPath_.getFilterName(lastPassedFilter) : "") << std::endl;
124  if(doRefAnalysis_) {
125  double matchDr = hltPath_.isFirstFilterL1Seed() ? l1MatchDr_ : hltMatchDr_;
126  for(int i=0; i<=lastPassedFilter; ++i) {
127  triggerObjs.clear();
128  matchedTriggerObjs.clear();
129  matchedOfflineObjs.clear();
130  hltPath_.getFilterObjects(triggerEvent, i, triggerObjs);
131  //std::cout << "Filter name " << hltPath_.getFilterName(i) << " nobjs " << triggerObjs.size() << std::endl;
132  bool matched = hltPath_.offlineMatching(i, triggerObjs, refCollection, matchDr, matchedTriggerObjs, matchedOfflineObjs);
133  //std::cout << " offline matching: " << matched << std::endl;
134  matchDr = hltMatchDr_;
135  if(!matched)
136  break;
137 
138  hAcceptedEvents_->Fill(i+0.5);
139  lastMatchedFilter = i;
140  }
141  }
142  else {
143  for(int i=0; i<=lastPassedFilter; ++i) {
144  hAcceptedEvents_->Fill(i+0.5);
145  }
146  }
147 
148  // Efficiency plots
149  if(doRefAnalysis_ && lastMatchedFilter >= 0) {
150  // L2 taus
151  if(hltPath_.hasL2Taus()) {
152  // Denominators
153  if(static_cast<size_t>(lastMatchedFilter) >= hltPath_.getLastFilterBeforeL2TauIndex()) {
154  for(const LV& tau: refCollection.taus) {
155  hL2TrigTauEtEffDenom_->Fill(tau.pt());
156  hL2TrigTauHighEtEffDenom_->Fill(tau.pt());
157  hL2TrigTauEtaEffDenom_->Fill(tau.eta());
158  hL2TrigTauPhiEffDenom_->Fill(tau.phi());
159  }
160  }
161 
162  // Numerators
163  if(static_cast<size_t>(lastMatchedFilter) >= hltPath_.getLastL2TauFilterIndex()) {
164  triggerObjs.clear();
165  matchedTriggerObjs.clear();
166  matchedOfflineObjs.clear();
167  hltPath_.getFilterObjects(triggerEvent, hltPath_.getLastL2TauFilterIndex(), triggerObjs);
168  bool matched = hltPath_.offlineMatching(hltPath_.getLastL2TauFilterIndex(), triggerObjs, refCollection, hltMatchDr_, matchedTriggerObjs, matchedOfflineObjs);
169  if(matched) {
170  for(const LV& tau: matchedOfflineObjs.taus) {
171  hL2TrigTauEtEffNum_->Fill(tau.pt());
172  hL2TrigTauHighEtEffNum_->Fill(tau.pt());
173  hL2TrigTauEtaEffNum_->Fill(tau.eta());
174  hL2TrigTauPhiEffNum_->Fill(tau.phi());
175  }
176  }
177  }
178  }
179 
180  // L3 taus
181  if(hltPath_.hasL3Taus()) {
182  // Denominators
183  if(static_cast<size_t>(lastMatchedFilter) >= hltPath_.getLastFilterBeforeL3TauIndex()) {
184  for(const LV& tau: refCollection.taus) {
185  hL3TrigTauEtEffDenom_->Fill(tau.pt());
186  hL3TrigTauHighEtEffDenom_->Fill(tau.pt());
187  hL3TrigTauEtaEffDenom_->Fill(tau.eta());
188  hL3TrigTauPhiEffDenom_->Fill(tau.phi());
189  }
190  }
191 
192  // Numerators
193  if(static_cast<size_t>(lastMatchedFilter) >= hltPath_.getLastL3TauFilterIndex()) {
194  triggerObjs.clear();
195  matchedTriggerObjs.clear();
196  matchedOfflineObjs.clear();
197  hltPath_.getFilterObjects(triggerEvent, hltPath_.getLastL3TauFilterIndex(), triggerObjs);
198  bool matched = hltPath_.offlineMatching(hltPath_.getLastL3TauFilterIndex(), triggerObjs, refCollection, hltMatchDr_, matchedTriggerObjs, matchedOfflineObjs);
199  if(matched) {
200  for(const LV& tau: matchedOfflineObjs.taus) {
201  hL3TrigTauEtEffNum_->Fill(tau.pt());
202  hL3TrigTauHighEtEffNum_->Fill(tau.pt());
203  hL3TrigTauEtaEffNum_->Fill(tau.eta());
204  hL3TrigTauPhiEffNum_->Fill(tau.phi());
205  }
206  }
207  }
208  }
209  }
210 
211  if(hltPath_.fired(triggerResults)) {
212  triggerObjs.clear();
213  matchedTriggerObjs.clear();
214  matchedOfflineObjs.clear();
215  hltPath_.getFilterObjects(triggerEvent, lastPassedFilter, triggerObjs);
216  if(doRefAnalysis_) {
217  bool matched = hltPath_.offlineMatching(lastPassedFilter, triggerObjs, refCollection, hltMatchDr_, matchedTriggerObjs, matchedOfflineObjs);
218  if(matched) {
219  // Di-object invariant mass
220  if(hMass_) {
221  const int ntaus = hltPath_.getFilterNTaus(lastPassedFilter);
222  if(ntaus == 2) {
223  // Di-tau (matchedOfflineObjs are already sorted)
224  hMass_->Fill( (matchedOfflineObjs.taus[0]+matchedOfflineObjs.taus[1]).M() );
225  }
226  // Electron+tau
227  else if(ntaus == 1 && hltPath_.getFilterNElectrons(lastPassedFilter) == 1) {
228  hMass_->Fill( (matchedOfflineObjs.taus[0]+matchedOfflineObjs.electrons[0]).M() );
229  }
230  // Muon+tau
231  else if(ntaus == 1 && hltPath_.getFilterNMuons(lastPassedFilter) == 1) {
232  hMass_->Fill( (matchedOfflineObjs.taus[0]+matchedOfflineObjs.muons[0]).M() );
233  }
234  }
235  }
236 
237  if(matched)
238  triggerObjs.swap(matchedTriggerObjs);
239  else
240  triggerObjs.clear();
241  }
242 
243  // Triggered tau kinematics
244  for(const HLTTauDQMPath::Object& obj: triggerObjs) {
245  if(obj.id != trigger::TriggerTau)
246  continue;
247  hTrigTauEt_->Fill(obj.object.pt());
248  hTrigTauEta_->Fill(obj.object.eta());
249  hTrigTauPhi_->Fill(obj.object.phi());
250  }
251  }
252 }
virtual char const * what() const
Definition: Exception.cc:141
size_t getLastL2TauFilterIndex() const
Definition: HLTTauDQMPath.h:62
int i
Definition: DBlmapReader.cc:9
MonitorElement * hL3TrigTauEtEffDenom_
MonitorElement * hL3TrigTauPhiEffDenom_
MonitorElement * hL2TrigTauPhiEffDenom_
MonitorElement * hL2TrigTauEtEffDenom_
MonitorElement * hTrigTauEt_
std::vector< LV > electrons
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:873
std::vector< LV > taus
MonitorElement * hL3TrigTauEtEffNum_
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
int lastPassedFilter(const edm::TriggerResults &triggerResults) const
const std::string & triggerTag() const
MonitorElement * hL2TrigTauEtEffNum_
MonitorElement * hAcceptedEvents_
int getFilterNElectrons(size_t i) const
Definition: HLTTauDQMPath.h:53
int getFilterNTaus(size_t i) const
Definition: HLTTauDQMPath.h:52
bool isFirstFilterL1Seed() const
Definition: HLTTauDQMPath.h:56
bool inited() const
Accessors (const methods)
MonitorElement * hL2TrigTauPhiEffNum_
void Fill(long long x)
void initialize(const edm::ParameterSet &pset)
size_t getLastFilterBeforeL3TauIndex() const
Definition: HLTTauDQMPath.h:63
std::string dqmFolder_
math::XYZTLorentzVectorD LV
void getFilterObjects(const trigger::TriggerEvent &triggerEvent, size_t i, std::vector< Object > &retval) const
MonitorElement * hL3TrigTauHighEtEffNum_
MonitorElement * hL3TrigTauEtaEffDenom_
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2765
int getFilterNMuons(size_t i) const
Definition: HLTTauDQMPath.h:54
size_t filtersSize() const
Definition: HLTTauDQMPath.h:50
MonitorElement * hL3TrigTauPhiEffNum_
bool isAvailable() const
Definition: Service.h:46
MonitorElement * hL3TrigTauEtaEffNum_
void analyze(const edm::TriggerResults &triggerResults, const trigger::TriggerEvent &triggerEvent, const HLTTauDQMOfflineObjects &refCollection)
bool hasL3Taus() const
Definition: HLTTauDQMPath.h:60
static std::string const triggerResults
Definition: EdmProvDump.cc:41
HLTTauDQMPathPlotter(const edm::ParameterSet &pset, bool doRefAnalysis, const std::string &dqmBaseFolder, const std::string &hltProcess, int ptbins, int etabins, int phibins, double ptmax, double highptmax, double l1MatchDr, double hltMatchDr)
size_t getLastL3TauFilterIndex() const
Definition: HLTTauDQMPath.h:64
bool beginRun(const HLTConfigProvider &HLTCP)
MonitorElement * hL2TrigTauHighEtEffNum_
bool offlineMatching(size_t i, const std::vector< Object > &triggerObjects, const HLTTauDQMOfflineObjects &offlineObjects, double dR, std::vector< Object > &matchedTriggerObjects, HLTTauDQMOfflineObjects &matchedOfflineObjects) const
MonitorElement * hTrigTauPhi_
const std::string & getFilterName(size_t i) const
Definition: HLTTauDQMPath.h:51
bool fired(const edm::TriggerResults &triggerResults) const
size_t getLastFilterBeforeL2TauIndex() const
Definition: HLTTauDQMPath.h:61
MonitorElement * hL2TrigTauEtaEffNum_
MonitorElement * hL2TrigTauHighEtEffDenom_
bool hasL2Taus() const
Definition: HLTTauDQMPath.h:59
MonitorElement * hTrigTauEta_
MonitorElement * hL2TrigTauEtaEffDenom_
void beginRun(const HLTConfigProvider &HLTCP)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
std::vector< LV > muons
MonitorElement * hL3TrigTauHighEtEffDenom_