ATLAS Offline Software
PixelRDO_ContainerCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "MsgUtil.h"
8 
9 #include <memory>
10 
11 #include <iostream>
12 
13 
14 
15 //================================================================
16 namespace {
17  std::string shortPrint(const PixelRDO_Container *main_input_Pixel, unsigned maxprint=25) {
18  std::ostringstream os;
19  if(main_input_Pixel) {
20  for(unsigned i=0; i<maxprint; i++) {
21  const auto* p = main_input_Pixel->indexFindPtr(i);
22  if(p != nullptr) {
23  os<<" "<< p->size();
24  }
25  else {
26  os<<" *";
27  }
28  }
29  }
30  else {
31  os<<" [PixelRDO_Container==NULL]";
32  }
33  return os.str();
34  }
35 }
36 //================================================================
39 
40  ATH_MSG_INFO("PixelRDO_ContainerCnv::initialize()");
41 
42  // Get the pixel helper from the detector store
43  const PixelID* idhelper(nullptr);
44  ATH_CHECK( detStore()->retrieve(idhelper, "PixelID") );
45 
46  m_converter_p0.initialize(idhelper);
47  m_converter_TP1.initialize(idhelper);
48  m_converter_TP2.initialize(idhelper);
49 
50  ATH_MSG_DEBUG("Converter initialized");
51 
52  return StatusCode::SUCCESS;
53 }
54 
55 //================================================================
57  ATH_MSG_DEBUG("createPersistent(): main converter. TRANS = "<<shortPrint(transCont));
58 
59  // converter_num is a switch to determine which persistent type to use
60  // 1: if concrete type private data is equivalent to InDetRawData_p1
61  // 2: for cosmic/TB not implemented
62  //
63  unsigned int converter_num(1);
64  PixelRDO_Container::const_iterator it_Coll = transCont->begin();
65  PixelRDO_Container::const_iterator it_CollEnd = transCont->end();
66  // check one element of the container. The container can't be empty for this...
67  if(it_Coll != it_CollEnd) {
68  while (it_Coll != it_CollEnd && (*it_Coll) && (*it_Coll)->size() == 0 ) ++it_Coll;
69  if(it_Coll != it_CollEnd) {
70  const PixelRDORawData *test((**it_Coll)[0]);
71  if(dynamic_cast<const Pixel1RawData*>(test) != nullptr ) {
72  ATH_MSG_DEBUG("Found container with Pixel1RawData concrete type objects");
73  converter_num=1;
74  } else {
75  ATH_MSG_FATAL("Converter not implemented for this concrete type ");
76  throw "Converter not implemented";
77  }
78  } else {
79  ATH_MSG_DEBUG("Container has only empty collections. Using TP1 converter");
80  }
81  } else {
82  ATH_MSG_DEBUG("Empty container. Using TP1 converter");
83  }
84  // Switch facility depending on the concrete data type of the contained objects
85  // Should do by getting the type_info of one of the contained objects
86  PixelRDO_Container_PERS *persObj(nullptr);
87  if(converter_num == 1) {
88  persObj = m_converter_PERS.createPersistent( transCont, msg() );
89  } else {
90  ATH_MSG_FATAL("This shouldn't happen!! ");
91  }
92  ATH_MSG_DEBUG("Success");
93  return persObj;
94 }
95 
96 //================================================================
98 
99  static const pool::Guid p0_guid("7F2C09B6-0B47-4957-8BBA-EDC665A290AC"); // with Pixel1RawData
100  static const pool::Guid TP1_guid("DA76970C-E019-43D2-B2F9-25660DCECD9D"); // for t/p separated version with InDetRawDataContainer_p1
101  static const pool::Guid TP2_guid("7138342E-0A80-4A32-A387-2842A01C2539"); // for t/p separated version with InDetRawDataContainer_p2
102  ATH_MSG_DEBUG("createTransient(): main converter");
103 
104  if( compareClassGuid(TP2_guid) ) {
105  ATH_MSG_DEBUG("createTransient(): New TP version - TP2 branch");
106 
107  std::unique_ptr< InDetRawDataContainer_p2 > col_vect( poolReadObject< InDetRawDataContainer_p2 >() );
108  PixelRDO_Container *res = m_converter_TP2.createTransient( col_vect.get(), msg() );
109 
110  ATH_MSG_DEBUG("createTransient(), TP2 branch: returns TRANS = "<<shortPrint(res));
111 
112  return res;
113 
114 
115  }
116  else if( compareClassGuid(TP1_guid) ) {
117  ATH_MSG_DEBUG("createTransient(): New TP version - TP1 branch");
118 
119  std::unique_ptr< InDetRawDataContainer_p1 > col_vect( poolReadObject< InDetRawDataContainer_p1 >() );
120  PixelRDO_Container *res = m_converter_TP1.createTransient( col_vect.get(), msg() );
121 
122  ATH_MSG_DEBUG("createTransient(), TP1 branch: returns TRANS = "<<shortPrint(res));
123 
124  return res;
125 
126 
127  }
128  else if( compareClassGuid(p0_guid) ) {
129  ATH_MSG_DEBUG("createTransient(): Old input file - p0 branch");
130 
131  std::unique_ptr< PixelRDO_Container_p0 > col_vect( poolReadObject< PixelRDO_Container_p0 >() );
132  PixelRDO_Container *res = m_converter_p0.createTransient( col_vect.get(), msg() );
133 
134  ATH_MSG_DEBUG("createTransient(), p0 branch: returns TRANS = "<<shortPrint(res));
135 
136  return res;
137  }
138  throw std::runtime_error("Unsupported persistent version of PixelRDO_Container");
139 }
140 
141 //================================================================
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PixelRDO_ContainerCnv::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition: PixelRDO_ContainerCnv.cxx:37
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PixelRDO_ContainerCnv::m_converter_PERS
PixelRDO_ContainerCnv_PERS m_converter_PERS
Definition: PixelRDO_ContainerCnv.h:34
InDetRawDataContainer_p2
Definition: InDetRawDataContainer_p2.h:31
PixelRDO_ContainerCnv.h
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
TPAbstractPolyCnvBase::createPersistent
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of a transient object.
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PixelRDO_ContainerCnv::m_converter_TP1
Pixel1RawDataContainerCnv_p1 m_converter_TP1
Definition: PixelRDO_ContainerCnv.h:32
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
Pixel1RawDataContainerCnv_p2::initialize
void initialize(const PixelID *idhelper)
Definition: Pixel1RawDataContainerCnv_p2.h:42
Pixel1RawData
Definition: Pixel1RawData.h:23
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
AthenaPoolConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: AthenaPoolConverter.h:69
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
PixelRDO_ContainerCnv_p0::initialize
void initialize(const PixelID *idhelper)
Definition: PixelRDO_ContainerCnv_p0.h:33
Pixel1RawDataContainerCnv_p1::createTransient
virtual PixelRDO_Container * createTransient(const InDetRawDataContainer_p1 *persObj, MsgStream &log)
Definition: Pixel1RawDataContainerCnv_p1.cxx:138
PixelRDO_ContainerCnv::m_converter_TP2
Pixel1RawDataContainerCnv_p2 m_converter_TP2
Definition: PixelRDO_ContainerCnv.h:33
PixelRDO_ContainerCnv::createTransient
virtual PixelRDO_Container * createTransient() override
Definition: PixelRDO_ContainerCnv.cxx:97
IdentifiableContainerMT::indexFindPtr
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
Definition: IdentifiableContainerMT.h:292
Pixel1RawDataContainerCnv_p2::createTransient
virtual PixelRDO_Container * createTransient(const InDetRawDataContainer_p2 *persObj, MsgStream &log)
Definition: Pixel1RawDataContainerCnv_p2.cxx:139
PixelRDO_ContainerCnv_p0::createTransient
virtual PixelRDO_Container * createTransient(const PixelRDO_Container_p0 *persObj, MsgStream &log)
Definition: PixelRDO_ContainerCnv_p0.cxx:19
Pixel1RawDataContainerCnv_p1::initialize
void initialize(const PixelID *idhelper)
Definition: Pixel1RawDataContainerCnv_p1.h:42
PixelRDORawData
Definition: PixelRDORawData.h:23
PixelRDO_ContainerCnv::createPersistent
virtual PixelRDO_Container_PERS * createPersistent(PixelRDO_Container *transCont) override
Definition: PixelRDO_ContainerCnv.cxx:56
T_AthenaPoolCustCnv::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
PixelRDO_ContainerCnv::m_converter_p0
PixelRDO_ContainerCnv_p0 m_converter_p0
Definition: PixelRDO_ContainerCnv.h:31
T_AthenaPoolCustCnv::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
PixelID
Definition: PixelID.h:67
MsgUtil.h