ATLAS Offline Software
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
22 
23  return StatusCode::SUCCESS;
24 }
25 
26 
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){
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 
LArMCSymCondAlg::m_isSC
BooleanProperty m_isSC
Definition: LArMCSymCondAlg.h:31
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArFCAL_Base_ID
Definition: LArFCAL_Base_ID.h:19
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1632
LArHEC_Base_ID::eta
int eta(const Identifier id) const
return eta [0,9] outer part [0,3] inner part
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
detail::ll
long long ll
Definition: PrimitiveHelpers.h:47
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArHEC_Base_ID
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
Definition: LArHEC_Base_ID.h:41
LArEM_Base_ID
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
Definition: LArEM_Base_ID.h:36
LArFCAL_Base_ID::pos_neg
int pos_neg(const Identifier id) const
pos_neg : +/- 2 (A/C side)
CaloIDHelper::channel_hash_max
size_type channel_hash_max() const
One more than the largest channel (cell) hash code.
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
LArEM_Base_ID::region_id
Identifier region_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArFCAL_Base_ID::module
int module(const Identifier id) const
module [1,3]
LArEM_Base_ID::region
int region(const Identifier id) const
return region according to :
LArFCAL_Base_ID::channel_hash
IdentifierHash channel_hash(Identifier channelId) const
Convert a connected channel (cell) Identifier to a hash code.
LArEM_Base_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LArMCSymCondAlg::m_writeKey
SG::WriteCondHandleKey< LArMCSym > m_writeKey
Definition: LArMCSymCondAlg.h:30
HWIdentifier
Definition: HWIdentifier.h:13
LArHEC_Base_ID::region_id
Identifier region_id(const ExpandedIdentifier &exp_id) const
region identifier for a channel from ExpandedIdentifier
LArMCSymCondAlg::m_readKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_readKey
Definition: LArMCSymCondAlg.h:29
LArEM_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
AtlasDetectorID::dictionaryVersion
virtual std::string dictionaryVersion(void) const override
Definition: AtlasDetectorID.cxx:276
LArEM_Base_ID::eta
int eta(const Identifier id) const
return eta according to :
LArFCAL_Base_ID::eta
int eta(const Identifier id) const
eta [0,63] module 1 ; [0,31] module 2 ; [0,15] module 3
CaloCell_ID.h
CaloCell_Base_ID::fcal_idHelper
const LArFCAL_Base_ID * fcal_idHelper() const
access to FCAL idHelper
Definition: CaloCell_Base_ID.h:341
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArOnlineID_Base::channelHashMax
size_type channelHashMax() const
Define channel hash tables max size.
Definition: LArOnlineID_Base.cxx:1897
python.PyAthena.module
module
Definition: PyAthena.py:131
LArFCAL_Base_ID::phi
int phi(const Identifier id) const
phi [0,15]
CaloCell_Base_ID::em_idHelper
const LArEM_Base_ID * em_idHelper() const
access to EM idHelper
Definition: CaloCell_Base_ID.h:330
LArEM_Base_ID::channel_hash
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
LArMCSymCondAlg.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloCell_SuperCell_ID
Helper class for offline supercell identifiers.
Definition: CaloCell_SuperCell_ID.h:45
LArEM_Base_ID::phi_min
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
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
LArFCAL_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
cell identifier for a channel from ExpandedIdentifier
LArHEC_Base_ID::phi_min
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
CaloCell_SuperCell_ID.h
Helper class for offline supercell identifiers.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
LArMCSymCondAlg::initialize
StatusCode initialize()
Definition: LArMCSymCondAlg.cxx:15
LArHEC_Base_ID::channel_hash
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
LArEM_Base_ID::barrel_ec
int barrel_ec(const Identifier id) const
return barrel_ec according to :
LArHEC_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
LArMCSymCondAlg::execute
StatusCode execute()
Definition: LArMCSymCondAlg.cxx:27
LArHEC_Base_ID::sampling
int sampling(const Identifier id) const
return sampling [0,3] (only 0 for supercells)
LArHEC_Base_ID::pos_neg
int pos_neg(const Identifier id) const
return pos_neg -2 (C side) or 2 (A side)
LArOnline_SuperCellID.h
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
CaloCell_Base_ID
Helper base class for offline cell identifiers.
Definition: CaloCell_Base_ID.h:38
LArHEC_Base_ID::region
int region(const Identifier id) const
return region [0,1]
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
LArOnlineID.h
CaloCell_Base_ID::hec_idHelper
const LArHEC_Base_ID * hec_idHelper() const
access to HEC idHelper
Definition: CaloCell_Base_ID.h:335
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
Identifier
Definition: IdentifierFieldParser.cxx:14