BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Options.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 "Options.hh"
19#include "BDSOutputROOTEventOptions.hh"
20
21#include "TTree.h"
22
23#include <iostream>
24
25ClassImp(Options)
26
27Options::Options():
28 Options(false)
29{;}
30
31Options::Options(bool debugIn):
32 debug(debugIn)
33{
34 options = new BDSOutputROOTEventOptions();
35}
36
37Options::~Options()
38{
39 delete options;
40}
41
43 bool allBranchesOn,
44 const RBDS::VectorString* branchesToTurnOn)
45{
46 // turn off all branches by default.
47 t->SetBranchStatus("*", false);
48
49 if (allBranchesOn)
50 {t->SetBranchStatus("*", true);}
51 else if (branchesToTurnOn)
52 {
53 for (auto name : *branchesToTurnOn)
54 {
55 std::string nameStar = name + ".*"; // necessary because of the splitting
56 if (debug)
57 {std::cout << "Turning on branch \"" << nameStar << "\"" << std::endl;}
58 t->SetBranchStatus(nameStar.c_str(), true);
59 }
60 }
61
62 t->SetBranchAddress("Options.",&options);
63}
Class to store all options for a BDSIM run.
Options loader.
Definition Options.hh:35
void SetBranchAddress(TTree *t, bool allBranchesOn=true, const RBDS::VectorString *branchesToTurnOn=nullptr)
Set the branch addresses to address the contents of the file.
Definition Options.cc:42
BDSOutputROOTEventOptions * options
Member that ROOT can map file data to locally.
Definition Options.hh:47