ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_RawDataContainerCnv_p2.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#include "SCT3_RawDataCnv_p2.h"
11
18
19#include <memory>
20
21//#define SCT_DEBUG
22
24{
25
40
41 using TRANS = SCT_RDO_Container;
42
43 SCT1_RawDataCnv_p1 chan1Cnv;
44 SCT3_RawDataCnv_p2 chan3Cnv;
45 TRANS::const_iterator it_Coll = transCont->begin();
46 TRANS::const_iterator it_CollEnd = transCont->end();
47 unsigned int collIndex;
48 unsigned int chanBegin = 0;
49 unsigned int chanEnd = 0;
50 int numColl = transCont->numberOfCollections();
51 persCont->m_collections.resize(numColl);
52#ifdef SCT_DEBUG
53 MSG_DEBUG(log,"SCT_RawDataContainerCnv_p2 Preparing " << persCont->m_collections.size() << "Collections");
54#endif
55
58 (persCont->m_numErrorsInRDO).clear();
59 (persCont->m_allErrorsInContainer).clear();
60
61 for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, ++it_Coll) {
63 const SCT_RDO_Collection& collection = (**it_Coll);
64 chanBegin = chanEnd;
65 chanEnd += collection.size();
66 InDetRawDataCollection_p1& pcollection = persCont->m_collections[collIndex];
67 pcollection.m_id = collection.identify().get_compact();
68 pcollection.m_hashId = static_cast<unsigned int>(collection.identifyHash());
69 pcollection.m_begin = chanBegin;
70 pcollection.m_end = chanEnd;
71#ifdef SCT_DEBUG
72 MSG_DEBUG(log,"Writing collection number " << collIndex << " with hash" << pcollection.m_hashId);
73#endif
75 if (m_type == 1) {
76#ifdef SCT_DEBUG
77 MSG_DEBUG(log,"SCT_RawDataContainerCnv_p2 m_type is 1");
78#endif
79 persCont->m_rawdata.resize(chanEnd);
80 for (unsigned int i = 0; i < collection.size(); ++i) {
81 InDetRawData_p1* pchan = &(persCont->m_rawdata[i + chanBegin]);
82 const SCT1_RawData* chan = dynamic_cast<const SCT1_RawData*>(collection[i]);
83 if (chan) {
84 chan1Cnv.transToPers(chan, pchan, log);
85 }
86 }
87 } else if (m_type == 3) {
88#ifdef SCT_DEBUG
89 MSG_DEBUG(log,"SCT_RawDataContainerCnv_p2 m_type is 3");
90#endif
91 persCont->m_sct3data.resize(chanEnd);
92 for (unsigned int i = 0; i < collection.size(); ++i) {
93 SCT3_RawData_p2* pchan = &(persCont->m_sct3data[i + chanBegin]);
94 const SCT3_RawData* chan = dynamic_cast<const SCT3_RawData*>(collection[i]);
95 if (chan) {
96 chan3Cnv.transToPers(chan, pchan, log);
97 const std::vector<int>& errHit = chan->getErrorCondensedHit();
98 persCont->m_numErrorsInRDO.push_back(errHit.size() );
99 persCont->m_allErrorsInContainer.insert (persCont->m_allErrorsInContainer.end(),
100 errHit.begin(),
101 errHit.end());
102 }
103 }
104 }
105 }
106#ifdef SCT_DEBUG
107 MSG_DEBUG(log," *** Writing SCT_RDO_Container (SCT1/3_RawData concrete type)");
108#endif
109}
110
112{
113
127
128
129 SCT1_RawDataCnv_p1 chan1Cnv;
130 SCT3_RawDataCnv_p2 chan3Cnv;
132
133 if (persCont->m_rawdata.size() !=0 && persCont->m_sct3data.size() != 0) {
134 log << MSG::FATAL << "The collection has mixed SCT1 and SCT3 elements, this is not allowed " << endmsg;
135 }
136 if (persCont->m_rawdata.size() != 0 ) m_type = 1;
137 if (persCont->m_sct3data.size() != 0 ) m_type = 3;
138#ifdef SCT_DEBUG
139 MSG_DEBUG(log," Reading " << persCont->m_collections.size() << " Collections");
140#endif
141 int errCount = 0;
142 for (unsigned int icoll = 0; icoll < persCont->m_collections.size(); ++icoll) {
143
146 const InDetRawDataCollection_p1& pcoll = persCont->m_collections[icoll];
147 Identifier collID(pcoll.m_id);
148 IdentifierHash collIDHash(pcoll.m_hashId);
149 std::unique_ptr<SCT_RDO_Collection> coll = std::make_unique<SCT_RDO_Collection>(IdentifierHash(collIDHash));
150 coll->setIdentifier(collID);
151 unsigned int nchans = pcoll.m_end - pcoll.m_begin;
152
153 coll->resize(nchans);
154#ifdef SCT_DEBUG
155 MSG_DEBUG(log,"Reading collection with id = " << pcoll.m_id << " id hash= " << pcoll.m_hashId
156 << " and num el= " << nchans << " m_type is "<<m_type);
157#endif
158 // Fill with channels
159 for (unsigned int ichan = 0; ichan < nchans; ++ ichan) {
160 if (m_type == 1) {
161 const InDetRawData_p1* pchan = &(persCont->m_rawdata[ichan + pcoll.m_begin]);
162 std::unique_ptr<SCT1_RawData> chan = std::make_unique<SCT1_RawData>();
163 chan1Cnv.persToTrans(pchan, chan.get(), log);
164 (*coll)[ichan] = chan.release();
165 } else if (m_type == 3) {
166 const SCT3_RawData_p2* pchan = &(persCont->m_sct3data[ichan + pcoll.m_begin]);
169 std::vector<int> errorCondensedHit;
170 int errEnd = errCount + persCont->m_numErrorsInRDO[ichan + pcoll.m_begin];
171 for ( ; errCount < errEnd ; ++errCount) {
172 errorCondensedHit.push_back(persCont->m_allErrorsInContainer[errCount]);
173 }
174 std::unique_ptr<SCT3_RawData> chan = std::make_unique<SCT3_RawData>(Identifier(pchan->m_rdoId),
175 pchan->m_word,
176 std::move(errorCondensedHit));
177 (*coll)[ichan] = chan.release();
178 }
179 }
180
181 // register the rdo collection in IDC with hash - faster addCollection
182 StatusCode sc = transCont->addCollection(coll.release(), collIDHash);
183 if (sc.isFailure()) {
184 throw std::runtime_error("Failed to add collection to ID Container");
185 }
186 MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = "
187 << collIDHash.value() << " / " << collID.get_compact() << ", added to Identifiable container.");
188
189 }
190#ifdef SCT_DEBUG
191 MSG_DEBUG(log," *** Reading SCT_RDO_Container (SCT1/3_RawData concrete type)");
192#endif
193}
194
195//================================================================
197#ifdef SCT_DEBUG
198 MSG_DEBUG(log,"creating transient SCT_RDO_Container");
199#endif
200 std::unique_ptr<SCT_RDO_Container> trans(std::make_unique<SCT_RDO_Container>(m_sctId->wafer_hash_max()));
201 persToTrans(persObj, trans.get(), log);
202 return trans.release();
203}
#define endmsg
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
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 transToPers(const SCT3_RawData *transObj, SCT3_RawData_p2 *persObj, MsgStream &log)
N.Barlow, Apr 2008 replace float[20] with vector<int> to represent strips with errors.
unsigned int m_word
Identifier32::value_type m_rdoId
virtual SCT_RDO_Container * createTransient(const SCT_RawDataContainer_p2 *persObj, MsgStream &log)
virtual void transToPers(const SCT_RDO_Container *transCont, SCT_RawDataContainer_p2 *persCont, MsgStream &log)
virtual void persToTrans(const SCT_RawDataContainer_p2 *persCont, SCT_RDO_Container *transCont, MsgStream &log)
Persistent represenation of an SCT_RawDataContainer.
std::vector< SCT3_RawData_p2 > m_sct3data
std::vector< InDetRawDataCollection_p1 > m_collections
std::vector< InDetRawData_p1 > m_rawdata
std::vector< int > m_numErrorsInRDO
std::vector< int > m_allErrorsInContainer
because ROOT isn't good at storing vectors of vectors, store the individual strip errors in the persi...