ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_RawDataContainerCnv_p3.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_p3.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_p2 chan1Cnv;
44 SCT3_RawDataCnv_p3 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_p3 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_identifier32().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_p3 m_type is 1");
78#endif
79 persCont->m_rawdata.resize(chanEnd);
80 for (unsigned int i = 0; i < collection.size(); ++i) {
81 InDetRawData_p2* pchan = &(persCont->m_rawdata[i + chanBegin]);
82 const SCT1_RawData* chan = dynamic_cast<const SCT1_RawData*>(collection[i]);
83 if (nullptr == chan) throw std::runtime_error("SCT_RawDataContainerCnv_p3::transToPers: *** UNABLE TO DYNAMIC CAST TO SCT1_RawData");
84 chan1Cnv.transToPers(chan, pchan, log);
85 }
86 } else if (m_type == 3) {
87#ifdef SCT_DEBUG
88 MSG_DEBUG(log,"SCT_RawDataContainerCnv_p3 m_type is 3");
89#endif
90 persCont->m_sct3data.resize(chanEnd);
91 for (unsigned int i = 0; i < collection.size(); ++i) {
92 SCT3_RawData_p3* pchan = &(persCont->m_sct3data[i + chanBegin]);
93 const SCT3_RawData* chan = dynamic_cast<const SCT3_RawData*>(collection[i]);
94 if (nullptr == chan) throw std::runtime_error("SCT_RawDataContainerCnv_p3::transToPers: *** UNABLE TO DYNAMIC CAST TO SCT3_RawData");
95 chan3Cnv.transToPers(chan, pchan, log);
96 const std::vector<int>& errHit = chan->getErrorCondensedHit();
97 persCont->m_numErrorsInRDO.push_back(errHit.size() );
98 persCont->m_allErrorsInContainer.insert(persCont->m_allErrorsInContainer.end(),
99 errHit.begin(),
100 errHit.end());
101 }
102 }
103 }
104#ifdef SCT_DEBUG
105 MSG_DEBUG(log," *** Writing SCT_RDO_Container (SCT1/3_RawData concrete type)");
106#endif
107}
108
110{
111
125
126
127 SCT1_RawDataCnv_p2 chan1Cnv;
128 SCT3_RawDataCnv_p3 chan3Cnv;
130
131 if (persCont->m_rawdata.size() !=0 && persCont->m_sct3data.size() != 0) {
132 log << MSG::FATAL << "The collection has mixed SCT1 and SCT3 elements, this is not allowed " << endmsg;
133 }
134 if (persCont->m_rawdata.size() != 0 ) m_type = 1;
135 if (persCont->m_sct3data.size() != 0 ) m_type = 3;
136#ifdef SCT_DEBUG
137 MSG_DEBUG(log," Reading " << persCont->m_collections.size() << " Collections");
138#endif
139 int errCount = 0;
140 for (unsigned int icoll = 0; icoll < persCont->m_collections.size(); ++icoll) {
141
144 const InDetRawDataCollection_p1& pcoll = persCont->m_collections[icoll];
145 Identifier collID(pcoll.m_id);
146 IdentifierHash collIDHash(pcoll.m_hashId);
147 std::unique_ptr<SCT_RDO_Collection> coll = std::make_unique<SCT_RDO_Collection>(IdentifierHash(collIDHash));
148 coll->setIdentifier(collID);
149 unsigned int nchans = pcoll.m_end - pcoll.m_begin;
150
151 coll->resize(nchans);
152#ifdef SCT_DEBUG
153 MSG_DEBUG(log,"Reading collection with id = " << pcoll.m_id << " id hash= " << pcoll.m_hashId
154 << " and num el= " << nchans << " m_type is "<<m_type);
155#endif
156 // Fill with channels
157 for (unsigned int ichan = 0; ichan < nchans; ++ ichan) {
158 if (m_type == 1) {
159 const InDetRawData_p2* pchan = &(persCont->m_rawdata[ichan + pcoll.m_begin]);
160 std::unique_ptr<SCT1_RawData> chan = std::make_unique<SCT1_RawData>();
161 chan1Cnv.persToTrans(pchan, chan.get(), log);
162 (*coll)[ichan] = chan.release();
163 } else if (m_type == 3) {
164 const SCT3_RawData_p3* pchan = &(persCont->m_sct3data[ichan + pcoll.m_begin]);
167 std::vector<int> errorCondensedHit;
168 int errEnd = errCount + persCont->m_numErrorsInRDO[ichan + pcoll.m_begin];
169 for ( ; errCount < errEnd ; ++errCount) {
170 errorCondensedHit.push_back(persCont->m_allErrorsInContainer[errCount]);
171 }
172 std::unique_ptr<SCT3_RawData> chan = std::make_unique<SCT3_RawData>(Identifier(pchan->m_rdoId),
173 pchan->m_word,
174 std::move (errorCondensedHit));
175 (*coll)[ichan] = chan.release();
176 }
177 }
178
179 // register the rdo collection in IDC with hash - faster addCollection
180 StatusCode sc = transCont->addCollection(coll.release(), collIDHash);
181 if (sc.isFailure()) {
182 throw std::runtime_error("Failed to add collection to ID Container");
183 }
184 MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = "
185 << collIDHash.value() << " / " << collID.get_compact() << ", added to Identifiable container.");
186
187 }
188#ifdef SCT_DEBUG
189 MSG_DEBUG(log," *** Reading SCT_RDO_Container (SCT1/3_RawData concrete type)");
190#endif
191}
192
193//================================================================
195#ifdef SCT_DEBUG
196 MSG_DEBUG(log,"creating transient SCT_RDO_Container");
197#endif
198 std::unique_ptr<SCT_RDO_Container> trans(std::make_unique<SCT_RDO_Container>(m_sctId->wafer_hash_max()));
199 persToTrans(persObj, trans.get(), log);
200 return trans.release();
201}
#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
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
value_type value() const
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
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_p2 *persObj, MsgStream &log)
virtual void persToTrans(const InDetRawData_p2 *persObj, SCT1_RawData *transObj, MsgStream &log)
virtual void transToPers(const SCT3_RawData *transObj, SCT3_RawData_p3 *persObj, MsgStream &log)
N.Barlow, Apr 2008 replace float[20] with vector<int> to represent strips with errors.
Identifier::value_type m_rdoId
unsigned int m_word
virtual SCT_RDO_Container * createTransient(const SCT_RawDataContainer_p3 *persObj, MsgStream &log)
virtual void transToPers(const SCT_RDO_Container *transCont, SCT_RawDataContainer_p3 *persCont, MsgStream &log)
virtual void persToTrans(const SCT_RawDataContainer_p3 *persCont, SCT_RDO_Container *transCont, MsgStream &log)
Persistent represenation of an SCT_RawDataContainer.
std::vector< InDetRawDataCollection_p1 > m_collections
std::vector< int > m_allErrorsInContainer
because ROOT isn't good at storing vectors of vectors, store the individual strip errors in the persi...
std::vector< InDetRawData_p2 > m_rawdata
std::vector< SCT3_RawData_p3 > m_sct3data
std::vector< int > m_numErrorsInRDO