ATLAS Offline Software
TrigTauMonitorSingleAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 TrigTauMonitorSingleAlgorithm::TrigTauMonitorSingleAlgorithm(const std::string& name, ISvcLocator* pSvcLocator)
9  : TrigTauMonitorBaseAlgorithm(name, pSvcLocator)
10 {}
11 
12 
14 {
16 
17  // Create the "cache" of TauID score accessors for the Monitoring...
18  for(const auto& [seq_name, m] : m_monitoredHLTIdScores) {
19  for(const auto& [key, p] : m) {
20  if(p.first.empty() || p.second.empty()) {
21  ATH_MSG_WARNING("Invalid HLT TauID score variable names; skipping this entry for the monitoring!");
22  continue;
23  }
24 
25  m_monitoredHLTIdAccessors[seq_name].emplace(
26  key,
27  std::make_pair(
30  )
31  );
32  }
33  }
34 
35  for(const auto& [key, p] : m_monitoredOfflineIdScores) {
36  if(p.first.empty() || p.second.empty()) {
37  ATH_MSG_WARNING("Invalid Offline TauID score variable names; skipping this entry for the monitoring!");
38  continue;
39  }
40 
42  key,
43  std::make_pair(
46  )
47  );
48  }
49 
50  return StatusCode::SUCCESS;
51 }
52 
53 
55 {
56  constexpr float threshold_offset = 10.0;
57 
58  // Offline taus
59  auto offline_taus_all = getOfflineTausAll(ctx, 0.0);
60 
61  if(m_requireOfflineTaus && offline_taus_all.empty()) return StatusCode::SUCCESS;
62 
63  for(const std::string& trigger : m_triggers) {
64  const TrigTauInfo& info = getTrigInfo(trigger);
65 
66  if(!info.isHLTSingleTau()) {
67  ATH_MSG_WARNING("Chain \"" << trigger << "\" is not a single tau trigger. Skipping...");
68  continue;
69  }
70 
71  const auto passBits = m_trigDecTool->isPassedBits(trigger);
72  const bool l1_accept_flag = passBits & TrigDefs::L1_isPassedAfterVeto;
73  const bool hlt_not_prescaled_flag = (passBits & TrigDefs::EF_prescaled) == 0;
74 
75  // Filter offline taus
76  auto offline_taus = classifyOfflineTaus(offline_taus_all, info.getHLTTauThreshold() - threshold_offset);
77  std::vector<const xAOD::TauJet*> offline_taus_1p = offline_taus.first;
78  std::vector<const xAOD::TauJet*> offline_taus_3p = offline_taus.second;
79 
80  // Online taus
81  std::vector<const xAOD::TauJet*> hlt_taus_all = getOnlineTausAll(trigger, true);
82  auto hlt_taus = classifyOnlineTaus(hlt_taus_all);
83  std::vector<const xAOD::TauJet*> hlt_taus_0p = std::get<0>(hlt_taus);
84  std::vector<const xAOD::TauJet*> hlt_taus_1p = std::get<1>(hlt_taus);
85  std::vector<const xAOD::TauJet*> hlt_taus_mp = std::get<2>(hlt_taus);
86 
88  // Offline variables:
89  if(m_doOfflineTausDistributions && !offline_taus_1p.empty()) {
90  fillBasicVars(ctx, trigger, offline_taus_1p, "1P", false);
91  fillIDScores(trigger, offline_taus_1p, "1P", false);
92  fillIDInputVars(trigger, offline_taus_1p, "1P", false);
93  fillIDTrack(trigger, offline_taus_1p, false);
94  fillIDCluster(trigger, offline_taus_1p, false);
95  }
96  if(m_doOfflineTausDistributions && !offline_taus_3p.empty()) {
97  fillBasicVars(ctx, trigger, offline_taus_3p, "3P", false);
98  fillIDScores(trigger, offline_taus_3p, "3P", false);
99  fillIDInputVars(trigger, offline_taus_3p, "3P", false);
100  fillIDTrack(trigger, offline_taus_3p, false);
101  fillIDCluster(trigger, offline_taus_3p, false);
102  }
103 
104  // Fill information for online 0 prong taus
105  if(!hlt_taus_0p.empty()) {
106  fillBasicVars(ctx, trigger, hlt_taus_0p, "0P", true);
107  fillIDScores(trigger, hlt_taus_0p, "0P", true);
108  fillIDInputVars(trigger, hlt_taus_0p, "0P", true);
109  fillIDTrack(trigger, hlt_taus_0p, true);
110  fillIDCluster(trigger, hlt_taus_0p, true);
111  }
112 
113  // Fill information for online 1 prong taus
114  if(!hlt_taus_1p.empty()) {
115  fillBasicVars(ctx, trigger, hlt_taus_1p, "1P", true);
116  fillIDScores(trigger, hlt_taus_1p, "1P", true);
117  fillIDInputVars(trigger, hlt_taus_1p, "1P", true);
118  fillIDTrack(trigger, hlt_taus_1p, true);
119  fillIDCluster(trigger, hlt_taus_1p, true);
120  }
121 
122  // Fill information for online multiprong prong taus
123  if(!hlt_taus_mp.empty()) {
124  fillBasicVars(ctx, trigger, hlt_taus_mp, "MP", true);
125  fillIDScores(trigger, hlt_taus_mp, "MP", true);
126  fillIDInputVars(trigger, hlt_taus_mp, "MP", true);
127  fillIDTrack(trigger, hlt_taus_mp, true);
128  fillIDCluster(trigger, hlt_taus_mp, true);
129  }
130  }
131 
132  if(m_do_efficiency_plots && hlt_not_prescaled_flag) {
133  fillHLTEfficiencies(ctx, trigger, l1_accept_flag, offline_taus_1p, hlt_taus_all, "1P");
134  fillHLTEfficiencies(ctx, trigger, l1_accept_flag, offline_taus_3p, hlt_taus_all, "3P");
135  }
136  }
137 
138  return StatusCode::SUCCESS;
139 }
140 
141 
142 void TrigTauMonitorSingleAlgorithm::fillHLTEfficiencies(const EventContext& ctx, const std::string& trigger, const bool l1_accept_flag, const std::vector<const xAOD::TauJet*>& offline_tau_vec, const std::vector<const xAOD::TauJet*>& online_tau_vec, const std::string& nProng) const
143 {
144  ATH_MSG_DEBUG("Fill HLT " << nProng << " efficiencies: " << trigger);
145 
146  const TrigTauInfo& info = getTrigInfo(trigger);
147 
148  // Efficiency for single leg tau triggers:
149  // denominator = offline tau + matching with L1 object with dR(offline tau,L1 item) < 0.3
150  // numerator = denominator + hlt fires + matching with HLT tau with dR(offline tau, HLT tau) < 0.2
151 
152  auto monGroup = getGroup(trigger+"_HLT_Efficiency_"+nProng);
153 
154  auto tauPt = Monitored::Scalar<float>("tauPt", 0.0);
155  auto tauEta = Monitored::Scalar<float>("tauEta", 0.0);
156  auto tauPhi = Monitored::Scalar<float>("tauPhi", 0.0);
157  auto averageMu = Monitored::Scalar<float>("averageMu", 0.0);
158  auto HLT_match = Monitored::Scalar<bool>("HLT_pass", false);
159  auto HLT_match_highPt = Monitored::Scalar<bool>("HLT_pass_highPt", false);
160  auto Total_match = Monitored::Scalar<bool>("Total_pass", false);
161  auto Total_match_highPt = Monitored::Scalar<bool>("Total_pass_highPt", false);
162 
163  bool hlt_fires = m_trigDecTool->isPassed(trigger, TrigDefs::Physics | TrigDefs::allowResurrectedDecision);
164 
165  std::vector<TLorentzVector> rois = getRoIsVector(ctx, trigger);
166  for(const auto *offline_tau : offline_tau_vec) {
167  bool L1_match = false;
168 
169  // Check the matching offline tau with L1 item -> depending on the L1 type (legacy, phase-1 eTAU, jTAU, cTAU)
170  // All L1 RoIs have a core size of 3x3 TTs -> 0.3 x 0.3
171  for(const TLorentzVector& roi : rois) {
172  L1_match = offline_tau->p4().DeltaR(roi) <= 0.3;
173  if(L1_match) break;
174  }
175 
176  tauPt = offline_tau->pt()/Gaudi::Units::GeV;
177  tauEta = offline_tau->eta();
178  tauPhi = offline_tau->phi();
179  averageMu = lbAverageInteractionsPerCrossing(ctx);
180 
181  bool is_highPt = tauPt > info.getHLTTauThreshold() + 20.0;
182 
183  // HLT matching: dR matching + HLT fires
184  HLT_match = matchObjects(offline_tau, online_tau_vec, 0.2) && hlt_fires;
185 
186  // Total efficiency (without L1 matching)
187  if(m_doTotalEfficiency) {
188  Total_match = static_cast<bool>(HLT_match);
189  fill(monGroup, tauPt, tauEta, tauPhi, Total_match);
190 
191  if(is_highPt) {
192  Total_match_highPt = static_cast<bool>(HLT_match);
193  fill(monGroup, tauEta, tauPhi, Total_match_highPt);
194  }
195  }
196 
197  if(!L1_match || !l1_accept_flag) continue; // Skip this offline tau since not matched with L1 item
198 
199  fill(monGroup, tauPt, tauEta, tauPhi, averageMu, HLT_match);
200 
201  if(is_highPt) {
202  HLT_match_highPt = static_cast<bool>(HLT_match);
203  fill(monGroup, tauEta, tauPhi, HLT_match_highPt);
204  }
205  }
206 
207  ATH_MSG_DEBUG("After fill HLT efficiencies: " << trigger);
208 }
209 
210 
211 void TrigTauMonitorSingleAlgorithm::fillIDInputVars(const std::string& trigger, const std::vector<const xAOD::TauJet*>& tau_vec,const std::string& nProng, bool online) const
212 {
213  ATH_MSG_DEBUG("Fill ID input variables: " << trigger);
214 
215  auto monGroup = getGroup(trigger+"_ID_"+(online ? "HLT" : "Offline")+"_InputScalar_"+nProng);
216 
217  auto centFrac = Monitored::Collection("centFrac", tau_vec, [](const xAOD::TauJet* tau){
218  float detail = -999;
220  return detail;
221  });
222  auto etOverPtLeadTrk = Monitored::Collection("etOverPtLeadTrk", tau_vec, [](const xAOD::TauJet* tau){
223  float detail = -999;
225  return detail;
226  });
227  auto dRmax = Monitored::Collection("dRmax", tau_vec, [](const xAOD::TauJet* tau){
228  float detail = -999;
230  return detail;
231  });
232  auto absipSigLeadTrk = Monitored::Collection("absipSigLeadTrk", tau_vec, [](const xAOD::TauJet* tau){
233  float detail = (tau->nTracks()>0) ? std::abs(tau->track(0)->d0SigTJVA()) : 0;
234  detail = std::min(std::abs(detail), 30.0f);
235  return detail;
236  });
237  auto sumPtTrkFrac = Monitored::Collection("sumPtTrkFrac", tau_vec, [](const xAOD::TauJet* tau){
238  float detail = -999;
240  return detail;
241  });
242  auto emPOverTrkSysP = Monitored::Collection("emPOverTrkSysP", tau_vec, [](const xAOD::TauJet* tau){
243  float detail = -999;
245  return detail;
246  });
247  auto ptRatioEflowApprox = Monitored::Collection("ptRatioEflowApprox", tau_vec, [](const xAOD::TauJet* tau){
248  float detail = -999;
250  return detail;
251  });
252  auto mEflowApprox = Monitored::Collection("mEflowApprox", tau_vec, [](const xAOD::TauJet* tau){
253  float detail = -999;
254  if(tau->detail(xAOD::TauJetParameters::mEflowApprox, detail)) detail = std::log10(std::max(detail, 140.0f));
255  return detail;
256  });
257  auto ptDetectorAxis = Monitored::Collection("ptDetectorAxis", tau_vec, [](const xAOD::TauJet* tau){
258  float detail = -999;
259  if( tau->ptDetectorAxis() > 0) detail = std::log10(std::min(tau->ptDetectorAxis()/Gaudi::Units::GeV, 100.0));
260  return detail;
261  });
262  auto massTrkSys = Monitored::Collection("massTrkSys", tau_vec, [&nProng](const xAOD::TauJet* tau){
263  float detail = -999;
264  if( tau->detail(xAOD::TauJetParameters::massTrkSys, detail) && (nProng.find("MP") != std::string::npos || nProng.find("3P") != std::string::npos)) {
265  detail = std::log10(std::max(detail, 140.0f));
266  }
267  return detail;});
268  auto trFlightPathSig = Monitored::Collection("trFlightPathSig", tau_vec, [&nProng](const xAOD::TauJet* tau){
269  float detail = -999;
270  if(nProng.find("MP") != std::string::npos || nProng.find("3P") != std::string::npos) tau->detail(xAOD::TauJetParameters::trFlightPathSig, detail);
271  return detail;
272  });
273 
275 
276  ATH_MSG_DEBUG("After fill ID input variables: " << trigger);
277 }
278 
279 
280 void TrigTauMonitorSingleAlgorithm::fillIDTrack(const std::string& trigger, const std::vector<const xAOD::TauJet*>& tau_vec, bool online) const
281 {
282  ATH_MSG_DEBUG("Fill ID input Track: " << trigger);
283 
284  auto monGroup = getGroup(trigger+"_ID_"+(online ? "HLT" : "Offline")+"_InputTrack");
285 
286  auto track_pt_jetseed_log = Monitored::Collection("track_pt_jetseed_log", tau_vec, [](const xAOD::TauJet* tau){ return std::log10(tau->ptJetSeed()); });
287  fill(monGroup, track_pt_jetseed_log);
288 
289  for(const auto *tau : tau_vec) {
290  // Don't call ->allTracks() unless the element links are valid
291  static const SG::AuxElement::ConstAccessor< std::vector<ElementLink<xAOD::TauTrackContainer>> > tauTrackAcc("tauTrackLinks");
292  bool linksValid = true;
293  for(const ElementLink<xAOD::TauTrackContainer>& trackEL : tauTrackAcc(*tau)) {
294  if(!trackEL.isValid()) {
295  linksValid = false;
296  break;
297  }
298  }
299  if(!linksValid) {
300  ATH_MSG_WARNING("Invalid track element links from TauJet in " << trigger);
301  continue;
302  }
303 
304  auto tracks = tau->allTracks();
305  std::sort(tracks.begin(), tracks.end(), [](const xAOD::TauTrack* lhs, const xAOD::TauTrack* rhs){ return lhs->pt() > rhs->pt(); });
306 
307  auto n_track = Monitored::Scalar<int>("n_track", tracks.size());
308 
309  auto track_pt_log = Monitored::Collection("track_pt_log", tracks, [](const xAOD::TauTrack *track){ return std::log10(track->pt()); });
310  auto track_eta = Monitored::Collection("track_eta", tracks, [](const xAOD::TauTrack *track){ return track->eta(); });
311  auto track_phi = Monitored::Collection("track_phi", tracks, [](const xAOD::TauTrack *track){ return track->phi(); });
312 
313  auto track_dEta = Monitored::Collection("track_dEta", tracks, [&tau](const xAOD::TauTrack *track){ return track->eta() - tau->eta(); });
314  auto track_dPhi = Monitored::Collection("track_dPhi", tracks, [&tau](const xAOD::TauTrack *track){ return track->p4().DeltaPhi(tau->p4()); });
315 
316  auto track_z0sinthetaTJVA_abs_log = Monitored::Collection("track_z0sinthetaTJVA_abs_log", tracks, [](const xAOD::TauTrack *track){return track->z0sinthetaTJVA(); });
317  auto track_d0_abs_log = Monitored::Collection("track_d0_abs_log", tracks, [](const xAOD::TauTrack *track){ return std::log10(std::abs(track->track()->d0()) + 1e-6); });
318 
319  auto track_nIBLHitsAndExp = Monitored::Collection("track_nIBLHitsAndExp", tracks, [](const xAOD::TauTrack *track){
320  uint8_t inner_pixel_hits, inner_pixel_exp;
321  const auto success1_innerPixel_hits = track->track()->summaryValue(inner_pixel_hits, xAOD::numberOfInnermostPixelLayerHits);
322  const auto success2_innerPixel_exp = track->track()->summaryValue(inner_pixel_exp, xAOD::expectInnermostPixelLayerHit);
323  float detail = -999;
324  if(success1_innerPixel_hits && success2_innerPixel_exp) { detail = inner_pixel_exp ? inner_pixel_hits : 1.; };
325  return detail;
326  });
327  auto track_nPixelHitsPlusDeadSensors = Monitored::Collection("track_nPixelHitsPlusDeadSensors", tracks, [](const xAOD::TauTrack *track){
328  uint8_t pixel_hits, pixel_dead;
329  const auto success1_pixel_hits = track->track()->summaryValue(pixel_hits, xAOD::numberOfPixelHits);
330  const auto success2_pixel_dead = track->track()->summaryValue(pixel_dead, xAOD::numberOfPixelDeadSensors);
331  float detail = -999;
332  if(success1_pixel_hits && success2_pixel_dead) { detail = pixel_hits + pixel_dead; };
333  return detail;
334  });
335  auto track_nSCTHitsPlusDeadSensors = Monitored::Collection("track_nSCTHitsPlusDeadSensors", tracks, [](const xAOD::TauTrack *track){
336  uint8_t sct_hits, sct_dead;
337  const auto success1_sct_hits = track->track()->summaryValue(sct_hits, xAOD::numberOfSCTHits);
338  const auto success2_sct_dead = track->track()->summaryValue(sct_dead, xAOD::numberOfSCTDeadSensors);
339  float detail = -999;
340  if(success1_sct_hits && success2_sct_dead) { detail = sct_hits + sct_dead; };
341  return detail;
342  });
343 
344  fill(monGroup, n_track, track_pt_log, track_eta, track_phi, track_dEta, track_dPhi, track_z0sinthetaTJVA_abs_log, track_d0_abs_log, track_nIBLHitsAndExp, track_nPixelHitsPlusDeadSensors, track_nSCTHitsPlusDeadSensors);
345  }
346 
347  ATH_MSG_DEBUG("After fill ID input Track: " << trigger);
348 }
349 
350 
351 void TrigTauMonitorSingleAlgorithm::fillIDCluster(const std::string& trigger, const std::vector<const xAOD::TauJet*>& tau_vec, bool online) const
352 {
353  ATH_MSG_DEBUG("Fill ID input Cluster: " << trigger << " for online/offline " << online);
354 
355  auto monGroup = getGroup(trigger+"_ID_"+(online ? "HLT" : "Offline")+"_InputCluster");
356 
357  for(const auto *tau : tau_vec){
358  auto cluster_pt_jetseed_log = Monitored::Collection("cluster_pt_jetseed_log", tau_vec, [](const xAOD::TauJet* tau){ return std::log10(tau->ptJetSeed()); });
359 
360  std::vector<const xAOD::CaloCluster*> clusters;
361  for(const xAOD::IParticle* particle : tau->clusters()) {
362  const xAOD::CaloCluster* cluster = static_cast<const xAOD::CaloCluster*>(particle);
363  clusters.push_back(cluster);
364  }
365  std::sort(clusters.begin(), clusters.end(), [](const xAOD::CaloCluster *lhs, const xAOD::CaloCluster *rhs){ return lhs->et() > rhs->et(); });
366 
367  auto n_cluster = Monitored::Scalar<int>("n_cluster", 0);
368  n_cluster = clusters.size();
369 
370  auto cluster_et_log = Monitored::Collection("cluster_et_log",clusters, [](const xAOD::CaloCluster *cluster){ return std::log10( cluster->et()); });
371  auto cluster_eta = Monitored::Collection("cluster_eta", clusters, [](const xAOD::CaloCluster *cluster){ return cluster->eta(); });
372  auto cluster_phi = Monitored::Collection("cluster_phi", clusters, [](const xAOD::CaloCluster *cluster){ return cluster->phi(); });
373  auto cluster_dEta = Monitored::Collection("cluster_dEta", clusters, [&tau](const xAOD::CaloCluster *cluster){ return cluster->eta() - tau->eta(); });
374  auto cluster_dPhi = Monitored::Collection("cluster_dPhi", clusters, [&tau](const xAOD::CaloCluster *cluster){ return cluster->p4().DeltaPhi(tau->p4()); });
375  auto cluster_SECOND_R_log10 = Monitored::Collection("cluster_SECOND_R_log10", clusters, [](const xAOD::CaloCluster *cluster){
376  double detail = -999;
377  const auto success_SECOND_R = cluster->retrieveMoment(xAOD::CaloCluster::MomentType::SECOND_R,detail);
378  if(success_SECOND_R) detail = std::log10(detail + 0.1);
379  return detail;
380  });
381 
382  auto cluster_SECOND_LAMBDA_log10 = Monitored::Collection("cluster_SECOND_LAMBDA_log10", clusters, [](const xAOD::CaloCluster *cluster){
383  double detail = -999;
384  const auto success_SECOND_LAMBDA = cluster->retrieveMoment(xAOD::CaloCluster::MomentType::SECOND_LAMBDA, detail);
385  if(success_SECOND_LAMBDA) detail = std::log10(detail + 0.1);
386  return detail;
387  });
388 
389  auto cluster_CENTER_LAMBDA_log10 = Monitored::Collection("cluster_CENTER_LAMBDA_log10", clusters, [](const xAOD::CaloCluster *cluster){
390  double detail = -999;
391  const auto success_CENTER_LAMBDA = cluster->retrieveMoment(xAOD::CaloCluster::MomentType::CENTER_LAMBDA, detail);
392  if(success_CENTER_LAMBDA) detail = std::log10(detail + 1e-6);
393  return detail;
394  });
395 
396  fill(monGroup, n_cluster, cluster_pt_jetseed_log, cluster_et_log, cluster_eta, cluster_phi, cluster_dEta, cluster_dPhi, cluster_SECOND_R_log10, cluster_SECOND_LAMBDA_log10, cluster_CENTER_LAMBDA_log10);
397  }
398 
399  ATH_MSG_DEBUG("After fill ID input Cluster: " << trigger);
400 }
401 
402 
403 void TrigTauMonitorSingleAlgorithm::fillBasicVars(const EventContext& ctx, const std::string& trigger, const std::vector<const xAOD::TauJet*>& tau_vec, const std::string& nProng, bool online) const
404 {
405  ATH_MSG_DEBUG("Fill Basic Variables: " << trigger);
406 
407  auto monGroup = getGroup(trigger+"_"+(online ? "HLT" : "Offline")+"_basicVars_"+nProng);
408 
409  auto Pt = Monitored::Collection("Pt", tau_vec, [](const xAOD::TauJet* tau){ return tau->pt()/Gaudi::Units::GeV; });
410  auto Eta = Monitored::Collection("Eta", tau_vec, [](const xAOD::TauJet* tau){ return tau->eta(); });
411  auto Phi = Monitored::Collection("Phi", tau_vec, [](const xAOD::TauJet* tau){ return tau->phi(); });
412 
413  auto nTrack = Monitored::Collection("nTrack", tau_vec, [](const xAOD::TauJet* tau){
414  int nTrack = -1;
416  return nTrack;
417  });
418  auto nIsoTrack = Monitored::Collection("nIsoTrack", tau_vec, [](const xAOD::TauJet* tau){ return tau->nTracksIsolation(); });
419 
420  auto averageMu = Monitored::Scalar<float>("averageMu", 0.0);
421  averageMu = lbAverageInteractionsPerCrossing(ctx);
422 
423  auto TauVertexX = Monitored::Collection("TauVertexX", tau_vec, [](const xAOD::TauJet* tau){
424  double vtx = -999;
425  if(tau->vertex() != nullptr) vtx = tau->vertex()->x();
426  return vtx;
427  });
428  auto TauVertexY = Monitored::Collection("TauVertexY", tau_vec, [](const xAOD::TauJet* tau){
429  double vty = -999;
430  if(tau->vertex() != nullptr) vty = tau->vertex()->y();
431  return vty;
432  });
433  auto TauVertexZ = Monitored::Collection("TauVertexZ", tau_vec, [](const xAOD::TauJet* tau){
434  double vtz = -999;
435  if(tau->vertex() != nullptr) vtz = tau->vertex()->z();
436  return vtz;
437  });
438 
439  fill(monGroup, Pt, Eta, Phi, nTrack, nIsoTrack, averageMu, TauVertexX, TauVertexY, TauVertexZ);
440 
441  ATH_MSG_DEBUG("After fill Basic variables: " << trigger);
442 }
443 
444 
445 void TrigTauMonitorSingleAlgorithm::fillIDScores(const std::string& trigger, const std::vector<const xAOD::TauJet*>& tau_vec, const std::string& nProng, bool online) const
446 {
447  ATH_MSG_DEBUG("Fill TauID Scores: " << trigger);
448 
449  const TrigTauInfo& info = getTrigInfo(trigger);
450  const std::string tau_id = info.getHLTTauID();
451  bool store_all = tau_id == "idperf" || tau_id == "perf";
452 
453  if(online) {
454  if(m_monitoredHLTIdAccessors.find(info.getHLTTauType()) == m_monitoredHLTIdAccessors.end()) return;
455  } else {
456  if(m_monitoredOfflineIdAccessors.size() == 0) return;
457  }
458  const auto& idAccessors = online ? m_monitoredHLTIdAccessors.at(info.getHLTTauType()) : m_monitoredOfflineIdAccessors;
459 
460  // This has to be down here, because otherwise we crash on unmonitored chains
461  auto monGroup = getGroup(trigger+"_"+(online ? "HLT" : "Offline")+"_IDScores_"+nProng);
462 
463  for(const auto& [key, p] : idAccessors) {
464  // We will either store the TauID scores indicated in the chain name, or all of them in case of (id)perf chains
465  if(online && !store_all && tau_id != key) continue;
466 
467  std::vector<float> score, score_sig_trans;
468 
469  for(const xAOD::TauJet* tau : tau_vec) {
470  // Skip if both the Score and ScoreSigTrans aren't available
471  if(!p.first.isAvailable(*tau) || !p.second.isAvailable(*tau)) continue;
472 
473  score.push_back(p.first(*tau));
474  score_sig_trans.push_back(p.second(*tau));
475  }
476 
477  auto IDScore = Monitored::Collection(key + "_TauIDScore", score);
478  auto IDScoreSigTrans = Monitored::Collection(key + "_TauIDScoreSigTrans", score_sig_trans);
479  fill(monGroup, IDScore, IDScoreSigTrans);
480  }
481 
482  ATH_MSG_DEBUG("After fill TauID Scores: " << trigger);
483 }
484 
485 
486 std::vector<TLorentzVector> TrigTauMonitorSingleAlgorithm::getRoIsVector(const EventContext& ctx, const std::string& trigger) const
487 {
488  std::vector<TLorentzVector> ret;
489 
490  const TrigTauInfo& info = getTrigInfo(trigger);
491 
492  TLorentzVector v;
493  if(info.getL1TauType() == "eTAU") {
494  for(const xAOD::eFexTauRoI* roi : getL1eTAUs(ctx, info.getL1TauItem())) {
495  v.SetPtEtaPhiM(roi->et(), roi->eta(), roi->phi(), 0);
496  ret.push_back(v);
497  }
498  } else if(info.getL1TauType() == "jTAU") {
499  for(const xAOD::jFexTauRoI* roi : getL1jTAUs(ctx, info.getL1TauItem())) {
500  v.SetPtEtaPhiM(roi->et(), roi->eta(), roi->phi(), 0);
501  ret.push_back(v);
502  }
503  } else if(info.getL1TauType() == "cTAU") {
504  for(const auto& [eTau_roi, jTau_roi] : getL1cTAUs(ctx, info.getL1TauItem())) {
505  v.SetPtEtaPhiM(eTau_roi->et(), eTau_roi->eta(), eTau_roi->phi(), 0);
506  ret.push_back(v);
507  }
508  } else { // Legacy
509  for(const xAOD::EmTauRoI* roi : getL1LegacyTAUs(ctx, info.getL1TauItem())) {
510  v.SetPtEtaPhiM(roi->eT(), roi->eta(), roi->phi(), 0);
511  ret.push_back(v);
512  }
513  }
514 
515  return ret;
516 }
grepfile.info
info
Definition: grepfile.py:38
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
xAOD::jFexTauRoI_v1
Class describing properties of a LVL1 jFEX global Trigger Object (TOB) in the xAOD format.
Definition: jFexTauRoI_v1.h:22
xAOD::Vertex_v1::x
float x() const
Returns the x position.
python.TIDAMonTool.monGroup
def monGroup(analysis_chain)
Definition: TIDAMonTool.py:297
TauGNNUtils::Variables::Cluster::CENTER_LAMBDA
bool CENTER_LAMBDA(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, double &out)
Definition: TauGNNUtils.cxx:840
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
max
#define max(a, b)
Definition: cfImp.cxx:41
TauAnalysisTools::tauEta
double tauEta(const xAOD::TauJet &xTau)
return tau eta
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:99
xAOD::TauJetParameters::trFlightPathSig
@ trFlightPathSig
Definition: TauDefs.h:163
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
AthMonitorAlgorithm::m_trigDecTool
PublicToolHandle< Trig::TrigDecisionTool > m_trigDecTool
Tool to tell whether a specific trigger is passed.
Definition: AthMonitorAlgorithm.h:340
TauGNNUtils::Variables::absipSigLeadTrk
bool absipSigLeadTrk(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:269
xAOD::TauTrack_v1::d0SigTJVA
float d0SigTJVA() const
Definition: TauTrack_v1.cxx:129
xAOD::TauJet_v3::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
TrigTauMonitorBaseAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TrigTauMonitorBaseAlgorithm.cxx:16
TauAnalysisTools::tauPt
double tauPt(const xAOD::TauJet &xTau)
return tau pt in GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:85
TrigTauMonitorSingleAlgorithm::m_monitoredHLTIdScores
Gaudi::Property< std::map< std::string, std::map< std::string, std::pair< std::string, std::string > > > > m_monitoredHLTIdScores
Definition: TrigTauMonitorSingleAlgorithm.h:30
TrigTauMonitorSingleAlgorithm::fillIDInputVars
void fillIDInputVars(const std::string &trigger, const std::vector< const xAOD::TauJet * > &tau_vec, const std::string &nProng, bool online) const
Definition: TrigTauMonitorSingleAlgorithm.cxx:211
xAOD::TauJet_v3::nTracks
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
Definition: TauJet_v3.cxx:526
xAOD::passBits
passBits
Definition: TrigPassBits_v1.cxx:115
TrigTauMonitorBaseAlgorithm::getL1cTAUs
std::vector< std::pair< const xAOD::eFexTauRoI *, const xAOD::jFexTauRoI * > > getL1cTAUs(const EventContext &ctx, const std::string &l1_item) const
Definition: TrigTauMonitorBaseAlgorithm.cxx:189
TrigTauMonitorBaseAlgorithm::classifyOnlineTaus
std::tuple< std::vector< const xAOD::TauJet * >, std::vector< const xAOD::TauJet * >, std::vector< const xAOD::TauJet * > > classifyOnlineTaus(const std::vector< const xAOD::TauJet * > &taus, const float threshold=0.0) const
Definition: TrigTauMonitorBaseAlgorithm.cxx:317
xAOD::CaloCluster_v1::et
double et() const
Definition: CaloCluster_v1.h:856
xAOD::TauJetParameters::mEflowApprox
@ mEflowApprox
Definition: TauDefs.h:292
detail
Definition: extract_histogram_tag.cxx:14
xAOD::numberOfPixelHits
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Definition: TrackingPrimitives.h:259
xAOD::expectInnermostPixelLayerHit
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
Definition: TrackingPrimitives.h:236
Phi
@ Phi
Definition: RPCdef.h:8
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
TrigTauMonitorBaseAlgorithm::getL1eTAUs
std::vector< const xAOD::eFexTauRoI * > getL1eTAUs(const EventContext &ctx, const std::string &l1_item) const
Definition: TrigTauMonitorBaseAlgorithm.cxx:125
xAOD::TauJet_v3::ptJetSeed
double ptJetSeed() const
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::TauJet_v3::ptDetectorAxis
double ptDetectorAxis() const
xAOD::TauJetParameters::ptRatioEflowApprox
@ ptRatioEflowApprox
Definition: TauDefs.h:293
TrigTauMonitorSingleAlgorithm::TrigTauMonitorSingleAlgorithm
TrigTauMonitorSingleAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigTauMonitorSingleAlgorithm.cxx:8
TrigTauMonitorBaseAlgorithm::m_do_variable_plots
Gaudi::Property< bool > m_do_variable_plots
Definition: TrigTauMonitorBaseAlgorithm.h:41
TrigTauMonitorSingleAlgorithm::processEvent
virtual StatusCode processEvent(const EventContext &ctx) const override
Definition: TrigTauMonitorSingleAlgorithm.cxx:54
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
xAOD::TauJet_v3::clusters
std::vector< const IParticle * > clusters() const
Definition: TauJet_v3.cxx:585
TrigTauMonitorSingleAlgorithm::m_monitoredOfflineIdScores
Gaudi::Property< std::map< std::string, std::pair< std::string, std::string > > > m_monitoredOfflineIdScores
Definition: TrigTauMonitorSingleAlgorithm.h:34
TrigTauMonitorSingleAlgorithm::fillIDCluster
void fillIDCluster(const std::string &trigger, const std::vector< const xAOD::TauJet * > &tau_vec, bool online) const
Definition: TrigTauMonitorSingleAlgorithm.cxx:351
TrigTauMonitorSingleAlgorithm::m_monitoredOfflineIdAccessors
std::map< std::string, std::pair< SG::AuxElement::ConstAccessor< float >, SG::AuxElement::ConstAccessor< float > > > m_monitoredOfflineIdAccessors
Definition: TrigTauMonitorSingleAlgorithm.h:35
xAOD::TauJetParameters::centFrac
@ centFrac
Get centrality fraction.
Definition: TauDefs.h:200
xAOD::TauJetParameters::dRmax
@ dRmax
Get maximal dR of tracks associated to calo-seeded tau.
Definition: TauDefs.h:226
xAOD::TauJet_v3::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
TileSynchronizeBch.online
online
Definition: TileSynchronizeBch.py:88
xAOD::TauJet_v3::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
TrigTauMonitorBaseAlgorithm::getOnlineTausAll
std::vector< const xAOD::TauJet * > getOnlineTausAll(const std::string &trigger, bool include_0P=true) const
Definition: TrigTauMonitorBaseAlgorithm.cxx:55
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TrigTauMonitorSingleAlgorithm::fillIDScores
void fillIDScores(const std::string &trigger, const std::vector< const xAOD::TauJet * > &tau_vec, const std::string &nProng, bool online) const
Definition: TrigTauMonitorSingleAlgorithm.cxx:445
TrigTauMonitorBaseAlgorithm::classifyOfflineTaus
std::pair< std::vector< const xAOD::TauJet * >, std::vector< const xAOD::TauJet * > > classifyOfflineTaus(const std::vector< const xAOD::TauJet * > &taus, const float threshold=0.0) const
Definition: TrigTauMonitorBaseAlgorithm.cxx:336
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
xAOD::EmTauRoI_v2
Class describing a LVL1 em/tau region of interest.
Definition: EmTauRoI_v2.h:35
xAOD::eFexTauRoI_v1
Class describing a LVL1 eFEX tau region of interest.
Definition: eFexTauRoI_v1.h:29
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
xAOD::TauJetParameters::nChargedTracks
@ nChargedTracks
Definition: TauDefs.h:322
xAOD::TauJet_v3::track
const TauTrack * track(size_t i, TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged, int *container_index=0) const
Get the pointer to a given tauTrack associated with this tau /*container index needed by trackNonCons...
Definition: TauJet_v3.cxx:450
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TauJetParameters::etOverPtLeadTrk
@ etOverPtLeadTrk
Definition: TauDefs.h:158
hist_file_dump.f
f
Definition: hist_file_dump.py:135
xAOD::CaloCluster_v1::retrieveMoment
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
Definition: CaloCluster_v1.cxx:738
xAOD::Vertex_v1::z
float z() const
Returns the z position.
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
TauGNNUtils::Variables::Cluster::SECOND_LAMBDA
bool SECOND_LAMBDA(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, double &out)
Definition: TauGNNUtils.cxx:835
TrigTauMonitorSingleAlgorithm::m_monitoredHLTIdAccessors
std::map< std::string, std::map< std::string, std::pair< SG::AuxElement::ConstAccessor< float >, SG::AuxElement::ConstAccessor< float > > > > m_monitoredHLTIdAccessors
Definition: TrigTauMonitorSingleAlgorithm.h:31
TrigTauMonitorSingleAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TrigTauMonitorSingleAlgorithm.cxx:13
xAOD::TauJetParameters::massTrkSys
@ massTrkSys
Definition: TauDefs.h:161
min
#define min(a, b)
Definition: cfImp.cxx:40
xAOD::CaloCluster_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: CaloCluster_v1.cxx:465
xAOD::TauJet_v3::detail
bool detail(TauJetParameters::Detail detail, int &value) const
Set veto flag.
Definition: TauJet_v3.cxx:292
TrigTauMonitorSingleAlgorithm::getRoIsVector
std::vector< TLorentzVector > getRoIsVector(const EventContext &ctx, const std::string &trigger) const
Definition: TrigTauMonitorSingleAlgorithm.cxx:486
TrigTauMonitorSingleAlgorithm::m_requireOfflineTaus
Gaudi::Property< bool > m_requireOfflineTaus
Definition: TrigTauMonitorSingleAlgorithm.h:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TrigTauMonitorBaseAlgorithm
Definition: TrigTauMonitorBaseAlgorithm.h:24
TauGNNUtils::Variables::Cluster::SECOND_R
bool SECOND_R(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, double &out)
Definition: TauGNNUtils.cxx:830
TrigTauMonitorBaseAlgorithm::m_do_efficiency_plots
Gaudi::Property< bool > m_do_efficiency_plots
Definition: TrigTauMonitorBaseAlgorithm.h:40
AthMonitorAlgorithm::lbAverageInteractionsPerCrossing
virtual float lbAverageInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the average mu, i.e.
Definition: AthMonitorAlgorithm.cxx:222
TrigTauMonitorSingleAlgorithm.h
xAOD::score
@ score
Definition: TrackingPrimitives.h:513
TrigTauMonitorSingleAlgorithm::m_doTotalEfficiency
Gaudi::Property< bool > m_doTotalEfficiency
Definition: TrigTauMonitorSingleAlgorithm.h:21
TrigTauInfo
Definition: TrigTauInfo.h:15
python.PyAthena.v
v
Definition: PyAthena.py:154
Prompt::Def::Pt
@ Pt
Definition: VarHolder.h:76
TrigTauMonitorSingleAlgorithm::m_doOfflineTausDistributions
Gaudi::Property< bool > m_doOfflineTausDistributions
Definition: TrigTauMonitorSingleAlgorithm.h:27
TrigTauMonitorBaseAlgorithm::getL1jTAUs
std::vector< const xAOD::jFexTauRoI * > getL1jTAUs(const EventContext &ctx, const std::string &l1_item) const
Definition: TrigTauMonitorBaseAlgorithm.cxx:157
xAOD::TauJet_v3::vertex
const Vertex * vertex() const
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::numberOfSCTDeadSensors
@ numberOfSCTDeadSensors
number of dead SCT sensors crossed [unit8_t].
Definition: TrackingPrimitives.h:273
TrigTauMonitorBaseAlgorithm::matchObjects
bool matchObjects(const T1 *tau, const std::vector< const T2 * > &tau_vec, float threshold) const
Definition: TrigTauMonitorBaseAlgorithm.h:73
xAOD::TauTrack_v1
Definition: TauTrack_v1.h:27
xAOD::TauJet_v3::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: TauJet_v3.cxx:97
TriggerTest.rois
rois
Definition: TriggerTest.py:23
xAOD::Vertex_v1::y
float y() const
Returns the y position.
TrigTauMonitorBaseAlgorithm::getL1LegacyTAUs
std::vector< const xAOD::EmTauRoI * > getL1LegacyTAUs(const EventContext &ctx, const std::string &l1_item) const
Definition: TrigTauMonitorBaseAlgorithm.cxx:233
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
TrigTauMonitorBaseAlgorithm::m_triggers
Gaudi::Property< std::vector< std::string > > m_triggers
Definition: TrigTauMonitorBaseAlgorithm.h:32
xAOD::numberOfSCTHits
@ numberOfSCTHits
number of hits in SCT [unit8_t].
Definition: TrackingPrimitives.h:268
TrigTauMonitorSingleAlgorithm::fillIDTrack
void fillIDTrack(const std::string &trigger, const std::vector< const xAOD::TauJet * > &tau_vec, bool online) const
Definition: TrigTauMonitorSingleAlgorithm.cxx:280
xAOD::numberOfPixelDeadSensors
@ numberOfPixelDeadSensors
number of dead pixel sensors crossed [unit8_t].
Definition: TrackingPrimitives.h:266
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
TrigTauMonitorBaseAlgorithm::getTrigInfo
const TrigTauInfo & getTrigInfo(const std::string &trigger) const
Definition: TrigTauMonitorBaseAlgorithm.h:45
xAOD::TauJetParameters::SumPtTrkFrac
@ SumPtTrkFrac
Definition: TauDefs.h:289
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
TrigTauMonitorSingleAlgorithm::fillBasicVars
void fillBasicVars(const EventContext &ctx, const std::string &trigger, const std::vector< const xAOD::TauJet * > &tau_vec, const std::string &nProng, bool online) const
Definition: TrigTauMonitorSingleAlgorithm.cxx:403
TauGNNUtils::Variables::ptDetectorAxis
bool ptDetectorAxis(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:343
xAOD::TauJet_v3::nTracksIsolation
size_t nTracksIsolation() const
Definition: TauJet_v3.cxx:536
TrigTauMonitorSingleAlgorithm::fillHLTEfficiencies
void fillHLTEfficiencies(const EventContext &ctx, const std::string &trigger, const bool l1_accept_flag, const std::vector< const xAOD::TauJet * > &offline_tau_vec, const std::vector< const xAOD::TauJet * > &online_tau_vec, const std::string &nProng) const
Definition: TrigTauMonitorSingleAlgorithm.cxx:142
xAOD::TauJet_v3::allTracks
std::vector< const TauTrack * > allTracks() const
Get the v<const pointer> to all tracks associated with this tau, regardless of classification.
Definition: TauJet_v3.cxx:514
AthMonitorAlgorithm::getGroup
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
Definition: AthMonitorAlgorithm.cxx:164
Eta
@ Eta
Definition: RPCdef.h:8
TrigTauMonitorBaseAlgorithm::getOfflineTausAll
std::vector< const xAOD::TauJet * > getOfflineTausAll(const EventContext &ctx, const float threshold=20.0) const
Definition: TrigTauMonitorBaseAlgorithm.cxx:83
xAOD::TauJetParameters::EMPOverTrkSysP
@ EMPOverTrkSysP
Definition: TauDefs.h:279
xAOD::numberOfInnermostPixelLayerHits
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
Definition: TrackingPrimitives.h:237
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37