ATLAS Offline Software
L1CaloCondSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <list>
8 #include <set>
9 
11 ATLAS_NO_CHECK_FILE_THREAD_SAFETY; // obsolete, replaced by L1CaloCondAlg
12 
13 L1CaloCondSvc::L1CaloCondSvc(const std::string& name, ISvcLocator* svc) :
15  m_detStore ("DetectorStore", name),
16  m_regSvc ("IOVRegistrationSvc", name)
17 {
18  // declare properties
19  declareProperty("StreamName", m_streamName = "COOLStream");
20  declareProperty("BeginRun", m_iovBeginRun = 0 );
22  declareProperty("BeginLB", m_iovBeginLB = 0 );
24  declareProperty("BeginTime", m_iovBeginTime = 0);
25  declareProperty("EndTime", m_iovEndTime = 0);
26  declareProperty("TimeStamp", m_bUseTimeStamp = false);
27  declareProperty("WriteNewChannels", m_bWriteNewChannels = false);
28 }
29 
31 
32 StatusCode L1CaloCondSvc::queryInterface(const InterfaceID& riid, void** ppvInterface)
33 {
34  ATH_MSG_DEBUG("in queryInterface()");
35 
36  if (L1CaloCondSvc::interfaceID().versionMatch(riid)) {
37  ATH_MSG_DEBUG("matched L1CaloCondSvc");
38  *ppvInterface=(L1CaloCondSvc*)this;
39  } else {
40  ATH_MSG_DEBUG("Default to Service interface");
41  return AthService::queryInterface(riid,ppvInterface);
42  }
43  return StatusCode::SUCCESS;
44 }
45 
46 
48 {
50  ATH_CHECK( m_detStore.retrieve() );
51  ATH_CHECK( m_regSvc.retrieve() );
52  return StatusCode::SUCCESS;
53 }
54 
56 {
57  ATH_MSG_DEBUG("in finalize()");
58 
59  std::map<std::string, const DataHandle<AthenaAttributeList>* >::iterator it_AttrList = m_mDataHandleAttrList.begin();
60  for(;it_AttrList!=m_mDataHandleAttrList.end();++it_AttrList) {
61  delete it_AttrList->second;
62  }
63 
64  std::map<std::string, const DataHandle<CondAttrListCollection>* >::iterator it_AttrListColl = m_mDataHandleAttrListColl.begin();
65  for(;it_AttrListColl!=m_mDataHandleAttrListColl.end();++it_AttrListColl) {
66  delete it_AttrListColl->second;
67  }
68 
69  return StatusCode::SUCCESS;
70 }
71 
73 
74 
75 // ATH_MSG_INFO("ACH updateConditions()");
76  ATH_MSG_VERBOSE("updateConditions()");
77 
78  // set to store the list of objects to be updated.
79  std::set<IL1CaloPersistenceCapable*> vToBeUpdated;
80 
81  // loop over the keys of folders that have new conditions to be cached
82  std::list<std::string>::const_iterator itr;
83  for(itr=keys.begin(); itr!=keys.end(); ++itr) {
84  std::string key = *itr;
85 // ATH_MSG_INFO("ACH key = " << key);
86  ATH_MSG_VERBOSE("key = " << key);
87 
88  // find the current key in the map
89  std::map<std::string, std::vector<IL1CaloPersistenceCapable*> >::const_iterator it_map = m_mConditions.find(key);
90  if(it_map!=m_mConditions.end()) {
91 
92  // loop over objects that depend on the current folder/key
93  std::vector<IL1CaloPersistenceCapable*> vObjs = it_map->second;
94  std::vector<IL1CaloPersistenceCapable*>::const_iterator it_vObjs = vObjs.begin();
95  for(;it_vObjs!=vObjs.end();++it_vObjs) {
96  IL1CaloPersistenceCapable* pobj = *it_vObjs;
97  vToBeUpdated.insert(pobj);
98  }
99  }
100  }
101 
102  // form here vToBeUpdated contains the list of objects to be updated
103  // loop over them, get the required datahandles and pass them to pobj
104  std::set<IL1CaloPersistenceCapable*>::const_iterator it_set = vToBeUpdated.begin();
105  for(;it_set!=vToBeUpdated.end();++it_set) {
106  IL1CaloPersistenceCapable* pobj = *it_set;
107 
108  // get the keys/folders required by current object
109  std::vector<std::string> vCoolInputKeys = pobj->coolInputKeys();
110 
111  std::vector<std::string> otherkeys = m_map_conditions2key[pobj];
112  vCoolInputKeys.insert(vCoolInputKeys.end(),otherkeys.begin(),otherkeys.end());
113 
114  std::string conditionType = pobj->conditionType();
115 // ATH_MSG_INFO("ACH conditionType = "<<conditionType);
116 
117  if(conditionType=="CondAttrListCollection") {
118 
119  // will contain pointer to the CondAttrListCollection(s) required by pobj to populate itself.
120  std::map<std::string, const CondAttrListCollection*> condAttrListCollectionMap;
121 
122  // loop onver input keys, to get the corresponding datahandle
123  std::vector<std::string>::const_iterator it_coolInputKeys = vCoolInputKeys.begin();
124  for(;it_coolInputKeys!=vCoolInputKeys.end();++it_coolInputKeys) {
125  std::string key = *it_coolInputKeys;
126 // ATH_MSG_INFO("ACH update key = " << key);
127  std::map<std::string, const DataHandle<CondAttrListCollection>* >::iterator it = m_mDataHandleAttrListColl.find(key);
128  if (it != m_mDataHandleAttrListColl.end()) {
130  const CondAttrListCollection* attrListCollection = &(*dh);
131  if (attrListCollection) {
132 // ATH_MSG_INFO("ACH attrListCollection = "<<attrListCollection);
133  condAttrListCollectionMap[key] = (CondAttrListCollection*)attrListCollection;
134  }
135  }
136  }
137 // ATH_MSG_INFO("ACH condAttrListCollectionMap size is "<<condAttrListCollectionMap.size());
138  pobj->makeTransient(condAttrListCollectionMap);
139 
140  } else if(conditionType=="AthenaAttributeList"){
141 /*
142  const DataHandle<AthenaAttributeList>& dh = *m_mDataHandleAttrList[key];
143 
144  const AthenaAttributeList* athenaAttributeList = &(*dh);
145  pobj->makeTransient(athenaAttributeList);
146 */
147  } else {
148  ATH_MSG_ERROR("Condition type " << conditionType<< "not recognized by L1CaloCondSvc");
149  return StatusCode::FAILURE;
150  }
151 
152  }
153 
154 
155 
156 /*
157  std::map<std::string, std::vector<IL1CaloPersistenceCapable*> >::const_iterator it_obj = m_mConditions.find(key);
158  if(it_obj!=m_mConditions.end()) {
159 
160  IL1CaloPersistenceCapable* pobj = it_obj->second;
161 
162  std::string conditionType = pobj->conditionType();
163  if(conditionType=="CondAttrListCollection") {
164 
165  const DataHandle<CondAttrListCollection>& dh = *m_mDataHandleAttrListColl[key];
166 
167  const CondAttrListCollection* attrListCollection = &(*dh);
168  pobj->makeTransient(attrListCollection);
169 
170  } else if(conditionType=="AthenaAttributeList"){
171 
172  const DataHandle<AthenaAttributeList>& dh = *m_mDataHandleAttrList[key];
173 
174  const AthenaAttributeList* athenaAttributeList = &(*dh);
175  pobj->makeTransient(athenaAttributeList);
176 
177  } else {
178  log << MSG::ERROR << "Condition type " << conditionType<< "not recognized by L1CaloCondSvc" << endmsg;
179  return StatusCode::FAILURE;
180  }
181  }
182 */
183 
184 
185  ATH_MSG_VERBOSE("end of L1CaloCondSvc::updateConditions(IOVSVC_CALLBACK_ARGS_P(/*I*/, keys))");
186  return StatusCode::SUCCESS;
187 }
188 
189 
190 //StatusCode L1CaloCondSvc::updateConditions(IOVSVC_CALLBACK_ARGS_P(/*I*/, keys)) {
191 // MsgStream log(msgSvc(),name());
192 //
193 // log<<MSG::VERBOSE<<"updateConditions()"<<endmsg;
194 //
195 // std::list<std::string>::const_iterator itr;
196 // for(itr=keys.begin(); itr!=keys.end(); ++itr) {
197 // std::string key = *itr;
198 // log << MSG::VERBOSE << key << endmsg;
199 //
200 // std::map<std::string, std::vector<IL1CaloPersistenceCapable*> >::const_iterator it_obj = m_mConditions.find(key);
201 // if(it_obj!=m_mConditions.end()) {
202 //
203 // IL1CaloPersistenceCapable* pobj = it_obj->second;
204 //
205 // std::string conditionType = pobj->conditionType();
206 // if(conditionType=="CondAttrListCollection") {
207 //
208 // const DataHandle<CondAttrListCollection>& dh = *m_mDataHandleAttrListColl[key];
209 //
210 // const CondAttrListCollection* attrListCollection = &(*dh);
211 // pobj->makeTransient(attrListCollection);
212 //
213 // } else if(conditionType=="AthenaAttributeList"){
214 //
215 // const DataHandle<AthenaAttributeList>& dh = *m_mDataHandleAttrList[key];
216 //
217 // const AthenaAttributeList* athenaAttributeList = &(*dh);
218 // pobj->makeTransient(athenaAttributeList);
219 //
220 // } else {
221 // log << MSG::ERROR << "Condition type " << conditionType<< "not recognized by L1CaloCondSvc" << endmsg;
222 // return StatusCode::FAILURE;
223 // }
224 // }
225 // }
226 //
227 // log << MSG::VERBOSE << "end of L1CaloCondSvc::updateConditions(IOVSVC_CALLBACK_ARGS_P(/*I*/, keys))" << endmsg;
228 // return StatusCode::SUCCESS;
229 //}
230 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
L1CaloCondSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: L1CaloCondSvc.h:114
L1CaloCondSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Definition: L1CaloCondSvc.cxx:32
IL1CaloPersistenceCapable
Definition: IL1CaloPersistenceCapable.h:21
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: L1CaloCondSvc.cxx:11
L1CaloCondSvc::m_mDataHandleAttrListColl
std::map< std::string, const DataHandle< CondAttrListCollection > * > m_mDataHandleAttrListColl
Definition: L1CaloCondSvc.h:108
L1CaloCondSvc::m_iovEndRun
unsigned int m_iovEndRun
Definition: L1CaloCondSvc.h:93
initialize
void initialize()
Definition: run_EoverP.cxx:894
skel.it
it
Definition: skel.GENtoEVGEN.py:423
IOVSVC_CALLBACK_ARGS_K
#define IOVSVC_CALLBACK_ARGS_K(K)
short hand for IOVSvc call back argument list, to be used when when only the keys argument is needed.
Definition: IOVSvcDefs.h:33
L1CaloCondSvc::L1CaloCondSvc
L1CaloCondSvc(const std::string &name, ISvcLocator *svc)
Definition: L1CaloCondSvc.cxx:13
L1CaloCondSvc.h
PyPoolBrowser.dh
dh
Definition: PyPoolBrowser.py:102
IL1CaloPersistenceCapable::makeTransient
virtual void makeTransient(const std::map< std::string, const CondAttrListCollection * > &condAttrListCollectionMap)=0
L1CaloCondSvc::m_bUseTimeStamp
bool m_bUseTimeStamp
Definition: L1CaloCondSvc.h:98
L1CaloCondSvc::updateConditions
virtual StatusCode updateConditions(IOVSVC_CALLBACK_ARGS)
Definition: L1CaloCondSvc.cxx:72
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthenaAttributeList.h
python.LArBadChannelDBAlg.x7FFFFFFF
x7FFFFFFF
Definition: LArBadChannelDBAlg.py:72
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.LArBadChannelDBAlg.xFFFFFFFF
xFFFFFFFF
Definition: LArBadChannelDBAlg.py:73
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthService
Definition: AthService.h:32
L1CaloCondSvc::finalize
virtual StatusCode finalize()
Definition: L1CaloCondSvc.cxx:55
L1CaloCondSvc::initialize
virtual StatusCode initialize()
Definition: L1CaloCondSvc.cxx:47
L1CaloCondSvc::~L1CaloCondSvc
virtual ~L1CaloCondSvc()
Definition: L1CaloCondSvc.cxx:30
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
L1CaloCondSvc::m_regSvc
ServiceHandle< IIOVRegistrationSvc > m_regSvc
Definition: L1CaloCondSvc.h:84
IL1CaloPersistenceCapable::coolInputKeys
virtual std::vector< std::string > coolInputKeys() const =0
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
L1CaloCondSvc::m_mConditions
std::map< std::string, std::vector< IL1CaloPersistenceCapable * > > m_mConditions
Definition: L1CaloCondSvc.h:109
IL1CaloPersistenceCapable::conditionType
virtual std::string conditionType() const =0
L1CaloCondSvc::m_iovEndTime
uint64_t m_iovEndTime
Definition: L1CaloCondSvc.h:97
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
L1CaloCondSvc::m_bWriteNewChannels
bool m_bWriteNewChannels
Definition: L1CaloCondSvc.h:89
DataHandle< CondAttrListCollection >
L1CaloCondSvc::m_iovBeginRun
unsigned int m_iovBeginRun
Definition: L1CaloCondSvc.h:92
L1CaloCondSvc::m_map_conditions2key
std::map< IL1CaloPersistenceCapable *, std::vector< std::string > > m_map_conditions2key
Definition: L1CaloCondSvc.h:110
L1CaloCondSvc::m_streamName
std::string m_streamName
Definition: L1CaloCondSvc.h:87
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
L1CaloCondSvc::m_iovBeginLB
unsigned int m_iovBeginLB
Definition: L1CaloCondSvc.h:94
L1CaloCondSvc::m_iovEndLB
unsigned int m_iovEndLB
Definition: L1CaloCondSvc.h:95
checker_macros.h
Define macros for attributes used to control the static checker.
L1CaloCondSvc::m_iovBeginTime
uint64_t m_iovBeginTime
Definition: L1CaloCondSvc.h:96
L1CaloCondSvc
L1CaloCondSvc class.
Definition: L1CaloCondSvc.h:39
L1CaloCondSvc::m_mDataHandleAttrList
std::map< std::string, const DataHandle< AthenaAttributeList > * > m_mDataHandleAttrList
Definition: L1CaloCondSvc.h:107
L1CaloCondSvc::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Definition: L1CaloCondSvc.h:83
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37