40int main(
int argc, 
char** argv)
 
   42  const std::string testCCDB = 
"http://ccdb-test.cern.ch:8080";
 
   43  const std::string prodCCDB = 
"http://o2-ccdb.internal";
 
   44  bpo::variables_map vm;
 
   45  bpo::options_description opt_general(
"Usage:\n  " + std::string(argv[0]) +
 
   46                                       " Write orbit staff to ccdb\n");
 
   47  bpo::options_description opt_hidden(
"");
 
   48  bpo::options_description opt_all;
 
   49  bpo::positional_options_description opt_pos;
 
   51    auto add_option = opt_general.add_options();
 
   52    add_option(
"help,h", 
"Print this help message");
 
   53    add_option(
"output-file,o", bpo::value<std::string>()->default_value(
"none"), 
"output file name, none - file not created");
 
   54    add_option(
"output-dir,d", bpo::value<std::string>()->default_value(
"./"), 
"output dir");
 
   55    add_option(
"ccdb", bpo::value<std::string>()->default_value(
"test"), 
"choose databse: test- test ccdb; prod - production ccdb; else ccdb parameter");
 
   56    add_option(
"action,a", bpo::value<std::string>()->default_value(
""), 
"sox - first orbit otherwise orbit reset");
 
   57    add_option(
"run-number,r", bpo::value<int64_t>()->default_value(123), 
"run number");
 
   58    add_option(
"testReset,t", bpo::value<bool>()->default_value(0), 
"0 = CTP/Calib/OrbitReset; 1 = CTP/Calib/OrbitResetTest");
 
   59    add_option(
"sox-orbit,x", bpo::value<int64_t>()->default_value(0), 
"SOX orbit");
 
   60    add_option(
"timestamp,s", bpo::value<uint64_t>()->default_value(0), 
"timestamp of SOX/orbit reading; if 0 timestamp is calulated inside this code");
 
   63    opt_all.add(opt_general).add(opt_hidden);
 
   64    bpo::store(bpo::command_line_parser(argc, argv).options(opt_all).positional(opt_pos).run(), vm);
 
   65    if (vm.count(
"help")) {
 
   66      std::cout << opt_general << std::endl;
 
   70  } 
catch (bpo::error& e) {
 
   71    std::cerr << 
"ERROR: " << e.what() << std::endl
 
   73    std::cerr << opt_general << std::endl;
 
   75  } 
catch (std::exception& e) {
 
   76    std::cerr << e.what() << 
", application will now exit" << std::endl;
 
   80  std::string action = vm[
"action"].as<std::string>();
 
   81  std::vector<int64_t> vect;
 
   83  long tt = vm[
"timestamp"].as<uint64_t>();
 
   85    auto now = std::chrono::system_clock::now();
 
   86    tt = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
 
   89  if (action == 
"sox") {
 
   91    std::cout << 
"===> FirsRunOrbit" << std::endl;
 
   92    vect.push_back(vm[
"run-number"].as<int64_t>());
 
   93    vect.push_back(vm[
"sox-orbit"].as<int64_t>());
 
   94    ccdbPath = 
"CTP/Calib/FirstRunOrbit";
 
   97    std::cout << 
"===> ResetOrbit" << std::endl;
 
   99    if (vm[
"testReset"].as<bool>()) {
 
  104  std::string ccdbAddress;
 
  105  if (vm[
"ccdb"].as<std::string>() == 
"prod") {
 
  106    ccdbAddress = prodCCDB;
 
  107  } 
else if (vm[
"ccdb"].as<std::string>() == 
"test") {
 
  108    ccdbAddress = testCCDB;
 
  110    ccdbAddress = vm[
"ccdb"].as<std::string>();
 
  112  std::cout << 
" Writing to db:" << ccdbAddress << std::endl;
 
  113  if (ccdbAddress != 
"none") {
 
  116    api.
init(ccdbAddress.c_str());
 
  117    std::map<std::string, std::string> metadata;
 
  118    long tmin = 
tt / 1000;
 
  119    long tmax = tmin + 381928219;
 
  120    if (action == 
"sox") {
 
  121      int64_t runnum = vm[
"run-number"].as<int64_t>();
 
  123      std::cout << 
"Storing:" << 
ccdbPath << 
" " << metadata[
"runNumber"] << 
" tmin:" << tmin << 
" tmax:" << tmax << 
" ts:" << 
tt << std::endl;
 
  126      std::cout << 
"Storing:" << 
ccdbPath << 
" tmin:" << tmin << 
" tmax:" << tmax << 
" ts:" << 
tt << std::endl;
 
  127      std::string 
filename = 
"orbitReset.root";
 
  128      auto classname = 
"std::vector<int64_t>";
 
  129      metadata[
"adjustableEOV"] = 
"true";
 
  132      adjustOverriddenEOV(api, oi);
 
  136  if (vm[
"output-file"].as<std::string>() != 
"none") {
 
  137    std::string 
file = vm[
"output-dir"].as<std::string>() + vm[
"output-file"].as<std::string>();
 
  138    TFile* 
f = TFile::Open(
file.c_str(), 
"RECREATE");
 
  140      std::cout << 
"Error: File" << 
file << 
" could not be open for writing !!!" << std::endl;
 
  143      std::cout << 
"File" << 
file << 
" being writen." << std::endl;
 
  144      f->WriteObject(&vect, 
"ccdb_object");
 
  148    std::cout << 
"No file created" << std::endl;
 
 
int storeAsTFileAny(const T *obj, std::string const &path, std::map< std::string, std::string > const &metadata, long startValidityTimestamp=-1, long endValidityTimestamp=-1, std::vector< char >::size_type maxSize=0) const