@@ -103,17 +103,17 @@ struct tpcPid {
103103 // TPC PID Response
104104 o2::pid::tpc::Response* response;
105105
106+ // CCDB accessor
107+ Service<o2::ccdb::BasicCCDBManager> ccdb;
108+
106109 // Network correction for TPC PID response
107110 OnnxModel network;
108- o2::ccdb::CcdbApi ccdbApi;
109111 std::map<std::string, std::string> metadata;
110- std::map<std::string, std::string> nullmetadata;
111112 std::map<std::string, std::string> headers;
112113 std::vector<int > speciesNetworkFlags = std::vector<int >(9 );
113114 std::string networkVersion;
114115
115116 // Input parameters
116- Service<o2::ccdb::BasicCCDBManager> ccdb;
117117 Configurable<std::string> paramfile{" param-file" , " " , " Path to the parametrization object, if empty the parametrization is not taken from file" };
118118 Configurable<std::string> url{" ccdb-url" , " http://alice-ccdb.cern.ch" , " url of the ccdb repository" };
119119 Configurable<std::string> ccdbPath{" ccdbPath" , " Analysis/PID/TPC/Response" , " Path of the TPC parametrization on the CCDB" };
@@ -242,21 +242,18 @@ struct tpcPid {
242242 ccdb->setCaching (true );
243243 ccdb->setLocalObjectValidityChecking ();
244244 ccdb->setCreatedNotAfter (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ());
245- ccdbApi.init (url);
246245 if (time != 0 ) {
247246 LOGP (info, " Initialising TPC PID response for fixed timestamp {} and reco pass {}:" , time, recoPass.value );
248247 ccdb->setTimestamp (time);
249- response = ccdb->getSpecific <o2::pid::tpc::Response>(path, time, metadata);
250- headers = ccdbApi.retrieveHeaders (path, metadata, time);
248+ response = ccdb->getSpecific <o2::pid::tpc::Response>(path, time, metadata, &headers);
251249 if (!response) {
252250 LOGF (warning, " Unable to find TPC parametrisation for specified pass name - falling back to latest object" );
253- response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(path, time);
254- headers = ccdbApi.retrieveHeaders (path, metadata, time);
255- networkVersion = headers[" NN-Version" ];
251+ response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(path, time, &headers);
256252 if (!response) {
257253 LOGF (fatal, " Unable to find any TPC object corresponding to timestamp {}!" , time);
258254 }
259255 }
256+ networkVersion = headers[" NN-Version" ];
260257 LOG (info) << " Successfully retrieved TPC PID object from CCDB for timestamp " << time << " , period " << headers[" LPMProductionTag" ] << " , recoPass " << headers[" RecoPassName" ];
261258 metadata[" RecoPassName" ] = headers[" RecoPassName" ]; // Force pass number for NN request to match retrieved BB
262259 response->PrintAll ();
@@ -274,8 +271,7 @@ struct tpcPid {
274271 if (ccdbTimestamp > 0 ) {
275272 // / Fetching network for specific timestamp
276273 LOG (info) << " Fetching network for timestamp: " << ccdbTimestamp.value ;
277- bool retrieveSuccess = ccdbApi.retrieveBlob (networkPathCCDB.value , " ." , metadata, ccdbTimestamp.value , false , networkPathLocally.value );
278- headers = ccdbApi.retrieveHeaders (networkPathCCDB.value , metadata, ccdbTimestamp.value );
274+ bool retrieveSuccess = ccdb->getCCDBAccessor ().retrieveBlob (networkPathCCDB.value , " ." , metadata, ccdbTimestamp.value , false , networkPathLocally.value , " " , " " , &headers);
279275 networkVersion = headers[" NN-Version" ];
280276 if (retrieveSuccess) {
281277 network.initModel (networkPathLocally.value , enableNetworkOptimizations.value , networkSetNumThreads.value , strtoul (headers[" Valid-From" ].c_str (), NULL , 0 ), strtoul (headers[" Valid-Until" ].c_str (), NULL , 0 ));
@@ -318,32 +314,29 @@ struct tpcPid {
318314 } else {
319315 LOGP (info, " Retrieving TPC Response for timestamp {} and recoPass {}:" , bc.timestamp (), recoPass.value );
320316 }
321- response = ccdb->getSpecific <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), metadata);
322- headers = ccdbApi.retrieveHeaders (ccdbPath.value , metadata, bc.timestamp ());
323- networkVersion = headers[" NN-Version" ];
317+ response = ccdb->getSpecific <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), metadata, &headers);
324318 if (!response) {
325319 LOGP (warning, " !! Could not find a valid TPC response object for specific pass name {}! Falling back to latest uploaded object." , metadata[" RecoPassName" ]);
326- headers = ccdbApi.retrieveHeaders (ccdbPath.value , nullmetadata, bc.timestamp ());
327- response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp ());
320+ response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), &headers);
328321 if (!response) {
329322 LOGP (fatal, " Could not find ANY TPC response object for the timestamp {}!" , bc.timestamp ());
330323 }
331324 }
325+ networkVersion = headers[" NN-Version" ];
332326 LOG (info) << " Successfully retrieved TPC PID object from CCDB for timestamp " << bc.timestamp () << " , period " << headers[" LPMProductionTag" ] << " , recoPass " << headers[" RecoPassName" ];
333327 metadata[" RecoPassName" ] = headers[" RecoPassName" ]; // Force pass number for NN request to match retrieved BB
334328 response->PrintAll ();
335329 }
336330
337331 if (bc.timestamp () < network.getValidityFrom () || bc.timestamp () > network.getValidityUntil ()) { // fetches network only if the runnumbers change
338332 LOG (info) << " Fetching network for timestamp: " << bc.timestamp ();
339- bool retrieveSuccess = ccdbApi.retrieveBlob (networkPathCCDB.value , " ." , metadata, bc.timestamp (), false , networkPathLocally.value );
340- headers = ccdbApi.retrieveHeaders (networkPathCCDB.value , metadata, bc.timestamp ());
333+ bool retrieveSuccess = ccdb->getCCDBAccessor ().retrieveBlob (networkPathCCDB.value , " ." , metadata, bc.timestamp (), false , networkPathLocally.value , " " , " " , &headers);
341334 networkVersion = headers[" NN-Version" ];
342335 if (retrieveSuccess) {
343336 network.initModel (networkPathLocally.value , enableNetworkOptimizations.value , networkSetNumThreads.value , strtoul (headers[" Valid-From" ].c_str (), NULL , 0 ), strtoul (headers[" Valid-Until" ].c_str (), NULL , 0 ));
344337 std::vector<float > dummyInput (network.getNumInputNodes (), 1 .);
345338 network.evalModel (dummyInput);
346- LOGP (info, " Retrieved NN corrections for production tag {}, pass number {}, NN-Version number{}" , headers[" LPMProductionTag" ], headers[" RecoPassName" ], headers[" NN-Version" ]);
339+ LOGP (info, " Retrieved NN corrections for production tag {}, pass number {}, NN-Version number {}" , headers[" LPMProductionTag" ], headers[" RecoPassName" ], headers[" NN-Version" ]);
347340 } else {
348341 LOG (fatal) << " No valid NN object found matching retrieved Bethe-Bloch parametrisation for pass " << metadata[" RecoPassName" ] << " . Please ensure that the requested pass has dedicated NN corrections available" ;
349342 }
@@ -553,12 +546,10 @@ struct tpcPid {
553546 } else {
554547 LOGP (info, " Retrieving TPC Response for timestamp {} and recoPass {}:" , bc.timestamp (), recoPass.value );
555548 }
556- response = ccdb->getSpecific <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), metadata);
557- headers = ccdbApi.retrieveHeaders (ccdbPath.value , metadata, bc.timestamp ());
549+ response = ccdb->getSpecific <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), metadata, &headers);
558550 if (!response) {
559551 LOGP (warning, " !! Could not find a valid TPC response object for specific pass name {}! Falling back to latest uploaded object." , metadata[" RecoPassName" ]);
560- response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp ());
561- headers = ccdbApi.retrieveHeaders (ccdbPath.value , nullmetadata, bc.timestamp ());
552+ response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), &headers);
562553 if (!response) {
563554 LOGP (fatal, " Could not find ANY TPC response object for the timestamp {}!" , bc.timestamp ());
564555 }
@@ -651,12 +642,11 @@ struct tpcPid {
651642 } else {
652643 LOGP (info, " Retrieving TPC Response for timestamp {} and recoPass {}:" , bc.timestamp (), recoPass.value );
653644 }
654- response = ccdb->getSpecific <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), metadata);
655- headers = ccdbApi. retrieveHeaders (ccdbPath. value , metadata, bc. timestamp ());
645+ response = ccdb->getSpecific <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), metadata, &headers );
646+
656647 if (!response) {
657648 LOGP (warning, " !! Could not find a valid TPC response object for specific pass name {}! Falling back to latest uploaded object." , metadata[" RecoPassName" ]);
658- response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp ());
659- headers = ccdbApi.retrieveHeaders (ccdbPath.value , nullmetadata, bc.timestamp ());
649+ response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), &headers);
660650 if (!response) {
661651 LOGP (fatal, " Could not find ANY TPC response object for the timestamp {}!" , bc.timestamp ());
662652 }
@@ -737,10 +727,10 @@ struct tpcPid {
737727 } else {
738728 LOGP (info, " Retrieving TPC Response for timestamp {} and recoPass {}:" , bc.timestamp (), recoPass.value );
739729 }
740- response = ccdb->getSpecific <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), metadata);
730+ response = ccdb->getSpecific <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), metadata, &headers );
741731 if (!response) {
742732 LOGP (warning, " !! Could not find a valid TPC response object for specific pass name {}! Falling back to latest uploaded object." , metadata[" RecoPassName" ]);
743- response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp ());
733+ response = ccdb->getForTimeStamp <o2::pid::tpc::Response>(ccdbPath.value , bc.timestamp (), &headers );
744734 if (!response) {
745735 LOGP (fatal, " Could not find ANY TPC response object for the timestamp {}!" , bc.timestamp ());
746736 }
0 commit comments