ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaPrecisionPhotonCaloIsoHypoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 * =====================================================================================
7 *
8 * Filename: TrigEgammaPrecisionPhotonCaloIsoHypoTool.cxx
9 *
10 * Description: Hypo tool for Calorimeter isolation applied HLT precision step for photon triggers
11 *
12 * Created: 08/09/2022 11:19:55 AM
13 *
14 * Author: Fernando Monticelli (), Fernando.Monticelli@cern.ch
15 * Organization: UNLP/IFLP/CONICET
16 *
17 * =====================================================================================
18 */
19#include <algorithm>
25
27
28namespace TCU = TrigCompositeUtils;
29
31 const std::string& name,
32 const IInterface* parent )
33 : base_class( type, name, parent ),
34 m_decisionId( HLT::Identifier::fromToolName( name ) ) {
35}
36
37
39{
40 ATH_MSG_DEBUG( "Initialization completed successfully" );
41 ATH_MSG_DEBUG( "EtaBins = " << m_etabin );
42
43 if ( m_etabin.empty() ) {
44 ATH_MSG_ERROR( " There are no cuts set (EtaBins property is an empty list)" );
45 return StatusCode::FAILURE;
46 }
47
48 for (unsigned idx = 0; idx < s_nCones; ++idx) {
49 if (s_coneSizes[idx] == m_TopoEtConeSize) {
50 m_coneIdx = idx;
51 break;
52 }
53 }
54 if ( m_coneIdx < 0 && !m_acceptAll ) {
55 ATH_MSG_ERROR("Invalid cone size: " << m_TopoEtConeSize);
56 return StatusCode::FAILURE;
57 }
58
59 // Retrieving Luminosity info
60 ATH_MSG_DEBUG( "Retrieving luminosityCondData..." );
61 ATH_CHECK( m_avgMuKey.initialize() );
62
63 ATH_MSG_DEBUG( "Tool configured for chain/id: " << m_decisionId );
64
65 if ( not m_monTool.name().empty() )
66 CHECK( m_monTool.retrieve() );
67
68 return StatusCode::SUCCESS;
69}
70
71
73{
74 auto mon_ET = Monitored::Scalar( "Et_em", -1.0 );
75 auto mon_etaBin = Monitored::Scalar( "EtaBin", -1.0 );
76 auto mon_Eta = Monitored::Scalar( "Eta", -99. );
77 auto mon_Phi = Monitored::Scalar( "Phi", -99. );
78 auto mon_mu = Monitored::Scalar("mu", -1.);
79 auto mon_etcone20 = Monitored::Scalar("etcone20", -99.);
80 auto mon_topoetcone20 = Monitored::Scalar("topoetcone20", -99.);
81 auto mon_relEtCone20 = Monitored::Scalar("relEtCone20", -99.);
82 auto mon_relTopoEtCone20 = Monitored::Scalar("relTopoEtCone20", -99.);
83
84 auto mon_etcone30 = Monitored::Scalar("etcone30", -99.);
85 auto mon_topoetcone30 = Monitored::Scalar("topoetcone30", -99.);
86 auto mon_relEtCone30 = Monitored::Scalar("relEtCone30", -99.);
87 auto mon_relTopoEtCone30 = Monitored::Scalar("relTopoEtCone30", -99.);
88
89 auto mon_etcone40 = Monitored::Scalar("etcone40", -99.);
90 auto mon_topoetcone40 = Monitored::Scalar("topoetcone40", -99.);
91 auto mon_relEtCone40 = Monitored::Scalar("relEtCone40", -99.);
92 auto mon_relTopoEtCone40 = Monitored::Scalar("relTopoEtCone40", -99.);
93
94 auto PassedCuts = Monitored::Scalar<int>( "CutCounter", -1 );
95 auto monitorIt = Monitored::Group( m_monTool,
96 mon_etaBin, mon_Eta, mon_Phi, mon_mu,
97 mon_etcone20, mon_topoetcone20, mon_relEtCone20, mon_relTopoEtCone20,
98 mon_etcone30, mon_topoetcone30, mon_relEtCone30, mon_relTopoEtCone30,
99 mon_etcone40, mon_topoetcone40, mon_relEtCone40, mon_relTopoEtCone40,
100 PassedCuts );
101
102 // when leaving scope it will ship data to monTool
103 PassedCuts = PassedCuts + 1; //got called (data in place)
104
105 auto roiDescriptor = input.roi;
106
107 if ( fabs( roiDescriptor->eta() ) > 2.6 ) {
108 ATH_MSG_DEBUG( "REJECT The photon had eta coordinates beyond the EM fiducial volume : "
109 << roiDescriptor->eta() << "; stop the chain now" );
110 return false; // special case
111 }
112
113 ATH_MSG_DEBUG( "; RoI ID = " << roiDescriptor->roiId()
114 << ": Eta = " << roiDescriptor->eta()
115 << ", Phi = " << roiDescriptor->phi() );
116
117
118 const auto pClus = input.photon->caloCluster();
119
120 const float absEta = fabs( pClus->eta() );
121 const int cutIndex = findCutIndex( absEta );
122
123 // eta range
124 if ( !m_acceptAll && cutIndex == -1 ) { // VD
125 ATH_MSG_DEBUG( "Photon : " << absEta << " outside eta range " << m_etabin[m_etabin.size()-1] );
126 return false;
127 } else {
128 ATH_MSG_DEBUG( "eta bin used for cuts " << cutIndex << " AcceptAll = " << m_acceptAll );
129 }
130 mon_etaBin = m_etabin[cutIndex];
131 PassedCuts = PassedCuts + 1; // passed eta cut
132
133 const float photon_eT = pClus->et();
134 mon_ET = photon_eT;
135
136 // get average luminosity information to calculate LH
137 float avg_mu = 0;
139 if(eventInfoDecor.isPresent()) {
140 avg_mu = eventInfoDecor(0);
141 ATH_MSG_DEBUG("Average mu " << avg_mu);
142 }
143 mon_mu = avg_mu;
144
145 float ptCone[s_nCones] = {999, 999, 999};
146 float etCone[s_nCones] = {999, 999, 999};
147 float topoEtCone[s_nCones] = {999, 999, 999};
148
149 float relEtCone[s_nCones] = {999, 999, 999};
150 float relTopoEtCone[s_nCones] = {999, 999, 999};
151
152 for (int idx = 0; idx < s_nCones; ++idx) {
153 input.photon->isolationValue(ptCone[idx], s_ptConeIsoTypes[idx]);
154 input.photon->isolationValue(etCone[idx], s_etConeIsoTypes[idx]);
155 input.photon->isolationValue(topoEtCone[idx], s_topoEtconeIsoTypes[idx]);
156
157 ATH_MSG_DEBUG( " ptCone" << s_coneSizes[idx] << " = " << ptCone[idx] );
158 ATH_MSG_DEBUG( " etCone" << s_coneSizes[idx] << " = " << etCone[idx] );
159 ATH_MSG_DEBUG( " topoEtCone" << s_coneSizes[idx] << " = " << topoEtCone[idx] );
160 }
161
162 // Calculate relative isolations and assign monitoring variables
163 for (int idx = 0; idx < s_nCones; ++idx) {
164 relEtCone[idx] = etCone[idx] / photon_eT;
165 relTopoEtCone[idx] = topoEtCone[idx] / photon_eT;
166
167 ATH_MSG_DEBUG("relEtCone" << s_coneSizes[idx] << " = " << relEtCone[idx]);
168 ATH_MSG_DEBUG("relTopoEtCone" << s_coneSizes[idx] << " = " << relTopoEtCone[idx]);
169 }
170
171 // Fill monitoring variables (per-cone names preserved for downstream monitoring)
172 mon_etcone20 = etCone[0];
173 mon_topoetcone20 = topoEtCone[0];
174 mon_relEtCone20 = relEtCone[0];
175 mon_relTopoEtCone20 = relTopoEtCone[0];
176
177 mon_etcone30 = etCone[1];
178 mon_topoetcone30 = topoEtCone[1];
179 mon_relEtCone30 = relEtCone[1];
180 mon_relTopoEtCone30 = relTopoEtCone[1];
181
182 mon_etcone40 = etCone[2];
183 mon_topoetcone40 = topoEtCone[2];
184 mon_relEtCone40 = relEtCone[2];
185 mon_relTopoEtCone40 = relTopoEtCone[2];
186
187 if ( m_acceptAll ) {
188 return true;
189 }
190
191 const bool pass_relTopoEtCone = ( m_RelTopoEtConeCut > 900 || ( relTopoEtCone[m_coneIdx] - m_CutOffset/photon_eT < m_RelTopoEtConeCut ));
193 "pass_relTopoEtCone for cone size " << m_TopoEtConeSize << " (m_coneIdx = " << m_coneIdx << ") = "
194 << relTopoEtCone[m_coneIdx] << " - " << m_CutOffset << '/' << photon_eT << " < "
195 << m_RelTopoEtConeCut << " = " << pass_relTopoEtCone
196 );
197
198 return pass_relTopoEtCone;
199
200}
201
203 const float absEta = std::abs(eta);
204
205 auto binIterator = std::adjacent_find( m_etabin.begin(), m_etabin.end(), [=](float left, float right){ return left < absEta and absEta < right; } );
206 if ( binIterator == m_etabin.end() ) {
207 return -1;
208 }
209 return binIterator - m_etabin.begin();
210}
211
212
213StatusCode TrigEgammaPrecisionPhotonCaloIsoHypoTool::decide( std::vector<PhotonInfo>& input ) const {
214 for ( auto& i: input ) {
215 if ( TCU::passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
216 if ( decide( i ) ) {
217 TCU::addDecisionID( m_decisionId, i.decision );
218 }
219 }
220 }
221 return StatusCode::SUCCESS;
222}
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Header file to be included by clients of the Monitored infrastructure.
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
Handle class for reading a decoration on an object.
bool isPresent() const
Is the referenced container present in SG?
Gaudi::Property< std::vector< float > > m_etabin
selection variable for PRECISION calo selection:eta bins
static constexpr xAOD::Iso::IsolationType s_topoEtconeIsoTypes[s_nCones]
TrigEgammaPrecisionPhotonCaloIsoHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
static constexpr xAOD::Iso::IsolationType s_ptConeIsoTypes[s_nCones]
static constexpr xAOD::Iso::IsolationType s_etConeIsoTypes[s_nCones]
virtual StatusCode decide(std::vector< ITrigEgammaPrecisionPhotonCaloIsoHypoTool::PhotonInfo > &input) const override
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.