Project
Loading...
Searching...
No Matches
bad-channels-ccdb.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
16
17#include <string>
18#include <map>
19#include <vector>
20#include <boost/program_options.hpp>
21#include "CCDB/CcdbApi.h"
23
24namespace po = boost::program_options;
25
26const std::string BadChannelCCDBPath = "MID/Calib/BadChannels";
27
28void queryBadChannels(const std::string ccdbUrl, long timestamp, bool verbose)
29{
31 api.init(ccdbUrl);
32 std::map<std::string, std::string> metadata;
33 auto* badChannels = api.retrieveFromTFileAny<std::vector<o2::mid::ColumnData>>(BadChannelCCDBPath.c_str(), metadata, timestamp);
34 std::cout << "number of bad channels = " << badChannels->size() << std::endl;
35 if (verbose) {
36 for (const auto& badChannel : *badChannels) {
37 std::cout << badChannel << "\n";
38 }
39 }
40}
41
42void uploadBadChannels(const std::string ccdbUrl, long timestamp)
43{
44 std::vector<o2::mid::ColumnData> badChannels;
45
47 api.init(ccdbUrl);
48 std::map<std::string, std::string> md;
49 std::cout << "storing default MID bad channels (valid from " << timestamp << ") to " << BadChannelCCDBPath << "\n";
50
52}
53
54int main(int argc, char** argv)
55{
56 po::variables_map vm;
57 po::options_description usage("Usage");
58
59 std::string ccdbUrl;
60 long timestamp;
61 bool put;
62 bool query;
63 bool verbose;
64
65 uint64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
66
67 // clang-format off
68 usage.add_options()
69 ("help,h", "produce help message")
70 ("ccdb,c",po::value<std::string>(&ccdbUrl)->default_value("http://ccdb-test.cern.ch:8080"),"ccdb url")
71 ("timestamp,t",po::value<long>(&timestamp)->default_value(now),"timestamp for query or put")
72 ("put,p",po::bool_switch(&put),"upload bad channel default object")
73 ("query,q",po::bool_switch(&query),"dump bad channel object from CCDB")
74 ("verbose,v",po::bool_switch(&verbose),"verbose output")
75 ;
76 // clang-format on
77
78 po::options_description cmdline;
79 cmdline.add(usage);
80
81 po::store(po::command_line_parser(argc, argv).options(cmdline).run(), vm);
82
83 if (vm.count("help")) {
84 std::cout << "Dump or upload MID bad channels CCDB object\n";
85 std::cout << usage << "\n";
86 return 2;
87 }
88
89 try {
90 po::notify(vm);
91 } catch (boost::program_options::error& e) {
92 std::cout << "Error: " << e.what() << "\n";
93 exit(1);
94 }
95
96 if (query) {
97 queryBadChannels(ccdbUrl, timestamp, verbose);
98 }
99
100 if (put) {
101 uploadBadChannels(ccdbUrl, timestamp);
102 }
103
104 return 0;
105}
Strip pattern (aka digits)
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 Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
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
const std::string BadChannelCCDBPath
void queryBadChannels(const std::string ccdbUrl, long timestamp, bool verbose)
void uploadBadChannels(const std::string ccdbUrl, long timestamp)
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
Definition CcdbApi.h:163
void init(std::string const &hosts)
Definition CcdbApi.cxx:240
std::enable_if<!std::is_base_of< o2::conf::ConfigurableParam, T >::value, T * >::type retrieveFromTFileAny(std::string const &path, std::map< std::string, std::string > const &metadata, long timestamp=-1, std::map< std::string, std::string > *headers=nullptr, std::string const &etag="", const std::string &createdNotAfter="", const std::string &createdNotBefore="") const
Definition CcdbApi.h:662
static constexpr long INFINITE_TIMESTAMP
GLsizeiptr const void GLenum usage
Definition glcorearb.h:659
std::string ccdbUrl
#define main