ATLAS Offline Software
Loading...
Searching...
No Matches
FastHitConvertTool.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
7#include "GaudiKernel/ConcurrencyFlags.h"
8
19#include "LArSimEvent/LArHit.h"
25
26//================ Constructor =================================================
27
29 const std::string& name,
30 const IInterface* parent )
31 :
32 base_class(type,name,parent)
33{
34}
35
36//================ Destructor =================================================
37
38// FastHitConvertTool::~FastHitConvertTool()
39//{}
40
41
42//================ Initialisation =================================================
43
45{
46
47 const CaloIdManager* caloIdManager = nullptr;
48 CHECK(detStore()->retrieve(caloIdManager));
49 m_larEmID=caloIdManager->getEM_ID();
50 if(m_larEmID==0)
51 throw std::runtime_error("FastHitConvertTool: Invalid LAr EM ID helper");
52 m_larFcalID=caloIdManager->getFCAL_ID();
53 if(m_larFcalID==0)
54 throw std::runtime_error("FastHitConvertTool: Invalid FCAL ID helper");
55 m_larHecID=caloIdManager->getHEC_ID();
56 if(m_larHecID==0)
57 throw std::runtime_error("FastHitConvertTool: Invalid HEC ID helper");
58 m_tileID=caloIdManager->getTileID();
59 if(m_tileID==0)
60 throw std::runtime_error("FastHitConvertTool: Invalid Tile ID helper");
61
62 // LAr and Tile Sampling Fractions
63 ATH_CHECK(m_fSamplKey.initialize());
64
65 ATH_CHECK(detStore()->retrieve(m_tileHWID));
67
68 ATH_CHECK( m_tileCablingSvc.retrieve() );
69 m_tileCabling = m_tileCablingSvc->cablingService();
70
71 // Output keys
72 ATH_CHECK(m_embHitContainerKey.initialize());
73 ATH_CHECK(m_emecHitContainerKey.initialize());
74 ATH_CHECK(m_fcalHitContainerKey.initialize());
75 ATH_CHECK(m_hecHitContainerKey.initialize());
76 ATH_CHECK(m_tileHitVectorKey.initialize());
77
78 return StatusCode::SUCCESS;
79}
80
81StatusCode FastHitConvertTool::process(CaloCellContainer* theCellCont, const EventContext& ctx) const
82{
83 ATH_MSG_DEBUG("initEvent()");
84 auto embHitContainer = SG::makeHandle<LArHitContainer>( m_embHitContainerKey, ctx );
85 auto emecHitContainer = SG::makeHandle<LArHitContainer>( m_emecHitContainerKey, ctx );
86 auto fcalHitContainer = SG::makeHandle<LArHitContainer>( m_fcalHitContainerKey, ctx );
87 auto hecHitContainer = SG::makeHandle<LArHitContainer>( m_hecHitContainerKey, ctx );
88 auto tileHitVector = SG::makeHandle<TileHitVector>( m_tileHitVectorKey, ctx );
89 embHitContainer = std::make_unique<LArHitContainer>( m_embHitContainerKey.key() );
90 emecHitContainer = std::make_unique<LArHitContainer>( m_emecHitContainerKey.key() );
91 fcalHitContainer = std::make_unique<LArHitContainer>( m_fcalHitContainerKey.key() );
92 hecHitContainer = std::make_unique<LArHitContainer>( m_hecHitContainerKey.key() );
93 tileHitVector = std::make_unique<TileHitVector>( m_tileHitVectorKey.key() );
94
95 ATH_MSG_DEBUG("ATLFASTIIDigi "<<this->name()<<" hitConstruction");
96 const double minEnergy=1e-9;
97 double hitTime=0.0;
98 Identifier cellid((unsigned int) 0);
99 double energy=0.0;
100 double energyConv=0.0;
101 float SampFrac=0.0;
102
103 int countFastCell=0;
104
105 double eLArEMRead=0.0;
106 double eLArHECRead=0.0;
107 double eLArFCALRead=0.0;
108 double eTileRead=0.0;
109
110 double eLArEMConv=0.0;
111 double eLArHECConv=0.0;
112 double eLArFCALConv=0.0;
113 double eTileConv=0.0;
114
116 const ILArfSampl* fSampl=*fSamplHdl;
117
120 for(;it1!=it2;++it1)
121 {
122 ATH_MSG_DEBUG("FastCell LArEM"<<countFastCell);
123
124 cellid=(*it1)->ID();
125 energy=(*it1)->energy();
126 SampFrac=fSampl->FSAMPL(cellid);
127 energyConv=energy*SampFrac;
128
129 eLArEMRead+=energy;
130 eLArEMConv+=energyConv;
131
132 ATH_MSG_DEBUG("ReadFastCell id= "<<cellid<<"E= "<<energy<<" SampFrac= "<<SampFrac);
133 if(energyConv > minEnergy)
134 {
135 if(m_larEmID->is_lar_em(cellid))
136 {
137 if(m_larEmID->is_em_barrel(cellid))
138 {
139 ATH_MSG_DEBUG("Storing em barrel hit");
140 embHitContainer->push_back(new LArHit(cellid,energyConv,hitTime));
141 }
142 else if(m_larEmID->is_em_endcap(cellid))
143 {
144 ATH_MSG_DEBUG("Storing em endcap hit");
145 emecHitContainer->push_back(new LArHit(cellid,energyConv,hitTime));
146 }
147 }
148 }
149 countFastCell++;
150 }
151
152 it1=theCellCont->beginConstCalo(CaloCell_ID::LARHEC);
153 it2=theCellCont->endConstCalo(CaloCell_ID::LARHEC);
154
155 countFastCell=0;
156 for(;it1!=it2;++it1)
157 {
158 ATH_MSG_DEBUG("FastCell LArHEC"<<countFastCell);
159
160 cellid=(*it1)->ID();
161 energy=(*it1)->energy();
162 SampFrac=fSampl->FSAMPL(cellid);
163 energyConv=energy*SampFrac;
164
165 eLArHECRead+=energy;
166 eLArHECConv+=energyConv;
167
168 ATH_MSG_DEBUG("ReadFastCell id= "<<cellid<<"E= "<<energy<<"SampFrac= "<<SampFrac);
169
170 if(energyConv>minEnergy)
171 {
172 if(m_larHecID->is_lar_hec(cellid))
173 {
174 ATH_MSG_DEBUG("Storing hec hit");
175 hecHitContainer->push_back(new LArHit(cellid,energyConv,hitTime));
176 }
177 }
178 countFastCell++;
179 }
180
181 it1=theCellCont->beginConstCalo(CaloCell_ID::LARFCAL);
182 it2=theCellCont->endConstCalo(CaloCell_ID::LARFCAL);
183 countFastCell=0;
184 for(;it1!=it2;++it1)
185 {
186 ATH_MSG_DEBUG("FastCell LArFCAL"<<countFastCell);
187 cellid=(*it1)->ID();
188 energy=(*it1)->energy();
189 SampFrac=fSampl->FSAMPL(cellid);
190 energyConv=energy*SampFrac;
191
192 eLArHECRead+=energy;
193 eLArHECConv+=energyConv;
194
195 ATH_MSG_DEBUG("ReadFastCell id= "<<cellid<<"E="<<energy<<"SampFrac="<<SampFrac);
196 if(energyConv>minEnergy)
197 {
198 if(m_larFcalID->is_lar_fcal(cellid))
199 {
200 ATH_MSG_DEBUG("Storing fcal hit");
201 fcalHitContainer->push_back(new LArHit(cellid,energyConv,hitTime));
202 }
203 }
204 countFastCell++;
205 }
206
208 ATH_CHECK( tileSamplingFraction.isValid() );
209
210 it1=theCellCont->beginConstCalo(CaloCell_ID::TILE);
211 it2=theCellCont->endConstCalo(CaloCell_ID::TILE);
212
213 countFastCell=0;
214 Identifier pmt_id0((unsigned int) 0);
215 Identifier pmt_id1((unsigned int) 0);
216
217 for(;it1!=it2;++it1)
218 {
219 ATH_MSG_DEBUG("FastCell Tile Cal"<<countFastCell);
220 cellid=(*it1)->ID();
221 energy=(*it1)->energy();
222
223 pmt_id0=m_tileID->pmt_id(cellid,0);
224 pmt_id1=m_tileID->pmt_id(cellid,1);
225
226 HWIdentifier channel_id = m_tileCabling->s2h_channel_id(pmt_id0);
227 int channel = m_tileHWID->channel(channel_id);
228 int drawerIdx = m_tileHWID->drawerIdx(channel_id);
229 SampFrac = tileSamplingFraction->getSamplingFraction(drawerIdx, channel);
230 energyConv=energy/SampFrac;
231
232 eTileRead+=energy;
233 eTileConv+=energyConv;
234
235 ATH_MSG_DEBUG("ReadFastCell id= "<<cellid<<"E="<<energy<<"SampFrac"<<SampFrac);
236 ATH_MSG_DEBUG("PMT_id0="<<pmt_id0<<"PMT_id1="<<pmt_id1);
237 if(energyConv>minEnergy)
238 {
239 if(m_tileID->is_tile(cellid))
240 {
241 ATH_MSG_DEBUG("Storing tile hit");
242 if(m_tileID->is_tile_gapscin(cellid))
243 {
244 tileHitVector->push_back(TileHit(pmt_id0,energyConv,hitTime));
245 }
246 else
247 {
248 tileHitVector->push_back(TileHit(pmt_id0,energyConv/2.0,hitTime));
249 tileHitVector->push_back(TileHit(pmt_id1,energyConv/2.0,hitTime));
250 }
251 }
252 }
253 countFastCell++;
254 }
255 ATH_MSG_DEBUG("eReadTot= "<<eLArEMRead+eLArHECRead+eLArFCALRead+eTileRead);
256 ATH_MSG_DEBUG("eLArEMRead= "<<eLArEMRead<<" eLArHECRead= "<<eLArHECRead<<" eLArFCALRead= "<<eLArFCALRead<<" eTileRead= "<<eTileRead);
257 ATH_MSG_DEBUG("eConvTot= "<<eLArEMConv+eLArHECConv+eLArFCALConv+eTileConv);
258 ATH_MSG_DEBUG("eLArEMConv= "<<eLArEMConv<<" eLArHECConv= "<<eLArHECConv<<"eLArFCALConv"<<eLArFCALConv<<"eTileConv"<<eTileConv);
259
260 ATH_MSG_DEBUG("finaliseEvent()");
261 ATH_MSG_DEBUG(embHitContainer.name()<<" : "<<embHitContainer->size()<<" hits ");
262 ATH_MSG_DEBUG(emecHitContainer.name()<<" : "<<emecHitContainer->size()<<" hits ");
263 ATH_MSG_DEBUG(fcalHitContainer.name()<<" : "<<fcalHitContainer->size()<<" hits ");
264 ATH_MSG_DEBUG(hecHitContainer.name()<<" : "<<hecHitContainer->size()<<" hits ");
265 ATH_MSG_DEBUG(tileHitVector.name()<<" : "<<tileHitVector->size()<<" hits ");
266
267 return StatusCode::SUCCESS;
268}
float hitTime(const AFP_SIDSimHit &hit)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Define macros for attributes used to control the static checker.
Container class for CaloCell.
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
This class initializes the Calo (LAr and Tile) offline identifiers.
const TileID * getTileID(void) const
const LArHEC_ID * getHEC_ID(void) const
const LArFCAL_ID * getFCAL_ID(void) const
const LArEM_ID * getEM_ID(void) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
standard Athena-Algorithm method
const TileID * m_tileID
SG::ReadCondHandleKey< TileSamplingFraction > m_tileSamplingFractionKey
Name of TileSamplingFraction in condition store.
const LArFCAL_ID * m_larFcalID
SG::WriteHandleKey< LArHitContainer > m_hecHitContainerKey
const LArHEC_ID * m_larHecID
SG::WriteHandleKey< LArHitContainer > m_embHitContainerKey
SG::WriteHandleKey< LArHitContainer > m_emecHitContainerKey
FastHitConvertTool(const std::string &type, const std::string &name, const IInterface *parent)
const TileHWID * m_tileHWID
SG::ReadCondHandleKey< ILArfSampl > m_fSamplKey
SG::WriteHandleKey< TileHitVector > m_tileHitVectorKey
virtual StatusCode initialize() override final
standard Athena-Algorithm method
const TileCablingService * m_tileCabling
ServiceHandle< TileCablingSvc > m_tileCablingSvc
Name of Tile cabling service.
SG::WriteHandleKey< LArHitContainer > m_fcalHitContainerKey
const LArEM_ID * m_larEmID
virtual const float & FSAMPL(const HWIdentifier &id) const =0
Class to store hit energy and time in LAr cell from G4 simulation.
Definition LArHit.h:25
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())