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