ATLAS Offline Software
Loading...
Searching...
No Matches
TBDetDescrLoader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5//Gaudi Includes
6#include "GaudiKernel/IDataProviderSvc.h"
7#include "GaudiKernel/SmartDataPtr.h"
8
10
11//TBDetDescr includes
14#include "TBDetDescrLoader.h"
15
16// Constructor & destructor
17TBDetDescrLoader::TBDetDescrLoader(const std::string& name, ISvcLocator* pSvcLocator)
18 : AthAlgorithm(name, pSvcLocator),
19 m_TBDDM(0),
20 c_TBDDM(0)
21{
22 declareProperty("TBDetDescrManager", m_TBDetDescrManager = "TBDetDescrMgr");
23 declareProperty("TBElementContainer", m_TBElementContainer = "TBElementCnt");
24 declareProperty("ReadAction", m_readAction = -1);
25 declareProperty("WriteAction", m_writeAction = 0);
26}
27
31
32// Alg standard interface function
34{
35 StatusCode sc;
36
37 if (m_readAction != 0) {
38
39 ATH_MSG_INFO( "Creating TBDetDescrManager in DetectorStore" );
40
42
43 // somebody else should provide coordinates for all envelopes
44 // we can't do anything here
45 // so this initialization is not needed,
46 // it is kept here as an example
47 std::vector<TBElement> vec;
48 vec.resize(1); // it will contain just one "Unknown" element
49
50 // initialize the manager with detectors we just created
51 m_TBDDM->initialize(vec);
52 m_TBDDM->print(msg());
53
54 if (m_readAction < 0) {
55 m_readAction = 0;
56 sc=detStore()->record(m_TBDDM, m_TBDetDescrManager, true);
57 } else {
58 sc=detStore()->record(m_TBDDM, m_TBDetDescrManager, false);
59 }
60
61 if(sc.isFailure()) {
62 ATH_MSG_ERROR( "failed to register TBDetDescrManager in Detector Store" );
63 m_readAction = 0;
64 ATH_MSG_ERROR( "resetting m_readAction to 0" );
65 delete m_TBDDM;
66 // do not exit wih FAILURE here
67 // probably manager is created already
68 // and we just want to use it
69 // return sc;
70 }
71 } else {
72
74 (new DetDescrAddress(
77
78 sc = detStore()->recordAddress(addr);
79 if (sc != StatusCode::SUCCESS) {
80 ATH_MSG_INFO( "unable to fill address for " << (*addr->par())
81 << " with CLID " << addr->clID()
82 << " and storage type " << addr->svcType()
83 << " to detector store " );
84 }
85 else {
86 unsigned int st = addr->svcType();
87 ATH_MSG_INFO( "filling address for " << (*addr->par())
88 << " with CLID " << addr->clID()
89 << " and storage type " << st
90 << " to detector store " );
91 }
92 }
93
94 if (m_writeAction != 0) {
95
96 ATH_MSG_INFO( "Retrieving TBDetDescrManager from DetectorStore" );
97
98 sc = detStore()->retrieve(c_TBDDM);
99 if (sc.isFailure()) {
100 ATH_MSG_ERROR( "Unable to retrieve TBDetDescrManager from DetectorStore" );
101 m_writeAction = 0;
102 ATH_MSG_ERROR( "resetting m_writeAction to 0" );
103 return StatusCode::RECOVERABLE;
104 }
105 c_TBDDM->print(msg());
106 }
107
108 ATH_MSG_INFO( "initialization completed" );
109 return StatusCode::SUCCESS;
110}
111
113 StatusCode sc;
114
115 TBElementContainer* pTBElementContainer;
116
117 switch (m_readAction) {
118
119 case 0: // do nothing
120 ATH_MSG_DEBUG( "readAction: do nothing" );
121
122 // write to StoreGate only if we are not reading from it!
123
124 switch (m_writeAction) {
125
126 case 0: // do nothing
127 ATH_MSG_DEBUG( "writeAction: do nothing" );
128 break;
129
130 case 1: // write once
131 m_writeAction = 0; // don't do anything anymore
132 // but without break proceed to next case
133 /* FALLTHROUGH */
134
135 case 2: // write always
136
137 ATH_MSG_DEBUG( "Action: write TBDetDescr to StoreGate" );
138
139 pTBElementContainer = new TBElementContainer();
140
141 c_TBDDM->getAll(pTBElementContainer);
142 c_TBDDM->print(msg());
143
144 sc=evtStore()->record(pTBElementContainer, m_TBElementContainer, false);
145 if(sc.isFailure()) {
146 ATH_MSG_FATAL( "failed to register the TBElementContainer" );
147 return StatusCode::FAILURE;
148 }
149 break;
150
151 default:
152 break;
153 }
154
155 break;
156
157 case 1: // read once
158 m_readAction = 0; // don't do anything anymore
159 // but without break proceed to next case
160 /* FALLTHROUGH */
161
162 case 2: // read always
163
164 ATH_MSG_DEBUG( "Action: read TBDetDescr from StoreGate" );
165 {
166 const TBElementContainer* pContainer = nullptr;
167 ATH_CHECK( evtStore()->retrieve(pContainer,m_TBElementContainer) );
168 m_TBDDM->initialize(pContainer);
169 m_TBDDM->print(msg());
170 }
171 break;
172
173 default:
174 break;
175
176 }
177
178 return StatusCode::SUCCESS;
179}
180
181StatusCode
183 ATH_MSG_INFO( "finalized successfully" );
184 return StatusCode::SUCCESS;
185}
186
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::vector< size_t > vec
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
Simple smart pointer for Gaudi-style refcounted objects.
virtual StatusCode finalize() override
std::string m_TBElementContainer
const TBDetDescrManager * c_TBDDM
virtual StatusCode initialize() override
TBDetDescrLoader(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute() override
std::string m_TBDetDescrManager
TBDetDescrManager * m_TBDDM