ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_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#ifdef SCT_DEBUG
17 std::string shortPrint(const SCT_RDO_Container* main_input_SCT, unsigned maxprint=25) {
18 std::ostringstream os;
19 if (main_input_SCT) {
20 for (unsigned i=0; i<maxprint; i++) {
21 const auto* p = main_input_SCT->indexFindPtr(i);
22 if (p != nullptr) {
23 os<<" "<< p->size();
24 }
25 else {
26 os<<" *";
27 }
28 }
29 }
30 else {
31 os<<" [SCT_RDO_Container==nullptr]";
32 }
33 return os.str();
34 }
35#endif
36}
37
39 : SCT_RDO_ContainerCnvBase(svcloc, "SCT_RDO_ContainerCnv"),
41{}
42
43//================================================================
46
47 ATH_MSG_DEBUG("SCT_RDO_ContainerCnv::initialize()");
48
49 // Get the sct helper from the detector store
50 const SCT_ID* idhelper(nullptr);
51 ATH_CHECK( detStore()->retrieve(idhelper, "SCT_ID") );
52
53 m_converter_p0.initialize(idhelper);
54 m_converter_TP1.initialize(idhelper);
55 m_converter_SCT_TP1.initialize(idhelper);
56 m_converter_SCT_TP2.initialize(idhelper);
57 m_converter_SCT_TP3.initialize(idhelper);
58 m_converter_SCT_TP4.initialize(idhelper);
59 m_converter_PERS.initialize(idhelper);
60
61 return StatusCode::SUCCESS;
62}
63
64//================================================================
66
67#ifdef SCT_DEBUG
68 ATH_MSG_DEBUG("createPersistent(): main converter. TRANS = "<<shortPrint(transCont));
69#endif
70 // converter_num is a switch to determine which persistent type to use
71 // 1: if concrete type private data is equivalent to InDetRawData_p1
72 // 3: for cosmic/TB
73 //
74 unsigned int converter_num(1);
75 SCT_RDO_Container::const_iterator it_Coll = transCont->begin();
76 SCT_RDO_Container::const_iterator it_CollEnd = transCont->end();
77 // check one element of the container. The container can't be empty for this...
78 if (it_Coll != it_CollEnd) {
79 while (it_Coll != it_CollEnd && (*it_Coll)->size() == 0) ++it_Coll;
80 if (it_Coll != it_CollEnd) {
81 const SCT_RDORawData* test((**it_Coll)[0]);
82 if (dynamic_cast<const SCT1_RawData*>(test) != nullptr) {
83 //ATH_MSG_DEBUG("Found container with SCT1_RawData concrete type objects");
84 converter_num=1;
85 } else if (dynamic_cast<const SCT3_RawData*>(test) != nullptr) {
86 //ATH_MSG_DEBUG("Found container with SCT3_RawData concrete type objects");
87 converter_num=3;
88 } else {
89 ATH_MSG_FATAL("Converter not implemented for this concrete type ");
90 throw "Converter not implemented";
91 }
92 } else {
93 ATH_MSG_WARNING("Container has only empty collections. Using TP1 converter");
94 }
95 } else {
96 ATH_MSG_WARNING("Empty container. Using TP1 converter");
97 }
98 // Switch facility depending on the concrete data type of the contained objects
99 // Should do by getting the type_info of one of the contained objects
100 SCT_RDO_Container_PERS* persObj(nullptr);
101 if (converter_num == 1 || converter_num == 3) {
102 m_converter_PERS.setType(converter_num);
103 persObj = m_converter_PERS.createPersistent( transCont, msg() );
104 } else {
105 ATH_MSG_FATAL("This shouldn't happen!! ");
106 }
107#ifdef SCT_DEBUG
108 ATH_MSG_DEBUG("Success");
109#endif
110 return persObj;
111}
112
113//================================================================
115
116 static const pool::Guid p0_guid("B82A1D11-3F86-4F07-B380-B61BA2DAF3A9"); // with SCT1_RawData
117 static const pool::Guid TP1_guid("DA76970C-E019-43D2-B2F9-25660DCECD9D"); // for t/p separated version with InDetRawDataContainer_p1
118 static const pool::Guid SCT_TP1_guid("8E13963E-13E5-4D10-AA8B-73F00AFF8FA8"); // for t/p separated version with SCT_RawDataContainer_p1
119 static const pool::Guid SCT_TP2_guid("D1258125-2CBA-476E-8578-E09D54F477E1"); // for t/p separated version with SCT_RawDataContainer_p2
120 static const pool::Guid SCT_TP3_guid("5FBC8D4D-7B4D-433A-8487-0EA0C870CBDB"); // for t/p separated version with SCT_RawDataContainer_p3
121 static const pool::Guid SCT_TP4_guid("6C7540BE-E85C-4777-BC1C-A9FF11460F54"); // for t/p separated version with SCT_RawDataContainer_p4
122
123#ifdef SCT_DEBUG
124 ATH_MSG_DEBUG("createTransient(): main converter");
125#endif
126 if ( compareClassGuid(SCT_TP4_guid) ) {
127#ifdef SCT_DEBUG
128 ATH_MSG_DEBUG("createTransient(): New TP version - TP4 branch");
129#endif
130
131 std::unique_ptr< SCT_RawDataContainer_p4 > col_vect( poolReadObject< SCT_RawDataContainer_p4 >() );
132 SCT_RDO_Container* res = m_converter_SCT_TP4.createTransient( col_vect.get(), msg() );
133#ifdef SCT_DEBUG
134 ATH_MSG_DEBUG("createTransient(), TP4 branch: returns TRANS = "<<shortPrint(res));
135#endif
136 return res;
137
138 }
139 else if ( compareClassGuid(SCT_TP3_guid) ) {
140#ifdef SCT_DEBUG
141 ATH_MSG_DEBUG("createTransient(): New TP version - TP3 branch");
142#endif
143
144 std::unique_ptr< SCT_RawDataContainer_p3 > col_vect( poolReadObject< SCT_RawDataContainer_p3 >() );
145 SCT_RDO_Container* res = m_converter_SCT_TP3.createTransient( col_vect.get(), msg() );
146#ifdef SCT_DEBUG
147 ATH_MSG_DEBUG("createTransient(), TP3 branch: returns TRANS = "<<shortPrint(res));
148#endif
149 return res;
150
151 }
152 else if ( compareClassGuid(SCT_TP2_guid) ) {
153#ifdef SCT_DEBUG
154 ATH_MSG_DEBUG("createTransient(): New TP version - TP2 branch");
155#endif
156
157 std::unique_ptr< SCT_RawDataContainer_p2 > col_vect( poolReadObject< SCT_RawDataContainer_p2 >() );
158 SCT_RDO_Container* res = m_converter_SCT_TP2.createTransient( col_vect.get(), msg() );
159#ifdef SCT_DEBUG
160 ATH_MSG_DEBUG("createTransient(), TP2 branch: returns TRANS = "<<shortPrint(res));
161#endif
162 return res;
163
164 }
165 else if ( compareClassGuid(SCT_TP1_guid) ) {
166#ifdef SCT_DEBUG
167 ATH_MSG_DEBUG("createTransient(): New TP version - TP1 branch");
168#endif
169 std::unique_ptr< SCT_RawDataContainer_p1 > col_vect( poolReadObject< SCT_RawDataContainer_p1 >() );
170 SCT_RDO_Container* res = m_converter_SCT_TP1.createTransient( col_vect.get(), msg() );
171#ifdef SCT_DEBUG
172 ATH_MSG_DEBUG("createTransient(), TP1 branch: returns TRANS = "<<shortPrint(res));
173#endif
174 return res;
175
176
177 }
178 else if ( compareClassGuid(TP1_guid) ) {
179 ATH_MSG_DEBUG("createTransient(): New TP version - TP1 branch");
180
181 std::unique_ptr< InDetRawDataContainer_p1 > col_vect( poolReadObject< InDetRawDataContainer_p1 >() );
182 SCT_RDO_Container* res = m_converter_TP1.createTransient( col_vect.get(), msg() );
183#ifdef SCT_DEBUG
184 ATH_MSG_DEBUG("createTransient(), TP1 branch: returns TRANS = "<<shortPrint(res));
185#endif
186 return res;
187
188
189 }
190 else if ( compareClassGuid(p0_guid) ) {
191#ifdef SCT_DEBUG
192 ATH_MSG_DEBUG("createTransient(): Old input file - p0 branch");
193#endif
194 std::unique_ptr< SCT_RDO_Container_p0 > col_vect( poolReadObject< SCT_RDO_Container_p0 >() );
195 SCT_RDO_Container* res = m_converter_p0.createTransient( col_vect.get(), msg() );
196#ifdef SCT_DEBUG
197 ATH_MSG_DEBUG("createTransient(), p0 branch: returns TRANS = "<<shortPrint(res));
198#endif
199 return res;
200 }
201
202 throw std::runtime_error("Unsupported persistent version of SCT_RDO_Container");
203}
204
205//================================================================
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(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 SCT subdetector.
T_AthenaPoolCustomCnv< SCT_RDO_Container, SCT_RDO_Container_PERS > SCT_RDO_ContainerCnvBase
SCT_RawDataContainer_p4 SCT_RDO_Container_PERS
InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > SCT_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 SCT subdetector.
Definition SCT_ID.h:68
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
SCT_RawDataContainerCnv_p1 m_converter_SCT_TP1
SCT_RDO_ContainerCnv_PERS m_converter_PERS
SCT_RDO_ContainerCnv(ISvcLocator *svcloc)
SCT1_RawDataContainerCnv_p1 m_converter_TP1
SCT_RawDataContainerCnv_p3 m_converter_SCT_TP3
SCT_RDO_ContainerCnv_p0 m_converter_p0
SCT_RawDataContainerCnv_p2 m_converter_SCT_TP2
SCT_RawDataContainerCnv_p4 m_converter_SCT_TP4
virtual SCT_RDO_Container_PERS * createPersistent(SCT_RDO_Container *transCont) override
virtual SCT_RDO_Container * createTransient() override