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 "RemixSim.hpp"
5#include <TFile.h>
6#include <TLeaf.h>
7#include <TTree.h>
8
9namespace BeamEnergies {
10
11TString SimPath() {
12 return Paths::DatasetDir() + "/sim_root_files/" +
13 Constants::cfg.CROSS_SECTION_CONFIG.BEAM_SIM_FILE;
14}
15
16Bool_t Profile(const TString &path, Double_t *dE, Double_t &e_strip0) {
17 TFile f(path, "READ");
18 if (f.IsZombie())
19 return kFALSE;
20 TTree *t = static_cast<TTree *>(f.Get("events_MeV"));
21 TTree *mc = static_cast<TTree *>(f.Get("MC"));
22 if (!t || !mc)
23 return kFALSE;
25 if (!e.Attach(t))
26 return kFALSE;
27 for (Int_t s = 0; s < 18; s++)
28 dE[s] = 0.0;
29 const Long64_t n = t->GetEntries();
30 if (n == 0)
31 return kFALSE;
32 for (Long64_t i = 0; i < n; i++) {
33 t->GetEntry(i);
34 for (Int_t s = 0; s < 18; s++)
35 dE[s] += e.Total(s);
36 }
37 for (Int_t s = 0; s < 18; s++)
38 dE[s] /= Double_t(n);
39
40 TLeaf *gas = mc->GetLeaf("beam_energy_gas");
41 TLeaf *dead = mc->GetLeaf("DeadUS_dE");
42 if (!gas || !dead)
43 return kFALSE;
44 const Long64_t nm = mc->GetEntries();
45 if (nm == 0)
46 return kFALSE;
47 Double_t sum = 0.0;
48 for (Long64_t i = 0; i < nm; i++) {
49 mc->GetEntry(i);
50 sum += gas->GetValue() - dead->GetValue();
51 }
52 e_strip0 = sum / Double_t(nm);
53 return kTRUE;
54}
55
56Double_t LabAtStrip(const Double_t *dE, Double_t e_strip0, Int_t reac) {
57 Double_t e = e_strip0;
58 for (Int_t s = 0; s < reac; s++)
59 e -= dE[s];
60 return e;
61}
62
63Double_t CmFraction() {
64 const CrossSectionConfig &X = Constants::cfg.CROSS_SECTION_CONFIG;
65 const Int_t target_a = TargetGasA(X.TARGET_GAS);
66 return Double_t(target_a) / Double_t(X.BEAM_A + target_a);
67}
68
69} // namespace BeamEnergies
Dataset configuration.
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:63
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.
Experimental details needed to properly calculate the cross section.
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...
One entry of a simulation's events_MeV tree.
Definition RemixSim.hpp:91
Double_t Total(Int_t s) const
The strip's deposit, Left(s) + Right(s).
Definition RemixSim.hpp:111
Bool_t Attach(TTree *t)
Bind to an events_MeV tree and set up the branch addresses.
Definition RemixSim.cpp:10