ATLAS Offline Software
Loading...
Searching...
No Matches
HIGlobalAugmentationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <format>
7
9{
10 // Athena initialize and finalize
12 {
13 ATH_CHECK( m_eventInfoKey.initialize() );
14 ATH_CHECK( m_TP_key.initialize() );
15 ATH_CHECK( m_eventShapeKey.initialize() );
16 ATH_CHECK( m_caloClusterKey.initialize(SG::AllowEmpty) ); // Only needed if m_doTopoClusDec = True
17 unsigned int nTrackSels = m_trkSelTools.size();
18 for (unsigned int its = 0; its < nTrackSels; ++its) {
19 ATH_CHECK(m_trkSelTools[its].retrieve());
20 m_decTrack_count.emplace_back(SG::AuxElement::Decorator<int>("TrackParticleMultiplicity_" + m_cutLevels[its] ));
21 }
22 //initilize decorators for flow vectors
23 for (int vn = 1; vn <= m_nHarmonic; ++vn) {
24 m_decFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}x", vn + 1)));
25 m_decFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}y", vn + 1)));
26 m_decFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}x", vn + 1)));
27 m_decFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}y", vn + 1)));
28
29 // half FCal is for FCal with eta > 4.0 only
30 m_decHalfFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}x", vn + 1)));
31 m_decHalfFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}y", vn + 1)));
32 m_decHalfFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}x", vn + 1)));
33 m_decHalfFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}y", vn + 1)));
34 }
35
36
37 return StatusCode::SUCCESS;
38 }
40 {
41 for (auto trkSelTool : m_trkSelTools ) {
42 ATH_CHECK(trkSelTool->finalize());
43 }
44
45 return StatusCode::SUCCESS;
46 }
47
48 StatusCode HIGlobalAugmentationTool::addBranches(const EventContext& ctx) const
49 {
51
52 //Load track particle container
54 if (!tracks.isValid()) {
55 ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key " << m_TP_key);
56 return StatusCode::FAILURE;
57 }
58
59 //Count tracks
60 unsigned int nTrackSels = m_trkSelTools.size();
61 std::vector <int> TrackParticleMultiplicity(nTrackSels,0);
62 for (const auto* tp : *tracks) {
63 if (tp) {
64 for (unsigned int its = 0; its < nTrackSels; ++its) {
65 if (m_trkSelTools[its]->accept(*tp)) ++TrackParticleMultiplicity[its];
66 }
67 }
68 }
69 //decorate eventInfo with track multiplicity
70 for (unsigned int its = 0; its < nTrackSels; ++its) {
71 (m_decTrack_count[its])(*eventInfo) = TrackParticleMultiplicity[its];
72 }
73
74 float FCalEtA = 0;
75 float FCalEtC = 0;
76
77 std::vector<float> FCalEtA_Qnx(m_nHarmonic,0);
78 std::vector<float> FCalEtA_Qny(m_nHarmonic,0);
79 std::vector<float> FCalEtC_Qnx(m_nHarmonic,0);
80 std::vector<float> FCalEtC_Qny(m_nHarmonic,0);
81
82 float HalfFCalEtA = 0;
83 float HalfFCalEtC = 0;
84
85 std::vector<float> HalfFCalEtA_Qnx(m_nHarmonic,0);
86 std::vector<float> HalfFCalEtA_Qny(m_nHarmonic,0);
87 std::vector<float> HalfFCalEtC_Qnx(m_nHarmonic,0);
88 std::vector<float> HalfFCalEtC_Qny(m_nHarmonic,0);
89
90 // Set up the decorators for FCal Et
91 SG::AuxElement::Decorator< float > decFCalEtA("FCalEtA");
92 SG::AuxElement::Decorator< float > decFCalEtC("FCalEtC");
93
94 SG::AuxElement::Decorator< float > decHalfFCalEtA("HalfFCalEtA");
95 SG::AuxElement::Decorator< float > decHalfFCalEtC("HalfFCalEtC");
96
97 //Retrieve HIEventShape
99 if (!eventShape.isValid()){
100 ATH_MSG_ERROR ("Cannot retrieve HIEventShape");
101 return StatusCode::FAILURE;
102 }
103
104 //Calculate FCal A and FCal C sums
105 for(const auto* ptrEvtShp : *eventShape){
106 if(ptrEvtShp->layer()!=21 && ptrEvtShp->layer()!=22 &&
107 ptrEvtShp->layer()!=23) continue;
108
109 float eta = ptrEvtShp->etaMin();
110 const std::vector<float>&c1 = ptrEvtShp->etCos();
111 const std::vector<float>&s1 = ptrEvtShp->etSin();
112
113 if (eta > 0) {
114 FCalEtA += ptrEvtShp->et();
115 for (int vn = 1; vn <= m_nHarmonic; ++vn){
116 FCalEtA_Qnx.at(vn-1) += c1.at(vn);
117 FCalEtA_Qny.at(vn-1) += s1.at(vn);
118 }
119 if(eta > 4.0) {
120 HalfFCalEtA += ptrEvtShp->et();
121 for (int vn = 1; vn <= m_nHarmonic; ++vn){
122 HalfFCalEtA_Qnx.at(vn-1) += c1.at(vn);
123 HalfFCalEtA_Qny.at(vn-1) += s1.at(vn);
124 }
125 }
126 } else if (eta < 0) {
127 FCalEtC += ptrEvtShp->et();
128 for (int vn = 1; vn <= m_nHarmonic; ++vn){
129 FCalEtC_Qnx.at(vn-1) += c1.at(vn);
130 FCalEtC_Qny.at(vn-1) += s1.at(vn);
131 }
132 if(eta < -4.0){
133 HalfFCalEtC += ptrEvtShp->et();
134 for (int vn = 1; vn <= m_nHarmonic; ++vn){
135 HalfFCalEtC_Qnx.at(vn-1) += c1.at(vn);
136 HalfFCalEtC_Qny.at(vn-1) += s1.at(vn);
137 }
138 }
139 }
140 }
141
142 if (m_doTopoClusDec) {
143 // Setup the decorator for TopoCaloCluster cut
144 // If this is true, the event is not compatible with UPC topologies in the FCal
145 SG::AuxElement::Decorator< bool > decTopoClusterFCalCut("passUPCTopoCaloCut");
146 //Default decoration set to false
147 decTopoClusterFCalCut(*eventInfo) = false;
148
149 //access topoClusters
151 bool hasTowerA{false};
152 bool hasTowerC{false};
153 for (const auto topo : *topos) {
154 float topo_eta = topo->eta();
155 if (abs(topo_eta) > 3.2 && abs(topo_eta) < 4.9) {
156 float topo_pt = topo->pt() * 1e-3;
157 if (topo_pt > 0.4) {
158 if (topo_eta > 0) {
159 hasTowerA = true;
160 } else {
161 hasTowerC = true;
162 }
163 }
164 }
165 }
166 //decorate
167 decTopoClusterFCalCut(*eventInfo) = (hasTowerA && hasTowerC);
168 }
169
170
171 //decorate
172 decFCalEtA(*eventInfo) = FCalEtA;
173 decFCalEtC(*eventInfo) = FCalEtC;
174 decHalfFCalEtA(*eventInfo) = HalfFCalEtA;
175 decHalfFCalEtC(*eventInfo) = HalfFCalEtC;
176
177 for (int vn = 0; vn < m_nHarmonic; ++vn){
178 (m_decFCalEtA_Qnx[vn])(*eventInfo) = FCalEtA_Qnx.at(vn);
179 (m_decFCalEtA_Qny[vn])(*eventInfo) = FCalEtA_Qny.at(vn);
180 (m_decFCalEtC_Qnx[vn])(*eventInfo) = FCalEtC_Qnx.at(vn);
181 (m_decFCalEtC_Qny[vn])(*eventInfo) = FCalEtC_Qny.at(vn);
182 (m_decHalfFCalEtA_Qnx[vn])(*eventInfo) = HalfFCalEtA_Qnx.at(vn);
183 (m_decHalfFCalEtA_Qny[vn])(*eventInfo) = HalfFCalEtA_Qny.at(vn);
184 (m_decHalfFCalEtC_Qnx[vn])(*eventInfo) = HalfFCalEtC_Qnx.at(vn);
185 (m_decHalfFCalEtC_Qny[vn])(*eventInfo) = HalfFCalEtC_Qny.at(vn);
186 }
187
188 return StatusCode::SUCCESS;
189 }
190
191}
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtC_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtA_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtA_Qnx
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClusterKey
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtC_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtC_Qnx
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_eventShapeKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TP_key
Gaudi::Property< std::vector< std::string > > m_cutLevels
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtC_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtA_Qny
std::vector< SG::AuxElement::Decorator< int > > m_decTrack_count
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
PublicToolHandleArray< InDet::IInDetTrackSelectionTool > m_trkSelTools
track selection tool which can be optionally used for N_trk and sum pt cuts
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtA_Qny
virtual StatusCode addBranches(const EventContext &ctx) const override final
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:575
virtual bool isValid() override final
Can the handle be successfully dereferenced?
THE reconstruction tool.