Project
Loading...
Searching...
No Matches
make-parameter-collection.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
18
19#include "TGraph.h"
20#include "TSystem.h"
21#include "TCanvas.h"
22#include <boost/program_options.hpp>
23#include "TFile.h"
25
26namespace bpo = boost::program_options;
27using namespace std::chrono;
28using namespace o2::tof;
29
30bpo::variables_map arguments; // Command line arguments
31bool initOptionsAndParse(bpo::options_description& options, int argc, char* argv[])
32{
33 options.add_options()(
34 "ccdb-path,c", bpo::value<std::string>()->default_value("Analysis/PID/TOF"), "CCDB path for storage/retrieval")(
35 "reso-name,n", bpo::value<std::string>()->default_value("TOFResoParams"), "Name of the parametrization object")(
36 "mode,m", bpo::value<unsigned int>()->default_value(1), "Working mode: 0 push, 1 pull and test, 2 create and performance")(
37 "p0", bpo::value<float>()->default_value(0.008f), "Parameter 0 of the TOF resolution")(
38 "p1", bpo::value<float>()->default_value(0.008f), "Parameter 1 of the TOF resolution")(
39 "p2", bpo::value<float>()->default_value(0.002f), "Parameter 2 of the TOF resolution")(
40 "p3", bpo::value<float>()->default_value(40.0f), "Parameter 3 of the TOF resolution")(
41 "p4", bpo::value<float>()->default_value(60.0f), "Parameter 4 of the TOF resolution: average TOF resolution");
42 try {
43 bpo::store(parse_command_line(argc, argv, options), arguments);
44
45 // help
46 if (arguments.count("help")) {
47 LOG(info) << options;
48 return false;
49 }
50
51 bpo::notify(arguments);
52 } catch (const bpo::error& e) {
53 LOG(error) << e.what() << "\n";
54 LOG(error) << "Error parsing command line arguments; Available options:";
55 LOG(error) << options;
56 return false;
57 }
58 return true;
59}
60
61class ParamExample : public Parameters<5>
62{
63 public:
64 ParamExample() : Parameters(std::array<std::string, 5>{"p0", "p1", "p2", "p3", "p4"},
65 "ParamExample") { setParameters(std::array<paramvar_t, 5>{0, 1, 2, 3, 4}); }; // Default constructor with default parameters
66 ~ParamExample() = default;
67};
68
69int main(int argc, char* argv[])
70{
71 bpo::options_description options("Allowed options");
72 if (!initOptionsAndParse(options, argc, argv)) {
73 LOG(info) << "Nothing to do";
74 return 1;
75 }
76 ParameterCollection collection;
77 ParamExample parameters;
78 ParamExample parameters2;
79 parameters2.setParameters(std::array<paramvar_t, 5>{5, 6, 7, 8, 9});
80 collection.storeParameters(parameters, "test1");
81 collection.storeParameters(parameters2, "test2");
82 TFile f("/tmp/testparamcollection.root", "RECREATE");
83 collection.Write("test");
84 f.Close();
85
86 ParameterCollection collection2;
87 collection2.loadParamFromFile("/tmp/testparamcollection.root", "test");
88 LOG(info) << "Input:";
89 collection.print();
90 LOG(info) << "Retrieved:";
91 collection2.print();
92 ParamExample parameters3;
93 collection.retrieveParameters(parameters3, "test1");
94 LOG(info) << "Input parameters:";
95 parameters.print();
96 LOG(info) << "Retrieved parameters:";
97 parameters3.print();
98
99 return 0;
100}
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
char error[CURL_ERROR_SIZE]
Definitions of the containers for the general parameters.
~ParamExample()=default
Class container to hold different parameters meant to be stored on the CCDB.
bool retrieveParameters(ParType &p, const std::string &key) const
Function to load the parameters from the this container into the array based for the asked key,...
void print(const std::string &pass) const
printing function for the content of the pass
void loadParamFromFile(const TString FileName, const TString ParamName)
bool storeParameters(const ParType &p, const std::string &key)
Function to push the parameters from the sub container into the collection and store it under a given...
void setParameters(const paramvar_t *params)
void print() const
Printer of the parameter values.
GLsizei const GLchar *const * string
Definition glcorearb.h:809
GLenum array
Definition glcorearb.h:4274
GLdouble f
Definition glcorearb.h:310
bool initOptionsAndParse(bpo::options_description &options, int argc, char *argv[])
bpo::variables_map arguments
#define main
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"