ATLAS Offline Software
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 
5 #include "FastHitConvertTool.h"
6 
7 #include "GaudiKernel/ConcurrencyFlags.h"
8 
15 #include "CaloIdentifier/TileID.h"
19 #include "LArSimEvent/LArHit.h"
23 #include "TileSimEvent/TileHit.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
64 
67 
68  ATH_CHECK( m_tileCablingSvc.retrieve() );
69  m_tileCabling = m_tileCablingSvc->cablingService();
70 
71  // Output keys
76  ATH_CHECK(m_tileHitVectorKey.initialize());
77 
78  return StatusCode::SUCCESS;
79 }
80 
81 StatusCode 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 
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 
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
TileSamplingFraction::getSamplingFraction
float getSamplingFraction(unsigned int drawerIdx, unsigned int channel) const
Return Tile Calorimeter sampling fraction.
Definition: TileSamplingFraction.h:53
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:46
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
LArEM_ID.h
FastHitConvertTool::process
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
standard Athena-Algorithm method
Definition: FastHitConvertTool.cxx:81
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
AthCheckMacros.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
FastHitConvertTool::m_larEmID
const LArEM_ID * m_larEmID
Definition: FastHitConvertTool.h:80
AtlasDetectorID::is_lar_fcal
bool is_lar_fcal(Identifier id) const
Definition: AtlasDetectorID.h:839
FastHitConvertTool::initialize
virtual StatusCode initialize() override final
standard Athena-Algorithm method
Definition: FastHitConvertTool.cxx:44
FastHitConvertTool.h
FastHitConvertTool::m_embHitContainerKey
SG::WriteHandleKey< LArHitContainer > m_embHitContainerKey
Definition: FastHitConvertTool.h:60
CaloIdManager::getEM_ID
const LArEM_ID * getEM_ID(void) const
Definition: CaloIdManager.cxx:80
CaloCellContainer::beginConstCalo
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
Definition: CaloCellContainer.cxx:119
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
FastHitConvertTool::m_fcalHitContainerKey
SG::WriteHandleKey< LArHitContainer > m_fcalHitContainerKey
Definition: FastHitConvertTool.h:62
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:46
FastHitConvertTool::m_hecHitContainerKey
SG::WriteHandleKey< LArHitContainer > m_hecHitContainerKey
Definition: FastHitConvertTool.h:63
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LArHEC_ID.h
LArHitFloatContainer.h
HWIdentifier
Definition: HWIdentifier.h:13
FastHitConvertTool::m_tileSamplingFractionKey
SG::ReadCondHandleKey< TileSamplingFraction > m_tileSamplingFractionKey
Name of TileSamplingFraction in condition store.
Definition: FastHitConvertTool.h:71
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
TileID.h
FastHitConvertTool::FastHitConvertTool
FastHitConvertTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: FastHitConvertTool.cxx:28
FastHitConvertTool::m_tileHitVectorKey
SG::WriteHandleKey< TileHitVector > m_tileHitVectorKey
Definition: FastHitConvertTool.h:64
CaloIdManager::getTileID
const TileID * getTileID(void) const
Definition: CaloIdManager.cxx:100
CaloIdManager::getHEC_ID
const LArHEC_ID * getHEC_ID(void) const
Definition: CaloIdManager.cxx:95
TileHWID.h
Tile_Base_ID::is_tile_gapscin
bool is_tile_gapscin(const Identifier &id) const
Definition: Tile_Base_ID.cxx:268
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
CaloIdManager
This class initializes the Calo (LAr and Tile) offline identifiers.
Definition: CaloIdManager.h:45
DetDescrDictionaryDict::it1
std::vector< HWIdentifier >::iterator it1
Definition: DetDescrDictionaryDict.h:17
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
FastHitConvertTool::m_tileHWID
const TileHWID * m_tileHWID
Definition: FastHitConvertTool.h:84
ILArfSampl::FSAMPL
virtual const float & FSAMPL(const HWIdentifier &id) const =0
CaloIdManager::getFCAL_ID
const LArFCAL_ID * getFCAL_ID(void) const
Definition: CaloIdManager.cxx:85
createCoolChannelIdFile.channel_id
channel_id
Definition: createCoolChannelIdFile.py:52
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
AtlasDetectorID::is_tile
bool is_tile(Identifier id) const
Definition: AtlasDetectorID.h:695
AtlasDetectorID::is_lar_hec
bool is_lar_hec(Identifier id) const
Definition: AtlasDetectorID.h:829
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
LArHitFloat.h
FastHitConvertTool::m_tileCabling
const TileCablingService * m_tileCabling
Definition: FastHitConvertTool.h:85
FastHitConvertTool::m_larFcalID
const LArFCAL_ID * m_larFcalID
Definition: FastHitConvertTool.h:81
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
TileHitVector.h
TileHit.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TileHWID::drawerIdx
int drawerIdx(const HWIdentifier &id) const
construct drawer index from HW identifier
Definition: TileHWID.h:175
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TileHit
Definition: TileSimEvent/TileSimEvent/TileHit.h:30
LArHit
Class to store hit energy and time in LAr cell from G4 simulation.
Definition: LArHit.h:25
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
LArFCAL_ID.h
LArHit.h
FastHitConvertTool::m_tileID
const TileID * m_tileID
Definition: FastHitConvertTool.h:83
FastHitConvertTool::m_emecHitContainerKey
SG::WriteHandleKey< LArHitContainer > m_emecHitContainerKey
Definition: FastHitConvertTool.h:61
LArEM_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
LArHitContainer.h
Tile_Base_ID::pmt_id
Identifier pmt_id(const Identifier &any_id) const
Definition: Tile_Base_ID.cxx:640
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloCellContainer::endConstCalo
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
Definition: CaloCellContainer.cxx:133
FastHitConvertTool::m_tileCablingSvc
ServiceHandle< TileCablingSvc > m_tileCablingSvc
Name of Tile cabling service.
Definition: FastHitConvertTool.h:77
CaloIdManager.h
hitTime
float hitTime(const AFP_SIDSimHit &hit)
Definition: AFP_SIDSimHit.h:39
FastHitConvertTool::m_larHecID
const LArHEC_ID * m_larHecID
Definition: FastHitConvertTool.h:82
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
checker_macros.h
Define macros for attributes used to control the static checker.
FastHitConvertTool::m_fSamplKey
SG::ReadCondHandleKey< ILArfSampl > m_fSamplKey
Definition: FastHitConvertTool.h:66
AtlasDetectorID::is_lar_em
bool is_lar_em(Identifier id) const
Definition: AtlasDetectorID.h:818
LArEM_Base_ID::is_em_endcap
bool is_em_endcap(const Identifier id) const
test if the id belongs to the EM Endcap
ILArfSampl
Definition: ILArfSampl.h:14
TileCablingService::s2h_channel_id
HWIdentifier s2h_channel_id(const Identifier &id) const
Definition: TileCablingService.cxx:1076
TileCellContainer.h
Identifier
Definition: IdentifierFieldParser.cxx:14