Skip to content

Commit f951cc6

Browse files
author
Mattia Faggin
committed
Download file from CCDB only if not present in local folder.
1 parent e2f1c4c commit f951cc6

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

Common/TableProducer/trackPropagation.cxx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,7 @@ struct TrackPropagation {
134134
break;
135135
}
136136

137-
/// see if other track-propagation devices are present
138-
int counter = 0;
139-
LOG(info) << " ---> looking for track-propagation devices";
140-
const auto& workflows = initContext.services().get<RunningWorkflowInfo const>();
141-
for (const DeviceSpec& device : workflows.devices) {
142-
if (device.name.compare("track-propagation") == 0) {
143-
counter++;
144-
}
145-
}
146-
LOGF(info, "Number of track propagation tasks detected: %i", counter);
147-
148-
std::string tmpDirName = std::string("./") + std::to_string(counter);
149-
trackTunerObj.getDcaGraphs(tmpDirName);
137+
trackTunerObj.getDcaGraphs();
150138
trackTunedTracks->SetTitle(outputStringParams.c_str());
151139
trackTunedTracks->GetXaxis()->SetBinLabel(1, "all tracks");
152140
}

Common/Tools/TrackTuner.h

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <TGraphErrors.h>
4242

4343
#include <fmt/core.h>
44+
#include <sys/stat.h>
4445

4546
#include <algorithm>
4647
#include <map>
@@ -458,18 +459,31 @@ struct TrackTuner : o2::framework::ConfigurableGroup {
458459
// properly init the ccdb
459460
ccdbApi.init("http://alice-ccdb.cern.ch");
460461

461-
// get the DCA correction file from CCDB
462-
if (!ccdbApi.retrieveBlob(pathInputFile.data(), tmpDir, metadata, 0, false, nameInputFile.data())) {
463-
LOG(fatal) << "[TrackTuner] input file for DCA corrections not found on CCDB, please check the pathInputFile and nameInputFile!";
462+
// name of the file in the tmp local folder
463+
fullNameInputFile = tmpDir + std::string("/") + nameInputFile;
464+
fullNameFileQoverPt = tmpDir + std::string("/") + nameFileQoverPt;
465+
466+
// get the DCA correction file from CCDB if not yet downloaded before
467+
struct stat sbDca; // search utility
468+
if (stat(fullNameInputFile.c_str(), &sbDca) == 0) {
469+
LOG(info) << " [TrackTuner] File " << fullNameInputFile << " already downloaded. Not downloading it anymore";
470+
} else {
471+
LOG(info) << "[TrackTuner] downloading input file " << nameInputFile << " from CCDB...";
472+
if (!ccdbApi.retrieveBlob(pathInputFile.data(), tmpDir, metadata, 0, false, nameInputFile.data())) {
473+
LOG(fatal) << "[TrackTuner] input file for DCA corrections not found on CCDB, please check the pathInputFile and nameInputFile!";
474+
}
464475
}
465476

466-
// get the Q/Pt correction file from CCDB
467-
if (!ccdbApi.retrieveBlob(pathFileQoverPt.data(), tmpDir, metadata, 0, false, nameFileQoverPt.data())) {
468-
LOG(fatal) << "[TrackTuner] input file for Q/Pt corrections not found on CCDB, please check the pathFileQoverPt and nameFileQoverPt!";
477+
// get the Q/Pt correction file from CCDB if not yet downloaded before
478+
struct stat sbQoverPt; // search utility
479+
if (stat(fullNameFileQoverPt.c_str(), &sbQoverPt) == 0) {
480+
LOG(info) << " [TrackTuner] File " << fullNameFileQoverPt << " already downloaded. Not downloading it anymore";
481+
} else {
482+
LOG(info) << "[TrackTuner] downloading input file " << nameFileQoverPt << " from CCDB...";
483+
if (!ccdbApi.retrieveBlob(pathFileQoverPt.data(), tmpDir, metadata, 0, false, nameFileQoverPt.data())) {
484+
LOG(fatal) << "[TrackTuner] input file for Q/Pt corrections not found on CCDB, please check the pathFileQoverPt and nameFileQoverPt!";
485+
}
469486
}
470-
// point to the file in the tmp local folder
471-
fullNameInputFile = tmpDir + std::string("/") + nameInputFile;
472-
fullNameFileQoverPt = tmpDir + std::string("/") + nameFileQoverPt;
473487
} else {
474488
/// use input correction file from local filesystem
475489
fullNameInputFile = pathInputFile + std::string("/") + nameInputFile;

0 commit comments

Comments
 (0)