Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HGTD_ALTIROC_RDO_ContainerCnv_p1.cxx
Go to the documentation of this file.
1 
11 
13 #include "GaudiKernel/ISvcLocator.h"
14 #include "GaudiKernel/MsgStream.h"
15 #include "GaudiKernel/StatusCode.h"
20 #include "Identifier/Identifier.h"
21 #include "StoreGate/StoreGateSvc.h"
22 
23 #include <memory>
24 
26  // Do not initialize again:
27  m_is_initialized = true;
28 
29  // Get Storegate, ID helpers, and so on
30  ISvcLocator* svcLocator = Gaudi::svcLocator();
31 
32  // get DetectorStore service
33  SmartIF<StoreGateSvc> detStore{svcLocator->service("DetectorStore")};
34  CHECK(detStore.isValid());
35 
36  // Get the ID helper from the detector store
37  CHECK(detStore->retrieve(m_hgtd_idhelper, "HGTD_ID"));
38 
39  return StatusCode::SUCCESS;
40 }
41 
43  const Trans_t* transient_container, Pers_t* persistent_container,
44  MsgStream& log) {
45 
46  if (!m_is_initialized) {
47  if (this->initialize(log) != StatusCode::SUCCESS) {
48  log << MSG::FATAL << "Could not initialize HGTD_ALTIROC_RDO_ContainerCnv_p1 "
49  << endmsg;
50  }
51  }
52 
53  HGTD_ALTIROC_RDO_Cnv_p1 rdo_converter;
54  size_t n_collections = transient_container->numberOfCollections();
55  Trans_t::const_iterator container_itr = transient_container->begin();
56 
57  persistent_container->m_collection_separator.resize(n_collections);
58 
59  size_t collection_separator_index_begin = 0;
60  size_t total_n_clusters = 0;
61 
62  for (size_t coll_i = 0; coll_i < n_collections; coll_i++, ++container_itr) {
63  const HGTD_ALTIROC_RDO_Collection& collection = (**container_itr);
64 
65  size_t collection_size = collection.size();
66 
67  persistent_container->m_collection_separator.at(coll_i).m_hash_id =
68  collection.identifierHash().value();
69  persistent_container->m_collection_separator.at(coll_i).m_size =
70  collection_size;
71 
72  // continously resize the toal size of vector holding the individual
73  // clusters
74  total_n_clusters += collection_size;
75  persistent_container->m_rdo_list.resize(total_n_clusters);
76 
77  if (log.level() <= MSG::VERBOSE) {
78  log << MSG::VERBOSE << "Reading RDO collections size of "
79  << collection_size << endmsg;
80  }
81 
82  for (size_t rdo_i = 0; rdo_i < collection_size; rdo_i++) {
83  // get pointer to next position in the vector that will be persistified
84  HGTD_ALTIROC_RDO_p1* pers_rdo =
85  &((persistent_container->m_rdo_list)
86  .at(rdo_i + collection_separator_index_begin));
87 
88  const HGTD_ALTIROC_RDO* trans_rdo =
89  dynamic_cast<const HGTD_ALTIROC_RDO*>(collection.at(rdo_i));
90 
91  rdo_converter.transToPers(trans_rdo, pers_rdo, log);
92  }
93  // start next collection at end of previous
94  collection_separator_index_begin += collection.size();
95  }
96 
97  if (log.level() <= MSG::DEBUG) {
98  log << MSG::DEBUG
99  << "Writing HGTD_ClusterContainer to HGTD_ClusterContainer_p1 done"
100  << endmsg;
101  }
102 }
103 
106 
108  const Pers_t* persistent_container, Trans_t* transient_container,
109  MsgStream& log) {
110 
111  if (!m_is_initialized) {
112  if (this->initialize(log) != StatusCode::SUCCESS) {
113  log << MSG::FATAL << "Could not initialize HGTD_ALTIROC_RDO_ContainerCnv_p1 "
114  << endmsg;
115  }
116  }
117 
118  std::unique_ptr<HGTD_ALTIROC_RDO_Collection> collection = nullptr;
119 
120  HGTD_ALTIROC_RDO_Cnv_p1 rdo_converter;
121  size_t collection_separator_index_begin = 0;
122 
123  for (size_t coll_i = 0;
124  coll_i < persistent_container->m_collection_separator.size(); ++coll_i) {
125  const HGTD_ALTIROC_RDO_Collection_p1& rdo_coll =
126  persistent_container->m_collection_separator.at(coll_i);
127  // get the identifier for the collection
128  IdentifierHash coll_idhash = IdentifierHash(rdo_coll.m_hash_id);
129  Identifier coll_id = m_hgtd_idhelper->wafer_id(coll_idhash);
130 
131  collection = std::make_unique<HGTD_ALTIROC_RDO_Collection>(coll_idhash);
132  collection->setIdentifier(coll_id);
133 
134  unsigned short n_clusters = rdo_coll.m_size;
135  collection->resize(n_clusters);
136  for (unsigned short rdo_i = 0; rdo_i < n_clusters; ++rdo_i) {
137  const HGTD_ALTIROC_RDO_p1* pers_rdo =
138  &((persistent_container->m_rdo_list)
139  .at(rdo_i + collection_separator_index_begin));
140 
141  // NOTE I think I have to new it before calling the converter
142  HGTD_ALTIROC_RDO* trans_rdo = new HGTD_ALTIROC_RDO();
143  rdo_converter.persToTrans(pers_rdo, trans_rdo, log);
144  (*collection).at(rdo_i) = trans_rdo;
145  }
146  collection_separator_index_begin += n_clusters;
147 
148  StatusCode sc =
149  transient_container->addCollection(collection.release(), coll_idhash);
150  if (sc.isFailure()) {
151  throw std::runtime_error("Failed to add collection to ID Container");
152  }
153  }
154 }
155 
158  const Pers_t* persistent_container, MsgStream& log) {
159 
160  if (!m_is_initialized) {
161  if (this->initialize(log) != StatusCode::SUCCESS) {
162  log << MSG::FATAL << "Could not initialize HGTD_ALTIROC_RDO_ContainerCnv_p1 "
163  << endmsg;
164  }
165  }
166 
167  std::unique_ptr<Trans_t> transient_container =
168  std::make_unique<Trans_t>(m_hgtd_idhelper->wafer_hash_max());
169 
170  persToTrans(persistent_container, transient_container.get(), log);
171 
172  return (transient_container.release());
173 }
HGTD_ALTIROC_RDO_Collection::identifierHash
const IdentifierHash & identifierHash() const
Definition: HGTD_ALTIROC_RDO_Collection.h:32
HGTD_ALTIROC_RDO_Container_p1::m_rdo_list
std::vector< HGTD_ALTIROC_RDO_p1 > m_rdo_list
Definition: HGTD_ALTIROC_RDO_Container_p1.h:27
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:18
HGTD_ALTIROC_RDO_p1
Definition: HGTD_ALTIROC_RDO_p1.h:16
IdentifierHash::value
unsigned int value() const
HGTD_ALTIROC_RDO_Container_p1::m_collection_separator
std::vector< HGTD_ALTIROC_RDO_Collection_p1 > m_collection_separator
Definition: HGTD_ALTIROC_RDO_Container_p1.h:25
HGTD_ALTIROC_RDO_Container
Definition: HGTD_ALTIROC_RDO_Container.h:18
HGTD_ALTIROC_RDO_Cnv_p1::transToPers
void transToPers(const HGTD_ALTIROC_RDO *trans_obj, HGTD_ALTIROC_RDO_p1 *pers_obj, MsgStream &log)
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
Definition: HGTD_ALTIROC_RDO_Cnv_p1.cxx:13
HGTD_ALTIROC_RDO_ContainerCnv_p1.h
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
HGTD_ALTIROC_RDO_ContainerCnv_p1::m_is_initialized
bool m_is_initialized
Definition: HGTD_ALTIROC_RDO_ContainerCnv_p1.h:43
HGTD_ALTIROC_RDO
Definition: HGTD_ALTIROC_RDO.h:20
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
HGTD_ID::wafer_id
Identifier wafer_id(int endcap, int layer, int phi_module, int eta_module) const
For a single crystal.
Definition: HGTD_ID.h:287
HGTD_ALTIROC_RDO_ContainerCnv_p1::persToTrans
virtual void persToTrans(const Pers_t *persistent_container, Trans_t *transient_container, MsgStream &log)
Definition: HGTD_ALTIROC_RDO_ContainerCnv_p1.cxx:107
HGTD_ALTIROC_RDO_ContainerCnv_p1::createTransient
virtual Trans_t * createTransient(const Pers_t *persistent_container, MsgStream &log)
Definition: HGTD_ALTIROC_RDO_ContainerCnv_p1.cxx:157
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
HGTD_ALTIROC_RDO_Collection::setIdentifier
void setIdentifier(Identifier id)
Definition: HGTD_ALTIROC_RDO_Collection.h:30
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
ITPConverterFor::Trans_t
TransBase_t Trans_t
Definition: TPConverter.h:40
HGTD_ALTIROC_RDO_Container_p1
Definition: HGTD_ALTIROC_RDO_Container_p1.h:18
HGTD_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: HGTD_ID.cxx:832
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
HGTD_ALTIROC_RDO_Collection_p1.h
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
DataVector::resize
void resize(size_type sz)
Resizes the collection to the specified number of elements.
errorcheck.h
Helpers for checking error return status codes and reporting errors.
HGTD_ID.h
HGTD_ALTIROC_RDO_ContainerCnv_p1::initialize
StatusCode initialize(MsgStream &log)
Definition: HGTD_ALTIROC_RDO_ContainerCnv_p1.cxx:25
HGTD_ALTIROC_RDO_Collection_p1::m_hash_id
IdType_t m_hash_id
Definition: HGTD_ALTIROC_RDO_Collection_p1.h:27
HGTD_ALTIROC_RDO_Cnv_p1
Definition: HGTD_ALTIROC_RDO_Cnv_p1.h:21
DEBUG
#define DEBUG
Definition: page_access.h:11
HGTD_ALTIROC_RDO_Collection
Definition: HGTD_ALTIROC_RDO_Collection.h:20
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
HGTD_ALTIROC_RDO_Cnv_p1.h
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
HGTD_ALTIROC_RDO_Collection_p1::m_size
unsigned short m_size
Definition: HGTD_ALTIROC_RDO_Collection_p1.h:30
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
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
HGTD_ALTIROC_RDO_ContainerCnv_p1::m_hgtd_idhelper
const HGTD_ID * m_hgtd_idhelper
Definition: HGTD_ALTIROC_RDO_ContainerCnv_p1.h:41
HGTD_ALTIROC_RDO_p1.h
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
StoreGateSvc.h
HGTD_ALTIROC_RDO_Cnv_p1::persToTrans
void persToTrans(const HGTD_ALTIROC_RDO_p1 *pers_obj, HGTD_ALTIROC_RDO *trans_obj, MsgStream &log)
Definition: HGTD_ALTIROC_RDO_Cnv_p1.cxx:22
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
HGTD_ALTIROC_RDO_Collection_p1
Definition: HGTD_ALTIROC_RDO_Collection_p1.h:15
HGTD_ALTIROC_RDO_ContainerCnv_p1::transToPers
virtual void transToPers(const Trans_t *transient_container, Pers_t *persistent_container, MsgStream &log)
Definition: HGTD_ALTIROC_RDO_ContainerCnv_p1.cxx:42
Identifier
Definition: IdentifierFieldParser.cxx:14