ATLAS Offline Software
Loading...
Searching...
No Matches
LArMCSymCondAlg.cxx
Go to the documentation of this file.
1//dear emacs, this is -*-c++-*-
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
7#include "LArMCSymCondAlg.h"
12#include <cmath> //std::abs
13
14
16
17 ATH_MSG_DEBUG("initializing");
18
19 // Read Handles
20 ATH_CHECK( m_readKey.initialize() );
21 ATH_CHECK( m_writeKey.initialize() );
22
23 return StatusCode::SUCCESS;
24}
25
26
27StatusCode LArMCSymCondAlg::execute(const EventContext& ctx) const {
28
30
31 if (writeHandle.isValid()) {
32 ATH_MSG_DEBUG("Found valid write handle");
33 return StatusCode::SUCCESS;
34 }
35
37 const LArOnOffIdMapping* cabling{*readHandle};
38
39 if (cabling==nullptr) {
40 ATH_MSG_ERROR("Failed to retrieve CondAttributeListCollection with key " << m_readKey.key());
41 return StatusCode::FAILURE;
42 }
43 writeHandle.addDependency(readHandle);
44
45 const LArOnlineID_Base *larOnlineID=nullptr;
46 const CaloCell_Base_ID *caloCellID=nullptr;
47 if(m_isSC){
48 const LArOnline_SuperCellID *ll;
49 ATH_CHECK(detStore()->retrieve(ll,"LArOnline_SuperCellID"));
50 larOnlineID=static_cast<const LArOnlineID_Base*>(ll);
51 const CaloCell_SuperCell_ID *cal;
52 ATH_CHECK(detStore()->retrieve(cal,"CaloCell_SuperCell_ID"));
53 caloCellID=static_cast<const CaloCell_Base_ID *>(cal);
54 } else {
55 const LArOnlineID *ll;
56 ATH_CHECK(detStore()->retrieve(ll,"LArOnlineID"));
57 larOnlineID=static_cast<const LArOnlineID_Base*>(ll);
58 const CaloCell_ID *cal;
59 ATH_CHECK(detStore()->retrieve(cal,"CaloCell_ID"));
60 caloCellID=static_cast<const CaloCell_Base_ID *>(cal);
61 }
62
63 const LArEM_Base_ID* lar_em_id=caloCellID->em_idHelper();
64 const LArHEC_Base_ID* lar_hec_id=caloCellID->hec_idHelper();
65 const LArFCAL_Base_ID* lar_fcal_id=caloCellID->fcal_idHelper();
66
67 const unsigned ncellem=lar_em_id->channel_hash_max();
68 const unsigned ncellhec=lar_hec_id->channel_hash_max();
69 const unsigned ncellfcal=lar_fcal_id->channel_hash_max();
70
71 const unsigned larHashMax=ncellem+ncellhec+ncellfcal;
72
73 const unsigned onlHashMax=larOnlineID->channelHashMax();
74
75 std::vector<HWIdentifier> oflHashtoSymOnl(larHashMax);
76 std::vector<HWIdentifier> onlHashtoSymOnl(onlHashMax);
77
78 std::set<HWIdentifier> symIds;
79
80 ATH_MSG_DEBUG("Start looping over EM calo cells");
81 for ( unsigned int idhash=0; idhash<ncellem;idhash++){
82 const Identifier id=lar_em_id->channel_id (idhash);
83 const HWIdentifier hwid=cabling->createSignalChannelID(id);
84 const IdentifierHash hwid_hash=larOnlineID->channel_Hash(hwid);
85 const int barrel_ec = std::abs( lar_em_id->barrel_ec(id) ) ;
86 const int sampling = lar_em_id->sampling(id);
87 const int region = lar_em_id->region(id);
88 const Identifier regId = lar_em_id->region_id(barrel_ec, sampling, region );
89 const int eta = lar_em_id->eta(id);
90 const int phi = lar_em_id->phi_min(regId);
91 const Identifier symOffId = lar_em_id->channel_id(barrel_ec, sampling, region, eta, phi );
92 const HWIdentifier symOnId = cabling->createSignalChannelID(symOffId);
93 const IdentifierHash idHash = lar_em_id->channel_hash(id);
94 oflHashtoSymOnl[idHash] = symOnId;
95 onlHashtoSymOnl[hwid_hash]= symOnId;
96 symIds.insert(symOnId);
97 }
98
99 ATH_MSG_DEBUG("start loop over HEC calo");
100
101 for ( unsigned int idhash=0; idhash<ncellhec;idhash++){
102 const Identifier id=lar_hec_id->channel_id (idhash);
103 const HWIdentifier hwid=cabling->createSignalChannelID(id);
104 const IdentifierHash hwid_hash=larOnlineID->channel_Hash(hwid);
105
106 const int pos_neg = std::abs( lar_hec_id->pos_neg(id) ) ;
107 const int sampling = lar_hec_id->sampling(id);
108 const int region = lar_hec_id->region(id);
109 const Identifier regId = lar_hec_id->region_id(pos_neg, sampling, region );
110 const int eta = lar_hec_id->eta(id);
111 const int phi = lar_hec_id->phi_min(regId);
112 const Identifier symOffId = lar_hec_id->channel_id(pos_neg, sampling, region, eta, phi );
113 const HWIdentifier symOnId = cabling->createSignalChannelID(symOffId);
114 const IdentifierHash idHash=lar_hec_id->channel_hash(id);
115 oflHashtoSymOnl[ncellem+idHash] = symOnId;
116 onlHashtoSymOnl[hwid_hash]= symOnId;
117 symIds.insert(symOnId);
118 }
119
120 ATH_MSG_DEBUG("start loop over FCAL calo");
121
122 const bool isTB= lar_fcal_id->dictionaryVersion() == "H6TestBeam";
123 for ( unsigned int idhash=0; idhash<lar_fcal_id->channel_hash_max();
124 idhash++){
125 const Identifier id=lar_fcal_id->channel_id (idhash);
126 const HWIdentifier hwid=cabling->createSignalChannelID(id);
127 const IdentifierHash hwid_hash=larOnlineID->channel_Hash(hwid);
128
129
130 const int pos_neg = std::abs( lar_fcal_id->pos_neg(id) ) ;
131 const int module = lar_fcal_id->module(id);
132
133// symmetry for FCAL: save all y>0 part of the +side module
134// y<0 side deduced by point symmetry around x=y=0
135 const int eta = lar_fcal_id->eta(id);
136 int phi = lar_fcal_id->phi(id);
137 if (!isTB) {
138 if (phi > 7) phi = phi-8;
139 }
140 Identifier symOffId = lar_fcal_id->channel_id(pos_neg, module, eta, phi );
141 HWIdentifier symOnId = cabling->createSignalChannelID(symOffId);
142 IdentifierHash idHash=lar_fcal_id->channel_hash(id);
143 oflHashtoSymOnl[ncellem+ncellhec+idHash] = symOnId;
144 onlHashtoSymOnl[hwid_hash]= symOnId;
145 symIds.insert(symOnId);
146 }
147
148
149 std::vector<HWIdentifier> symIdVec(symIds.begin(),symIds.end());
150 std::unique_ptr<LArMCSym> mcSym=std::make_unique<LArMCSym>(larOnlineID,caloCellID,
151 std::move(oflHashtoSymOnl),
152 std::move(onlHashtoSymOnl),
153 std::move(symIdVec));
154
155
156
157 if(writeHandle.record(std::move(mcSym)).isFailure()) {
158 ATH_MSG_ERROR("Could not record LArMCSym object with "
159 << writeHandle.key()
160 << " with EventRange " << writeHandle.getRange()
161 << " into Conditions Store");
162 return StatusCode::FAILURE;
163 }
164 ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
165
166
167 return StatusCode::SUCCESS;
168}
169
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#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)
Helper class for offline supercell identifiers.
const ServiceHandle< StoreGateSvc > & detStore() const
virtual std::string dictionaryVersion(void) const override
Helper base class for offline cell identifiers.
const LArFCAL_Base_ID * fcal_idHelper() const
access to FCAL idHelper
const LArHEC_Base_ID * hec_idHelper() const
access to HEC idHelper
const LArEM_Base_ID * em_idHelper() const
access to EM idHelper
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
Helper class for offline supercell identifiers.
size_type channel_hash_max() const
One more than the largest channel (cell) hash code.
This is a "hash" representation of an Identifier.
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
int region(const Identifier id) const
return region according to :
int eta(const Identifier id) const
return eta according to :
Identifier region_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
Identifier channel_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
int barrel_ec(const Identifier id) const
return barrel_ec according to :
int sampling(const Identifier id) const
return sampling according to :
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
int eta(const Identifier id) const
eta [0,63] module 1 ; [0,31] module 2 ; [0,15] module 3
IdentifierHash channel_hash(Identifier channelId) const
Convert a connected channel (cell) Identifier to a hash code.
int phi(const Identifier id) const
phi [0,15]
Identifier channel_id(const ExpandedIdentifier &exp_id) const
cell identifier for a channel from ExpandedIdentifier
int pos_neg(const Identifier id) const
pos_neg : +/- 2 (A/C side)
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
int region(const Identifier id) const
return region [0,1]
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
Identifier region_id(const ExpandedIdentifier &exp_id) const
region identifier for a channel from ExpandedIdentifier
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
int eta(const Identifier id) const
return eta [0,9] outer part [0,3] inner part
int pos_neg(const Identifier id) const
return pos_neg -2 (C side) or 2 (A side)
int sampling(const Identifier id) const
return sampling [0,3] (only 0 for supercells)
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
BooleanProperty m_isSC
SG::WriteCondHandleKey< LArMCSym > m_writeKey
StatusCode initialize()
SG::ReadCondHandleKey< LArOnOffIdMapping > m_readKey
StatusCode execute(const EventContext &ctx) const
Helper for the Liquid Argon Calorimeter cell identifiers.
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
size_type channelHashMax() const
Define channel hash tables max size.
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED