ATLAS Offline Software
SCT1_RawDataContainerCnv_p1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 #include "MsgUtil.h"
9 #include "SCT1_RawDataCnv_p1.h"
10 
13 #include "InDetIdentifier/SCT_ID.h"
17 
19 {
20 
21  // The transient model has a container holding collections and the
22  // collections hold channels.
23  //
24  // The persistent model flattens this so that the persistent
25  // container has two vectors:
26  // 1) all collections, and
27  // 2) all RDO
28  //
29  // The persistent collections, then only maintain indexes into the
30  // container's vector of all channels.
31  //
32  // So here we loop over all collection and add their channels
33  // to the container's vector, saving the indexes in the
34  // collection.
35 
36  using TRANS = SCT_RDO_Container;
37 
38  SCT1_RawDataCnv_p1 chanCnv;
39  TRANS::const_iterator it_Coll = transCont->begin();
40  TRANS::const_iterator it_CollEnd = transCont->end();
41  unsigned int collIndex;
42  unsigned int chanBegin = 0;
43  unsigned int chanEnd = 0;
44  persCont->m_collections.resize(transCont->numberOfCollections());
45  MSG_DEBUG(log," Preparing " << persCont->m_collections.size() << "Collections");
46 
47  for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
48  // Add in new collection
49  const SCT_RDO_Collection& collection = (**it_Coll);
50  chanBegin = chanEnd;
51  chanEnd += collection.size();
52  InDetRawDataCollection_p1& pcollection = persCont->m_collections[collIndex];
53  pcollection.m_id = collection.identify().get_compact();
54  pcollection.m_hashId = static_cast<unsigned int>(collection.identifyHash());
55  pcollection.m_begin = chanBegin;
56  pcollection.m_end = chanEnd;
57  // Add in channels
58  persCont->m_rawdata.resize(chanEnd);
59  for (unsigned int i = 0; i < collection.size(); ++i) {
60  InDetRawData_p1* pchan = &(persCont->m_rawdata[i + chanBegin]);
61  const SCT1_RawData* chan = dynamic_cast<const SCT1_RawData*>(collection[i]);
62  if (chan) {
63  chanCnv.transToPers(chan, pchan, log);
64  }
65  }
66  }
67  MSG_DEBUG(log," *** Writing SCT_RDO_Container (SCT1_RawData concrete type)");
68 }
69 
71 {
72 
73  // The transient model has a container holding collections and the
74  // collections hold channels.
75  //
76  // The persistent model flattens this so that the persistent
77  // container has two vectors:
78  // 1) all collections, and
79  // 2) all channels
80  //
81  // The persistent collections, then only maintain indexes into the
82  // container's vector of all channels.
83  //
84  // So here we loop over all collection and extract their channels
85  // from the vector.
86 
87 
88  SCT1_RawDataCnv_p1 chanCnv;
89  MSG_DEBUG(log," Reading " << persCont->m_collections.size() << "Collections");
90  for (unsigned int icoll = 0; icoll < persCont->m_collections.size(); ++icoll) {
91 
92  // Create trans collection - in NOT owner of SCT_RDO_RawData (SG::VIEW_ELEMENTS)
93  // IDet collection don't have the Ownership policy c'tor
94  const InDetRawDataCollection_p1& pcoll = persCont->m_collections[icoll];
95  Identifier collID(Identifier(pcoll.m_id));
96  IdentifierHash collIDHash(IdentifierHash(pcoll.m_hashId));
97  std::unique_ptr<SCT_RDO_Collection> coll = std::make_unique<SCT_RDO_Collection>(collIDHash);
98  coll->setIdentifier(Identifier(collID));
99  unsigned int nchans = pcoll.m_end - pcoll.m_begin;
100  coll->resize(nchans);
101  // Fill with channels
102  for (unsigned int ichan = 0; ichan < nchans; ++ ichan) {
103  const InDetRawData_p1* pchan = &(persCont->m_rawdata[ichan + pcoll.m_begin]);
104  std::unique_ptr<SCT1_RawData> chan = std::make_unique<SCT1_RawData>();
105  chanCnv.persToTrans(pchan, chan.get(), log);
106  (*coll)[ichan] = chan.release();
107  }
108 
109  // register the rdo collection in IDC with hash - faster addCollection
110  StatusCode sc = transCont->addCollection(coll.release(), collIDHash);
111  if (sc.isFailure()) {
112  throw std::runtime_error("Failed to add collection to ID Container");
113  }
114  MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << collIDHash.value()
115  << " / " << collID.get_compact() << ", added to Identifiable container.");
116  }
117 
118  MSG_DEBUG(log," *** Reading SCT_RDO_Container (SCT1_RawData concrete type)");
119 }
120 
121 //================================================================
123  std::unique_ptr<SCT_RDO_Container> trans(std::make_unique<SCT_RDO_Container>(m_sctId->wafer_hash_max()));
124  persToTrans(persObj, trans.get(), log);
125  return trans.release();
126 }
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
InDetRawDataCollection::setIdentifier
void setIdentifier(Identifier id)
SCT1_RawDataCnv_p1
Definition: SCT1_RawDataCnv_p1.h:22
SCT1_RawDataContainerCnv_p1::createTransient
virtual SCT_RDO_Container * createTransient(const InDetRawDataContainer_p1 *persObj, MsgStream &log)
Definition: SCT1_RawDataContainerCnv_p1.cxx:122
IdentifiableContainerMT::addCollection
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
Definition: IdentifiableContainerMT.h:300
InDetRawDataCollection::identify
virtual Identifier identify() const override final
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
InDetRawDataCollection_p1::m_hashId
IdentifierHash::value_type m_hashId
Definition: InDetRawDataCollection_p1.h:36
InDetRawData_p1.h
InDetRawDataCollection_p1::m_end
unsigned int m_end
Definition: InDetRawDataCollection_p1.h:42
InDetRawDataCollection_p1::m_id
Identifier32::value_type m_id
Definition: InDetRawDataCollection_p1.h:32
InDetRawDataCollection_p1
Definition: InDetRawDataCollection_p1.h:13
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
InDetRawDataCollection::identifyHash
virtual IdentifierHash identifyHash() const override final
SCT_RDO_Container.h
IdentifiableContainerMT::numberOfCollections
virtual size_t numberOfCollections() const override final
return number of collections
Definition: IdentifiableContainerMT.h:216
lumiFormat.i
int i
Definition: lumiFormat.py:92
SCT1_RawData.h
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
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
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
InDetRawDataContainer_p1::m_collections
std::vector< InDetRawDataCollection_p1 > m_collections
Definition: InDetRawDataContainer_p1.h:39
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
SCT1_RawDataCnv_p1::persToTrans
virtual void persToTrans(const InDetRawData_p1 *persObj, SCT1_RawData *transObj, MsgStream &log)
Definition: SCT1_RawDataCnv_p1.cxx:18
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
InDetRawDataContainer_p1::m_rawdata
std::vector< InDetRawData_p1 > m_rawdata
Definition: InDetRawDataContainer_p1.h:40
DataVector::resize
void resize(size_type sz)
Resizes the collection to the specified number of elements.
defineDB.ichan
int ichan
Definition: JetTagCalibration/share/defineDB.py:28
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:639
InDetRawDataCollection_p1::m_begin
unsigned int m_begin
Definition: InDetRawDataCollection_p1.h:39
SCT_RDO_Collection.h
SCT_RDO_Container
InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > SCT_RDO_Container
Definition: SCT_RDO_Container.h:23
MSG_VERBOSE
#define MSG_VERBOSE(log, x)
Definition: MsgUtil.h:17
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
IdentifierHash::value
unsigned int value(void) const
SCT1_RawDataContainerCnv_p1::persToTrans
virtual void persToTrans(const InDetRawDataContainer_p1 *persCont, SCT_RDO_Container *transCont, MsgStream &log)
Definition: SCT1_RawDataContainerCnv_p1.cxx:70
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MSG_DEBUG
#define MSG_DEBUG(log, x)
Definition: MsgUtil.h:15
SCT1_RawData
Definition: SCT1_RawData.h:27
SCT1_RawDataContainerCnv_p1::transToPers
virtual void transToPers(const SCT_RDO_Container *transCont, InDetRawDataContainer_p1 *persCont, MsgStream &log)
Definition: SCT1_RawDataContainerCnv_p1.cxx:18
InDetRawData_p1
Definition: InDetRawData_p1.h:10
IdentifierHash
Definition: IdentifierHash.h:38
SCT1_RawDataCnv_p1::transToPers
virtual void transToPers(const SCT1_RawData *transObj, InDetRawData_p1 *persObj, MsgStream &log)
Definition: SCT1_RawDataCnv_p1.cxx:26
SCT1_RawDataContainerCnv_p1::m_sctId
const SCT_ID * m_sctId
Definition: SCT1_RawDataContainerCnv_p1.h:28
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetRawDataContainer_p1
Definition: InDetRawDataContainer_p1.h:31
SCT1_RawDataContainerCnv_p1.h
InDetRawDataCollection_p1.h
SCT1_RawDataCnv_p1.h
MsgUtil.h