BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSScoringMeshCylinder.cc
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#include "BDSDebug.hh"
20#include "BDSException.hh"
21#include "BDSHistBinMapper.hh"
22#include "BDSScoringMeshCylinder.hh"
23#include "BDSScorerMeshInfo.hh"
24
25#include "globals.hh"
26#include "G4RotationMatrix.hh"
27#include "G4Version.hh"
28
30 const BDSScorerMeshInfo& recipe,
31 const G4Transform3D& placementTransform):
32 BDSScoringMeshCylinder(name, placementTransform.getTranslation(), placementTransform.getRotation())
33{
34 // size of the scoring mesh
35#if G4VERSION_NUMBER < 1100
36 scorerSize[0] = recipe.ScoringMeshR(); // RMax
37 scorerSize[1] = recipe.ScoringMeshZ(); // ZSize
38#else
39 scorerSize[0] = 0; // RMin
40 scorerSize[1] = recipe.ScoringMeshR(); // RMax
41 scorerSize[2] = recipe.ScoringMeshZ(); // ZSize
42#endif
43 SetSize(scorerSize);
44
45 // divisions of the scoring mesh
46 nSegment[0] = recipe.nBinsZ;
47 nSegment[1] = recipe.nBinsPhi;
48 nSegment[2] = recipe.nBinsR;
49 nEnergySegments = recipe.nBinsE;
50 SetNumberOfSegments(nSegment);
51
52#ifdef USE_BOOST
53 mapper = new BDSHistBinMapper(fNSegment[0], fNSegment[1], fNSegment[2], nEnergySegments, recipe.energyAxis);
54#else
55 mapper = new BDSHistBinMapper(fNSegment[0], fNSegment[1], fNSegment[2], nEnergySegments);
56#endif
57}
58
59
61 const G4ThreeVector& translation,
62 const G4RotationMatrix& rotation):
63 G4ScoringCylinder(name),
64 mapper(nullptr)
65{
66 fRotationMatrix = new G4RotationMatrix(rotation.inverse());
67 fCenterPosition = translation;
68}
69
70const BDSHistBinMapper* BDSScoringMeshCylinder::Mapper() const
71{
72 if (!sizeIsSet)
73 {throw BDSException(__METHOD_NAME__, "mesh \"" + fWorldName + "\" size not set but queried");}
74 if (!mapper)
75 {throw BDSException(__METHOD_NAME__, "mesh \"" + fWorldName + "\" mapper has mysteriously disappeared");}
76 return mapper;
77}
78
79BDSScoringMeshCylinder::~BDSScoringMeshCylinder()
80{
81 delete mapper;
82}
General exception with possible name of object and message.
Definition: BDSException.hh:35
Mapping from axis indices to 1D index.
Recipe class for a scoring mesh.
Wrapper for G4ScoringCylinder to allow full access to placement.
BDSScoringMeshCylinder(const G4String &name, const BDSScorerMeshInfo &recipe, const G4Transform3D &placementTransform)