ATLAS Offline Software
LArOnOffMappingAlg.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 "LArOnOffMappingAlg.h"
9 #include "CoralBase/Blob.h"
10 
15 
16 
18 
19  ATH_MSG_DEBUG("initializing");
20 
21  // Read Handles
24 
25  return StatusCode::SUCCESS;
26 }
27 
28 
30  ATH_MSG_DEBUG("executing");
31 
33 
34  if (writeHandle.isValid()) {
35  ATH_MSG_DEBUG("Found valid write handle");
36  return StatusCode::SUCCESS;
37  }
38 
40  const AthenaAttributeList* attr{*readHandle};
41 
42  if (attr==nullptr) {
43  ATH_MSG_ERROR("Failed to retrieve CondAttributeListCollection with key " << m_readKey.key());
44  return StatusCode::FAILURE;
45  }
46 
47  writeHandle.addDependency(readHandle);
48 
49  const LArOnlineID_Base* larOnlineID=nullptr;
50  const CaloCell_Base_ID* calocellID=nullptr;
51 
52  //Identifier helper:
53  if (m_isSuperCell) {
54  const LArOnline_SuperCellID* scidhelper = nullptr;
55  ATH_CHECK(detStore()->retrieve(scidhelper,"LArOnline_SuperCellID"));
56  larOnlineID=scidhelper; //cast to base-class
57 
58  const CaloCell_SuperCell_ID* sccaloid = nullptr;
59  ATH_CHECK(detStore()->retrieve(sccaloid,"CaloCell_SuperCell_ID"));
60  calocellID=sccaloid; //cast to base-class
61 
62  }
63  else {//regular cells
64  const LArOnlineID* idhelper = nullptr;
65  ATH_CHECK(detStore()->retrieve(idhelper,"LArOnlineID"));
66  larOnlineID=idhelper; //cast to base-class
67 
68  const CaloCell_ID* sccaloid = nullptr;
69  ATH_CHECK(detStore()->retrieve(sccaloid,"CaloCell_ID"));
70  calocellID=sccaloid; //cast to base-class
71 
72  }
73 
74 
75  std::unique_ptr<LArOnOffIdMapping> onOffMap=std::make_unique<LArOnOffIdMapping>(larOnlineID,calocellID);
76 
77  const coral::Blob& blobOnOff=(*attr)["OnlineHashToOfflineId"].data<coral::Blob>();
78  unsigned nChan=blobOnOff.size()/sizeof(uint32_t);
79  const uint32_t* pBlobOnOff=static_cast<const uint32_t*>(blobOnOff.startingAddress());
80 
81  if (nChan!=larOnlineID->channelHashMax()) {
82  ATH_MSG_ERROR("Number of channels read from DB (" << nChan << ") does not match online hash max ("
83  <<larOnlineID->channelHashMax() << ")");
84  return StatusCode::FAILURE;
85  }
86 
87 
88  unsigned nConnected=0;
89 
90  for (unsigned i=0;i<nChan;++i) {
91  const Identifier id=Identifier(Identifier32(pBlobOnOff[i]));
92  if (id.is_valid()) {
93  const IdentifierHash oflHash=calocellID->calo_cell_hash(id);
94  const HWIdentifier hwid=larOnlineID->channel_Id(IdentifierHash(i));
95  ++nConnected;
96  onOffMap->m_onlHashToOffline[i]=id;
97  onOffMap->m_oflHashToOnline[oflHash]=hwid;
98  onOffMap->m_onlHashToOflHash[i]=oflHash;
99  }
100  }//end loop over channels
101 
102  ATH_MSG_INFO("Done reading online/offline identifier mapping");
103  ATH_MSG_INFO("Found " << nChan << " online identifier and " << nConnected << " offline identifier. "
104  << nChan-nConnected << " disconnected channels.");
105 
106  if(writeHandle.record(std::move(onOffMap)).isFailure()) {
107  ATH_MSG_ERROR("Could not record LArOnOffMapping object with "
108  << writeHandle.key()
109  << " with EventRange " << writeHandle.getRange()
110  << " into Conditions Store");
111  return StatusCode::FAILURE;
112  }
113  ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
114 
115  return StatusCode::SUCCESS;
116 }
117 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
Identifier32
Definition: Identifier32.h:25
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArOnOffIdMapping::m_onlHashToOflHash
std::vector< IdentifierHash > m_onlHashToOflHash
Definition: LArOnOffIdMapping.h:83
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
AthenaAttributeList.h
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
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArOnOffMappingAlg::initialize
virtual StatusCode initialize() override
Definition: LArOnOffMappingAlg.cxx:17
CaloCell_SuperCell_ID
Helper class for offline supercell identifiers.
Definition: CaloCell_SuperCell_ID.h:48
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
LArOnlineID_Base::channel_Id
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
Definition: LArOnlineID_Base.cxx:1569
CaloCell_SuperCell_ID.h
Helper class for offline supercell identifiers.
LArOnOffMappingAlg::m_readKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition: LArOnOffMappingAlg.h:30
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
LArOnOffMappingAlg::m_writeKey
SG::WriteCondHandleKey< LArOnOffIdMapping > m_writeKey
Definition: LArOnOffMappingAlg.h:31
LArOnOffMappingAlg::execute
virtual StatusCode execute() override
Definition: LArOnOffMappingAlg.cxx:29
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
LArOnlineID_Base::channelHashMax
size_type channelHashMax(void) const
Define channel hash tables max size.
Definition: LArOnlineID_Base.cxx:1901
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
LArOnOffMappingAlg.h
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
LArOnline_SuperCellID.h
LArOnOffMappingAlg::m_isSuperCell
Gaudi::Property< bool > m_isSuperCell
Definition: LArOnOffMappingAlg.h:32
IdentifierHash
Definition: IdentifierHash.h:38
CaloCell_Base_ID
Helper base class for offline cell identifiers.
Definition: CaloCell_Base_ID.h:41
LArOnOffIdMapping::m_oflHashToOnline
std::vector< HWIdentifier > m_oflHashToOnline
Definition: LArOnOffIdMapping.h:82
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
LArOnOffIdMapping::m_onlHashToOffline
std::vector< Identifier > m_onlHashToOffline
Definition: LArOnOffIdMapping.h:81
LArOnlineID.h