Project
Loading...
Searching...
No Matches
inspect-collision-context.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 <boost/program_options.hpp>
13#include <string>
14#include <iostream>
15#include "Framework/Logger.h"
16#include <TFile.h>
18#include <gsl/span>
20#include <limits>
21
22namespace po = boost::program_options;
23
24void report(gsl::span<o2::InteractionTimeRecord> irs, int threshold, bool verbose)
25{
26 o2::InteractionTimeRecord ir0(std::numeric_limits<double>::max());
27 int tooClose{0};
28 for (auto ir : irs) {
29 if (verbose) {
30 std::cout << ir;
31 }
32 auto d = ir.differenceInBC(ir0);
33 if (d >= 0 && d < threshold) {
34 if (verbose) {
35 std::cout << " **** BC distance to previous " << d;
36 }
37 ++tooClose;
38 }
39 if (verbose) {
40 std::cout << "\n";
41 }
42 ir0 = ir;
43 }
44 if (verbose) {
45 std::cout << "Number of IR(s) strictly below the " << threshold << " BC distance limit : "
46 << tooClose << "\n";
47 } else {
48 std::cout << tooClose << "\n";
49 }
50}
51
52int main(int argc, char* argv[])
53{
54 po::options_description generic("options");
55 po::variables_map vm;
56
57 // clang-format off
58 generic.add_options()
59 ("help,h", "produce help message")
60 ("input-file,i",po::value<std::string>()->default_value("collisioncontext.root"),"input file name")
61 ("min-distance,d",po::value<int>()->default_value(4), "min distance between IRs to consider as a problem")
62 ("verbose,v",po::value<bool>()->default_value(false),"verbose output");
63 // clang-format on
64
65 po::options_description cmdline;
66 cmdline.add(generic);
67
68 po::store(po::command_line_parser(argc, argv).options(cmdline).run(), vm);
69
70 if (vm.count("help")) {
71 std::cout << generic << "\n";
72 return 2;
73 }
74
75 try {
76 po::notify(vm);
77 } catch (boost::program_options::error& e) {
78 std::cout << "Error: " << e.what() << "\n";
79 exit(1);
80 }
81
82 po::notify(vm);
83
84 // first things first : check the input path actually exists
85 std::string input = vm["input-file"].as<std::string>();
86
87 TFile fin(input.c_str());
88 if (!fin.IsOpen()) {
89 LOGP(fatal, "could not open input file {}", input);
90 return -1;
91 }
92 auto context = fin.Get<o2::steer::DigitizationContext>("DigitizationContext");
93 if (!context) {
94 std::cout << "Could not get context\n";
95 return 1;
96 }
97 report(context->getEventRecords(), vm["min-distance"].as<int>(), vm["verbose"].as<bool>());
98 return 0;
99}
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
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 d
void report(gsl::span< o2::InteractionTimeRecord > irs, int threshold, bool verbose)
int64_t differenceInBC(const InteractionRecord &other) const
#define main
o2::InteractionRecord ir(0, 0)
o2::InteractionRecord ir0(3, 5)