Skip to content

Commit 1e1fa6f

Browse files
committed
fix TPC PID response handler tool
1 parent e2f2256 commit 1e1fa6f

1 file changed

Lines changed: 10 additions & 30 deletions

File tree

Common/Tools/handleParamTPCResponse.cxx

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
///
1313
/// \file handleParamTPCResponse.cxx
1414
/// \author Jeremy Wilkinson
15-
/// \brief exec for writing and reading Response object
15+
/// \brief exec for writing and reading TPC PID Response object
1616

1717
#include <array>
1818
#include <fstream>
@@ -26,16 +26,7 @@ using namespace o2::pid::tpc;
2626
bool initOptionsAndParse(bpo::options_description& options, int argc, char* argv[])
2727
{
2828
options.add_options()(
29-
"url,u", bpo::value<std::string>()->default_value("http://alice-ccdb.cern.ch"), "URL of the CCDB database e.g. http://ccdb-test.cern.ch:8080 or http://alice-ccdb.cern.ch")(
3029
"ccdb-path,c", bpo::value<std::string>()->default_value("Analysis/PID/TPC"), "CCDB path for storage/retrieval")(
31-
"rct-path", bpo::value<std::string>()->default_value("RCT/Info/RunInformation"), "path to the ccdb RCT objects for the SOR/EOR timestamps")(
32-
"start,s", bpo::value<long>()->default_value(0), "Start timestamp of object validity. If 0 and runnumber != 0 it will be set to the run SOR")(
33-
"stop,S", bpo::value<long>()->default_value(0), "Stop timestamp of object validity. If 0 and runnumber != 0 it will be set to the run EOR")(
34-
"timestamp,T", bpo::value<long>()->default_value(-1), "Timestamp of the object to retrieve, used in alternative to the run number")(
35-
"runnumber,R", bpo::value<unsigned int>()->default_value(0), "Timestamp of the object to retrieve, used in alternative to the timestamp (if 0 using the timestamp)")(
36-
"delete-previous,delete_previous,d", bpo::value<int>()->default_value(0), "Flag to delete previous versions of converter objects in the CCDB before uploading the new one so as to avoid proliferation on CCDB")(
37-
"save-to-file,file,f,o", bpo::value<std::string>()->default_value(""), "Option to save parametrization to file instead of uploading to ccdb")(
38-
"read-from-file,i", bpo::value<std::string>()->default_value(""), "Option to get parametrization from a file")(
3930
"objname,n", bpo::value<std::string>()->default_value("Response"), "Object name to be stored in file")(
4031
"inobjname,n", bpo::value<std::string>()->default_value("Response"), "Object name to be read from file in 'push' mode")(
4132
"bb0", bpo::value<float>()->default_value(0.03209809958934784f), "Bethe-Bloch parameter 0")(
@@ -51,9 +42,9 @@ bool initOptionsAndParse(bpo::options_description& options, int argc, char* argv
5142
"paramChargeFactor", bpo::value<float>()->default_value(2.299999952316284f), "Charge factor value")(
5243
"paramMultNormalization", bpo::value<float>()->default_value(11000.), "Multiplicity Normalization")(
5344
"useDefaultParam", bpo::value<bool>()->default_value(true), "Use default sigma parametrisation")(
54-
"dryrun,D", bpo::value<int>()->default_value(0), "Perform a dryrun check before uploading")(
5545
"mode", bpo::value<string>()->default_value(""), "Running mode ('read' from file, 'write' to file, 'pull' from CCDB, 'push' to CCDB)")(
5646
"help,h", "Produce help message.");
47+
setStandardOpt(options);
5748
try {
5849
bpo::store(parse_command_line(argc, argv, options), arguments);
5950

@@ -84,11 +75,6 @@ int main(int argc, char* argv[])
8475

8576
const std::string urlCCDB = arguments["url"].as<std::string>();
8677
const auto pathCCDB = arguments["ccdb-path"].as<std::string>();
87-
auto startTime = arguments["start"].as<long>();
88-
auto endTime = arguments["stop"].as<long>();
89-
const auto runnumber = arguments["runnumber"].as<unsigned int>();
90-
auto timestamp = arguments["timestamp"].as<long>();
91-
const int optDelete = arguments["delete-previous"].as<int>();
9278

9379
const std::string outFilename = arguments["save-to-file"].as<std::string>();
9480
const std::string inFilename = arguments["read-from-file"].as<std::string>();
@@ -135,17 +121,13 @@ int main(int argc, char* argv[])
135121
}
136122

137123
if (optMode.compare("push") == 0 || optMode.compare("pull") == 0) { // Initialise CCDB if in push/pull mode
138-
api.init(urlCCDB);
139-
if (!api.isHostReachable()) {
140-
LOG(warning) << "CCDB mode (push/pull) enabled but host " << urlCCDB << " is unreachable.";
141-
return 1;
142-
}
143-
setupTimestamps(timestamp, startTime, endTime);
124+
initCCDBApi();
125+
setupTimestamps(ccdbTimestamp, validityStart, validityStop);
144126
}
145127

146128
if (optMode.compare("read") == 0) { // Read existing object from local file
147129
if (inFilename.empty()) {
148-
LOG(error) << "read mode defined with no input file, please set --read-from-file";
130+
LOG(error) << "Read mode defined with no input file, please set --read-from-file";
149131
return 1;
150132
}
151133

@@ -215,20 +197,18 @@ int main(int argc, char* argv[])
215197
if (optMode.compare("push") == 0) {
216198
LOG(info) << "Attempting to push object to CCDB";
217199

218-
if (optDelete) {
219-
api.truncate(pathCCDB);
220-
}
221200
std::map<std::string, std::string> metadata;
222-
if (runnumber != 0) {
223-
metadata["runnumber"] = Form("%i", runnumber);
201+
if (minRunNumber != 0) {
202+
metadata["min-runnumber"] = Form("%i", minRunNumber);
203+
metadata["max-runnumber"] = Form("%i", maxRunNumber);
224204
}
225-
storeOnCCDB(pathCCDB + "/" + objname, metadata, startTime, endTime, tpc);
205+
storeOnCCDB(pathCCDB + "/" + objname, metadata, validityStart, validityStop, tpc);
226206
}
227207
}
228208

229209
else if (optMode.compare("pull") == 0) { // pull existing from CCDB; write out to file if requested
230210
LOG(info) << "Attempting to pull object from CCDB (" << urlCCDB << "): " << pathCCDB << "/" << objname;
231-
tpc = retrieveFromCCDB<Response>(pathCCDB + "/" + objname, timestamp);
211+
tpc = retrieveFromCCDB<Response>(pathCCDB + "/" + objname, ccdbTimestamp);
232212

233213
tpc->PrintAll();
234214

0 commit comments

Comments
 (0)