ATLAS Offline Software
Loading...
Searching...
No Matches
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"
10
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}
static Double_t sc
#define MSG_VERBOSE(log, x)
Definition MsgUtil.h:17
#define MSG_DEBUG(log, x)
Definition MsgUtil.h:15
This is an Identifier helper class for the SCT subdetector.
InDetRawDataCollection< SCT_RDORawData > SCT_RDO_Collection
InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > SCT_RDO_Container
size_type size() const noexcept
const_iterator end() const
return const_iterator for end of container
virtual size_t numberOfCollections() const override final
return number of collections
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,...
const_iterator begin() const
return const_iterator for first entry
This is a "hash" representation of an Identifier.
value_type value() const
value_type get_compact() const
Get the compact id.
IdentifierHash::value_type m_hashId
virtual Identifier identify() const override final
virtual IdentifierHash identifyHash() const override final
std::vector< InDetRawDataCollection_p1 > m_collections
std::vector< InDetRawData_p1 > m_rawdata
virtual void transToPers(const SCT1_RawData *transObj, InDetRawData_p1 *persObj, MsgStream &log)
virtual void persToTrans(const InDetRawData_p1 *persObj, SCT1_RawData *transObj, MsgStream &log)
virtual void persToTrans(const InDetRawDataContainer_p1 *persCont, SCT_RDO_Container *transCont, MsgStream &log)
virtual void transToPers(const SCT_RDO_Container *transCont, InDetRawDataContainer_p1 *persCont, MsgStream &log)
virtual SCT_RDO_Container * createTransient(const InDetRawDataContainer_p1 *persObj, MsgStream &log)