ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
8
9#include <memory>
10
11#include <iostream>
12
13
14//================================================================
15namespace {
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//================================================================
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
std::pair< std::vector< unsigned int >, bool > res
This is an Identifier helper class for the TRT subdetector.
InDetRawDataContainer_p3 TRT_RDO_Container_PERS
InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > TRT_RDO_Container
const_iterator end() const
return const_iterator for end of container
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,...
const_iterator begin() const
return const_iterator for first entry
This is an Identifier helper class for the TRT subdetector.
Definition TRT_ID.h:82
ServiceHandle< StoreGateSvc > m_storeGate
virtual TRT_RDO_Container_PERS * createPersistent(TRT_RDO_Container *transCont)
TRT_RDO_ContainerCnv_p1 m_converter_p1
virtual TRT_RDO_Container * createTransient()
TRT_LoLumRawDataContainerCnv_p2 m_converter_TP2
TRT_LoLumRawDataContainerCnv_p3 m_converter_TP3
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
TRT_RDO_ContainerCnv_p0 m_converter_p0
TRT_RDO_ContainerCnv_PERS m_converter_PERS
TRT_LoLumRawDataContainerCnv_p1 m_converter_TP1