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