4 #include <fmt/ranges.h>
6 #include <spdlog/sinks/stdout_color_sinks.h>
7 #include <spdlog/spdlog.h>
10 #include "TrdKCluster.h"
16 #include "NAIAVersion.h"
21 static constexpr
auto EXENAME = R
"(NtpMaker)";
22 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
)";
27 spdlog::warn(
"Signal Handler called with signal {}", signum);
31 int main(
int argc,
char **argv) {
34 auto naiaVersion = NAIA::Version{};
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 spdlog::debug(
"isMC = {}", isMC);
78 if (spdlog::get_level() == spdlog::level::info) {
83 unsigned long long EventNumber = 0;
84 unsigned long long firstev, lastev;
85 if (arguments[
"--single-event"]) {
86 logger->debug(
"Run in single event mode");
87 EventNumber = amsChain->GetEntryNo(event->Run(), arguments[
"--single-event"].asLong());
88 logger->debug(
" event no. {} - {}", event->Run(), EventNumber);
89 firstev = EventNumber;
90 lastev = EventNumber + 1;
91 }
else if (arguments[
"--from_event"]) {
92 logger->debug(
"Run in from-event mode");
93 EventNumber = amsChain->GetEntryNo(event->Run(), arguments[
"--from_event"].asLong());
94 logger->debug(
" event no. {} - {}", event->Run(), EventNumber);
95 firstev = EventNumber;
96 lastev = arguments[
"--nevents"] ? EventNumber + arguments[
"--nevents"].asLong() : nEvents;
99 lastev = arguments[
"--nevents"] ? arguments[
"--nevents"].asLong() : nEvents;
102 bool reprocess_rti = arguments[
"--reprocess_rti"].asBool();
104 logger->info(
"Reprocessing RTIInfo tree only");
110 AMSSetupR::RTI::UseLatest(8);
112 AMSSetupR::SlowControlR::ReadFromExternalFile =
false;
115 TRMCFFKEY_DEF::ReadFromFile = 0;
116 TRFITFFKEY_DEF::ReadFromFile = 0;
117 TRFITFFKEY.ErcHeY = 0;
120 RichRingR::useEffectiveTemperatureCorrection =
true;
122 RichRingR::reloadRunTag =
true;
126 TrdKCluster::ForceReadAlignment = 0;
127 TrdKCluster::ForceReadCalibration = 0;
128 TrdKCluster::ForceReadXePressure = 0;
129 TrdKCluster::SetDefaultMCXePressure(900);
134 analysis.ReprocessRTI(reprocess_rti);
135 analysis.firstentry = firstev;
136 analysis.lastentry = lastev;
138 amsChain->Process(&analysis,
"", lastev - firstev, firstev);
140 logger->info(
"...exiting");
143
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.