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) 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#include "BDSDebug.hh"
19#include "BDSException.hh"
20#include "BDSHistBinMapper.hh"
21#include "BDSScoringMeshBox.hh"
22#include "BDSScorerMeshInfo.hh"
23
24#include "globals.hh"
25#include "G4RotationMatrix.hh"
26
28 const BDSScorerMeshInfo& recipe,
29 const G4Transform3D& placementTransform):
30 BDSScoringMeshBox(name, placementTransform.getTranslation(), placementTransform.getRotation())
31{
32 // size of the scoring mesh
33 scorerSize[0] = recipe.ScoringMeshX();
34 scorerSize[1] = recipe.ScoringMeshY();
35 scorerSize[2] = recipe.ScoringMeshZ();
36 SetSize(scorerSize);
37
38 // divisions of the scoring mesh
39 nSegment[0] = recipe.nBinsX;
40 nSegment[1] = recipe.nBinsY;
41 nSegment[2] = recipe.nBinsZ;
42 nEnergySegments = recipe.nBinsE;
43 SetNumberOfSegments(nSegment);
44
45#ifdef USE_BOOST
46 mapper = new BDSHistBinMapper(fNSegment[0], fNSegment[1], fNSegment[2], nEnergySegments, recipe.energyAxis);
47#else
48 mapper = new BDSHistBinMapper(fNSegment[0], fNSegment[1], fNSegment[2], nEnergySegments);
49#endif
50}
51
53 const G4ThreeVector& translation,
54 const G4RotationMatrix& rotation):
55 G4ScoringBox(name),
56 mapper(nullptr)
57{
58 fRotationMatrix = new G4RotationMatrix(rotation.inverse());
59 fCenterPosition = translation;
60}
61
62const BDSHistBinMapper* BDSScoringMeshBox::Mapper() const
63{
64 if (!sizeIsSet)
65 {throw BDSException(__METHOD_NAME__, "mesh \"" + fWorldName + "\" size not set but queried");}
66 if (!mapper)
67 {throw BDSException(__METHOD_NAME__, "mesh \"" + fWorldName + "\" mapper has mysteriously disappeared");}
68 return mapper;
69}
70
71BDSScoringMeshBox::~BDSScoringMeshBox()
72{
73 delete mapper;
74}
General exception with possible name of object and message.
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)