MUSIC
unknown
Analysis for the MUSIC active-target ionization chamber
Toggle main menu visibility
Loading...
Searching...
No Matches
main_calibrate_beam.cpp
Go to the documentation of this file.
1
#include "
CalibrateBeam.hpp
"
2
#include "
Constants.hpp
"
3
#include <TString.h>
4
#include <cstdlib>
5
#include <iostream>
6
7
// Resolve the epoch from the run number in a file label ("run100_8_c000") and
8
// make it active for the run. Without this the tool would calibrate on the flat
9
// DatasetConfig while the pipeline uses the epoch's hardware settings, and the
10
// two would silently disagree.
11
static
Bool_t SetEpochFromLabel(
const
TString &file_label) {
12
if
(
Constants::cfg
.EPOCHS.empty())
13
return
kTRUE;
14
// A tagged label ("compass_run37_1") names its epoch outright. Run numbers
15
// repeat across acquisition systems, so the tag is the only thing that
16
// disambiguates them; fall back to the run number only for untagged eras.
17
for
(Int_t e = 0; e < Int_t(
Constants::cfg
.EPOCHS.size()); e++) {
18
const
RunEpoch
&ep =
Constants::cfg
.EPOCHS[e];
19
if
(ep.
file_tag
.Length() > 0 && file_label.BeginsWith(ep.
file_tag
+
"_"
)) {
20
Constants::SetActiveEpoch
(&ep);
21
std::cout <<
"label '"
<< file_label <<
"' -> epoch "
<< ep.
name
22
<< std::endl;
23
return
kTRUE;
24
}
25
}
26
Int_t start = file_label.Index(
"run"
);
27
if
(start < 0)
28
return
kFALSE;
29
Int_t i = start + 3, run = 0, ndig = 0;
30
while
(i < file_label.Length() && isdigit(file_label[i])) {
31
run = run * 10 + (file_label[i] -
'0'
);
32
i++;
33
ndig++;
34
}
35
if
(ndig == 0)
36
return
kFALSE;
37
const
RunEpoch
*ep =
Constants::EpochForRun
(run);
38
if
(!ep) {
39
std::cerr <<
"run "
<< run <<
" belongs to no declared epoch"
<< std::endl;
40
return
kFALSE;
41
}
42
Constants::SetActiveEpoch
(ep);
43
std::cout <<
"run "
<< run <<
" -> epoch "
<< ep->
name
<< std::endl;
44
return
kTRUE;
45
}
46
47
int
main
(
int
argc,
char
**argv) {
48
TString file_label = (argc > 1) ? TString(argv[1]) : TString(
""
);
49
if
(!
Constants::cfg
.EPOCHS.empty() && file_label.Length() == 0) {
50
std::cerr <<
"this dataset declares epochs, so a file label is required "
51
"(e.g. run100_8_c000): the epoch cannot be resolved otherwise"
52
<< std::endl;
53
return
1;
54
}
55
if
(!SetEpochFromLabel(file_label)) {
56
std::cerr <<
"cannot resolve an epoch for '"
<< file_label <<
"'"
57
<< std::endl;
58
return
1;
59
}
60
CalibrateBeam::Run
(file_label);
61
Constants::SetActiveEpoch
(
nullptr
);
62
return
0;
63
}
CalibrateBeam.hpp
Constants.hpp
The dataset configuration, and how it is layered.
CalibrateBeam::Run
static void Run(const TString &file_label="")
Calibrate every configured subfile, then aggregate per run.
Definition
CalibrateBeam.cpp:2158
main
int main()
Definition
main_compute_regions.cpp:18
Constants::EpochForRun
const RunEpoch * EpochForRun(Int_t run)
The epoch owning a run number.
Definition
Constants.cpp:234
Constants::cfg
const DatasetConfig & cfg
The active dataset's configuration, flat block.
Constants::SetActiveEpoch
void SetActiveEpoch(const RunEpoch *epoch)
Set the epoch the Active*() accessors read from.
Definition
Constants.cpp:231
RunEpoch
One acquisition period of a dataset.
Definition
RunEpoch.hpp:37
RunEpoch::name
TString name
Epoch name, used in logs and plot paths.
Definition
RunEpoch.hpp:38
RunEpoch::file_tag
TString file_tag
Prefix for this epoch's output files and plot directories.
Definition
RunEpoch.hpp:49
tooling
mains
main_calibrate_beam.cpp
Generated by
1.17.0