ATLAS Offline Software
Loading...
Searching...
No Matches
UHT1TauCondition.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11#include <sstream>
12#include <cmath>
13#include <TLorentzVector.h>
14
16 const std::string &decName_ptau,
17 const std::string &decName_pu,
18 const std::string &decName_isValid) :
19 m_workingPoint(workingPoint),
20 m_decName_ptau(decName_ptau),
21 m_decName_pu(decName_pu),
22 m_decName_isValid(decName_isValid)
23{
24
25}
26
28 const std::unique_ptr<ITrigJetHypoInfoCollector> &collector,
29 const std::string &decName) const
30{
31
32 float momentValue = -1;
33 if (!(ip->getAttribute(decName, momentValue)))
34 {
35 if (collector)
36 {
37 auto j_addr = static_cast<const void *>(ip.get());
38
39 std::stringstream ss0;
40 ss0 << "UHT1TauCondition: "
41 << " unable to retrieve " << decName << '\n';
42 std::stringstream ss1;
43 ss1 << " jet : (" << j_addr << ")";
44 collector->collect(ss0.str(), ss1.str());
45 }
46
47 throw std::runtime_error("Impossible to retrieve decorator \'" + decName + "\' for jet hypo");
48 }
49
50 return momentValue;
51}
52
53float UHT1TauCondition::evaluateUHT1Tau(const float &ptau,
54 const float &pu) const {
55 return safeLogRatio(ptau, pu);
56}
57
59 const std::unique_ptr<ITrigJetHypoInfoCollector> &collector) const
60{
61 if (!m_decName_isValid.empty()) {
62 // short circuit if uht1tau is invalid and we ask for a check
63 //
64 // we have to dynamic cast to xAOD jets here because there's no char
65 // accessor on IJet and it's not clear if we need one generally.
66 const auto* jet = dynamic_cast<const HypoJet::xAODJetAsIJet*>(ip.get());
67 if (!jet) throw std::runtime_error("Fast uht1tau has to run on xAOD::Jet");
68 char valid = (*jet->xAODJet())->getAttribute<char>(m_decName_isValid);
69 if (valid == 0) return false;
70 }
71
72 // if we got this far check the uht1tau hypo
73 float ptau = getUHT1TauDecValue(ip, collector, m_decName_ptau);
74 float pu = getUHT1TauDecValue(ip, collector, m_decName_pu);
75 float output = evaluateUHT1Tau(ptau, pu);
76
77 bool pass = (output >= m_workingPoint);
78
79 if (collector)
80 {
81 const void *address = static_cast<const void *>(this);
82
83 std::stringstream ss0;
84 ss0 << "UHT1TauCondition: (" << address
85 << ")"
86 << " pass: " << std::boolalpha << pass << '\n';
87
88 auto j_addr = static_cast<const void *>(ip.get());
89 std::stringstream ss1;
90 ss1 << " jet : (" << j_addr << ") "
91 << m_decName_ptau << " value: " << ptau << '\n';
92
93 collector->collect(ss0.str(), ss1.str());
94 }
95
96 return pass;
97}
98
99bool
101 const std::unique_ptr<ITrigJetHypoInfoCollector>& c) const {
102 auto result = isSatisfied(ips[0], c);
103 return result;
104}
105
106
107std::string UHT1TauCondition::toString() const {
108 std::stringstream ss;
109 ss << "UHT1TauCondition (" << this << ") "
110 << " Cleaning decs: "
111 << m_decName_ptau << ", "
112 << m_decName_pu << ", "
113 <<'\n';
114
115 return ss.str();
116}
std::vector< pHypoJet > HypoJetVector
Definition HypoJetDefs.h:27
std::shared_ptr< const HypoJet::IJet > pHypoJet
Definition HypoJetDefs.h:25
static Double_t ss
float getUHT1TauDecValue(const pHypoJet &ip, const std::unique_ptr< ITrigJetHypoInfoCollector > &collector, const std::string &decName) const
std::string m_decName_pu
float evaluateUHT1Tau(const float &uht1tau_ptau, const float &uht1tau_pu) const
bool isSatisfied(const HypoJetVector &, const std::unique_ptr< ITrigJetHypoInfoCollector > &) const override
std::string toString() const override
UHT1TauCondition(float workingPoint, const std::string &decName_ptau, const std::string &decName_pu, const std::string &decName_isValid="")
std::string m_decName_ptau
std::string m_decName_isValid
float safeLogRatio(float num, float denom)