Project
Loading...
Searching...
No Matches
InspectCCDBFile.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
12#include "CCDB/CcdbApi.h"
13#include "CCDB/CCDBQuery.h"
14#include <map>
15#include "TFile.h"
16#include "TKey.h"
17#include <iostream>
18#include <boost/program_options.hpp>
19
20namespace bpo = boost::program_options;
21
22bool initOptionsAndParse(bpo::options_description& options, int argc, char* argv[], bpo::variables_map& vm)
23{
24 options.add_options()(
25 "files,f", bpo::value<std::vector<std::string>>()->multitoken(), "Space separated list of ROOT files holding (downloaded) CCDB object")(
26 "check-timestamp,t", bpo::value<long>()->default_value(-1), "Checks that validity of objects is compatible with this timestamp. In millisecond")(
27 "help,h", "Produce help message.");
28
29 try {
30 bpo::store(parse_command_line(argc, argv, options), vm);
31 // help
32 if (vm.count("help")) {
33 std::cout << options << std::endl;
34 return false;
35 }
36 bpo::notify(vm);
37 } catch (const bpo::error& e) {
38 std::cerr << e.what() << "\n\n";
39 std::cerr << "Error parsing command line arguments; Available options:\n";
40
41 std::cerr << options << std::endl;
42 return false;
43 }
44 return true;
45}
46
47// A simple tool to inspect/print metadata content of ROOT files containing CCDB entries
48// TODO: optionally print as JSON
49int main(int argc, char* argv[])
50{
51 bpo::options_description options("Tool to inspect meta-data content of downloaded CCDB objects. Allowed options:");
52 bpo::variables_map vm;
53 if (!initOptionsAndParse(options, argc, argv, vm)) {
54 return 1;
55 }
56 auto filenames = vm["files"].as<std::vector<std::string>>();
57 auto timestamp2bchecked = vm["check-timestamp"].as<long>();
58 std::vector<std::string> filesWrongValidity; // record files failing validity check
59
60 for (auto& f : filenames) {
61 std::cout << "### Loading file : " << f << "\n";
62 TFile file(f.c_str());
63
64 // query the list of objects
65 auto keys = file.GetListOfKeys();
66 if (keys) {
67 std::cout << "--- found the following objects -----\n";
68 for (int i = 0; i < keys->GetEntries(); ++i) {
69 auto key = static_cast<TKey*>(keys->At(i));
70 if (key) {
71 std::cout << key->GetName() << " of type " << key->GetClassName() << "\n";
72 }
73 }
74 } else {
75 std::cout << "--- no objects found -----\n";
76 }
77
79 if (queryinfo) {
80 std::cout << "---found query info -----\n";
81 queryinfo->print();
82 } else {
83 std::cout << "--- no query information found ------\n";
84 }
85
87 if (meta) {
88 std::cout << "---found meta info -----\n";
89 for (auto keyvalue : *meta) {
90 std::cout << keyvalue.first << " : " << keyvalue.second << "\n";
91 }
92 if (timestamp2bchecked > 0) {
93 // retrieve Valid-From and Valid-To headers
94 try {
95 auto valid_from = std::stol((*meta)["Valid-From"]);
96 auto valid_to = std::stol((*meta)["Valid-Until"]);
97 if (!(valid_from <= timestamp2bchecked) && (timestamp2bchecked <= valid_to)) {
98 std::cerr << "### ERROR: failed validity check for timestamp " << timestamp2bchecked << " not in [" << valid_from << ":" << valid_to << "]\n";
99 filesWrongValidity.push_back(f);
100 }
101 } catch (std::exception e) {
102 // no validity could be extracted;
103 filesWrongValidity.push_back(f);
104 }
105 }
106 } else {
107 std::cout << "--- no meta information found ---\n";
108 }
109 }
110
111 if (filesWrongValidity.size() > 0) {
112 std::cerr << "### ERROR: Validity checks failed for:\n";
113 for (auto& f : filesWrongValidity) {
114 std::cerr << "### " << f << "\n";
115 }
116 return 1;
117 }
118 return 0;
119}
std::vector< std::string > keys
int32_t i
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
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
bool initOptionsAndParse(bpo::options_description &options, int argc, char *argv[], bpo::variables_map &vm)
StringRef key
static std::map< std::string, std::string > * retrieveMetaInfo(TFile &)
Definition CcdbApi.cxx:1710
static CCDBQuery * retrieveQueryInfo(TFile &)
Definition CcdbApi.cxx:1701
GLdouble f
Definition glcorearb.h:310
#define main