12 #ifndef TILETPCNV_T_TILEPOOLCONTAINERCNV_H
13 #define TILETPCNV_T_TILEPOOLCONTAINERCNV_H
24 #include <GaudiKernel/IMessageSvc.h>
25 #include <GaudiKernel/MsgStream.h>
27 #include <unordered_map>
31 template<
class TRANS,
class PERS,
class CONV>
53 const std::vector<unsigned int>& param = pers->getParam();
56 unsigned int pers_type = (param.size()>0) ? param[0] : 0;
57 int hashType = pers_type & 0xF;
58 int type = (pers_type >> 4) & 0xF;
59 int unit = (pers_type >> 8) & 0xF;
60 uint32_t bsflags = pers_type & 0xFFFFF000;
65 <<
" - " << bsflags <<
" " <<
unit <<
" " <<
type <<
" " << hashType
66 << MSG::dec <<
" Nelements= " <<
vec.size() <<
endmsg;
70 if ( trans->get_hashType() != hashType ) {
72 <<
" does not match Trans hash type " << trans->get_hashType()
73 <<
" ==> reinitializing hash " <<
endmsg;
80 trans->set_bsflags(bsflags);
83 auto mutableContainer = std::make_unique<TileMutableDataContainer<TRANS>>();
84 if (mutableContainer->status().isFailure()) {
85 throw std::runtime_error(
"Failed to initialize Tile mutable Container");
89 if (mutableContainer->push_back(
m_elementCnv.createTransientConst(&(*
it),
log)).isFailure()) {
90 throw std::runtime_error(
"Failed to add Tile element to Collection");
94 std::vector<IdentifierHash>
hashes = mutableContainer->GetAllCurrentHashes();
96 if constexpr (std::is_same_v<TRANS, TileRawChannelContainer> ) {
97 int paramSize = param.size();
99 int firstHashPosition = 1;
100 unsigned int goodBCID = 0xDEAD;
101 if (((paramSize - 2) % 5) == 0) {
104 firstHashPosition = 2;
106 if (goodBCID != 0xDEAD) {
113 int lastHashPosition = paramSize - 5;
114 for (
int i = firstHashPosition;
i <= lastHashPosition; ++
i) {
116 if (!rawChannelCollection) {
130 auto newColl = std::make_unique<Collection>(std::move(*coll));
131 if (trans->addOrDelete(std::move(newColl),
hash).isFailure()) {
132 throw std::runtime_error(
"Failed to add Tile collection to Identifiable Container");
148 pers->reserve(1, 12288);
150 unsigned int pers_type = ((trans->get_hashType() & 0xF) |
151 ((trans->get_type() & 0xF)<<4) |
152 ((trans->get_unit() & 0xF)<<8) |
153 (trans->get_bsflags() & 0xFFFFF000) ) ;
154 pers->push_back_param(pers_type);
156 if constexpr (std::is_same_v<TRANS, TileRawChannelContainer> ) {
159 std::unordered_map<unsigned int, int> bcidFreequency;
160 std::vector<IdentifierHash>
hashes = trans->GetAllCurrentHashes();
166 unsigned int goodBCID = (*std::max_element(bcidFreequency.begin(), bcidFreequency.end(),
167 [] (
const auto& bcidAndFreequency1,
const auto& bcidAndFreequency2) {
168 return bcidAndFreequency1.second < bcidAndFreequency2.second;
171 if (goodBCID != 0xDEAD) {
172 pers->push_back_param(goodBCID);
178 int frag = rawChannelCollection->
identify();
179 bool extendedBarrel = (frag > 0x2ff);
180 bool specialModule = (frag == 0x30e || frag == 0x411);
182 unsigned int existingDMUmask = (~(specialModule ? 0xC301 : (extendedBarrel ? 0xC300 : 0))) & 0xFFFF;
185 if (extendedBarrel) {
186 if (specialModule) feDMUmask <<= 1;
187 feDMUmask = (feDMUmask & 0xFF) | ((feDMUmask & 0xF00) << 2);
199 unsigned int fragBCID = rawChannelCollection->
getFragBCID() & existingDMUmask;
203 || fragMemoryParity) {
205 pers->push_back_param(
hash);
207 pers->push_back_param(rawChannelCollection->
getFragBCID() & existingDMUmask);
209 pers->push_back_param(fragMemoryParity);
222 log <<
MSG::DEBUG << MSG::hex <<
"pers_type= 0x" << pers_type
223 <<
" - " << (trans->get_bsflags()>>12)
224 <<
" " << trans->get_unit()
225 <<
" " << trans->get_type()
226 <<
" " << trans->get_hashType()
227 << MSG::dec <<
" Nelements= " << pers->getVector().size() <<
endmsg;