ATLAS Offline Software
Loading...
Searching...
No Matches
CaloTowerContainerCnv.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
7// LArDetDescr includes
9
10// Gaudi
11#include "GaudiKernel/MsgStream.h"
12#include "GaudiKernel/IToolSvc.h"
13#include "GaudiKernel/ThreadLocalContext.h"
14
15// Athena
18
19
21 :
22 // Base class constructor
24{}
25
27 const EventContext& ctx = Gaudi::Hive::currentContext();
28 MsgStream log(msgSvc(), "CaloTowerContainerCnv::createTransient" );
29 CaloTowerContainer* Cont = 0;
30
32 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Read version p0 of CaloTowerContainer. GUID="
33 << m_classID.toString() << endmsg;
35 }
36 else if(compareClassGuid(p1_guid)) {
37 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Read version p1 of CaloTowerContainer. GUID="
38 << m_classID.toString() << endmsg;
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(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
133 MsgStream log(msgSvc(), "CaloTowerContainerCnv::createPersistent");
134 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Writing CaloTowerContainer_p1" << endmsg;
136 m_converter.transToPers(trans,pers,log);
137 return pers;
138}
139
140
142const 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}
#define endmsg
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
Definition of CaloDetDescrManager.
Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current CaloTowerContainer
Definition CaloTPCnv.cxx:68
T_AthenaPoolCustomCnv< CaloTowerContainer, CaloTowerContainerPERS > CaloTowerContainerCnvBase
CaloTowerContainer_p1 CaloTowerContainerPERS
static Double_t sc
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
CaloTowerBuilderTool * m_emHecTowerBldr
CaloTowerBuilderToolBase * m_fcalTowerBldr
CaloTowerBuilderToolBase * m_tileTowerBldr
CaloTowerBuilderToolBase * getTool(const std::string &type, const std::string &nm)
virtual CaloTowerContainerPERS * createPersistent(CaloTowerContainer *) override
virtual CaloTowerContainer * createTransient() override
CaloTowerContainerCnv(ISvcLocator *svcloc)
CaloTowerContainerCnv_p1 m_converter
Storable container class for CaloTower.
size_t getCalos(std::vector< CaloCell_ID::SUBCALO > &theCalos) const
Retrieve the list of used calorimeters.
void init()
Initializes the CaloTowerContainer.