BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSPSPopulationScaled.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
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#ifndef BDSPSPOPULATIONSCALED_H
20#define BDSPSPOPULATIONSCALED_H
21#include "G4String.hh"
22#include "G4THitsMap.hh"
23#include "G4TrackLogger.hh"
24#include "G4Types.hh"
25#include "G4VPrimitiveScorer.hh"
26
27#include <map>
28#include <vector>
29
30class G4PhysicsVector;
31
43class BDSPSPopulationScaled: public G4VPrimitiveScorer
44{
45public:
48 explicit BDSPSPopulationScaled(const G4String& name, G4int depth=0);
49
52 BDSPSPopulationScaled(const G4String& scorerName,
53 const G4String& pathname,
54 G4int depth=0);
55
56 virtual ~BDSPSPopulationScaled() override;
57
58public:
59 void Initialize(G4HCofThisEvent* HCE) override;
60 void EndOfEvent(G4HCofThisEvent* HCE) override;
61 void clear() override;
62
63 G4bool ProcessHits(G4Step* aStep, G4TouchableHistory*) override;
64
65 virtual G4double GetConversionFactor(G4int particleID,
66 G4double kineticEnergy,
67 G4double angle) const;
68
69 static std::vector<G4String> LoadDirectoryContents(const G4String& dirname);
70 G4int NearestNeighbourAngleIndex(const std::vector<G4double>& vec, G4double value) const;
71 G4int NearestNeighbourIonPID(const std::vector<G4int>& vec, G4int value) const;
72 G4int GetZFromParticleID(G4int particleID) const;
73 void PrintAll() override;
74
75private:
76 G4int HCID;
78
79 std::map<G4int, G4TrackLogger> fCellTrackLogger;
80 std::map< G4int, std::map<G4int, G4PhysicsVector*> > conversionFactors;
81 std::map< G4int, std::vector<G4int> > ionParticleIDs;
82 std::vector<G4double> angles;
83};
84
85#endif
Primitive scorer for population in a volume with a conversion factor based on angle and kinetic energ...