ATLAS Offline Software
TRT_RDO_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 
5 #include "TRT_RDO_ContainerCnv.h"
6 
8 
9 #include <memory>
10 
11 #include <iostream>
12 
13 
14 //================================================================
15 namespace {
16  std::string shortPrint(const TRT_RDO_Container *main_input_TRT, unsigned maxprint=25) {
17  std::ostringstream os;
18  if(main_input_TRT) {
19  for(unsigned i=0; i<maxprint; i++) {
20  const auto* p = main_input_TRT->indexFindPtr(i);
21  if(p != nullptr) {
22  os<<" "<< p->size();
23  }
24  else {
25  os<<" *";
26  }
27  }
28  }
29  else {
30  os<<" [TRT_RDO_Container==NULL]";
31  }
32  return os.str();
33  }
34 }
35 //================================================================
37  ATH_MSG_INFO("TRT_RDO_ContainerCnv::initialize()");
38 
40 
41  // get StoreGate service. This is needed only for clients
42  // that register collections directly to the SG instead of adding
43  // them to the container.
44  ATH_CHECK( m_storeGate.retrieve() );
45 
46  // Get the trt helper from the detector store
47  const TRT_ID* idhelper(nullptr);
48  ATH_CHECK( detStore()->retrieve(idhelper, "TRT_ID") );
49 
50  m_converter_p0.initialize(idhelper);
51  m_converter_p1.initialize(idhelper, m_storeGate.get());
52  m_converter_TP1.initialize(idhelper);
53  m_converter_TP2.initialize(idhelper);
54  m_converter_TP3.initialize(idhelper);
55 
56  ATH_MSG_DEBUG("Converter initialized");
57 
58  return StatusCode::SUCCESS;
59 }
60 
61 //================================================================
63  ATH_MSG_DEBUG("createPersistent(): main converter. TRANS = "<<shortPrint(transCont));
64  // converter_num is a switch to determine which persistent type to use
65  // 1: if concrete type private data is equivalent to InDetRawData_p1
66  // 2: for cosmic/TB not implemented
67  //
68  unsigned int converter_num(1);
69  TRT_RDO_Container::const_iterator it_Coll = transCont->begin();
70  TRT_RDO_Container::const_iterator it_CollEnd = transCont->end();
71  // check one element of the container. The container can't be empty for this...
72  if(it_Coll != it_CollEnd) {
73  while (it_Coll != it_CollEnd && (*it_Coll)->size() == 0 ) ++it_Coll;
74  if(it_Coll != it_CollEnd) {
75  const TRT_RDORawData *test((**it_Coll)[0]);
76  if(dynamic_cast<const TRT_LoLumRawData*>(test) != nullptr ) {
77  ATH_MSG_DEBUG("Found container with TRT_LoLumRawData concrete type objects");
78  converter_num=1;
79  } else {
80  ATH_MSG_FATAL("Converter not implemented for this concrete type " );
81  throw "Converter not implemented";
82  }
83  } else {
84  ATH_MSG_WARNING("Container has only empty collections. Using TP1 converter");
85  }
86  } else {
87  ATH_MSG_WARNING("Empty container. Using TP1 converter");
88  }
89  // Switch facility depending on the concrete data type of the contained objects
90  // Should do by getting the type_info of one of the contained objects
91  TRT_RDO_Container_PERS *persObj(nullptr);
92  if(converter_num == 1) {
93  persObj = m_converter_PERS.createPersistent( transCont, msg() );
94  } else {
95  ATH_MSG_FATAL("This shouldn't happen!! ");
96  }
97  ATH_MSG_DEBUG("Success");
98  return persObj;
99 }
100 
101 //================================================================
103 
104  static const pool::Guid p0_guid("5DB01CED-F6FD-4866-A1C6-E046641E44F5"); // with TRT_LoLumRawData
105  static const pool::Guid p1_guid("CFBDB7A8-C788-4EE7-A260-3C8B680234FE"); // with TRT_RDORawData
106  static const pool::Guid TP1_guid("DA76970C-E019-43D2-B2F9-25660DCECD9D"); // for t/p separated version with InDetRawDataContainer_p1
107  static const pool::Guid TP2_guid("7138342E-0A80-4A32-A387-2842A01C2539"); // for t/p separated version with InDetRawDataContainer_p2
108  static const pool::Guid TP3_guid("D0313948-9BC8-415F-BE58-7BA8178F93CD"); // for t/p separated version with InDetRawDataContainer_p3
109  ATH_MSG_DEBUG("createTransient(): main converter");
110 
111  if( compareClassGuid(TP3_guid) ) {
112  ATH_MSG_DEBUG("createTransient(): New TP version - TP3 branch");
113  std::unique_ptr< InDetRawDataContainer_p3 > col_vect( poolReadObject< InDetRawDataContainer_p3 >() );
114  TRT_RDO_Container *res = m_converter_TP3.createTransient( col_vect.get(), msg() );
115  ATH_MSG_DEBUG("createTransient(), TP3 branch: returns TRANS = "<<shortPrint(res));
116  return res;
117  }
118  else if( compareClassGuid(TP2_guid) ) {
119  ATH_MSG_DEBUG("createTransient(): New TP version - TP2 branch");
120  std::unique_ptr< InDetRawDataContainer_p2 > col_vect( poolReadObject< InDetRawDataContainer_p2 >() );
121  TRT_RDO_Container *res = m_converter_TP2.createTransient( col_vect.get(), msg() );
122  ATH_MSG_DEBUG("createTransient(), TP2 branch: returns TRANS = "<<shortPrint(res));
123  return res;
124  }
125  else if( compareClassGuid(TP1_guid) ) {
126  ATH_MSG_DEBUG("createTransient(): New TP version - TP1 branch");
127  std::unique_ptr< InDetRawDataContainer_p1 > col_vect( poolReadObject< InDetRawDataContainer_p1 >() );
128  TRT_RDO_Container *res = m_converter_TP1.createTransient( col_vect.get(), msg() );
129  ATH_MSG_DEBUG("createTransient(), TP1 branch: returns TRANS = "<<shortPrint(res));
130  return res;
131  }
132  else if( compareClassGuid(p1_guid) ) {
133  ATH_MSG_DEBUG("createTransient(): New input file - p1 branch");
134  std::unique_ptr< TRT_RDO_Container_p1 > col_vect( poolReadObject< TRT_RDO_Container_p1 >() );
135  TRT_RDO_Container *res = m_converter_p1.createTransient( col_vect.get(), msg() );
136  ATH_MSG_DEBUG("createTransient(), p1 branch: returns TRANS = "<<shortPrint(res));
137  return res;
138  }
139  else if( compareClassGuid(p0_guid) ) {
140  ATH_MSG_DEBUG("createTransient(): Old input file - p0 branch");
141  std::unique_ptr< TRT_RDO_Container_p0 > col_vect( poolReadObject< TRT_RDO_Container_p0 >() );
142  TRT_RDO_Container *res = m_converter_p0.createTransient( col_vect.get(), msg() );
143  ATH_MSG_DEBUG("createTransient(), p0 branch: returns TRANS = "<<shortPrint(res));
144  return res;
145  }
146  throw std::runtime_error("Unsupported persistent version of TRT_RDO_Container");
147 }
148 
149 //================================================================
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TRT_LoLumRawDataContainerCnv_p3::createTransient
virtual TRT_RDO_Container * createTransient(const InDetRawDataContainer_p3 *persObj, MsgStream &log)
Definition: TRT_LoLumRawDataContainerCnv_p3.cxx:256
TRT_RDO_ContainerCnv_p1::initialize
void initialize(const TRT_ID *idhelper, StoreGateSvc *sg)
Definition: TRT_RDO_ContainerCnv_p1.h:30
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TRT_LoLumRawData
Definition: TRT_LoLumRawData.h:25
TRT_RDO_ContainerCnv::m_converter_TP1
TRT_LoLumRawDataContainerCnv_p1 m_converter_TP1
Definition: TRT_RDO_ContainerCnv.h:36
TRT_RDO_ContainerCnv::m_converter_TP3
TRT_LoLumRawDataContainerCnv_p3 m_converter_TP3
Definition: TRT_RDO_ContainerCnv.h:38
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
InDetRawDataContainer_p3
Definition: InDetRawDataContainer_p3.h:19
TRT_RDO_ContainerCnv::createPersistent
virtual TRT_RDO_Container_PERS * createPersistent(TRT_RDO_Container *transCont)
Definition: TRT_RDO_ContainerCnv.cxx:62
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
TRT_LoLumRawDataContainerCnv_p2::initialize
void initialize(const TRT_ID *idhelper)
Definition: TRT_LoLumRawDataContainerCnv_p2.h:42
TPAbstractPolyCnvBase::createPersistent
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of a transient object.
TRT_RDORawData
Definition: TRT_RDORawData.h:24
TRT_RDO_ContainerCnv::m_converter_p1
TRT_RDO_ContainerCnv_p1 m_converter_p1
Definition: TRT_RDO_ContainerCnv.h:34
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
TRT_RDO_ContainerCnv::m_converter_p0
TRT_RDO_ContainerCnv_p0 m_converter_p0
Definition: TRT_RDO_ContainerCnv.h:35
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TRT_RDO_ContainerCnv_p1::createTransient
virtual TRT_RDO_Container * createTransient(const TRT_RDO_Container_p1 *persObj, MsgStream &log)
Definition: TRT_RDO_ContainerCnv_p1.cxx:127
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
TRT_LoLumRawDataContainerCnv_p2::createTransient
virtual TRT_RDO_Container * createTransient(const InDetRawDataContainer_p2 *persObj, MsgStream &log)
Definition: TRT_LoLumRawDataContainerCnv_p2.cxx:137
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT_LoLumRawDataContainerCnv_p1::initialize
void initialize(const TRT_ID *idhelper)
Definition: TRT_LoLumRawDataContainerCnv_p1.h:42
TRT_RDO_ContainerCnv::m_converter_TP2
TRT_LoLumRawDataContainerCnv_p2 m_converter_TP2
Definition: TRT_RDO_ContainerCnv.h:37
TRT_RDO_ContainerCnv_p0::initialize
void initialize(const TRT_ID *idhelper)
Definition: TRT_RDO_ContainerCnv_p0.h:35
TRT_LoLumRawDataContainerCnv_p1::createTransient
virtual TRT_RDO_Container * createTransient(const InDetRawDataContainer_p1 *persObj, MsgStream &log)
Definition: TRT_LoLumRawDataContainerCnv_p1.cxx:137
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
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
TRT_RDO_ContainerCnv.h
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
TRT_RDO_ContainerCnv::m_converter_PERS
TRT_RDO_ContainerCnv_PERS m_converter_PERS
Definition: TRT_RDO_ContainerCnv.h:39
TRT_RDO_ContainerCnv::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Definition: TRT_RDO_ContainerCnv.h:42
TRT_RDO_ContainerCnv::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
Definition: TRT_RDO_ContainerCnv.cxx:36
TRT_LoLumRawDataContainerCnv_p3::initialize
void initialize(const TRT_ID *idhelper)
Definition: TRT_LoLumRawDataContainerCnv_p3.h:42
TRT_RDO_ContainerCnv::createTransient
virtual TRT_RDO_Container * createTransient()
Definition: TRT_RDO_ContainerCnv.cxx:102
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
TRT_ID
Definition: TRT_ID.h:84
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
T_AthenaPoolCustCnv::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
T_AthenaPoolCustCnv::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
TRT_RDO_ContainerCnv_p0::createTransient
virtual TRT_RDO_Container * createTransient(const TRT_RDO_Container_p0 *persObj, MsgStream &log)
Definition: TRT_RDO_ContainerCnv_p0.cxx:19