MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches
CalibrateBeam.hpp
Go to the documentation of this file.
1#ifndef CALIBRATE_BEAM_HPP
2#define CALIBRATE_BEAM_HPP
3
4#include "BeamFit2D.hpp"
5#include "Constants.hpp"
6#include "FileSet.hpp"
7#include "IOUtils.hpp"
8#include "InitUtils.hpp"
9#include "Normalization.hpp"
10#include "Paths.hpp"
11#include "PlottingUtils.hpp"
12#include <Rtypes.h>
13#include <TCanvas.h>
14#include <TDirectory.h>
15#include <TEllipse.h>
16#include <TF1.h>
17#include <TF2.h>
18#include <TFile.h>
19#include <TFitResult.h>
20#include <TGraph.h>
21#include <TGraphErrors.h>
22#include <TH1.h>
23#include <TH1D.h>
24#include <TH1F.h>
25#include <TH2.h>
26#include <TH2F.h>
27#include <TKey.h>
28#include <TLegend.h>
29#include <TLine.h>
30#include <TList.h>
31#include <TMath.h>
32#include <TROOT.h>
33#include <TSpectrum.h>
34#include <TString.h>
35#include <TSystem.h>
36#include <TTree.h>
37#include <algorithm>
38#include <cmath>
39#include <fstream>
40#include <iostream>
41#include <map>
42#include <mutex>
43#include <queue>
44#include <set>
45#include <thread>
46#include <toml++/toml.hpp>
47#include <vector>
48
55struct ChannelCal {
56 TString name;
57 Char_t side;
58 Int_t strip;
59 Double_t fit_adc = 0.0;
60 Double_t fit_sigma_adc = 0.0;
61 Long64_t n_samples = 0.0;
70 Double_t gain = -1.0;
77 Double_t ridge_ratio = 0.0;
78};
79
101 Bool_t ok = kFALSE;
102 Double_t beam_e_min =
103 0.0;
104 Double_t beam_e_max = 0.0;
108 Double_t factors[18] = {};
110 Double_t centroids[18] = {};
111};
112
126public:
132 static std::vector<ChannelCal> BuildChannels();
133
140 static void
142 const std::vector<ChannelCal> &chans_template);
143
151 static void
152 SaveCalibSampleOverlay(const std::vector<ChannelCal> &chans,
153 const std::vector<std::vector<Float_t>> &samples,
154 const TString &plot_subdir, const TString &file_label);
155
166 static void AggregateRidgeRatiosForRun(Int_t run,
167 const std::vector<FileSpec> &specs);
173 static void AggregateEresTomlForRun(Int_t run,
174 const std::vector<FileSpec> &specs);
175
181 static void Run(const TString &file_label = "");
182};
183
184#endif
The dataset configuration, and how it is layered.
Per-channel beam-peak calibration, gain matching and strip alignment.
static void SaveCalibSampleOverlay(const std::vector< ChannelCal > &chans, const std::vector< std::vector< Float_t > > &samples, const TString &plot_subdir, const TString &file_label)
Save the per-channel calibration overlay figure.
static void Run(const TString &file_label="")
Calibrate every configured subfile, then aggregate per run.
static void CalibrateBeamOneSubfile(const FileSpec &spec, const std::vector< ChannelCal > &chans_template)
Calibrate one subfile end to end.
static void AggregateEresTomlForRun(Int_t run, const std::vector< FileSpec > &specs)
Aggregate the run's energy-resolution measurements into its TOML.
static std::vector< ChannelCal > BuildChannels()
One ChannelCal per readout channel in the active channel map.
static void AggregateRidgeRatiosForRun(Int_t run, const std::vector< FileSpec > &specs)
Replace each subfile's ridge ratio with the run-level median.
One readout channel's beam-peak calibration.
Char_t side
Readout end: 'L' or 'R'.
TString name
Channel name from the active channel map.
Double_t gain
Left/right gain-match override.
Double_t fit_adc
Fitted beam-peak centroid, in ADC.
Int_t strip
Anode strip index this channel reads.
Long64_t n_samples
Events entering the fit.
Double_t ridge_ratio
Short channels only: C_short / C_long from this subfile's own ridge fit, or 0 when the ridge was not ...
Double_t fit_sigma_adc
Fitted beam-peak width, in ADC.
One input file: a run number and the subfile suffix within it.
Definition FileSet.hpp:40
Output of the two post-gain calibration steps.
Double_t centroids[18]
Measured beam-peak centroid per strip, in calibrated units.
Double_t beam_e_max
Upper edge of the beam window.
Double_t factors[18]
Per-strip multiplicative alignment factors.
Double_t beam_e_min
Lower edge of the beam window, calibrated units.
Bool_t ok
Whether the steps produced usable results.