ATLAS Offline Software
Loading...
Searching...
No Matches
PhaseIIPixelRawDataContainerCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
7
8#include <memory>
9
12 ATH_CHECK( detStore()->retrieve(m_idHelper, "PixelID") );
13 return StatusCode::SUCCESS;
14}
15
17 assert( transCont);
18 std::unique_ptr< InDetRawDataContainer_p2 > persObj( std::make_unique<InDetRawDataContainer_p2>() );
19 persObj->m_collections.reserve( transCont->size() );
20 unsigned int n_rdos=0;
21
22 auto rdo_container_collection_proxy = PhaseII::makeRawDataCollectionProxy(*transCont);
25 for (PixelRawDataContainerProxy module_rdo_container_proxy : rdo_container_collection_proxy) {
26 if (!module_rdo_container_proxy.empty()) {
27 IdentifierHash id_hash(module_rdo_container_proxy.identifyHash());
28 assert( n_rdos + module_rdo_container_proxy.size() < std::numeric_limits<unsigned int>::max());
29 persObj->m_collections.emplace_back();
30 persObj->m_collections.back().m_id = m_idHelper->wafer_id(id_hash ).get_identifier32().get_compact();
31 persObj->m_collections.back().m_hashId = id_hash.value();
32 persObj->m_collections.back().m_begin = n_rdos;
33 persObj->m_collections.back().m_end = static_cast<unsigned int>(n_rdos+module_rdo_container_proxy.size());
34
35 n_rdos += module_rdo_container_proxy.size();
36 }
37 }
38
39 persObj->m_rawdata.reserve( n_rdos );
40 for (PixelRawDataContainerProxy module_rdo_container_proxy : rdo_container_collection_proxy) {
41 if (!module_rdo_container_proxy.empty()) {
42 IdentifierHash id_hash(module_rdo_container_proxy.identifyHash());
43 Identifier wafer_id = m_idHelper->wafer_id(id_hash);
44 assert( module_rdo_container_proxy.identifyHash() < persObj->m_collections.size());
45 assert( persObj->m_rawdata.size() == persObj->m_collections[ module_rdo_container_proxy.identifyHash() ].m_begin );
46 for (PixelRawDataProxy rdo_proxy : module_rdo_container_proxy) {
47 persObj->m_rawdata.emplace_back();
48 persObj->m_rawdata.back().m_rdoId = m_idHelper->pixel_id(wafer_id,
49 rdo_proxy.coordinates()[0],
50 rdo_proxy.coordinates()[1]).get_identifier32().get_compact();
51 persObj->m_rawdata.back().m_word = rdo_proxy.dataWord();
52 }
53 assert( persObj->m_rawdata.size() == persObj->m_collections[ module_rdo_container_proxy.identifyHash() ].m_end);
54 }
55 }
56 return persObj.release();
57}
58
60 // @TODO add support for p0 guid 7F2C09B6-0B47-4957-8BBA-EDC665A290AC i.e. initial version Pixel1RawData
61 // @TODO add support for p2 guid DA76970C-E019-43D2-B2F9-25660DCECD9D i.e. for t/p separated version with InDetRawDataContainer_p1
62 static const pool::Guid TP2_guid("7138342E-0A80-4A32-A387-2842A01C2539"); // for t/p separated version with InDetRawDataContainer_p2
63 if( compareClassGuid(TP2_guid) ) {
64 std::unique_ptr< InDetRawDataContainer_p2 > persCont( poolReadObject< InDetRawDataContainer_p2 >() );
65 std::unique_ptr<PhaseIIPixelRawDataContainer> transCont(std::make_unique<PhaseIIPixelRawDataContainer>(m_idHelper->wafer_hash_max(),
66 1 /* a single data container */));
67
68 unsigned int n_rdos_total=0u;
69 for ( const InDetRawDataCollection_p1 &a_collection : persCont->m_collections) {
70 assert( a_collection.m_hashId < transCont->size() );
71 assert( a_collection.m_hashId == m_idHelper->wafer_hash(Identifier(a_collection.m_id)));
72 unsigned int n_rdos = a_collection.m_end - a_collection.m_begin;
73
74 n_rdos_total += n_rdos;
75 }
76 assert( persCont->m_collections.size() <= transCont->size());
77
78 using RangeBeginIndex_t = PhaseII::DataRange::RangeBeginIndex_t;
79 using RangeSize_t = PhaseII::DataRange::RangeSize_t;
80 using ContainerIndex_t = PhaseII::DataRange::ContainerIndex_t;
81 constexpr ContainerIndex_t container_i=0u;
82
83 PhaseII::PixelRawDataContainer &rdo_container_dest = transCont->data(container_i);
84
85 rdo_container_dest.reserve(n_rdos_total);
86 assert(persCont->m_rawdata.size() == n_rdos_total);
87
88 [[maybe_unused]] unsigned int n_rejected_ranges=0u;
89 for ( const InDetRawDataCollection_p1 &a_collection : persCont->m_collections) {
90
91 PhaseII::DataRange new_range( static_cast<RangeBeginIndex_t>(rdo_container_dest.size()),
92 static_cast<RangeSize_t>(0u) ,
93 container_i);
94 // @TODO should use the ContainerRangeGuard, and the convenience method addDataForModule
95 for (unsigned int rdo_i = a_collection.m_begin; rdo_i < a_collection.m_end; ++rdo_i) {
96 assert( rdo_i < persCont->m_rawdata.size() );
97 assert( rdo_i == rdo_container_dest.size());
98 Identifier pixel_id (m_idHelper->pixel_id( persCont->m_rawdata[rdo_i].m_rdoId ));
99 assert( m_idHelper->phi_index(pixel_id) < std::numeric_limits<short int>::max());
100 assert( m_idHelper->eta_index(pixel_id) < std::numeric_limits<short int>::max());
101 rdo_container_dest.emplace_back( std::array<std::int16_t,2>{static_cast<std::int16_t>(m_idHelper->phi_index(pixel_id)),
102 static_cast<std::int16_t>(m_idHelper->eta_index(pixel_id))},
103 persCont->m_rawdata[rdo_i].m_word);
104 }
105
106 // @TODO remove :
107 assert( new_range.beginIndex() == a_collection.m_begin);
108 assert( rdo_container_dest.size() == a_collection.m_end);
109
110 assert( static_cast<std::size_t>(rdo_container_dest.size() - new_range.beginIndex()) < std::numeric_limits<RangeSize_t>::max() );
111 // update the number of elements in this range.
112 std::size_t capped_size = rdo_container_dest.size() - new_range.beginIndex();
113 if (capped_size >= std::numeric_limits<PhaseII::DataRange::RangeSize_t>::max()) {
114 ATH_MSG_WARNING( "Too many RDOs registered for module hash " << a_collection.m_hashId
115 << " : " << capped_size << " !< " << std::numeric_limits<PhaseII::DataRange::RangeSize_t>::max()
116 << ". Elements above maximum possible size will not be accessible.");
117 capped_size =std::numeric_limits<PhaseII::DataRange::RangeSize_t>::max();
118 }
119 new_range.setSize(static_cast<RangeSize_t>( capped_size));
120
121 // register the new hit range
122 n_rejected_ranges += !(transCont->registerOrEraseNewData( a_collection.m_hashId, new_range));
123 // since only this converter registers ranges in this container, the just added range of elements should never be erased:
124 assert( n_rejected_ranges == 0u);
125
126 }
127 return transCont.release();
128 }
129 throw std::runtime_error("Unsupported persistent version in PhaseIIPixelRawDataContainerCnv");
130}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
InDetRawDataContainer_p2 PixelRDO_Container_PERS
PhaseII::PixelRawDataContainerCollectionTypes<>::ContainerCollection PhaseIIPixelRawDataContainer
This is an Identifier helper class for the Pixel subdetector.
This is a "hash" representation of an Identifier.
value_type value() const
IdentifierHash::value_type m_hashId
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
virtual PixelRDO_Container_PERS * createPersistent(PhaseIIPixelRawDataContainer *transCont) override
virtual PhaseIIPixelRawDataContainer * createTransient() override
void emplace_back(std::array< std::int16_t, NDim > &&coordinates, std::uint32_t data_word)
Add a new RDO to the end of this container.
std::size_t size() const
total number of RDOs which are in this container.
void reserve(std::size_t new_capacity)
reserve space for a certain number of RDOs.
std::size_t size() const
return the total number of element ranges.
The container for pixel RDOs The base class is the InDetRawDataContainer with a coordinate dimension ...
auto makeRawDataCollectionProxy(const T_RawDataContainerCollection &collection)
Create the top level container proxy for an RDO container collection (read only).
Type describing a range of elements living in a one of N containers.
unsigned int beginIndex() const
void setSize(RangeSize_t new_size)
PhaseII::RawDataContainerProxy< PixelRawDataContainer, RawDataProxy, accessPolicy > RawDataContainerProxy
typename RawData::details::traits< PixelRawDataContainer >::template RawDataProxy< accessPolicy > RawDataProxy