BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Run.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "RebdsimTypes.hh"
19#include "Run.hh"
20
21#include "BDSOutputROOTEventRunInfo.hh"
22#include "BDSOutputROOTEventHistograms.hh"
23#include "BDSVersionData.hh"
24
25#include <iostream>
26#include <vector>
27
28ClassImp(Run)
29
30Run::Run():
31 Run(false)
32{;}
33
34Run::Run(bool debugIn):
35 Summary(nullptr),
36 Histos(nullptr),
37 Info(nullptr),
38 debug(debugIn),
39 dataVersion(BDSIM_DATA_VERSION)
40{
41 Summary = new BDSOutputROOTEventRunInfo();
42 Histos = new BDSOutputROOTEventHistograms();
43 Info = new BDSOutputROOTEventRunInfo();
44}
45
46Run::Run(bool debugIn,
47 int dataVersionIn):
48 Summary(nullptr),
49 Histos(nullptr),
50 Info(nullptr),
51 debug(debugIn),
52 dataVersion(dataVersionIn)
53{
54 Summary = new BDSOutputROOTEventRunInfo();
55 Histos = new BDSOutputROOTEventHistograms();
56 Info = new BDSOutputROOTEventRunInfo();
57}
58
59Run::~Run()
60{
61 delete Summary;
62 delete Histos;
63 delete Info;
64}
65
67 bool allBranchesOn,
68 const RBDS::VectorString* branchesToTurnOn)
69{
70 // turn off all branches by default.
71 t->SetBranchStatus("*", false);
72
73 if (allBranchesOn)
74 {t->SetBranchStatus("*", true);}
75 else if (branchesToTurnOn)
76 {
77 for (const auto& name : *branchesToTurnOn)
78 {
79 std::string nameStar = name + "*";
80 if (debug)
81 {std::cout << "Run::SetBranchAddress> Turning on branch \"" << nameStar << "\"" << std::endl;}
82 t->SetBranchStatus(nameStar.c_str(), true);
83 }
84 }
85
86 if (dataVersion < 4)
87 {t->SetBranchAddress("Info.", &Info);}
88 else
89 {t->SetBranchAddress("Summary.", &Summary);}
90 t->SetBranchAddress("Histos.", &Histos);
91}
Holder for a set of histograms to be stored.
Information pertaining to a run.
Class to overlay a run from a ROOT file with.
Definition Run.hh:35
BDSOutputROOTEventHistograms * Histos
Member that ROOT can map file data to locally.
Definition Run.hh:51
void SetBranchAddress(TTree *t, bool allBranchesOn=true, const RBDS::VectorString *branchesToTurnOn=nullptr)
Map the ROOT file to members in this class.
Definition Run.cc:66
BDSOutputROOTEventRunInfo * Summary
Member that ROOT can map file data to locally.
Definition Run.hh:50
BDSOutputROOTEventRunInfo * Info
For backwards compatibiliy.
Definition Run.hh:54