ATLAS Offline Software
CaloTowerContainerCnv.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
18 
19 
21  :
22  // Base class constructor
24  m_emHecTowerBldr(0),
25  m_fcalTowerBldr(0),
26  m_tileTowerBldr(0),
27  p0_guid("8F94A938-3C19-4509-BBAA-E8EB0A64B524"),
28  p1_guid("E56D5471-A9E2-4787-B413-D3BD9F2AC55D")
29 {}
30 
31 
32 
34 {}
35 
36 
37 // StatusCode CaloTowerContainerCnv::initialize()
38 // {
39 // // Call base clase initialize
40 // AthenaPoolConverter::initialize();
41 
42 // // Get the messaging service, print where you are
43 // MsgStream log(msgSvc(), "CaloTowerContainerCnv");
44 // log << MSG::INFO << "initialize()" << endmsg;
45 
46 // return StatusCode::SUCCESS;
47 // }
48 
49 
50 //StatusCode CaloTowerContainerCnv::PoolToDataObject(DataObject*& pObj,const std::string &token)
52  const EventContext& ctx = Gaudi::Hive::currentContext();
53  MsgStream log(msgSvc(), "CaloTowerContainerCnv::createTransient" );
54  CaloTowerContainer* Cont = 0;
55 
57  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Read version p0 of CaloTowerContainer. GUID="
58  << m_classID.toString() << endmsg;
59  Cont=poolReadObject<CaloTowerContainer>();
60  }
61  else if(compareClassGuid(p1_guid)) {
62  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Read version p1 of CaloTowerContainer. GUID="
63  << m_classID.toString() << endmsg;
64  CaloTowerContainerPERS* pers=poolReadObject<CaloTowerContainer_p1>();
65  Cont=new CaloTowerContainer();
66  m_converter.persToTrans(pers,Cont,log);
67  delete pers;
68  }
69  if (!Cont) {
70  log << MSG::FATAL << "Unable to get object from pool" << endmsg;
71  return Cont;
72  }
73 
74 
75  Cont->init();
76 
77  // rebuild the CaloTowers in the container.
78 
79  std::vector<CaloCell_ID::SUBCALO> v;
80 
81  if(Cont->getCalos(v)==0){
82  log<<MSG::WARNING<< " No SUBCALO in CaloTowerContainer"<<endmsg;
83  return Cont;
84  }
85 
86  std::vector<CaloCell_ID::SUBCALO> EmHec;
87 
88  std::vector<CaloCell_ID::SUBCALO>::const_iterator it = v.begin();
89  std::vector<CaloCell_ID::SUBCALO>::const_iterator it_e = v.end();
90  for(; it!=it_e;++it){
91  CaloCell_ID::SUBCALO sub = *it;
92 
93  if(sub == CaloCell_ID::LAREM) {
94  EmHec.push_back(sub);
95  }
96 
97  if(sub == CaloCell_ID::LARHEC) {
98  EmHec.push_back(sub);
99  }
100 
101  if(sub == CaloCell_ID::LARFCAL) {
102  if(! m_fcalTowerBldr){
103  m_fcalTowerBldr= getTool("LArFCalTowerBuilderTool",
104  "LArTowerFCal");
105  if(!m_fcalTowerBldr){
106  log<<MSG::ERROR<< " Failed to create LArFCalTowerBuilder " <<endmsg;
107  return 0;
108  }
109  }
110  if (log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<" Towers rebuild for FCAL "<<endmsg;
111  StatusCode scfcal = m_fcalTowerBldr->execute(ctx, Cont);
112  if (scfcal.isFailure()) {
113  log<<MSG::ERROR<<" Towers rebuild for FCAL failed "<<endmsg;
114  }
115  }
116 
117  if(sub == CaloCell_ID::TILE) {
118  if(! m_tileTowerBldr){
119  m_tileTowerBldr= getTool("TileTowerBuilderTool",
120  "TileTower");
121  if(!m_tileTowerBldr){
122  log<<MSG::ERROR<< " Failed to create TileTowerBuilder " <<endmsg;
123  return 0;
124  }
125  }
126  if (log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<" Towers rebuild for Tile "<<endmsg;
127  StatusCode sctile=m_tileTowerBldr->execute(ctx, Cont);
128  if (sctile.isFailure()) {
129  log<<MSG::ERROR<<" Towers rebuild for Tile failed "<<endmsg;
130  }
131  }
132 
133  }
134 
135  if(EmHec.size()>0){
136  if(! m_emHecTowerBldr){
137  CaloTowerBuilderToolBase * bldr = getTool("LArTowerBuilderTool",
138  "LArTowerEMHEC");
139  m_emHecTowerBldr=dynamic_cast<CaloTowerBuilderTool*>(bldr);
140  if(!m_emHecTowerBldr){
141  log<<MSG::ERROR<< " Failed to create LArTowerBuilder for EM&HEC" <<endmsg;
142  return 0;
143  }
144  }
145  if (log.level() <= MSG::DEBUG) log<<MSG::DEBUG<<" Towers rebuild for EM and/or HEC "<<endmsg;
146  m_emHecTowerBldr->setCalos(EmHec);
147  StatusCode scemHec=m_emHecTowerBldr->execute(ctx, Cont);
148  if (scemHec.isFailure()) {
149  log<<MSG::ERROR<<" Towers rebuild for EM and/or HEC failed "<<endmsg;
150  }
151 
152  }
153 
154  return Cont;
155 }
156 
158  MsgStream log(msgSvc(), "CaloTowerContainerCnv::createPersistent");
159  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Writing CaloTowerContainer_p1" << endmsg;
161  m_converter.transToPers(trans,pers,log);
162  return pers;
163 }
164 
165 
167 const std::string& type, const std::string& nm)
168 {
169  IToolSvc* myToolSvc;
170  StatusCode sc = service("ToolSvc",myToolSvc);
171 
172  MsgStream log(msgSvc(), "CaloTowerContainerCnv");
173  if ( sc.isFailure() )
174  {
175  log << MSG::ERROR
176  << "Tool Service not found"
177  << endmsg;
178  return 0 ;
179  }
180 
182  // Allocate Tools //
184 
185  IAlgTool* algToolPtr;
186  sc = myToolSvc->retrieveTool(type,nm,algToolPtr);
187  // tool not found
188  if ( sc.isFailure() )
189  {
190  log << MSG::INFO
191  << "Cannot find tool named <"
192  << type << "/" << nm
193  << ">"
194  << endmsg;
195  return 0;
196  }
197  return dynamic_cast<CaloTowerBuilderToolBase*>(algToolPtr);
198 
199 }
CaloTowerContainerCnv::p1_guid
pool::Guid p1_guid
Definition: CaloTowerContainerCnv.h:51
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
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:264
skel.it
it
Definition: skel.GENtoEVGEN.py:423
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:47
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:46
CaloTowerContainerCnv::p0_guid
pool::Guid p0_guid
Definition: CaloTowerContainerCnv.h:50
CaloTowerContainer::init
void init()
Initializes the CaloTowerContainer.
Definition: CaloTowerContainer.cxx:107
CaloTowerContainerCnv::createPersistent
virtual CaloTowerContainerPERS * createPersistent(CaloTowerContainer *)
Definition: CaloTowerContainerCnv.cxx:157
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
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:49
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:165
CaloTowerContainer::getCalos
size_t getCalos(std::vector< CaloCell_ID::SUBCALO > &theCalos) const
Retrieve the list of used calorimeters.
Definition: CaloTowerContainer.cxx:180
CaloTowerContainerCnv::createTransient
virtual CaloTowerContainer * createTransient()
initialization
Definition: CaloTowerContainerCnv.cxx:51
CaloTowerContainerCnv::m_converter
CaloTowerContainerCnv_p1 m_converter
Definition: CaloTowerContainerCnv.h:52
python.PyAthena.v
v
Definition: PyAthena.py:157
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
CaloTowerContainerCnv::~CaloTowerContainerCnv
virtual ~CaloTowerContainerCnv()
Definition: CaloTowerContainerCnv.cxx:33
CaloTowerContainerCnv::getTool
CaloTowerBuilderToolBase * getTool(const std::string &type, const std::string &nm)
Definition: CaloTowerContainerCnv.cxx:166
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:15
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloTowerContainerCnv::m_fcalTowerBldr
CaloTowerBuilderToolBase * m_fcalTowerBldr
Definition: CaloTowerContainerCnv.h:48
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