ATLAS Offline Software
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"
9 #include "SCT1_RawDataCnv_p1.h"
10 #include "SCT3_RawDataCnv_p2.h"
11 
14 #include "InDetIdentifier/SCT_ID.h"
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
74 
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;
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 }
SCT3_RawData_p2::m_rdoId
Identifier32::value_type m_rdoId
Definition: SCT3_RawData_p2.h:21
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)
SCT3_RawData_p2
N.Barlow, Apr 2008 replace float[20] with vector<int> to represent strips with errors.
Definition: SCT3_RawData_p2.h:15
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
SCT1_RawDataCnv_p1
Definition: SCT1_RawDataCnv_p1.h:22
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:297
IdentifierHash::value
unsigned int value() const
SCT3_RawData_p2::m_word
unsigned int m_word
Definition: SCT3_RawData_p2.h:22
InDetRawDataCollection::identify
virtual Identifier identify() const override final
SCT_RawDataContainerCnv_p2::m_sctId
const SCT_ID * m_sctId
Definition: SCT_RawDataContainerCnv_p2.h:29
SCT_RawDataContainerCnv_p2::m_type
int m_type
Definition: SCT_RawDataContainerCnv_p2.h:30
Identifier::get_compact
value_type get_compact() const
Get the compact id.
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
InDetRawDataCollection_p1::m_hashId
IdentifierHash::value_type m_hashId
Definition: InDetRawDataCollection_p1.h:36
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
SCT_RawDataContainerCnv_p2::createTransient
virtual SCT_RDO_Container * createTransient(const SCT_RawDataContainer_p2 *persObj, MsgStream &log)
Definition: SCT_RawDataContainerCnv_p2.cxx:196
SCT_RawDataContainer_p2::m_allErrorsInContainer
std::vector< int > m_allErrorsInContainer
because ROOT isn't good at storing vectors of vectors, store the individual strip errors in the persi...
Definition: SCT_RawDataContainer_p2.h:37
InDetRawDataCollection::identifyHash
virtual IdentifierHash identifyHash() const override final
SCT_RawDataContainerCnv_p2::transToPers
virtual void transToPers(const SCT_RDO_Container *transCont, SCT_RawDataContainer_p2 *persCont, MsgStream &log)
Definition: SCT_RawDataContainerCnv_p2.cxx:23
SCT_RDO_Container.h
SCT_RawDataContainer_p2::m_numErrorsInRDO
std::vector< int > m_numErrorsInRDO
Definition: SCT_RawDataContainer_p2.h:38
IdentifiableContainerMT::numberOfCollections
virtual size_t numberOfCollections() const override final
return number of collections
Definition: IdentifiableContainerMT.h:213
SCT3_RawData.h
SCT_RawDataContainer_p2::m_collections
std::vector< InDetRawDataCollection_p1 > m_collections
Definition: SCT_RawDataContainer_p2.h:30
SCT_RawDataContainer_p2::m_rawdata
std::vector< InDetRawData_p1 > m_rawdata
Definition: SCT_RawDataContainer_p2.h:31
lumiFormat.i
int i
Definition: lumiFormat.py:85
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
SCT3_RawData
Definition: SCT3_RawData.h:24
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:239
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:233
SCT3_RawDataCnv_p2::transToPers
virtual void transToPers(const SCT3_RawData *transObj, SCT3_RawData_p2 *persObj, MsgStream &log)
Definition: SCT3_RawDataCnv_p2.cxx:28
SCT3_RawDataCnv_p2
Definition: SCT3_RawDataCnv_p2.h:21
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:645
InDetRawDataCollection_p1::m_begin
unsigned int m_begin
Definition: InDetRawDataCollection_p1.h:39
SCT_RawDataContainer_p2::m_sct3data
std::vector< SCT3_RawData_p2 > m_sct3data
Definition: SCT_RawDataContainer_p2.h:32
SCT_RDO_Collection.h
SCT_RDO_Container
InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > SCT_RDO_Container
Definition: SCT_RDO_Container.h:23
SCT_RawDataContainer_p2
Persistent represenation of an SCT_RawDataContainer.
Definition: SCT_RawDataContainer_p2.h:24
MSG_VERBOSE
#define MSG_VERBOSE(log, x)
Definition: MsgUtil.h:17
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
SCT_RawDataContainerCnv_p2::persToTrans
virtual void persToTrans(const SCT_RawDataContainer_p2 *persCont, SCT_RDO_Container *transCont, MsgStream &log)
Definition: SCT_RawDataContainerCnv_p2.cxx:111
SCT3_RawDataCnv_p2.h
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
SCT3_RawData_p2.h
InDetRawData_p1
Definition: InDetRawData_p1.h:10
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
SCT_RawDataContainerCnv_p2.h
SCT1_RawDataCnv_p1::transToPers
virtual void transToPers(const SCT1_RawData *transObj, InDetRawData_p1 *persObj, MsgStream &log)
Definition: SCT1_RawDataCnv_p1.cxx:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetRawDataCollection_p1.h
SCT1_RawDataCnv_p1.h
Identifier
Definition: IdentifierFieldParser.cxx:14
MsgUtil.h