ATLAS Offline Software
LArMCSymCondAlg.cxx
Go to the documentation of this file.
1 //dear emacs, this is -*-c++-*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #include "LArMCSymCondAlg.h"
10 
11 
13 
14  ATH_MSG_DEBUG("initializing");
15 
16  // Read Handles
19 
20  return StatusCode::SUCCESS;
21 }
22 
23 
25 
27 
28  if (writeHandle.isValid()) {
29  ATH_MSG_DEBUG("Found valid write handle");
30  return StatusCode::SUCCESS;
31  }
32 
34  const LArOnOffIdMapping* cabling{*readHandle};
35 
36  if (cabling==nullptr) {
37  ATH_MSG_ERROR("Failed to retrieve CondAttributeListCollection with key " << m_readKey.key());
38  return StatusCode::FAILURE;
39  }
40  writeHandle.addDependency(readHandle);
41 
42  const LArOnlineID* larOnlineID=nullptr;
43  const CaloCell_ID* caloCellID=nullptr;
44  const LArEM_ID* lar_em_id=nullptr;
45  const LArHEC_ID* lar_hec_id=nullptr;
46  const LArFCAL_ID* lar_fcal_id=nullptr;
47 
48 
49  ATH_CHECK(detStore()->retrieve(lar_em_id,"LArEM_ID"));
50  ATH_CHECK(detStore()->retrieve(lar_hec_id,"LArHEC_ID"));
51  ATH_CHECK(detStore()->retrieve(lar_fcal_id,"LArFCAL_ID"));
52  ATH_CHECK(detStore()->retrieve(caloCellID,"CaloCell_ID"));
53  ATH_CHECK(detStore()->retrieve(larOnlineID,"LArOnlineID"));
54 
55  const unsigned ncellem=lar_em_id->channel_hash_max();
56  const unsigned ncellhec=lar_hec_id->channel_hash_max();
57  const unsigned ncellfcal=lar_fcal_id->channel_hash_max();
58 
59  const unsigned larHashMax=ncellem+ncellhec+ncellfcal;
60 
61  const unsigned onlHashMax=larOnlineID->channelHashMax();
62 
63  std::vector<HWIdentifier> oflHashtoSymOnl(larHashMax);
64  std::vector<HWIdentifier> onlHashtoSymOnl(onlHashMax);
65 
66  std::set<HWIdentifier> symIds;
67 
68  ATH_MSG_DEBUG("Start looping over EM calo cells");
69  for ( unsigned int idhash=0; idhash<ncellem;idhash++){
70  const Identifier id=lar_em_id->channel_id (idhash);
71  const HWIdentifier hwid=cabling->createSignalChannelID(id);
72  const IdentifierHash hwid_hash=larOnlineID->channel_Hash(hwid);
73  const int barrel_ec = abs( lar_em_id->barrel_ec(id) ) ;
74  const int sampling = lar_em_id->sampling(id);
75  const int region = lar_em_id->region(id);
76  const Identifier regId = lar_em_id->region_id(barrel_ec, sampling, region );
77  const int eta = lar_em_id->eta(id);
78  const int phi = lar_em_id->phi_min(regId);
79  const Identifier symOffId = lar_em_id->channel_id(barrel_ec, sampling, region, eta, phi );
80  const HWIdentifier symOnId = cabling->createSignalChannelID(symOffId);
81  const IdentifierHash idHash = lar_em_id->channel_hash(id);
82  oflHashtoSymOnl[idHash] = symOnId;
83  onlHashtoSymOnl[hwid_hash]= symOnId;
84  symIds.insert(symOnId);
85  }
86 
87  ATH_MSG_DEBUG("start loop over HEC calo");
88 
89  for ( unsigned int idhash=0; idhash<ncellhec;idhash++){
90  const Identifier id=lar_hec_id->channel_id (idhash);
91  const HWIdentifier hwid=cabling->createSignalChannelID(id);
92  const IdentifierHash hwid_hash=larOnlineID->channel_Hash(hwid);
93 
94  const int pos_neg = abs( lar_hec_id->pos_neg(id) ) ;
95  const int sampling = lar_hec_id->sampling(id);
96  const int region = lar_hec_id->region(id);
97  const Identifier regId = lar_hec_id->region_id(pos_neg, sampling, region );
98  const int eta = lar_hec_id->eta(id);
99  const int phi = lar_hec_id->phi_min(regId);
100  const Identifier symOffId = lar_hec_id->channel_id(pos_neg, sampling, region, eta, phi );
101  const HWIdentifier symOnId = cabling->createSignalChannelID(symOffId);
102  const IdentifierHash idHash=lar_hec_id->channel_hash(id);
103  oflHashtoSymOnl[ncellem+idHash] = symOnId;
104  onlHashtoSymOnl[hwid_hash]= symOnId;
105  symIds.insert(symOnId);
106  }
107 
108  ATH_MSG_DEBUG("start loop over FCAL calo");
109 
110  const bool isTB= lar_fcal_id->dictionaryVersion() == "H6TestBeam";
111  for ( unsigned int idhash=0; idhash<lar_fcal_id->channel_hash_max();
112  idhash++){
113  const Identifier id=lar_fcal_id->channel_id (idhash);
114  const HWIdentifier hwid=cabling->createSignalChannelID(id);
115  const IdentifierHash hwid_hash=larOnlineID->channel_Hash(hwid);
116 
117 
118  const int pos_neg = abs( lar_fcal_id->pos_neg(id) ) ;
119  const int module = lar_fcal_id->module(id);
120 
121 // symmetry for FCAL: save all y>0 part of the +side module
122 // y<0 side deduced by point symmetry around x=y=0
123  const int eta = lar_fcal_id->eta(id);
124  int phi = lar_fcal_id->phi(id);
125  if (!isTB) {
126  if (phi > 7) phi = phi-8;
127  }
128  Identifier symOffId = lar_fcal_id->channel_id(pos_neg, module, eta, phi );
129  HWIdentifier symOnId = cabling->createSignalChannelID(symOffId);
130  IdentifierHash idHash=lar_fcal_id->channel_hash(id);
131  oflHashtoSymOnl[ncellem+ncellhec+idHash] = symOnId;
132  onlHashtoSymOnl[hwid_hash]= symOnId;
133  symIds.insert(symOnId);
134  }
135 
136 
137  std::vector<HWIdentifier> symIdVec(symIds.begin(),symIds.end());
138  std::unique_ptr<LArMCSym> mcSym=std::make_unique<LArMCSym>(larOnlineID,caloCellID,
139  std::move(oflHashtoSymOnl),
140  std::move(onlHashtoSymOnl),
141  std::move(symIdVec));
142 
143 
144 
145  if(writeHandle.record(std::move(mcSym)).isFailure()) {
146  ATH_MSG_ERROR("Could not record LArMCSym object with "
147  << writeHandle.key()
148  << " with EventRange " << writeHandle.getRange()
149  << " into Conditions Store");
150  return StatusCode::FAILURE;
151  }
152  ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
153 
154 
155  return StatusCode::SUCCESS;
156 }
157 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1636
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:64
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
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:79
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.
LArHEC_ID
Helper class for LArHEC offline identifiers.
Definition: LArHEC_ID.h:85
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:347
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
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
python.PyAthena.module
module
Definition: PyAthena.py:134
LArFCAL_Base_ID::phi
int phi(const Identifier id) const
phi [0,15]
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
LArEM_Base_ID::phi_min
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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)
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:12
LArHEC_Base_ID::channel_hash
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
LArOnlineID_Base::channelHashMax
size_type channelHashMax(void) const
Define channel hash tables max size.
Definition: LArOnlineID_Base.cxx:1901
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
LArMCSymCondAlg::execute
StatusCode execute()
Definition: LArMCSymCondAlg.cxx:24
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)
LArEM_ID
Helper class for LArEM offline identifiers.
Definition: LArEM_ID.h:118
IdentifierHash
Definition: IdentifierHash.h:38
LArFCAL_ID
Helper class for LArFCAL offline identifiers.
Definition: LArFCAL_ID.h:60
LArHEC_Base_ID::region
int region(const Identifier id) const
return region [0,1]
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
LArOnlineID.h
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20