BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSScoringMeshBox.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 "BDSScoringMeshBox.hh"
23#include "BDSScorerMeshInfo.hh"
24
25#include "globals.hh"
26#include "G4RotationMatrix.hh"
27
29 const BDSScorerMeshInfo& recipe,
30 const G4Transform3D& placementTransform):
31 BDSScoringMeshBox(name, placementTransform.getTranslation(), placementTransform.getRotation())
32{
33 // size of the scoring mesh
34 scorerSize[0] = recipe.ScoringMeshX();
35 scorerSize[1] = recipe.ScoringMeshY();
36 scorerSize[2] = recipe.ScoringMeshZ();
37 SetSize(scorerSize);
38
39 // divisions of the scoring mesh
40 nSegment[0] = recipe.nBinsX;
41 nSegment[1] = recipe.nBinsY;
42 nSegment[2] = recipe.nBinsZ;
43 nEnergySegments = recipe.nBinsE;
44 SetNumberOfSegments(nSegment);
45
46#ifdef USE_BOOST
47 mapper = new BDSHistBinMapper(fNSegment[0], fNSegment[1], fNSegment[2], nEnergySegments, recipe.energyAxis);
48#else
49 mapper = new BDSHistBinMapper(fNSegment[0], fNSegment[1], fNSegment[2], nEnergySegments);
50#endif
51}
52
54 const G4ThreeVector& translation,
55 const G4RotationMatrix& rotation):
56 G4ScoringBox(name),
57 mapper(nullptr)
58{
59 fRotationMatrix = new G4RotationMatrix(rotation.inverse());
60 fCenterPosition = translation;
61}
62
63const BDSHistBinMapper* BDSScoringMeshBox::Mapper() const
64{
65 if (!sizeIsSet)
66 {throw BDSException(__METHOD_NAME__, "mesh \"" + fWorldName + "\" size not set but queried");}
67 if (!mapper)
68 {throw BDSException(__METHOD_NAME__, "mesh \"" + fWorldName + "\" mapper has mysteriously disappeared");}
69 return mapper;
70}
71
72BDSScoringMeshBox::~BDSScoringMeshBox()
73{
74 delete mapper;
75}
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 G4ScoringBox to allow full access to placement.
BDSScoringMeshBox(const G4String &name, const BDSScorerMeshInfo &recipe, const G4Transform3D &placementTransform)