MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches
Paths.cpp
Go to the documentation of this file.
1#include "Paths.hpp"
2#include <fstream>
3
4#ifndef MUSIC_DATASET_NAME
5#define MUSIC_DATASET_NAME "unknown"
6#endif
7#ifndef MUSIC_GIT_HASH
8#define MUSIC_GIT_HASH "unknown"
9#endif
13#ifndef MUSIC_DATASET_DIR
14#define MUSIC_DATASET_DIR ""
15#endif
16// Where the wordmark lives. Baked in at build like the paths above so the
17// binary stays self-locating; nix points it at the installed copy.
18#ifndef MUSIC_ASSETS_DIR
19#define MUSIC_ASSETS_DIR ""
20#endif
21
22TString Paths::DatasetName() { return TString(MUSIC_DATASET_NAME); }
23
25 const Char_t *env = gSystem->Getenv("MUSIC_RESULTS_DIR");
26 if (env && env[0] != '\0')
27 return TString(env);
28 return DatasetDir();
29}
30
32 std::ifstream in(TString(MUSIC_ASSETS_DIR) + "/music.txt");
33 if (!in)
34 return; // art is decoration; never let a missing asset stop a run
35 std::cout << std::endl << in.rdbuf() << std::endl;
36}
37
38void Paths::PrintBanner(const TString &dataset_dir) {
39 std::cout << "============================================================"
40 << std::endl;
41 std::cout << " MUSIC tooling | dataset=" << MUSIC_DATASET_NAME
42 << " | git=" << MUSIC_GIT_HASH << std::endl;
43 std::cout << " dataset dir : " << dataset_dir << std::endl;
44 std::cout << " CoMPASS base: " << Constants::cfg.COMPASS_BASE_DIR
45 << std::endl;
46 std::cout << " runs :";
47 for (Int_t i = 0; i < Int_t(Constants::cfg.RUN_NUMBERS.size()); i++)
48 std::cout << " " << Constants::cfg.RUN_NUMBERS[i];
49 std::cout << std::endl;
50 std::cout << " event mode : " << Constants::ActiveReferenceChannel() << " ("
51 << Constants::ActiveEventTimeWindowUs() << " us window)"
52 << " | plots ";
53 if (Constants::cfg.SAVE_FULL_PLOTS)
54 std::cout << "every subfile";
55 else
56 std::cout << "first " << Constants::cfg.PLOT_SAMPLE_FILES
57 << " subfile(s) per epoch";
58 std::cout << std::endl;
59 std::cout << "============================================================"
60 << std::endl;
61}
62
64 const Char_t *env = gSystem->Getenv("MUSIC_DATASET_DIR");
65 TString d;
66 if (env && env[0] != '\0') {
67 d = TString(env);
68 // Guard against running a binary for one dataset in another's dev shell:
69 // the env override would silently mix configs, so the env path must contain
70 TString name = TString(MUSIC_DATASET_NAME);
71 if (name.Length() > 0 && name != "unknown" && !d.Contains("/" + name)) {
72 std::cerr << "FATAL: this binary was built for dataset '" << name
73 << "' but MUSIC_DATASET_DIR points to '" << d << "'."
74 << std::endl;
75 std::cerr << "You are probably running the wrong ./result symlink or "
76 "are in the wrong dataset dev shell."
77 << std::endl;
78 std::cerr << "Rebuild with `nix build .#" << name
79 << "` or enter the matching shell (`nix develop .#" << name
80 << "`)." << std::endl;
81 gSystem->Exit(1);
82 }
83 } else {
85 if (d.Length() == 0) {
86 std::cerr
87 << "FATAL: this binary was built without a dataset dir baked in "
88 "(MUSIC_DATASET_DIR). Rebuild via the Makefile."
89 << std::endl;
90 gSystem->Exit(1);
91 }
92 }
93 static Bool_t printed = kFALSE;
94 if (!printed) {
95 PrintBanner(d);
96 printed = kTRUE;
97 }
98 return d;
99}
#define MUSIC_ASSETS_DIR
Definition Paths.cpp:19
#define MUSIC_DATASET_NAME
Definition Paths.cpp:5
#define MUSIC_DATASET_DIR
Absolute dataset dir, baked in at build by the Makefile (-DMUSIC_DATASET_DIR) from the DATASET the bi...
Definition Paths.cpp:14
#define MUSIC_GIT_HASH
Definition Paths.cpp:8
static TString DatasetName()
The dataset's isotope name, e.g.
Definition Paths.cpp:22
static TString DatasetDir()
Absolute path to the active dataset directory, analysis/<iso>.
Definition Paths.cpp:63
static TString ResultsDir()
Absolute path to the directory receiving generated output.
Definition Paths.cpp:24
static void PrintLogo()
Print the project wordmark.
Definition Paths.cpp:31
const TString & ActiveReferenceChannel()
Channel whose hits seed events.
Double_t ActiveEventTimeWindowUs()
Coincidence window for event building, in microseconds.
const DatasetConfig & cfg
The active dataset's configuration, flat block.