ATLAS Offline Software
PixelRDO_ContainerCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  if (sc.isFailure()) {
40  ATH_MSG_FATAL("PixelRDO_ContainerCnvBase::initialize() returned failure !");
41  return StatusCode::FAILURE;
42  }
43 
44  ATH_MSG_INFO("PixelRDO_ContainerCnv::initialize()");
45 
46  // get StoreGate service. This is needed only for clients
47  // that register collections directly to the SG instead of adding
48  // them to the container.
49  sc = service("StoreGateSvc", m_storeGate);
50  if (sc.isFailure()) {
51  ATH_MSG_FATAL("StoreGate service not found !");
52  return StatusCode::FAILURE;
53  }
54 
55  // get DetectorStore service
56  StoreGateSvc *detStore(nullptr);
57  if (service("DetectorStore", detStore).isFailure()) {
58  ATH_MSG_FATAL("DetectorStore service not found !");
59  return StatusCode::FAILURE;
60  } else {
61  ATH_MSG_DEBUG("Found DetectorStore.");
62  }
63 
64  // Get the pixel helper from the detector store
65  const PixelID* idhelper(nullptr);
66  if (detStore->retrieve(idhelper, "PixelID").isFailure()) {
67  ATH_MSG_FATAL("Could not get PixelID helper !");
68  return StatusCode::FAILURE;
69  } else {
70  ATH_MSG_DEBUG("Found the PixelID helper.");
71  }
72 
73  m_converter_p0.initialize(idhelper);
74  m_converter_TP1.initialize(idhelper);
75  m_converter_TP2.initialize(idhelper);
76 
77  ATH_MSG_DEBUG("Converter initialized");
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 //================================================================
84  ATH_MSG_DEBUG("createPersistent(): main converter. TRANS = "<<shortPrint(transCont));
85 
86  // converter_num is a switch to determine which persistent type to use
87  // 1: if concrete type private data is equivalent to InDetRawData_p1
88  // 2: for cosmic/TB not implemented
89  //
90  unsigned int converter_num(1);
91  PixelRDO_Container::const_iterator it_Coll = transCont->begin();
92  PixelRDO_Container::const_iterator it_CollEnd = transCont->end();
93  // check one element of the container. The container can't be empty for this...
94  if(it_Coll != it_CollEnd) {
95  while (it_Coll != it_CollEnd && (*it_Coll)->size() == 0 ) ++it_Coll;
96  if(it_Coll != it_CollEnd) {
97  const PixelRDORawData *test((**it_Coll)[0]);
98  if(dynamic_cast<const Pixel1RawData*>(test) != nullptr ) {
99  ATH_MSG_DEBUG("Found container with Pixel1RawData concrete type objects");
100  converter_num=1;
101  } else {
102  ATH_MSG_FATAL("Converter not implemented for this concrete type ");
103  throw "Converter not implemented";
104  }
105  } else {
106  ATH_MSG_DEBUG("Container has only empty collections. Using TP1 converter");
107  }
108  } else {
109  ATH_MSG_DEBUG("Empty container. Using TP1 converter");
110  }
111  // Switch facility depending on the concrete data type of the contained objects
112  // Should do by getting the type_info of one of the contained objects
113  PixelRDO_Container_PERS *persObj(nullptr);
114  if(converter_num == 1) {
115  persObj = m_converter_PERS.createPersistent( transCont, msg() );
116  } else {
117  ATH_MSG_FATAL("This shouldn't happen!! ");
118  }
119  ATH_MSG_DEBUG("Success");
120  return persObj;
121 }
122 
123 //================================================================
125 
126  static const pool::Guid p0_guid("7F2C09B6-0B47-4957-8BBA-EDC665A290AC"); // with Pixel1RawData
127  static const pool::Guid TP1_guid("DA76970C-E019-43D2-B2F9-25660DCECD9D"); // for t/p separated version with InDetRawDataContainer_p1
128  static const pool::Guid TP2_guid("7138342E-0A80-4A32-A387-2842A01C2539"); // for t/p separated version with InDetRawDataContainer_p2
129  ATH_MSG_DEBUG("createTransient(): main converter");
130 
131  if( compareClassGuid(TP2_guid) ) {
132  ATH_MSG_DEBUG("createTransient(): New TP version - TP2 branch");
133 
134  std::unique_ptr< InDetRawDataContainer_p2 > col_vect( poolReadObject< InDetRawDataContainer_p2 >() );
135  PixelRDO_Container *res = m_converter_TP2.createTransient( col_vect.get(), msg() );
136 
137  ATH_MSG_DEBUG("createTransient(), TP2 branch: returns TRANS = "<<shortPrint(res));
138 
139  return res;
140 
141 
142  }
143  else if( compareClassGuid(TP1_guid) ) {
144  ATH_MSG_DEBUG("createTransient(): New TP version - TP1 branch");
145 
146  std::unique_ptr< InDetRawDataContainer_p1 > col_vect( poolReadObject< InDetRawDataContainer_p1 >() );
147  PixelRDO_Container *res = m_converter_TP1.createTransient( col_vect.get(), msg() );
148 
149  ATH_MSG_DEBUG("createTransient(), TP1 branch: returns TRANS = "<<shortPrint(res));
150 
151  return res;
152 
153 
154  }
155  else if( compareClassGuid(p0_guid) ) {
156  ATH_MSG_DEBUG("createTransient(): Old input file - p0 branch");
157 
158  std::unique_ptr< PixelRDO_Container_p0 > col_vect( poolReadObject< PixelRDO_Container_p0 >() );
159  PixelRDO_Container *res = m_converter_p0.createTransient( col_vect.get(), msg() );
160 
161  ATH_MSG_DEBUG("createTransient(), p0 branch: returns TRANS = "<<shortPrint(res));
162 
163  return res;
164  }
165  throw std::runtime_error("Unsupported persistent version of PixelRDO_Container");
166 }
167 
168 //================================================================
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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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:144
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
TPAbstractPolyCnvBase::createPersistent
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of a transient object.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
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
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
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
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
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::m_storeGate
StoreGateSvc * m_storeGate
Definition: PixelRDO_ContainerCnv.h:37
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
PixelRDO_ContainerCnv::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
Definition: PixelRDO_ContainerCnv.cxx:37
PixelRDORawData
Definition: PixelRDORawData.h:23
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
PixelRDO_ContainerCnv::createPersistent
virtual PixelRDO_Container_PERS * createPersistent(PixelRDO_Container *transCont)
Definition: PixelRDO_ContainerCnv.cxx:83
PixelRDO_ContainerCnv::createTransient
virtual PixelRDO_Container * createTransient()
Definition: PixelRDO_ContainerCnv.cxx:124
MsgUtil.h