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