BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSSamplerCylinder.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 "BDSExtent.hh"
19#include "BDSSamplerCylinder.hh"
20#include "BDSSDManager.hh"
21#include "BDSSDSamplerCylinder.hh"
22#include "BDSUtilities.hh"
23
24#include "G4CutTubs.hh"
25#include "G4LogicalVolume.hh"
26#include "G4String.hh"
27#include "G4ThreeVector.hh"
28#include "G4Tubs.hh"
29#include "G4Types.hh"
30
31#include "CLHEP/Units/SystemOfUnits.h"
32
33
34BDSSamplerCylinder::BDSSamplerCylinder(const G4String& nameIn,
35 G4double radiusIn,
36 G4double fullLength,
37 G4double startAngle,
38 G4double sweepAngle,
39 G4int filterSetIDIn):
40 BDSSampler(nameIn, filterSetIDIn)
41{
42 G4double thickness = 1e-6 * radiusIn;
43 containerSolid = new G4Tubs(nameIn + "_solid", // name
44 radiusIn, // inner radius
45 radiusIn + thickness, // outer radius
46 fullLength*0.5, // half-length
47 startAngle, // start angle
48 sweepAngle); // sweep angle
49
50 SetExtent(BDSExtent(radiusIn, radiusIn, fullLength*0.5));
52}
53
54BDSSamplerCylinder::BDSSamplerCylinder(const G4String& nameIn,
55 G4double radiusIn,
56 G4double fullLength,
57 const G4ThreeVector& inputFaceNormal,
58 const G4ThreeVector& outputFaceNormal,
59 G4double startAngle,
60 G4double sweepAngle,
61 G4int filterSetIDIn):
62 BDSSampler(nameIn, filterSetIDIn)
63{
64 G4double thickness = 1e-6 * radiusIn;
65 if (!BDS::IsFinite(inputFaceNormal.angle({0,0,-1}),1e-6) && !BDS::IsFinite(outputFaceNormal.angle({0,0,1}),1e-6))
66 {
67 containerSolid = new G4Tubs(nameIn + "_solid", // name
68 radiusIn, // inner radius
69 radiusIn + thickness, // outer radius
70 fullLength*0.5, // half-length
71 startAngle, // start angle
72 sweepAngle); // sweep angle
73 }
74 else
75 {
76 containerSolid = new G4CutTubs(nameIn + "_solid", // name
77 radiusIn, // inner radius
78 radiusIn + thickness, // outer radius
79 fullLength * 0.5, // half-length
80 startAngle, // start angle
81 sweepAngle, // sweep angle
82 inputFaceNormal,
83 outputFaceNormal);
84 }
85 SetExtent(BDSExtent(radiusIn, radiusIn, fullLength*0.5));
87}
88
90{
91 auto sdMan = BDSSDManager::Instance();
92 BDSSDSamplerCylinder* sd = filterSetID > -1 ? sdMan->SamplerCylinderWithFilter(filterSetID) : sdMan->SamplerCylinder();
93 containerLogicalVolume->SetSensitiveDetector(sd);
94}
Holder for +- extents in 3 dimensions.
Definition BDSExtent.hh:38
void SetExtent(const BDSExtent &extIn)
Set extent.
The sensitive detector class that provides sensitivity to BDSSamplerCylinder instances.
virtual void SetSensitivity()
Attach sensitive detector to containerLogicalVolume.
Base class and registry of sampler instances.
Definition BDSSampler.hh:35
virtual void CommonConstruction()
Definition BDSSampler.cc:35
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())