MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
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
11static 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 systems; the tag disambiguates, run number only if untagged.
16 for (Int_t e = 0; e < Int_t(Constants::cfg.EPOCHS.size()); e++) {
17 const RunEpoch &ep = Constants::cfg.EPOCHS[e];
18 if (ep.file_tag.Length() > 0 && file_label.BeginsWith(ep.file_tag + "_")) {
20 std::cout << "label '" << file_label << "' -> epoch " << ep.name
21 << std::endl;
22 return kTRUE;
23 }
24 }
25 Int_t start = file_label.Index("run");
26 if (start < 0)
27 return kFALSE;
28 Int_t i = start + 3, run = 0, ndig = 0;
29 while (i < file_label.Length() && isdigit(file_label[i])) {
30 run = run * 10 + (file_label[i] - '0');
31 i++;
32 ndig++;
33 }
34 if (ndig == 0)
35 return kFALSE;
36 const RunEpoch *ep = Constants::EpochForRun(run);
37 if (!ep) {
38 std::cerr << "run " << run << " belongs to no declared epoch" << std::endl;
39 return kFALSE;
40 }
42 std::cout << "run " << run << " -> epoch " << ep->name << std::endl;
43 return kTRUE;
44}
45
46int main(int argc, char **argv) {
47 TString file_label = (argc > 1) ? TString(argv[1]) : TString("");
48 if (!Constants::cfg.EPOCHS.empty() && file_label.Length() == 0) {
49 std::cerr << "this dataset declares epochs, so a file label is required "
50 "(e.g. run100_8_c000): the epoch cannot be resolved otherwise"
51 << std::endl;
52 return 1;
53 }
54 if (!SetEpochFromLabel(file_label)) {
55 std::cerr << "cannot resolve an epoch for '" << file_label << "'"
56 << std::endl;
57 return 1;
58 }
59 CalibrateBeam::Run(file_label);
61 return 0;
62}
Dataset configuration.
static void Run(const TString &file_label="")
Calibrate every configured subfile, then aggregate per run.
int main()
compute-regions: fit each reaction strip's (a,n) and (a,a') regions from the scatter cache and save t...
const RunEpoch * EpochForRun(Int_t run)
The epoch owning a run number.
const DatasetConfig & cfg
The active dataset's configuration, flat block.
void SetActiveEpoch(const RunEpoch *epoch)
Set the epoch the Active*() accessors read from.
One acquisition period of a dataset.
Definition RunEpoch.hpp:34
TString name
Epoch name, used in logs and plot paths.
Definition RunEpoch.hpp:35
TString file_tag
Prefix for this epoch's output files and plot directories.
Definition RunEpoch.hpp:46