ATLAS Offline Software
CaloTopoTowerContainerCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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  m_TopoTowerBldr(0),
24  p0_guid("00B7F56C-1E49-4469-BEBA-C74620575A00"),
25  p1_guid("4ED29686-28E9-426F-B076-C4E4600F66A7")
26 {}
27 
28 
29 
31 {}
32 
33 
34 // StatusCode CaloTopoTowerContainerCnv::initialize()
35 // {
36 // // Call base clase initialize
37 // AthenaPoolConverter::initialize();
38 
39 // // Get the messaging service, print where you are
40 // MsgStream log(msgSvc(), "CaloTopoTowerContainerCnv");
41 // log << MSG::INFO << "initialize()" << endmsg;
42 
43 // return StatusCode::SUCCESS;
44 // }
45 
46 
47 //StatusCode CaloTopoTowerContainerCnv::PoolToDataObject(DataObject*& pObj,const std::string &token)
49  MsgStream log(msgSvc(), "CaloTopoTowerContainerCnv::createTransient" );
50  CaloTopoTowerContainer* Cont = 0;
51  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Starting CaloTopoTowerContainerCnv::PoolToDataObject" << endmsg;
53  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Read version p0 of CaloTopoTowerContainer. GUID="
54  << m_classID.toString() << endmsg;
55  Cont=poolReadObject<CaloTopoTowerContainer>();
56  }
57  else if(compareClassGuid(p1_guid)) {
58  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Read version p1 of CaloTopoTowerContainer. GUID="
59  << m_classID.toString() << endmsg;
60  CaloTopoTowerContainerPERS* pers=poolReadObject<CaloTopoTowerContainer_p1>();
61  Cont=new CaloTopoTowerContainer();
62  m_converter.persToTrans(pers,Cont,log);
63  delete pers;
64  }
65  if (!Cont) {
66  log << MSG::FATAL << "Unable to get object from pool" << endmsg;
67  return Cont;
68  }
69 
70  Cont->init();
71 
72  // rebuild the CaloTopoTowers in the container.
73  const EventContext& ctx = Gaudi::Hive::currentContext();
74 
75  m_TopoTowerBldr= getTool("CaloTopoTowerBuilderTool","TopoTowerTwrBldr");
76  if(!m_TopoTowerBldr){
77  log<<MSG::ERROR<< " Failed to create CaloTopoTowerContainer " <<endmsg;
78  return 0;
79  }
80  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "creating CaloTopoTowerContainerCnv::PoolToDataObject" << endmsg;
81  StatusCode scfcal = m_TopoTowerBldr->execute(ctx, Cont);
82  if (log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<" TopoTowers rebuild m_TopoTowerBldr->execute(Cont); Successful "<<endmsg;
83  if (scfcal.isFailure()) {
84  log<<MSG::ERROR<<" TopoTowers rebuild failed "<<endmsg;
85  }
86  if (log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<" TopoTowers rebuild worked "<<endmsg;
87 
88  return Cont;
89 }
90 
92  MsgStream log(msgSvc(), "CaloTopoTowerContainerCnv::createPersistent");
93  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Writing CaloTopoTowerContainer_p1" << endmsg;
95  m_converter.transToPers(trans,pers,log);
96  return pers;
97 }
98 
99 
101 const std::string& type, const std::string& nm)
102 {
103  IToolSvc* myToolSvc;
104  StatusCode sc = service("ToolSvc",myToolSvc);
105 
106  MsgStream log(msgSvc(), "CaloTopoTowerContainerCnv");
107  if ( sc.isFailure() )
108  {
109  log << MSG::ERROR
110  << "Tool Service not found"
111  << endmsg;
112  return 0 ;
113  }
114 
116  // Allocate Tools //
118 
119  IAlgTool* algToolPtr;
120  sc = myToolSvc->retrieveTool(type,nm,algToolPtr);
121  // tool not found
122  if ( sc.isFailure() )
123  {
124  log << MSG::INFO
125  << "Cannot find tool named <"
126  << type << "/" << nm
127  << ">"
128  << endmsg;
129  return 0;
130  }
131  return dynamic_cast<CaloTopoTowerBuilderToolBase*>(algToolPtr);
132 
133 }
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:100
CaloTopoTowerContainerCnv::createTransient
virtual CaloTopoTowerContainer * createTransient()
initialization
Definition: CaloTopoTowerContainerCnv.cxx:48
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
CaloTopoTowerContainerCnv.h
CaloTopoTowerContainerCnv::~CaloTopoTowerContainerCnv
virtual ~CaloTopoTowerContainerCnv()
Definition: CaloTopoTowerContainerCnv.cxx:30
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:22
CaloTopoTowerContainerCnv::CaloTopoTowerContainerCnv
CaloTopoTowerContainerCnv(ISvcLocator *svcloc)
Definition: CaloTopoTowerContainerCnv.cxx:19
CaloTopoTowerContainerCnv::p1_guid
pool::Guid p1_guid
Definition: CaloTopoTowerContainerCnv.h:49
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:48
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
CaloTopoTowerContainerCnv::createPersistent
virtual CaloTopoTowerContainerPERS * createPersistent(CaloTopoTowerContainer *)
Definition: CaloTopoTowerContainerCnv.cxx:91
ICaloTopoTowerBuilderToolBase::execute
virtual StatusCode execute(const EventContext &ctx, CaloTopoTowerContainer *theContainer, const CaloCellContainer *theCell=0) const =0
common initialization
CaloTopoTowerContainer
Storable container class for CaloTower.
Definition: CaloTopoTowerContainer.h:51
CaloTopoTowerContainerCnv::m_converter
CaloTopoTowerContainerCnv_p1 m_converter
Definition: CaloTopoTowerContainerCnv.h:50
CaloTopoTowerContainerCnv::m_TopoTowerBldr
CaloTopoTowerBuilderToolBase * m_TopoTowerBldr
Definition: CaloTopoTowerContainerCnv.h:47
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
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:15
CaloTopoTowerContainer_p1
Definition: CaloTopoTowerContainer_p1.h:13