BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSPrimaryGeneratorFileSampler.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 BDSPRIMARYGENERATORFILESAMPLER_H
19#define BDSPRIMARYGENERATORFILESAMPLER_H
20
21#include "BDSPrimaryGeneratorFile.hh"
22
23#include "G4RotationMatrix.hh"
24#include "G4String.hh"
25#include "G4ThreeVector.hh"
26#include "G4Types.hh"
27
28#include <vector>
29
32class G4Event;
33class G4PrimaryParticle;
34class G4PrimaryVertex;
35class G4VSolid;
36
44{
45public:
52 BDSPrimaryGeneratorFileSampler(const G4String& distrType,
53 const G4String& fileNameIn,
55 G4bool loopFileIn,
56 G4bool removeUnstableWithoutDecayIn = true,
57 G4bool warnAboutSkippedParticlesIn = true);
59
61 virtual void GeneratePrimaryVertex(G4Event* anEvent);
62
64 virtual void RecreateAdvanceToEvent(G4int eventOffset);
65
67 {
68 G4ThreeVector xyz;
69 G4double T;
70 G4PrimaryParticle* vertex;
71 };
72
75 void SkipEvents(G4long nEventsToSkip);
76
77protected:
79 void ReadSingleEvent(G4long index, G4Event* anEvent);
80
82 //void HepMC2G4(const HepMC3::GenEvent* hepmcevt, G4Event* g4event);
83
84 void ReadPrimaryParticlesFloat(G4long index);
85 void ReadPrimaryParticlesDouble(G4long index);
86
87private:
89 G4String fileName;
90 G4String samplerName;
91 G4bool removeUnstableWithoutDecay;
92 G4bool warnAboutSkippedParticles;
93 G4RotationMatrix referenceBeamMomentumOffset;
94
96 std::vector<DisplacedVertex> vertices;
97
98 std::vector<G4PrimaryVertex*> currentVertices;
99};
100
101#endif
A wrapper of BDSBunch to include a filter for the events loaded by an event generator.
Loader of ROOT Event output for receating events.
Loader to read a specific sampler from a BDSIM ROOT output file.
virtual void RecreateAdvanceToEvent(G4int eventOffset)
Advance to the correct event number in the file for recreation.
void ReadSingleEvent(G4long index, G4Event *anEvent)
Read sampler hits and put into primary vertices if they pass filters.
std::vector< DisplacedVertex > vertices
Used for transiently loading information.
BDSPrimaryGeneratorFileSampler()=delete
Do not require default constructor.
void ReadPrimaryParticlesFloat(G4long index)
Conversion from HepMC::GenEvent to G4Event.
virtual void GeneratePrimaryVertex(G4Event *anEvent)
Read the next non-empty sampler entry from the file.
Common interface for any primary generators that are file based.