ATLAS Offline Software
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"
9 #include "SCT1_RawDataCnv_p2.h"
10 #include "SCT3_RawDataCnv_p3.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_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
74 
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;
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 }
SCT3_RawData_p3.h
SCT_RawDataContainerCnv_p3::transToPers
virtual void transToPers(const SCT_RDO_Container *transCont, SCT_RawDataContainer_p3 *persCont, MsgStream &log)
Definition: SCT_RawDataContainerCnv_p3.cxx:23
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)
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
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
SCT1_RawDataCnv_p2::transToPers
virtual void transToPers(const SCT1_RawData *transObj, InDetRawData_p2 *persObj, MsgStream &log)
Definition: SCT1_RawDataCnv_p2.cxx:26
InDetRawDataCollection::identify
virtual Identifier identify() const override final
SCT_RawDataContainerCnv_p3::persToTrans
virtual void persToTrans(const SCT_RawDataContainer_p3 *persCont, SCT_RDO_Container *transCont, MsgStream &log)
Definition: SCT_RawDataContainerCnv_p3.cxx:109
SCT_RawDataContainerCnv_p3::m_type
int m_type
Definition: SCT_RawDataContainerCnv_p3.h:30
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
InDetRawDataCollection_p1::m_hashId
IdentifierHash::value_type m_hashId
Definition: InDetRawDataCollection_p1.h:36
SCT1_RawDataCnv_p2::persToTrans
virtual void persToTrans(const InDetRawData_p2 *persObj, SCT1_RawData *transObj, MsgStream &log)
Definition: SCT1_RawDataCnv_p2.cxx:18
InDetRawDataCollection_p1::m_end
unsigned int m_end
Definition: InDetRawDataCollection_p1.h:42
SCT_RawDataContainer_p3::m_rawdata
std::vector< InDetRawData_p2 > m_rawdata
Definition: SCT_RawDataContainer_p3.h:31
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_RawDataContainer_p3::m_collections
std::vector< InDetRawDataCollection_p1 > m_collections
Definition: SCT_RawDataContainer_p3.h:30
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
SCT3_RawData.h
Identifier32::get_compact
value_type get_compact(void) const
Get the compact id.
Definition: Identifier32.h:171
lumiFormat.i
int i
Definition: lumiFormat.py:92
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
SCT3_RawData
Definition: SCT3_RawData.h:24
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
SCT3_RawDataCnv_p3::transToPers
virtual void transToPers(const SCT3_RawData *transObj, SCT3_RawData_p3 *persObj, MsgStream &log)
Definition: SCT3_RawDataCnv_p3.cxx:28
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
SCT_RawDataContainer_p3::m_numErrorsInRDO
std::vector< int > m_numErrorsInRDO
Definition: SCT_RawDataContainer_p3.h:38
SCT_RawDataContainer_p3::m_sct3data
std::vector< SCT3_RawData_p3 > m_sct3data
Definition: SCT_RawDataContainer_p3.h:32
SCT_RawDataContainerCnv_p3::createTransient
virtual SCT_RDO_Container * createTransient(const SCT_RawDataContainer_p3 *persObj, MsgStream &log)
Definition: SCT_RawDataContainerCnv_p3.cxx:194
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
SCT_RawDataContainer_p3::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_p3.h:37
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
SCT3_RawDataCnv_p3
Definition: SCT3_RawDataCnv_p3.h:21
InDetRawData_p2
Definition: InDetRawData_p2.h:10
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
SCT_RawDataContainerCnv_p3::m_sctId
const SCT_ID * m_sctId
Definition: SCT_RawDataContainerCnv_p3.h:29
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
IdentifierHash::value
unsigned int value(void) const
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_p3
N.Barlow, Apr 2008 replace float[20] with vector<int> to represent strips with errors.
Definition: SCT3_RawData_p3.h:15
SCT3_RawData_p3::m_word
unsigned int m_word
Definition: SCT3_RawData_p3.h:22
SCT3_RawData_p3::m_rdoId
Identifier::value_type m_rdoId
Definition: SCT3_RawData_p3.h:21
SCT_RawDataContainerCnv_p3.h
SCT1_RawDataCnv_p2
Definition: SCT1_RawDataCnv_p2.h:22
IdentifierHash
Definition: IdentifierHash.h:38
Identifier::get_identifier32
Identifier32 get_identifier32(void) const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
SCT1_RawDataCnv_p2.h
SCT_RawDataContainer_p3
Persistent represenation of an SCT_RawDataContainer.
Definition: SCT_RawDataContainer_p3.h:24
SCT3_RawDataCnv_p3.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetRawDataCollection_p1.h
MsgUtil.h