BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSOutputROOTEventSampler.hh
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#ifndef BDSOUTPUTROOTEVENTSAMPLER_H
19#define BDSOUTPUTROOTEVENTSAMPLER_H
20
21#include "Rtypes.h"
22#include "TObject.h"
23
24#include <string>
25#include <vector>
26
28class TTree;
29
30#ifndef __ROOTBUILD__
31#include "globals.hh"
33class BDSHitSampler;
35#endif
36
43template<class U> class BDSOutputROOTEventSampler: public TObject
44{
45public:
46 std::string samplerName; //|| Don't split the header
47
48 int n;
49 std::vector<U> energy;
50 std::vector<U> x;
51 std::vector<U> y;
52 U z;
53 std::vector<U> xp;
54 std::vector<U> yp;
55 std::vector<U> zp;
56 std::vector<U> p;
57 std::vector<U> T;
58
59 std::vector<U> weight;
60 std::vector<int> partID;
61 std::vector<int> parentID;
62 std::vector<int> trackID;
63 int modelID;
64 std::vector<int> turnNumber;
65
66 U S;
67
68 std::vector<U> r;
69 std::vector<U> rp;
70 std::vector<U> phi;
71 std::vector<U> phip;
72 std::vector<U> theta;
73
75 std::vector<int> charge;
76 std::vector<U> kineticEnergy;
77 std::vector<U> mass;
78 std::vector<U> rigidity;
79 std::vector<bool> isIon;
80 std::vector<int> ionA;
81 std::vector<int> ionZ;
82 std::vector<int> nElectrons;
84
86 std::vector<U> getKineticEnergy();
87 std::vector<U> getMass();
88 std::vector<U> getRigidity();
89 std::vector<bool> getIsIon();
90 std::vector<int> getIonA();
91 std::vector<int> getIonZ();
93
95 explicit BDSOutputROOTEventSampler(std::string samplerNameIn);
97#ifndef __ROOTBUILD__
98 void Fill(const BDSHitSampler* hit,
99 G4bool storeMass = false,
100 G4bool storeCharge = false,
101 G4bool storePolarCoords = false,
102 G4bool storeElectrons = false,
103 G4bool storeRigidity = false,
104 G4bool storeKineticEnergy = false);
108 void Fill(const BDSParticleCoordsFull& coords,
109 G4double momentumIn,
110 G4double charge,
111 G4int pdgID,
112 G4int turnsTaken,
113 G4int beamlineIndex,
114 G4int nElectronsIn,
115 G4double massIn,
116 G4double rigidityIn,
117 G4bool fillIon = true,
118 G4bool* isIon = nullptr,
119 G4int* ionA = nullptr,
120 G4int* ionZ = nullptr);
121 void FillPolarCoords(const BDSParticleCoordsFull& coords);
122 void Fill(const BDSPrimaryVertexInformationV* vertexInfos,
123 const G4int turnsTaken);
124#endif
125 void Fill(const BDSOutputROOTEventSampler<U>* other);
126
128 inline void FillIon() {isIon = getIsIon(); ionA = getIonA(); ionZ = getIonZ();}
130
131 void SetBranchAddress(TTree *);
132 virtual void Flush();
133
134 void FlushLocal();
135
136 static BDSOutputROOTParticleData* particleTable;
137
138 ClassDef(BDSOutputROOTEventSampler,5);
139};
140
141// This unusually has to be in the header because it's a templated static member, so we need
142// the compiler to generate the intialisation for the ones required.
144
145#endif
The information recorded from a particle impacting a sampler.
Information stored per sampler per event.
std::vector< int > getIonA()
Function to calculate on the fly the parameters.
std::vector< bool > isIon
These are not filled by default.
std::vector< int > getIonZ()
Function to calculate on the fly the parameters.
std::vector< int > nElectrons
These are not filled by default.
std::vector< int > ionA
These are not filled by default.
void FlushLocal()
Actual flush that is non virtual function to use in constructor.
std::vector< U > getRigidity()
Function to calculate on the fly the parameters.
std::vector< U > getMass()
Function to calculate on the fly the parameters.
std::vector< U > rigidity
These are not filled by default.
std::vector< bool > getIsIon()
Function to calculate on the fly the parameters.
std::vector< int > charge
These are not filled by default.
void FillIon()
Calculate and fill calculated variables.
virtual void Flush()
Clean Sampler.
std::vector< U > kineticEnergy
These are not filled by default.
void FillPolarCoords(const BDSParticleCoordsFull &coords)
Calculate polar coords and fill.
std::vector< U > mass
These are not filled by default.
std::vector< int > ionZ
These are not filled by default.
std::vector< U > getKineticEnergy()
Function to calculate on the fly the parameters.
Geant4 particle data for particles used in simulation.
A set of particle coordinates including energy and weight.
Full set of coordinates for association with primary vertex. Vector version.