3 #include <fmt/ranges.h>
5 #include <spdlog/sinks/stdout_color_sinks.h>
6 #include <spdlog/spdlog.h>
9 #include "TrdKCluster.h"
20 static constexpr
auto EXENAME = R
"(NtpMaker)";
21 static constexpr
auto USAGE = R
"(NtpMaker, NAIA ntuple version
Usage:
NtpMaker (-i FILE...) (-o FILE) [-v | -vv] [options]
NtpMaker --version
Options:
-i, --input-file=FILE Input file
-o, --output-file=FILE Output file
-w, --overwrite Overwrite results
-v... Verbosity level (once for Debug, twice for Trace)
-e, --from-event=EVNO Process from this event
-E, --single-event=EVNO Process only this event
-n, --nevents=NEV Process # events
-h, --help Give this help list
)";
26 printf(
"Singal Handler called with signal %d\n", signum);
31 int main(
int argc,
char **argv) {
35 auto versionString = fmt::format(
"{} v{}.{}.{}",
EXENAME, naiaVersion.major, naiaVersion.minor, naiaVersion.patch);
36 std::map<std::string, docopt::value>
arguments = docopt::docopt(
USAGE, {std::next(argv), std::next(argv, argc)},
41 switch (arguments[
"-v"].asLong()) {
43 spdlog::set_level(spdlog::level::debug);
46 spdlog::set_level(spdlog::level::trace);
51 auto inputFiles = arguments[
"--input-file"].asStringList();
52 auto outputFile = arguments[
"--output-file"].asString();
56 logger->info(
"Input files: {}", inputFiles);
57 logger->info(
"Output file: {}", outputFile);
59 logger->debug(
"Creating AMSChain");
60 auto amsChain = std::make_unique<AMSChain>();
61 if (spdlog::get_level() == spdlog::level::info) {
65 for (
const auto &filename : fileList) {
66 amsChain->Add(filename.c_str());
69 unsigned long long nEvents = amsChain->GetEntries();
70 logger->info(
"{} events in this file", nEvents);
73 AMSEventR *
event = amsChain->GetEvent(0);
74 bool isMC =
event->nMCEventg() > 0;
76 if (spdlog::get_level() == spdlog::level::info) {
81 unsigned long long EventNumber = 0;
82 unsigned long long firstev, lastev;
83 if (arguments[
"--single-event"]) {
84 logger->debug(
"Run in single event mode");
85 EventNumber = amsChain->GetEntryNo(event->Run(), arguments[
"--single-event"].asLong());
86 logger->debug(
" event no. {} - {}", event->Run(), EventNumber);
87 firstev = EventNumber;
88 lastev = EventNumber + 1;
89 }
else if (arguments[
"--from_event"]) {
90 logger->debug(
"Run in from-event mode");
91 EventNumber = amsChain->GetEntryNo(event->Run(), arguments[
"--from_event"].asLong());
92 logger->debug(
" event no. {} - {}", event->Run(), EventNumber);
93 firstev = EventNumber;
94 lastev = arguments[
"--nevents"] ? EventNumber + arguments[
"--nevents"].asLong() : nEvents;
97 lastev = arguments[
"--nevents"] ? arguments[
"--nevents"].asLong() : nEvents;
103 AMSSetupR::RTI::UseLatest(7);
105 AMSSetupR::SlowControlR::ReadFromExternalFile =
false;
108 TRMCFFKEY_DEF::ReadFromFile = 0;
109 TRFITFFKEY_DEF::ReadFromFile = 0;
110 TRFITFFKEY.ErcHeY = 0;
113 RichRingR::useEffectiveTemperatureCorrection =
true;
115 RichRingR::reloadRunTag =
true;
119 TrdKCluster::ForceReadAlignment = 0;
120 TrdKCluster::ForceReadCalibration = 0;
121 TrdKCluster::ForceReadXePressure = 0;
122 TrdKCluster::SetDefaultMCXePressure(900);
130 amsChain->Process(&analysis,
"", lastev - firstev, firstev);
132 logger->info(
"...exiting");
135
Container class for versioning info.
int main(int argc, char **argv)
unsigned long long firstentry
first entry to be processed
static constexpr auto USAGE
static constexpr auto EXENAME
void sig_handler(int signum)
void SetOutputFilename(std::string outFilename)
auto getLogger(const std::string &fnName)
Create a new logger with a given function name.
NAIAVersion container class description.
unsigned long long lastentry
last entry to be processed