76 {
77 ATH_MSG_INFO (
"Finalize: preparing to write conditions objects ");
78
82 return( StatusCode::FAILURE);
83 }
84
85
86 struct obj_t{
91 std::string tagDescr;
92 SG::DataProxy*
proxy=
nullptr;
93 };
94
95 std::vector<obj_t>
objs;
96
97 for (
unsigned int iobj = 0; iobj <
m_objectList.size(); ++iobj) {
98
99 obj_t& objt=
objs.emplace_back();
103
104
105
106 auto hashSplit = std::ranges::views::split(objStr,std::string_view("#"));
107 for (
const auto [iHash,
ss] : std::views::enumerate(hashSplit)) {
108 switch(iHash) {
109 case 0:
110 objt.type=std::string_view(
ss);
111 break;
112 case 1:
113 objt.key=std::string_view(
ss);
114 break;
115 case 2:
116 objt.folder=std::string_view(
ss);
117 break;
118 default:
120 ATH_MSG_ERROR(
"Expect format typename#key#folder (where key and folder are optional)");
121 return StatusCode::FAILURE;
122 }
123 }
124
127 if (objt.key.empty()) {
128
129 objt.proxy =
detStore()->proxy(clid);
130 if (!objt.proxy) {
131 ATH_MSG_ERROR(
"Could not get default proxy for CLID {}, typename {}",clid,objt.type);
132 return StatusCode::FAILURE;
133 }
134 objt.key = objt.proxy->name();
135 }
136 else {
137 objt.proxy =
detStore()->proxy(clid, objt.key);
138 if (!objt.proxy) {
139 ATH_MSG_ERROR(
"Could not get proxy for CLID {}, typename {}, key {}",clid,objt.type,objt.key);
140 return StatusCode::FAILURE;
141 }
142
143 }
144
145 if (objt.folder.empty()) {
146 objt.folder=objt.key;
147 }
148
149 }
150
151
152 const size_t nObjects =
objs.size();
154 ATH_MSG_INFO(
"Identified a total of " << nObjects <<
" objects to write out:");
155
156 if (nObjects == 0)
157 return StatusCode::SUCCESS;
158
159 for (
unsigned i=1;
const obj_t& objt :
objs) {
160 typeKeys.emplace_back(std::make_pair(objt.type, objt.key));
161 ATH_MSG_INFO(
"{}: {}#{}#{}",i++,objt.type,objt.key,objt.folder);
162 }
163
164
165
167 if (
sc.isFailure()) {
169 return StatusCode::FAILURE;
170 }
171
173 if (
sc.isFailure()) {
175 return StatusCode::FAILURE;
176 }
177 ATH_MSG_INFO(
"Written {} objects to output stream",nObjects);
178
180
181
183 msg() << MSG::INFO <<
"Register objects in IOV database, interval of validity ";
186 } else {
188 }
189 int nreg = 0;
190 for (const obj_t& objt : objs) {
191 ATH_MSG_INFO(
"Register object {}#{} in IOV database folder {} {}", objt.type, objt.key, objt.folder,
192 objt.tag.size() ? "with tag " + objt.tag : "without tagging");
195 } else {
197 }
198 if (
sc == StatusCode::SUCCESS) {
199 ++nreg;
200 } else {
202 }
203 }
204 ATH_MSG_INFO(
"Registered " << nreg <<
" objects in COOL IOV database");
205 } else {
206
207
210
211 const std::string globalTagName = "GlobalTestTag";
212 chai::GlobalTagPtr gt;
213 std::vector<std::string> existingGlobalTags;
214 try {
215 existingGlobalTags =
db.findGlobalTags(globalTagName);
216 }
217 catch (std::exception& e) {
218
219 }
220 if (existingGlobalTags.empty()) {
221 gt =
db.createGlobalTag(
"GlobalTestTag",
"test",
"test");
223 } else {
224 gt =
db.getGlobalTag(globalTagName);
226 }
227
228
229 std::string address_data;
230
231 for (const obj_t& objt : objs) {
232 chai::TagIovType iovType;
235 iovType = chai::Tag::IovType::Time;
237 } else {
238 iovType = chai::Tag::IovType::RunNumberLumiBlock;
240 }
241 const CLID clid = objt.proxy->clID();
242
243
244 ATH_MSG_INFO(
"Working on object clid {}, type {}, folder {}",clid, objt.type, objt.folder);
245
247 if (clid == 40774348 || clid == 1238547719) {
248
249 description = chai::Tag::buildNodeDescription(iovType, objt.type, clid);
250 } else {
251
252 IOpaqueAddress* addr = objt.proxy->address();
253 if (!addr) {
254 ATH_MSG_ERROR(
"No IOpaqueAddress from Type/Key [{}/{}]",objt.type,objt.key);
255 return StatusCode::FAILURE;
256 }
257 std::string saddr;
259
260 std::string address_header;
261
262 if (
splitAddress(saddr, address_header, address_data).isFailure()) {
263 ATH_MSG_ERROR(
"Could not split address: {}\n hdr: {}\n data: {}",saddr,address_header,address_data);
264 return StatusCode::FAILURE;
265 }
266 ATH_MSG_DEBUG(
"split address: {}\n hdr: {}\n data: {}",saddr,address_header,address_data);
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284 std::string symLinkTypes;
285 for (
const CLID& c : objt.proxy->transientID()) {
286 if (c != clid) {
287 std::string symType;
289 if (!symLinkTypes.empty())
290 symLinkTypes += ":";
291 symLinkTypes.append(symType);
292 }
293 }
294 if (!symLinkTypes.empty()) {
296 }
297
298
299 if (iovType == chai::Tag::IovType::Time) {
301 } else {
303 }
304
305
307
308
309 if (objt.key != objt.folder) {
311 }
312 }
313 static const std::string crestObjTypeStr{"crest-json-single-iov"};
314 chai::Tag::Metadata chaiMD{.iovType = iovType,
315 .objectType = crestObjTypeStr,
316 .synchronization = chai::Tag::Synchronization::All,
317 .status = chai::Tag::Status::Unlocked,
319
320
321
322
323 IOpaqueAddress* addr = objt.proxy->address();
324
325 CondAttrListCollAddress* collAddr = dynamic_cast<CondAttrListCollAddress*>(addr);
326 if (collAddr) {
327
328
329 const CondAttrListCollection* attrListColl = collAddr->
attrListColl();
330
332 ATH_MSG_INFO(
"Created chai container with " << chaiCont.numChannels() <<
" channels.");
333 const chai::PayloadSpec& chaiSpec=chaiCont.payloadSpec();
334 auto chaiTag=
db.createTag(objt.tag, objt.tagDescr, chaiSpec,chaiMD);
335 chaiTag->addPayload(chaiCont,since);
336
337
338 } else if (clid == 40774348) {
339
340
341 const AthenaAttributeList* attrList;
343
345 const chai::PayloadSpec& chaiSpec=chaiCont.payloadSpec();
346 auto chaiTag=
db.createTag(objt.tag, objt.tagDescr, chaiSpec,chaiMD);
347 gt->addTag(objt.folder,objt.tag);
348 chaiTag->addPayload(chaiCont,since);
349 } else {
350
351
352 chai::PayloadSpec
spec(chai::FieldSpec({{
"PoolRef", chai::Type::String}}), chai::ChannelSpec({{0,
""}}));
353 auto tag =
db.createTag(objt.tag, objt.tagDescr, spec,chaiMD);
354 gt->addTag(objt.folder, objt.tag);
357
358
359 tag->addPayload(container, since);
360
361 }
362 }
363 ATH_MSG_INFO(
"Registered " <<
objs.size() <<
" objects in CREST IOV database");
364 }
365 }
366 else {
368 }
369 return StatusCode::SUCCESS;
370}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
uint32_t CLID
The Class ID type.
const ServiceHandle< StoreGateSvc > & detStore() const
static chai::Container toContainer(const AthenaAttributeList &attrList, uint64_t channelId=0, const std::string &channelName="")
Convert an AthenaAttributeList to a single-channel chai::Container.
CondAttrListCollection * attrListColl()
Access to AttributeList.
uint64_t timeToNano(unsigned long int timesec) const
UnsignedLongProperty m_par_time2
ServiceHandle< IClassIDSvc > p_clidsvc
Gaudi::Property< std::vector< std::string > > m_par_tagDescr
Gaudi::Property< bool > m_par_writeIOV
void buildDescription(const std::string &identifier, const std::string &value, std::string &description) const
ServiceHandle< IIOVRegistrationSvc > p_regsvc
Gaudi::Property< unsigned int > m_par_lumib2
Gaudi::Property< std::vector< std::string > > m_par_iovtags
Gaudi::Property< bool > m_par_timestamp
ToolHandle< IAthenaOutputStreamTool > m_streamer
StatusCode splitAddress(const std::string &address, std::string &address_header, std::string &address_data) const
ServiceHandle< IAddressCreator > m_persSvc
Gaudi::Property< std::vector< std::string > > m_objectList
Gaudi::Property< unsigned int > m_par_run2
UnsignedLongProperty m_par_time1
Gaudi::Property< unsigned int > m_par_lumib1
Gaudi::Property< unsigned int > m_par_run1
Gaudi::Property< std::string > m_par_crestDir
::StatusCode StatusCode
StatusCode definition for legacy code.
const SG::AuxVectorData * container() const
Return the container holding this element.