3 #include <fmt/ranges.h>
5 #include <spdlog/sinks/stdout_color_sinks.h>
6 #include <spdlog/spdlog.h>
9 #include "TrdKCluster.h"
15 #include "NAIAVersion.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
--reprocess_rti Reprocess and replace the RTIInfo tree only
-h, --help Give this help list
)";
26 spdlog::warn(
"Signal Handler called with signal {}", signum);
30 int main(
int argc,
char **argv) {
33 auto naiaVersion = NAIA::Version{};
34 auto versionString = fmt::format(
"{} v{}.{}.{}",
EXENAME, naiaVersion.major, naiaVersion.minor, naiaVersion.patch);
35 std::map<std::string, docopt::value>
arguments = docopt::docopt(
USAGE, {std::next(argv), std::next(argv, argc)},
40 switch (arguments[
"-v"].asLong()) {
42 spdlog::set_level(spdlog::level::debug);
45 spdlog::set_level(spdlog::level::trace);
50 auto inputFiles = arguments[
"--input-file"].asStringList();
51 auto outputFile = arguments[
"--output-file"].asString();
55 logger->info(
"Input files: {}", inputFiles);
56 logger->info(
"Output file: {}", outputFile);
58 logger->debug(
"Creating AMSChain");
59 auto amsChain = std::make_unique<AMSChain>();
60 if (spdlog::get_level() == spdlog::level::info) {
64 for (
const auto &filename : fileList) {
65 amsChain->Add(filename.c_str());
68 unsigned long long nEvents = amsChain->GetEntries();
69 logger->info(
"{} events in this file", nEvents);
72 AMSEventR *
event = amsChain->GetEvent(0);
73 bool isMC =
event->nMCEventg() > 0;
75 if (spdlog::get_level() == spdlog::level::info) {
80 unsigned long long EventNumber = 0;
81 unsigned long long firstev, lastev;
82 if (arguments[
"--single-event"]) {
83 logger->debug(
"Run in single event mode");
84 EventNumber = amsChain->GetEntryNo(event->Run(), arguments[
"--single-event"].asLong());
85 logger->debug(
" event no. {} - {}", event->Run(), EventNumber);
86 firstev = EventNumber;
87 lastev = EventNumber + 1;
88 }
else if (arguments[
"--from_event"]) {
89 logger->debug(
"Run in from-event mode");
90 EventNumber = amsChain->GetEntryNo(event->Run(), arguments[
"--from_event"].asLong());
91 logger->debug(
" event no. {} - {}", event->Run(), EventNumber);
92 firstev = EventNumber;
93 lastev = arguments[
"--nevents"] ? EventNumber + arguments[
"--nevents"].asLong() : nEvents;
96 lastev = arguments[
"--nevents"] ? arguments[
"--nevents"].asLong() : nEvents;
99 bool reprocess_rti = arguments[
"--reprocess_rti"].asBool();
101 logger->info(
"Reprocessing RTIInfo tree only");
107 AMSSetupR::RTI::UseLatest(7);
109 AMSSetupR::SlowControlR::ReadFromExternalFile =
false;
112 TRMCFFKEY_DEF::ReadFromFile = 0;
113 TRFITFFKEY_DEF::ReadFromFile = 0;
114 TRFITFFKEY.ErcHeY = 0;
117 RichRingR::useEffectiveTemperatureCorrection =
true;
119 RichRingR::reloadRunTag =
true;
123 TrdKCluster::ForceReadAlignment = 0;
124 TrdKCluster::ForceReadCalibration = 0;
125 TrdKCluster::ForceReadXePressure = 0;
126 TrdKCluster::SetDefaultMCXePressure(900);
131 analysis.ReprocessRTI(reprocess_rti);
132 analysis.firstentry = firstev;
133 analysis.lastentry = lastev;
135 amsChain->Process(&analysis,
"", lastev - firstev, firstev);
137 logger->info(
"...exiting");
140
int main(int argc, char **argv)
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.