ATLAS Offline Software
Loading...
Searching...
No Matches
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//================================================================
16namespace {
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//================================================================
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::pair< std::vector< unsigned int >, bool > res
This is an Identifier helper class for the Pixel subdetector.
InDetRawDataContainer_p2 PixelRDO_Container_PERS
InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > PixelRDO_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 Pixel subdetector.
Definition PixelID.h:67
virtual PixelRDO_Container * createTransient() override
virtual PixelRDO_Container_PERS * createPersistent(PixelRDO_Container *transCont) override
Pixel1RawDataContainerCnv_p1 m_converter_TP1
Pixel1RawDataContainerCnv_p2 m_converter_TP2
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
PixelRDO_ContainerCnv_p0 m_converter_p0
PixelRDO_ContainerCnv_PERS m_converter_PERS