MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches
BeamEnergies.cpp
Go to the documentation of this file.
1#include "BeamEnergies.hpp"
2#include "Constants.hpp"
3#include "Paths.hpp"
4#include <TFile.h>
5#include <TLeaf.h>
6#include <TTree.h>
7
8namespace BeamEnergies {
9
10TString SimPath() {
11 return Paths::DatasetDir() + "/sim_root_files/" +
12 Constants::cfg.CROSS_SECTION_CONFIG.BEAM_SIM_FILE;
13}
14
15Bool_t Profile(const TString &path, Double_t *dE, Double_t &e_strip0) {
16 TFile f(path, "READ");
17 if (f.IsZombie())
18 return kFALSE;
19 TTree *t = static_cast<TTree *>(f.Get("events_MeV"));
20 TTree *mc = static_cast<TTree *>(f.Get("MC"));
21 if (!t || !mc)
22 return kFALSE;
23 Float_t left[18], right[18];
24 t->SetBranchAddress("Left_0_17_dE", left);
25 t->SetBranchAddress("RightdE", right);
26 for (Int_t s = 0; s < 18; s++)
27 dE[s] = 0.0;
28 const Long64_t n = t->GetEntries();
29 if (n == 0)
30 return kFALSE;
31 for (Long64_t i = 0; i < n; i++) {
32 t->GetEntry(i);
33 for (Int_t s = 0; s < 18; s++)
34 dE[s] += left[s] + right[s];
35 }
36 for (Int_t s = 0; s < 18; s++)
37 dE[s] /= Double_t(n);
38
39 TLeaf *gas = mc->GetLeaf("beam_energy_gas");
40 TLeaf *dead = mc->GetLeaf("DeadUS_dE");
41 if (!gas || !dead)
42 return kFALSE;
43 const Long64_t nm = mc->GetEntries();
44 if (nm == 0)
45 return kFALSE;
46 Double_t sum = 0.0;
47 for (Long64_t i = 0; i < nm; i++) {
48 mc->GetEntry(i);
49 sum += gas->GetValue() - dead->GetValue();
50 }
51 e_strip0 = sum / Double_t(nm);
52 return kTRUE;
53}
54
55Double_t LabAtStrip(const Double_t *dE, Double_t e_strip0, Int_t reac) {
56 Double_t e = e_strip0;
57 for (Int_t s = 0; s < reac; s++)
58 e -= dE[s];
59 return e;
60}
61
62Double_t CmFraction() {
63 const CrossSectionConfig &X = Constants::cfg.CROSS_SECTION_CONFIG;
64 const Int_t target_a = TargetGasA(X.TARGET_GAS);
65 return Double_t(target_a) / Double_t(X.BEAM_A + target_a);
66}
67
68} // namespace BeamEnergies
The dataset configuration, and how it is layered.
Int_t TargetGasA(TargetGas gas)
Mass number of the target nucleus in a fill gas.
Definition Constants.cpp:3
static TString DatasetDir()
Absolute path to the active dataset directory, analysis/<iso>.
Definition Paths.cpp:60
The beam's energy at each anode strip, from the simulated unreacted beam.
Double_t LabAtStrip(const Double_t *dE, Double_t e_strip0, Int_t reac)
Lab energy entering a given strip.
Bool_t Profile(const TString &path, Double_t *dE, Double_t &e_strip0)
Read the per-strip energy loss profile from a beam simulation.
Double_t CmFraction()
Centre-of-mass energy fraction for this dataset's reaction.
TString SimPath()
Path to the dataset's beam simulation file.
const DatasetConfig & cfg
The active dataset's configuration, flat block.
What the cross section needs about the experiment rather than the analysis.
Int_t BEAM_A
Beam mass number, for the lab-to-centre-of-mass conversion; its Z and element symbol name it to a rea...