ATLAS Offline Software
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;
34  Cont=poolReadObject<CaloTowerContainer>();
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;
39  CaloTowerContainerPERS* pers=poolReadObject<CaloTowerContainer_p1>();
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 
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 }
CaloTowerContainerCnv::p1_guid
pool::Guid p1_guid
Definition: CaloTowerContainerCnv.h:43
T_AthenaPoolCustCnv::m_classID
Guid m_classID
Definition: T_AthenaPoolCustCnv.h:96
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:46
CaloTowerBuilderToolBase::execute
virtual StatusCode execute(const EventContext &ctx, CaloTowerContainer *theContainer, const CaloCellContainer *theCell=nullptr, const CaloTowerSeg::SubSeg *subseg=nullptr) const override=0
Run tower building and add results to the tower container.
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloTowerContainerCnv_p1::persToTrans
virtual void persToTrans(const CaloTowerContainer_p1 *pers, CaloTowerContainer *trans, MsgStream &log) const override
Definition: CaloTowerContainerCnv_p1.cxx:11
CaloTowerContainerCnv.h
CaloTowerBuilderTool::setCalos
virtual void setCalos(const std::vector< CaloCell_ID::SUBCALO > &v)
Definition: CaloTowerBuilderTool.cxx:265
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Guid::toString
const std::string toString() const
Automatic conversion to string representation.
Definition: Guid.cxx:58
CaloTowerContainerCnv::m_emHecTowerBldr
CaloTowerBuilderTool * m_emHecTowerBldr
Definition: CaloTowerContainerCnv.h:38
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:46
CaloTowerContainerCnv::p0_guid
pool::Guid p0_guid
Definition: CaloTowerContainerCnv.h:42
CaloTowerContainer::init
void init()
Initializes the CaloTowerContainer.
Definition: CaloTowerContainer.cxx:107
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloTowerContainer
Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current CaloTowerContainer
Definition: CaloTPCnv.cxx:68
CaloTowerContainer
Storable container class for CaloTower.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloTowerContainer.h:77
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
T_AthenaPoolCustomCnv
Compatibility for old converter classes that don't get passed the key.
Definition: T_AthenaPoolCustomCnv.h:132
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloTowerContainerCnv::m_tileTowerBldr
CaloTowerBuilderToolBase * m_tileTowerBldr
Definition: CaloTowerContainerCnv.h:40
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
CaloTowerBuilderTool::execute
virtual StatusCode execute(const EventContext &ctx, CaloTowerContainer *theContainer, const CaloCellContainer *theCell=0, const CaloTowerSeg::SubSeg *subseg=0) const override
Run tower building and add results to the tower container.
Definition: CaloTowerBuilderTool.cxx:173
CaloTowerContainer::getCalos
size_t getCalos(std::vector< CaloCell_ID::SUBCALO > &theCalos) const
Retrieve the list of used calorimeters.
Definition: CaloTowerContainer.cxx:180
CaloTowerContainerCnv::m_converter
CaloTowerContainerCnv_p1 m_converter
Definition: CaloTowerContainerCnv.h:44
python.PyAthena.v
v
Definition: PyAthena.py:154
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
CaloTowerContainerCnv::createPersistent
virtual CaloTowerContainerPERS * createPersistent(CaloTowerContainer *) override
Definition: CaloTowerContainerCnv.cxx:132
CaloTowerContainerCnv::getTool
CaloTowerBuilderToolBase * getTool(const std::string &type, const std::string &nm)
Definition: CaloTowerContainerCnv.cxx:141
CaloTowerBuilderToolBase
Definition: CaloTowerBuilderToolBase.h:31
CaloTowerContainerCnv_p1::transToPers
virtual void transToPers(const CaloTowerContainer *trans, CaloTowerContainer_p1 *pers, MsgStream &log) const override
Definition: CaloTowerContainerCnv_p1.cxx:21
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloTowerContainer_p1
Definition: CaloTowerContainer_p1.h:12
DEBUG
#define DEBUG
Definition: page_access.h:11
CaloTowerContainerPERS
CaloTowerContainer_p1 CaloTowerContainerPERS
Definition: CaloTowerContainerCnv.h:14
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloTowerContainerCnv::m_fcalTowerBldr
CaloTowerBuilderToolBase * m_fcalTowerBldr
Definition: CaloTowerContainerCnv.h:39
CaloTowerContainerCnv::createTransient
virtual CaloTowerContainer * createTransient() override
Definition: CaloTowerContainerCnv.cxx:26
T_AthenaPoolCustCnv::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
CaloTowerBuilderTool
Definition: CaloTowerBuilderTool.h:34
CaloTowerBuilderToolBase.h
CaloTowerContainerCnv::CaloTowerContainerCnv
CaloTowerContainerCnv(ISvcLocator *svcloc)
Definition: CaloTowerContainerCnv.cxx:20
CaloTowerBuilderTool.h