ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloCnv
CaloAthenaPool
src
CaloTowerContainerCnv.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CaloTowerContainerCnv.h
"
6
7
// LArDetDescr includes
8
#include "
CaloDetDescr/CaloDetDescrManager.h
"
9
10
// Gaudi
11
#include "GaudiKernel/MsgStream.h"
12
#include "GaudiKernel/IToolSvc.h"
13
#include "GaudiKernel/ThreadLocalContext.h"
14
15
// Athena
16
#include "
CaloUtils/CaloTowerBuilderToolBase.h
"
17
#include "
CaloUtils/CaloTowerBuilderTool.h
"
18
19
20
CaloTowerContainerCnv::CaloTowerContainerCnv
(ISvcLocator* svcloc)
21
:
22
// Base class constructor
23
CaloTowerContainerCnvBase
(svcloc)
24
{}
25
26
CaloTowerContainer
*
CaloTowerContainerCnv::createTransient
(
const
Token
* token) {
27
const
EventContext& ctx = Gaudi::Hive::currentContext();
28
MsgStream log(msgSvc(),
"CaloTowerContainerCnv::createTransient"
);
29
CaloTowerContainer
* Cont = 0;
30
31
if
(
compareClassGuid
(token,
p0_guid
)) {
32
if
(log.level() <= MSG::DEBUG) log << MSG::DEBUG <<
"Read version p0 of CaloTowerContainer. token="
33
<< token->
toString
() <<
endmsg
;
34
Cont=
poolReadObject<CaloTowerContainer>
(token);
35
}
36
else
if
(
compareClassGuid
(token,
p1_guid
)) {
37
if
(log.level() <= MSG::DEBUG) log << MSG::DEBUG <<
"Read version p1 of CaloTowerContainer. token="
38
<< token->
toString
() <<
endmsg
;
39
CaloTowerContainerPERS
* pers=
poolReadObject<CaloTowerContainer_p1>
(token);
40
Cont=
new
CaloTowerContainer
();
41
m_converter
.persToTrans(pers,Cont,log);
42
delete
pers;
43
}
44
if
(!Cont) {
45
log << MSG::FATAL <<
"Unable to get object from pool"
<<
endmsg
;
46
return
Cont;
47
}
48
49
50
Cont->
init
();
51
52
// rebuild the CaloTowers in the container.
53
54
std::vector<CaloCell_ID::SUBCALO> v;
55
56
if
(Cont->
getCalos
(v)==0){
57
log<<MSG::WARNING<<
" No SUBCALO in CaloTowerContainer"
<<
endmsg
;
58
return
Cont;
59
}
60
61
std::vector<CaloCell_ID::SUBCALO> EmHec;
62
63
std::vector<CaloCell_ID::SUBCALO>::const_iterator it = v.begin();
64
std::vector<CaloCell_ID::SUBCALO>::const_iterator it_e = v.end();
65
for
(; it!=it_e;++it){
66
CaloCell_ID::SUBCALO
sub = *it;
67
68
if
(sub ==
CaloCell_ID::LAREM
) {
69
EmHec.push_back(sub);
70
}
71
72
if
(sub ==
CaloCell_ID::LARHEC
) {
73
EmHec.push_back(sub);
74
}
75
76
if
(sub ==
CaloCell_ID::LARFCAL
) {
77
if
(!
m_fcalTowerBldr
){
78
m_fcalTowerBldr
=
getTool
(
"LArFCalTowerBuilderTool"
,
79
"LArTowerFCal"
);
80
if
(!
m_fcalTowerBldr
){
81
log<<MSG::ERROR<<
" Failed to create LArFCalTowerBuilder "
<<
endmsg
;
82
return
0;
83
}
84
}
85
if
(log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<
" Towers rebuild for FCAL "
<<
endmsg
;
86
StatusCode scfcal =
m_fcalTowerBldr
->execute(ctx, Cont);
87
if
(scfcal.isFailure()) {
88
log<<MSG::ERROR<<
" Towers rebuild for FCAL failed "
<<
endmsg
;
89
}
90
}
91
92
if
(sub ==
CaloCell_ID::TILE
) {
93
if
(!
m_tileTowerBldr
){
94
m_tileTowerBldr
=
getTool
(
"TileTowerBuilderTool"
,
95
"TileTower"
);
96
if
(!
m_tileTowerBldr
){
97
log<<MSG::ERROR<<
" Failed to create TileTowerBuilder "
<<
endmsg
;
98
return
0;
99
}
100
}
101
if
(log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<
" Towers rebuild for Tile "
<<
endmsg
;
102
StatusCode sctile=
m_tileTowerBldr
->execute(ctx, Cont);
103
if
(sctile.isFailure()) {
104
log<<MSG::ERROR<<
" Towers rebuild for Tile failed "
<<
endmsg
;
105
}
106
}
107
108
}
109
110
if
(EmHec.size()>0){
111
if
(!
m_emHecTowerBldr
){
112
CaloTowerBuilderToolBase
* bldr =
getTool
(
"LArTowerBuilderTool"
,
113
"LArTowerEMHEC"
);
114
m_emHecTowerBldr
=
dynamic_cast<
CaloTowerBuilderTool
*
>
(bldr);
115
if
(!
m_emHecTowerBldr
){
116
log<<MSG::ERROR<<
" Failed to create LArTowerBuilder for EM&HEC"
<<
endmsg
;
117
return
0;
118
}
119
}
120
if
(log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<
" Towers rebuild for EM and/or HEC "
<<
endmsg
;
121
m_emHecTowerBldr
->setCalos(ctx, EmHec);
122
StatusCode scemHec=
m_emHecTowerBldr
->execute(ctx, Cont);
123
if
(scemHec.isFailure()) {
124
log<<MSG::ERROR<<
" Towers rebuild for EM and/or HEC failed "
<<
endmsg
;
125
}
126
127
}
128
129
return
Cont;
130
}
131
132
CaloTowerContainerPERS
*
CaloTowerContainerCnv::createPersistent
(
CaloTowerContainer
* trans) {
133
MsgStream log(msgSvc(),
"CaloTowerContainerCnv::createPersistent"
);
134
if
(log.level() <= MSG::DEBUG) log << MSG::DEBUG <<
"Writing CaloTowerContainer_p1"
<<
endmsg
;
135
CaloTowerContainerPERS
* pers=
new
CaloTowerContainerPERS
();
136
m_converter
.transToPers(trans,pers,log);
137
return
pers;
138
}
139
140
141
CaloTowerBuilderToolBase
*
CaloTowerContainerCnv::getTool
(
142
const
std::string&
type
,
const
std::string& nm)
143
{
144
SmartIF<IToolSvc> myToolSvc{Gaudi::svcLocator()->service(
"ToolSvc"
)};
145
if
(!myToolSvc.isValid()) {
146
ATH_MSG_ERROR
(
"Cannot locate ToolSvc"
);
147
return
0;
148
}
149
151
// Allocate Tools //
153
154
IAlgTool* algToolPtr{
nullptr
};
155
StatusCode
sc
= myToolSvc->retrieveTool(
type
,nm,algToolPtr);
156
// tool not found
157
if
(
sc
.isFailure() )
158
{
159
ATH_MSG_INFO
(
"Cannot find tool named <"
160
<<
type
<<
"/"
<< nm
161
<<
">"
);
162
return
0;
163
}
164
return
dynamic_cast<
CaloTowerBuilderToolBase
*
>
(algToolPtr);
165
166
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
CaloTowerContainer
Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current CaloTowerContainer
Definition
CaloTPCnv.cxx:68
CaloTowerBuilderToolBase.h
CaloTowerBuilderTool.h
CaloTowerContainerCnv.h
CaloTowerContainerCnvBase
T_AthenaPoolCustomCnv< CaloTowerContainer, CaloTowerContainerPERS > CaloTowerContainerCnvBase
Definition
CaloTowerContainerCnv.h:17
CaloTowerContainerPERS
CaloTowerContainer_p1 CaloTowerContainerPERS
Definition
CaloTowerContainerCnv.h:16
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
CaloCell_Base_ID::LAREM
@ LAREM
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::TILE
@ TILE
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition
CaloCell_Base_ID.h:45
CaloCell_ID::SUBCALO
CaloCell_Base_ID::SUBCALO SUBCALO
Definition
CaloCell_ID.h:50
CaloTowerBuilderToolBase
Definition
CaloTowerBuilderToolBase.h:31
CaloTowerBuilderTool
Definition
CaloTowerBuilderTool.h:34
CaloTowerContainerCnv::m_emHecTowerBldr
CaloTowerBuilderTool * m_emHecTowerBldr
Definition
CaloTowerContainerCnv.h:38
CaloTowerContainerCnv::p1_guid
pool::Guid p1_guid
Definition
CaloTowerContainerCnv.h:43
CaloTowerContainerCnv::m_fcalTowerBldr
CaloTowerBuilderToolBase * m_fcalTowerBldr
Definition
CaloTowerContainerCnv.h:39
CaloTowerContainerCnv::p0_guid
pool::Guid p0_guid
Definition
CaloTowerContainerCnv.h:42
CaloTowerContainerCnv::m_tileTowerBldr
CaloTowerBuilderToolBase * m_tileTowerBldr
Definition
CaloTowerContainerCnv.h:40
CaloTowerContainerCnv::createTransient
virtual CaloTowerContainer * createTransient(const Token *token) override
Definition
CaloTowerContainerCnv.cxx:26
CaloTowerContainerCnv::getTool
CaloTowerBuilderToolBase * getTool(const std::string &type, const std::string &nm)
Definition
CaloTowerContainerCnv.cxx:141
CaloTowerContainerCnv::createPersistent
virtual CaloTowerContainerPERS * createPersistent(CaloTowerContainer *) override
Definition
CaloTowerContainerCnv.cxx:132
CaloTowerContainerCnv::CaloTowerContainerCnv
CaloTowerContainerCnv(ISvcLocator *svcloc)
Definition
CaloTowerContainerCnv.cxx:20
CaloTowerContainerCnv::m_converter
CaloTowerContainerCnv_p1 m_converter
Definition
CaloTowerContainerCnv.h:44
CaloTowerContainer
Storable container class for CaloTower.
Definition
Calorimeter/CaloEvent/CaloEvent/CaloTowerContainer.h:77
CaloTowerContainer::getCalos
size_t getCalos(std::vector< CaloCell_ID::SUBCALO > &theCalos) const
Retrieve the list of used calorimeters.
Definition
CaloTowerContainer.cxx:180
CaloTowerContainer::init
void init()
Initializes the CaloTowerContainer.
Definition
CaloTowerContainer.cxx:107
T_AthenaPoolCustomCnv< CaloTowerContainer, CaloTowerContainerPERS >::compareClassGuid
virtual bool compareClassGuid(const Token *token, const Guid &clid) const
T_AthenaPoolCustomCnv< CaloTowerContainer, CaloTowerContainerPERS >::poolReadObject
P * poolReadObject(const Token *token)
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition
Token.h:22
Token::toString
const std::string toString() const
Retrieve the string representation of the token.
Definition
Token.cxx:135
type
Generated on
for ATLAS Offline Software by
1.17.0