21 std::unique_ptr< SCT_RawDataContainer_p4 > persObj( std::make_unique<SCT_RawDataContainer_p4>() );
22 persObj->m_collections.reserve( transCont->
size() );
23 unsigned int n_rdos=0;
28 for (StripRawDataContainerProxy module_rdo_container_proxy : rdo_container_collection_proxy) {
29 if (!module_rdo_container_proxy.empty()) {
31 assert( n_rdos + module_rdo_container_proxy.size() < std::numeric_limits<unsigned int>::max());
32 persObj->m_collections.emplace_back();
33 persObj->m_collections.back().m_id =
m_idHelper->wafer_id(id_hash ).get_identifier32().get_compact();
34 persObj->m_collections.back().m_hashId = id_hash.
value();
35 persObj->m_collections.back().m_begin = n_rdos;
36 persObj->m_collections.back().m_end =
static_cast<unsigned int>(n_rdos+module_rdo_container_proxy.size());
37 n_rdos += module_rdo_container_proxy.size();
44 for (StripRawDataContainerProxy module_rdo_container_proxy : rdo_container_collection_proxy) {
45 if (!module_rdo_container_proxy.empty()) {
46 StripRawDataProxy rdo_proxy = module_rdo_container_proxy[0];
47 type=rdo_proxy.dataType();
55 persObj->m_rawdata.reserve( n_rdos );
56 for (StripRawDataContainerProxy module_rdo_container_proxy : rdo_container_collection_proxy) {
57 if (!module_rdo_container_proxy.empty()) {
60 assert( module_rdo_container_proxy.identifyHash() < persObj->m_collections.size());
61 assert( persObj->m_rawdata.size() == persObj->m_collections[ module_rdo_container_proxy.identifyHash() ].m_begin );
62 for (StripRawDataProxy rdo_proxy : module_rdo_container_proxy) {
63 persObj->m_rawdata.emplace_back();
64 persObj->m_rawdata.back().m_rdoId =
m_idHelper->strip_id(wafer_id,
65 rdo_proxy.coordinates()[0],
66 rdo_proxy.coordinates()[1]).get_identifier32().get_compact();
67 persObj->m_rawdata.back().m_word = rdo_proxy.dataWord();
69 assert( persObj->m_rawdata.size() == persObj->m_collections[ module_rdo_container_proxy.identifyHash() ].m_end);
75 throw std::runtime_error(
"Strip data type 3 not implemented in PhaseIIStripRawDataContainer");
78 throw std::runtime_error(
"Strip data type unhandled by the PhaseIIStripRawDataContainer");
81 return persObj.release();
87 static const pool::Guid SCT_TP4_guid(
"6C7540BE-E85C-4777-BC1C-A9FF11460F54");
91 std::unique_ptr<PhaseIIStripRawDataContainer> transCont(std::make_unique<PhaseIIStripRawDataContainer>(
m_idHelper->wafer_hash_max(),
95 if (persCont->m_sct3data.size() != 0){
98 else if (persCont->m_rawdata.size() != 0){
102 throw std::runtime_error(
"Unhandled persistent SCT raw data container.");
105 unsigned int n_rdos_total=0u;
107 assert( a_collection.
m_hashId < transCont->size() );
109 unsigned int n_rdos = a_collection.
m_end - a_collection.
m_begin;
111 assert( n_rdos_total == a_collection.
m_begin);
112 assert( n_rdos_total+n_rdos == a_collection.
m_end);
113 n_rdos_total += n_rdos;
119 constexpr ContainerIndex_t container_i=0u;
122 rdo_container_dest.
reserve(n_rdos_total);
123 assert(persCont->m_rawdata.size() == n_rdos_total);
125 [[maybe_unused]]
unsigned int n_rejected_ranges=0u;
127 assert(persCont->m_rawdata.size() == n_rdos_total);
132 static_cast<RangeSize_t
>(0u) ,
134 for (
unsigned int rdo_i = a_collection.
m_begin; rdo_i < a_collection.
m_end; ++rdo_i) {
135 assert( rdo_i < persCont->m_rawdata.size() );
136 Identifier strip_id(persCont->m_rawdata[rdo_i].m_rdoId);
138 assert(
strip <= std::numeric_limits<short>::max() &&
strip >= std::numeric_limits<short>::min());
139 assert( rdo_i == rdo_container_dest.
size());
140 rdo_container_dest.
emplace_back( std::array<std::int16_t,1>{
static_cast<short>(
strip)},
141 persCont->m_rawdata[rdo_i].m_word
147 assert( rdo_container_dest.
size() == a_collection.
m_end);
149 assert(
static_cast<std::size_t
>(rdo_container_dest.
size() - new_range.
beginIndex()) < std::numeric_limits<RangeSize_t>::max() );
153 n_rejected_ranges += !(transCont->registerOrEraseNewData( a_collection.
m_hashId, new_range));
155 assert( n_rejected_ranges == 0u);
157 assert( transCont->data(0).size() == n_rdos_total);
162 assert(persCont->m_sct3data.size() == n_rdos_total);
166 static_cast<RangeSize_t
>(0u) ,
168 for (
unsigned int rdo_i = a_collection.
m_begin; rdo_i < a_collection.
m_end; ++rdo_i) {
169 assert( rdo_i < persCont->m_sct3data.size() );
172 assert(
strip <= std::numeric_limits<short>::max() &&
strip >= std::numeric_limits<short>::min());
176 unsigned int word =
static_cast<unsigned int>(persObj.
m_word);
177 unsigned int group_size = word & 0x7FF;
178 unsigned int time_bin = (word>>11) & 0x7;
179 constexpr unsigned int errors =0u;
180 assert( rdo_i == rdo_container_dest.
size());
181 rdo_container_dest.
emplace_back( std::array<std::int16_t,1>{
static_cast<short>(
strip)},
187 assert( rdo_container_dest.
size() == a_collection.
m_end);
189 assert(
static_cast<std::size_t
>(rdo_container_dest.
size() - new_range.
beginIndex()) < std::numeric_limits<RangeSize_t>::max() );
191 std::size_t capped_size = rdo_container_dest.
size() - new_range.
beginIndex();
192 if (capped_size >= std::numeric_limits<PhaseII::DataRange::RangeSize_t>::max()) {
194 <<
" : " << capped_size <<
" !< " << std::numeric_limits<PhaseII::DataRange::RangeSize_t>::max()
195 <<
". Elements above maximum possible size will not be accessible.");
196 capped_size =std::numeric_limits<PhaseII::DataRange::RangeSize_t>::max();
198 new_range.
setSize(
static_cast<RangeSize_t
>( capped_size) );
200 n_rejected_ranges += !(transCont->registerOrEraseNewData( a_collection.
m_hashId, new_range));
202 assert( n_rejected_ranges == 0u);
204 assert( transCont->data(0).size() == n_rdos_total);
207 return transCont.release();
209 throw std::runtime_error(
"Unsupported persistent version in PhaseIIStripRawDataContainerCnv");