MUSIC
unknown
Analysis for the MUSIC active-target ionization chamber
Toggle main menu visibility
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
10
// Absolute dataset dir, baked in at build by the Makefile (-DMUSIC_DATASET_DIR)
11
// from the DATASET the binary was built for. The binary is self-locating; there
12
// is no runtime env-var dependency.
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
22
TString
Paths::DatasetName
() {
return
TString(
MUSIC_DATASET_NAME
); }
23
24
TString
Paths::ResultsDir
() {
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
31
void
Paths::PrintLogo
() {
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
38
void
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
<<
" | calibration "
53
<< (
Constants::cfg
.SKIP_CALIBRATION ?
"SKIPPED"
:
"on"
)
54
<<
" | plots "
<< (
Constants::cfg
.SAVE_PLOTS ?
"on"
:
"SKIPPED"
)
55
<< std::endl;
56
std::cout <<
"============================================================"
57
<< std::endl;
58
}
59
60
TString
Paths::DatasetDir
() {
61
const
Char_t *env = gSystem->Getenv(
"MUSIC_DATASET_DIR"
);
62
TString d;
63
if
(env && env[0] !=
'\0'
) {
64
d = TString(env);
65
// Guard against running a binary built for one dataset inside another
66
// dataset's dev shell: the env override would silently mix configs
67
// (e.g. an 87Rb binary reading 87Rb raw data but writing into the 37Cl
68
// analysis tree). The env path must contain the baked-in dataset name
69
// as a path component.
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
{
84
d =
MUSIC_DATASET_DIR
;
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
}
MUSIC_ASSETS_DIR
#define MUSIC_ASSETS_DIR
Definition
Paths.cpp:19
MUSIC_DATASET_NAME
#define MUSIC_DATASET_NAME
Definition
Paths.cpp:5
MUSIC_DATASET_DIR
#define MUSIC_DATASET_DIR
Definition
Paths.cpp:14
MUSIC_GIT_HASH
#define MUSIC_GIT_HASH
Definition
Paths.cpp:8
Paths.hpp
Paths::DatasetName
static TString DatasetName()
The dataset's isotope name, e.g.
Definition
Paths.cpp:22
Paths::DatasetDir
static TString DatasetDir()
Absolute path to the active dataset directory, analysis/<iso>.
Definition
Paths.cpp:60
Paths::ResultsDir
static TString ResultsDir()
Absolute path to the directory receiving generated output.
Definition
Paths.cpp:24
Paths::PrintLogo
static void PrintLogo()
Print the project wordmark.
Definition
Paths.cpp:31
Constants::ActiveReferenceChannel
const TString & ActiveReferenceChannel()
Channel whose hits seed events.
Definition
Constants.cpp:349
Constants::ActiveEventTimeWindowUs
Double_t ActiveEventTimeWindowUs()
Coincidence window for event building, in microseconds.
Definition
Constants.cpp:345
Constants::cfg
const DatasetConfig & cfg
The active dataset's configuration, flat block.
tooling
src
Paths.cpp
Generated by
1.17.0