ATLAS Offline Software
T_TilePoolContainerCnv.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // T_TilePoolContainerCnv.h
8 // Base class for Tile converters
9 // Author: Alexander Solodkov <Sanya.Solodkov@cern.ch>
10 // Date: June 2009
12 #ifndef TILETPCNV_T_TILEPOOLCONTAINERCNV_H
13 #define TILETPCNV_T_TILEPOOLCONTAINERCNV_H
14 
19 
20 #include <vector>
21 #include <inttypes.h>
22 
23 template<class TRANS, class PERS, class CONV>
25 public:
28 
29  typedef typename PERS::ElemVector pers_ElemVector;
30  typedef typename PERS::const_iterator pers_const_iterator;
32  using Collection = typename TRANS::IDENTIFIABLE;
33 
35 
42  virtual void persToTrans(const PERS* pers, TRANS* trans, MsgStream &log) const override
43  {
44 
45  const std::vector<unsigned int>& param = pers->getParam();
46  const pers_ElemVector& vec = pers->getVector();
47 
48  unsigned int pers_type = (param.size()>0) ? param[0] : 0;
49  int hashType = pers_type & 0xF;
50  int type = (pers_type >> 4) & 0xF;
51  int unit = (pers_type >> 8) & 0xF;
52  uint32_t bsflags = pers_type & 0xFFFFF000;
53  if (hashType == 0xF) hashType = TileFragHash::Beam;
54  if (type == 0xF) type = TileFragHash::Beam;
55 
56  log << MSG::DEBUG << MSG::hex << "pers_type= 0x" << pers_type
57  << " - " << bsflags << " " << unit << " " << type << " " << hashType
58  << MSG::dec << " Nelements= " << vec.size() << endmsg;
59 
60  trans->cleanup(); // remove all collections
61 
62  if ( trans->get_hashType() != hashType ) {
63  log << MSG::DEBUG << "Pers hash type " << hashType
64  << " does not match Trans hash type " << trans->get_hashType()
65  << " ==> reinitializing hash " << endmsg;
66 
67  trans->initialize(false,(TileFragHash::TYPE)hashType);
68  }
69 
70  trans->set_unit((TileRawChannelUnit::UNIT)unit);
71  trans->set_type((TileFragHash::TYPE)type);
72  trans->set_bsflags(bsflags);
73 
74 
75  auto mutableContainer = std::make_unique<TileMutableDataContainer<TRANS>>();
76  if (mutableContainer->status().isFailure()) {
77  throw std::runtime_error("Failed to initialize Tile mutable Container");
78  }
79 
80  for( pers_const_iterator it = vec.begin(), iEnd = vec.end(); it != iEnd; ++it) {
81  if (mutableContainer->push_back(m_elementCnv.createTransientConst(&(*it), log)).isFailure()) {
82  throw std::runtime_error("Failed to add Tile element to Collection");
83  }
84  }
85 
86  std::vector<IdentifierHash> hashes = mutableContainer->GetAllCurrentHashes();
87  for (const IdentifierHash& hash : hashes) {
88  Collection* coll = mutableContainer->indexFindPtr(hash);
89  auto newColl = std::make_unique<Collection>(std::move(*coll));
90  if (trans->addOrDelete(std::move(newColl), hash).isFailure()) {
91  throw std::runtime_error("Failed to add Tile collection to Identifiable Container");
92  }
93  }
94 
95  }
96 
103  virtual void transToPers(const TRANS* trans, PERS* pers, MsgStream &log) const override
104  {
105 
106  pers->clear();
107  pers->reserve(1, 12288);
108 
109  unsigned int pers_type = ((trans->get_hashType() & 0xF) |
110  ((trans->get_type() & 0xF)<<4) |
111  ((trans->get_unit() & 0xF)<<8) |
112  (trans->get_bsflags() & 0xFFFFF000) ) ;
113  pers->push_back_param(pers_type);
114 
115  SelectAllObject<TRANS> selAll(trans);
116  for(trans_const_iterator it = selAll.begin(),
117  iEnd = selAll.end();
118  it != iEnd; ++it) {
119  m_elementCnv.transToPers((*it), pers->newElem(), log);
120  }
121 
122  log << MSG::DEBUG << MSG::hex << "pers_type= 0x" << pers_type
123  << " - " << (trans->get_bsflags()>>12)
124  << " " << trans->get_unit()
125  << " " << trans->get_type()
126  << " " << trans->get_hashType()
127  << MSG::dec << " Nelements= " << pers->getVector().size() << endmsg;
128  }
129 
130 private:
133 };
134 
135 #endif
python.root_lsr_rank.hashes
hashes
Definition: root_lsr_rank.py:34
TileRawDataContainer.h
SelectAllObjectMT::end
const_iterator end()
Definition: SelectAllObjectMT.h:131
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
T_TilePoolContainerCnv::persToTrans
virtual void persToTrans(const PERS *pers, TRANS *trans, MsgStream &log) const override
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
Definition: T_TilePoolContainerCnv.h:42
TileFragHash::TYPE
TYPE
initialize
Definition: TileFragHash.h:33
skel.it
it
Definition: skel.GENtoEVGEN.py:396
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
T_TilePoolContainerCnv::pers_const_iterator
PERS::const_iterator pers_const_iterator
Definition: T_TilePoolContainerCnv.h:30
SelectAllObjectMT::begin
const_iterator begin()
Definition: SelectAllObjectMT.h:115
T_TilePoolContainerCnv::m_elementCnv
CONV m_elementCnv
TP converter used for vector elements.
Definition: T_TilePoolContainerCnv.h:132
SelectAllObjectMT
Definition: SelectAllObjectMT.h:11
T_TilePoolContainerCnv::Collection
typename TRANS::IDENTIFIABLE Collection
Definition: T_TilePoolContainerCnv.h:32
T_TilePoolContainerCnv::trans_const_iterator
SelectAllObject< TRANS >::const_iterator trans_const_iterator
Definition: T_TilePoolContainerCnv.h:31
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
T_AthenaPoolTPConverter.h
TileMutableDataContainer.h
Helper for holding non-const raw data prior to recording in SG.
SelectAllObjectMT::const_iterator
Definition: SelectAllObjectMT.h:22
TileRawChannelUnit::UNIT
UNIT
Definition: TileRawChannelUnit.h:16
TileFragHash::Beam
@ Beam
Definition: TileFragHash.h:33
RpcSectorLogicContainer_p1
Class to represent.
Definition: RpcSectorLogicContainer_p1.h:19
T_TilePoolContainerCnv::pers_ElemVector
PERS::ElemVector pers_ElemVector
Definition: T_TilePoolContainerCnv.h:29
T_TilePoolContainerCnv::transToPers
virtual void transToPers(const TRANS *trans, PERS *pers, MsgStream &log) const override
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
Definition: T_TilePoolContainerCnv.h:103
T_TilePoolContainerCnv::T_TilePoolContainerCnv
T_TilePoolContainerCnv()
Definition: T_TilePoolContainerCnv.h:34
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:21
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
T_TilePoolContainerCnv
Definition: T_TilePoolContainerCnv.h:24
SelectAllObject.h
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
TPConverterConstBase
Definition: TPConverter.h:776