ATLAS Offline Software
CaloTopoTowerContainerCnv.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
17 
18 
20  :
21  // Base class constructor
23 {}
24 
26  MsgStream log(msgSvc(), "CaloTopoTowerContainerCnv::createTransient" );
27  CaloTopoTowerContainer* Cont = 0;
28  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Starting CaloTopoTowerContainerCnv::PoolToDataObject" << endmsg;
30  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Read version p0 of CaloTopoTowerContainer. GUID="
31  << m_classID.toString() << endmsg;
32  Cont=poolReadObject<CaloTopoTowerContainer>();
33  }
34  else if(compareClassGuid(p1_guid)) {
35  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Read version p1 of CaloTopoTowerContainer. GUID="
36  << m_classID.toString() << endmsg;
37  CaloTopoTowerContainerPERS* pers=poolReadObject<CaloTopoTowerContainer_p1>();
38  Cont=new CaloTopoTowerContainer();
39  m_converter.persToTrans(pers,Cont,log);
40  delete pers;
41  }
42  if (!Cont) {
43  log << MSG::FATAL << "Unable to get object from pool" << endmsg;
44  return Cont;
45  }
46 
47  Cont->init();
48 
49  // rebuild the CaloTopoTowers in the container.
50  const EventContext& ctx = Gaudi::Hive::currentContext();
51 
52  m_TopoTowerBldr= getTool("CaloTopoTowerBuilderTool","TopoTowerTwrBldr");
53  if(!m_TopoTowerBldr){
54  log<<MSG::ERROR<< " Failed to create CaloTopoTowerContainer " <<endmsg;
55  return 0;
56  }
57  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "creating CaloTopoTowerContainerCnv::PoolToDataObject" << endmsg;
58  StatusCode scfcal = m_TopoTowerBldr->execute(ctx, Cont);
59  if (log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<" TopoTowers rebuild m_TopoTowerBldr->execute(Cont); Successful "<<endmsg;
60  if (scfcal.isFailure()) {
61  log<<MSG::ERROR<<" TopoTowers rebuild failed "<<endmsg;
62  }
63  if (log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<" TopoTowers rebuild worked "<<endmsg;
64 
65  return Cont;
66 }
67 
69  MsgStream log(msgSvc(), "CaloTopoTowerContainerCnv::createPersistent");
70  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Writing CaloTopoTowerContainer_p1" << endmsg;
72  m_converter.transToPers(trans,pers,log);
73  return pers;
74 }
75 
76 
78 const std::string& type, const std::string& nm)
79 {
80  SmartIF<IToolSvc> myToolSvc{Gaudi::svcLocator()->service("ToolSvc")};
81  if(!myToolSvc.isValid()) {
82  ATH_MSG_ERROR("Cannot locate ToolSvc");
83  return 0;
84  }
85 
87  // Allocate Tools //
89 
90  IAlgTool* algToolPtr;
91  StatusCode sc = myToolSvc->retrieveTool(type,nm,algToolPtr);
92  // tool not found
93  if ( sc.isFailure() )
94  {
95  ATH_MSG_INFO("Cannot find tool named <"
96  << type << "/" << nm
97  << ">");
98  return 0;
99  }
100  return dynamic_cast<CaloTopoTowerBuilderToolBase*>(algToolPtr);
101 
102 }
T_AthenaPoolCustCnv::m_classID
Guid m_classID
Definition: T_AthenaPoolCustCnv.h:96
CaloTopoTowerContainerCnv::getTool
CaloTopoTowerBuilderToolBase * getTool(const std::string &type, const std::string &nm)
Definition: CaloTopoTowerContainerCnv.cxx:77
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloTopoTowerContainerCnv.h
Guid::toString
const std::string toString() const
Automatic conversion to string representation.
Definition: Guid.cxx:58
CaloTowerContainer::init
void init()
Initializes the CaloTowerContainer.
Definition: CaloTowerContainer.cxx:107
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloTopoTowerBuilderToolBase
CaloTopoTowerBuilderToolBase is abstract base class for tower builders.
Definition: CaloTopoTowerBuilderToolBase.h:20
CaloTopoTowerContainerCnv::createPersistent
virtual CaloTopoTowerContainerPERS * createPersistent(CaloTopoTowerContainer *) override
Definition: CaloTopoTowerContainerCnv.cxx:68
CaloTopoTowerContainerCnv::CaloTopoTowerContainerCnv
CaloTopoTowerContainerCnv(ISvcLocator *svcloc)
Definition: CaloTopoTowerContainerCnv.cxx:19
CaloTopoTowerContainerCnv::p1_guid
pool::Guid p1_guid
Definition: CaloTopoTowerContainerCnv.h:41
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
CaloTopoTowerContainerCnv::p0_guid
pool::Guid p0_guid
Definition: CaloTopoTowerContainerCnv.h:40
CaloTopoTowerContainerCnv_p1::persToTrans
virtual void persToTrans(const CaloTopoTowerContainer_p1 *, CaloTopoTowerContainer *, MsgStream &msg) const override
Definition: CaloTopoTowerContainerCnv_p1.cxx:12
CaloTopoTowerContainerCnv_p1::transToPers
virtual void transToPers(const CaloTopoTowerContainer *, CaloTopoTowerContainer_p1 *, MsgStream &msg) const override
Definition: CaloTopoTowerContainerCnv_p1.cxx:39
CaloTopoTowerContainer
Storable container class for CaloTower.
Definition: CaloTopoTowerContainer.h:51
CaloTopoTowerContainerCnv::m_converter
CaloTopoTowerContainerCnv_p1 m_converter
Definition: CaloTopoTowerContainerCnv.h:42
CaloTopoTowerContainerCnv::m_TopoTowerBldr
CaloTopoTowerBuilderToolBase * m_TopoTowerBldr
Definition: CaloTopoTowerContainerCnv.h:39
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloTopoTowerBuilderToolBase.h
CaloTopoTowerContainerCnv::createTransient
virtual CaloTopoTowerContainer * createTransient() override
Definition: CaloTopoTowerContainerCnv.cxx:25
T_AthenaPoolCustCnv::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
CaloTopoTowerContainerPERS
CaloTopoTowerContainer_p1 CaloTopoTowerContainerPERS
Definition: CaloTopoTowerContainerCnv.h:14
CaloTopoTowerContainer_p1
Definition: CaloTopoTowerContainer_p1.h:13