ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcMCTruthAlg.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
10
11ZdcMCTruthAlg::ZdcMCTruthAlg(const std::string& name, ISvcLocator* pSvcLocator)
12 : AthAlgorithm(name, pSvcLocator),
13 m_zdcID(nullptr)
14{
15
16}
17
18
21
22
25{
26 ATH_MSG_INFO("Initializing " << name());
27
28 if (detStore()->retrieve( m_zdcID ).isFailure() ) {
29 ATH_MSG_ERROR("execute: Could not retrieve ZdcID object from the detector store");
30 return StatusCode::FAILURE;
31 }else{
32 ATH_MSG_DEBUG("execute: retrieved ZdcID");
33 }
34
35 //Initialize input hit container read handles
37
38 //Initialize output ZdcModuleContainer read handles
39 m_zdcModuleContainerName = "ZdcModules";
40 m_zdcSumContainerName = "ZdcSums";
41
42 //Per module AuxDecor handles
53
54 //RPD decorations required for processing
60 ATH_CHECK( m_rpdTileRowNumber.initialize());
62 ATH_CHECK( m_rpdTileColumnNumber.initialize());
63
64 //Sums container auxDecor handles
70 ATH_CHECK( m_zdcSumTruthEMEnergy.initialize());
74 ATH_CHECK( m_zdcSumTruthEscEnergy.initialize());
75
76 return StatusCode::SUCCESS;
77}
78
80{
81
82 /******************************************
83 * Get the CaloCalibrationHitContainer (input)
84 ******************************************/
86 if (!calibHitContainer.isValid()) {
87 ATH_MSG_ERROR("Could not get Calibration hit container " << calibHitContainer.name() << " from store " << calibHitContainer.store());
88 return StatusCode::FAILURE;
89 }
90
91 ATH_MSG_DEBUG ("--> ZDC: ZdcMCTruthAlg execute starting on "
92 << getContext().evt()
93 << "th event");
94
95 /******************************************
96 * Get the ZdcModuleContainer and
97 * ZdcModuleSumContainer (output)
98 ******************************************/
99 xAOD::ZdcModuleContainer const* moduleContainer = nullptr;
100 ATH_CHECK(evtStore()->retrieve(moduleContainer, m_zdcModuleContainerName));
101
102 xAOD::ZdcModuleContainer const* moduleSumContainer = nullptr;
103 ATH_CHECK(evtStore()->retrieve(moduleSumContainer, m_zdcSumContainerName));
104
105 //Create local variables to hold the per module and per side sums
106 float totalMod[2][7]={{0.0},{0.0}}, invisMod[2][7]={{0.0},{0.0}}, emMod[2][7]={{0.0},{0.0}}, nonEMMod[2][7]={{0.0},{0.0}}, escMod[2][7]={{0.0},{0.0}};
107 float totalSide[2]={0.0}, invisSide[2]={0.0}, emSide[2]={0.0}, nonEMSide[2]={0.0}, escSide[2]={0.0};
108 bool foundMod[2][7] = {{false},{false}};
109
110 /******************************************
111 * Sum all hits in each module
112 ******************************************/
113 for (const auto hit : *calibHitContainer){
114 Identifier id = hit->cellID();
115 int side = (m_zdcID->side(id) > 0) ? 1 : 0;
116 int mod = m_zdcID->module(id);
117
118 emMod[side][mod] += hit->energyEM();
119 nonEMMod[side][mod] += hit->energyNonEM();
120 invisMod[side][mod] += hit->energyInvisible();
121 totalMod[side][mod] += hit->energyTotal();
122 escMod[side][mod] += hit->energyEscaped();
123 }
124
125 /******************************************
126 * Decorate the ZdcModuleContainer with the
127 * per module sums and add the per module
128 * sums to the per side sums
129 ******************************************/
139 for (const auto zdcModule : *moduleContainer){
140 if(zdcModule->zdcSide() == 0) continue;
141 int side = (zdcModule->zdcSide() > 0) ? 1 : 0;
142 int mod = zdcModule->zdcModule();
143 foundMod[side][mod] = true;
144
145 //Add row/column info for RPD processing
146 if(mod == 4){
147 int lucrodId = (side == 0) ? 4 : 2;
148 int rpdChannel = zdcModule->zdcChannel();
149 int lucrodChannel = rpdChannel%8;
150 if(rpdChannel > 7)
151 lucrodId ++;
152
153 ATH_MSG_DEBUG("Accessing LUCROD ID " << lucrodId <<
154 ", lucrodChannel=" << lucrodChannel <<
155 " for RPD side " << zdcModule->zdcSide() <<
156 ", channel " << rpdChannel);
157
158 float xpos = ZdcLucrodMapRun3::getInstance()->getLucrod(lucrodId)["x"][lucrodChannel];
159 float ypos = ZdcLucrodMapRun3::getInstance()->getLucrod(lucrodId)["y"][lucrodChannel];
160 unsigned int row = ZdcLucrodMapRun3::getInstance()->getLucrod(lucrodId)["row"][lucrodChannel];
161 unsigned int col = ZdcLucrodMapRun3::getInstance()->getLucrod(lucrodId)["col"][lucrodChannel];
162 rpdTileXpositionRelative(*zdcModule) = xpos;
163 rpdTileYpositionRelative(*zdcModule) = ypos;
164 rpdTileRowNumber (*zdcModule) = row;
165 rpdTileColumnNumber (*zdcModule) = col;
166 }
167
168 //Only save RPD truth in channel 0
169 if(mod == 4 && zdcModule->zdcChannel() != 0) continue;
170
171 zdcModuleTruthTotalEnergy(*zdcModule) = totalMod[side][mod];
172 zdcModuleTruthInvisEnergy(*zdcModule) = invisMod[side][mod];
173 zdcModuleTruthEMEnergy (*zdcModule) = emMod [side][mod];
174 zdcModuleTruthNonEMEnergy(*zdcModule) = nonEMMod[side][mod];
175 zdcModuleTruthEscEnergy (*zdcModule) = escMod [side][mod];
176
177 totalSide[side] += totalMod[side][mod];
178 invisSide[side] += invisMod[side][mod];
179 emSide[side] += emMod [side][mod];
180 nonEMSide[side] += nonEMMod[side][mod];
181 escSide[side] += escMod [side][mod];
182 }
183
184 for(int iside : {0,1}){
185 for(int mod = 0; mod < 7; ++mod){
186 ATH_MSG_DEBUG("ZDC " << iside << ":" << mod << " total energy = " << totalMod[iside][mod]);
187 if(!foundMod[iside][mod]){
188 ATH_MSG_DEBUG("Failed to find " << iside << ":" << mod);
189 }
190 }
191 }
192
193 ATH_MSG_DEBUG("ZDC A total energy = " << totalSide[1] <<
194 ", invisible energy = " << invisSide[1] <<
195 ", EM energy = " << emSide[1] <<
196 ", non EM energy = " << nonEMSide[1] <<
197 ", escaped energy = " << escSide[1]);
198
199 ATH_MSG_DEBUG("ZDC C total energy = " << totalSide[0] <<
200 ", invisible energy = " << invisSide[0] <<
201 ", EM energy = " << emSide[0] <<
202 ", non EM energy = " << nonEMSide[0] <<
203 ", escaped energy = " << escSide[0]);
204
205
206 /******************************************
207 * Decorate the Sums container with the
208 * per side sums
209 ******************************************/
215 for (const auto zdcSum : *moduleSumContainer){
216 if (zdcSum->zdcSide() == 0) continue;
217 int side = (zdcSum->zdcSide()==-1) ? 0 : 1;
218 ATH_MSG_DEBUG("Filling zdcSum container side " << side);
219
220 zdcSumTruthTotalEnergy(*zdcSum) = totalSide[side];
221 zdcSumTruthInvisEnergy(*zdcSum) = invisSide[side];
222 zdcSumTruthEMEnergy (*zdcSum) = emSide [side];
223 zdcSumTruthNonEMEnergy(*zdcSum) = nonEMSide[side];
224 zdcSumTruthEscEnergy (*zdcSum) = escSide [side];
225 }
226
227 return StatusCode::SUCCESS;
228}
229
230
232{
233 ATH_MSG_DEBUG( "--> ZDC: ZdcMCTruthAlg finalize complete" );
234
235 return StatusCode::SUCCESS;
236}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Handle class for adding a decoration to an object.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::string store() const
Return the name of the store holding the object we are proxying.
const std::string & name() const
Return the StoreGate ID for the referenced object.
Handle class for adding a decoration to an object.
static const ZdcLucrodMapRun3 * getInstance()
const nlohmann::json & getLucrod(int i) const
StatusCode finalize()
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleTruthInvisEnergy
ZdcMCTruthAlg(const std::string &name, ISvcLocator *pSvcLocator)
std::string m_zdcModuleContainerName
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_rpdTileColumnNumber
const ZdcID * m_zdcID
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleTruthTotalEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_rpdTileYpositionRelative
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleTruthEMEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleTruthEscEnergy
virtual ~ZdcMCTruthAlg()
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_rpdTileXpositionRelative
Gaudi::Property< std::string > m_auxSuffix
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumTruthInvisEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_rpdTileRowNumber
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumTruthEMEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumTruthTotalEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumTruthEscEnergy
SG::ReadHandleKey< CaloCalibrationHitContainer > m_CaloCalibrationHitContainerKey
std::string m_zdcSumContainerName
StatusCode initialize()
StatusCode execute()
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcSumTruthNonEMEnergy
SG::WriteDecorHandleKey< xAOD::ZdcModuleContainer > m_zdcModuleTruthNonEMEnergy
ZdcModuleContainer_v1 ZdcModuleContainer