BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSOutputROOTEventCollimatorInfo.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 "BDSOutputROOTEventCollimatorInfo.hh"
19
20#ifndef __ROOTBUILD__
21#include "BDSAcceleratorComponent.hh"
22#include "BDSBeamlineElement.hh"
23#include "BDSCollimator.hh"
24#include "BDSCollimatorJaw.hh"
25#include "BDSTiltOffset.hh"
26
27#include "CLHEP/Units/SystemOfUnits.h"
28#endif
29
31
33 componentName(""),
34 componentType(""),
35 length(0),
36 tilt(0),
37 offsetX(0),
38 offsetY(0),
39 material(""),
40 xSizeIn(0),
41 ySizeIn(0),
42 xSizeOut(0),
43 ySizeOut(0),
44 jawTiltLeft(0),
45 jawTiltRight(0)
46{;}
47
48BDSOutputROOTEventCollimatorInfo::~BDSOutputROOTEventCollimatorInfo()
49{;}
50
51void BDSOutputROOTEventCollimatorInfo::Flush()
52{
53 componentName = "";
54 componentType = "";
55 length = 0;
56 tilt = 0;
57 offsetX = 0;
58 offsetY = 0;
59 material = "";
60 xSizeIn = 0;
61 ySizeIn = 0;
62 xSizeOut = 0;
63 ySizeOut = 0;
64 jawTiltLeft = 0;
65 jawTiltRight = 0;
66}
67
68#ifndef __ROOTBUILD__
69void BDSOutputROOTEventCollimatorInfo::Fill(const BDSBeamlineElement* element)
70{
71 componentName = element->GetName();
72 componentType = element->GetType();
73 length = element->GetChordLength() / CLHEP::m;
74 const BDSTiltOffset* to = element->GetTiltOffset();
75 if (to)
76 {
77 tilt = to->GetTilt() / CLHEP::rad;
78 offsetX = to->GetXOffset() / CLHEP::m;
79 offsetY = to->GetYOffset() / CLHEP::m;
80 }
81 else
82 {
83 tilt = 0;
84 offsetX = 0;
85 offsetY = 0;
86 }
87 material = element->GetMaterial();
88
90 BDSCollimator* coll = dynamic_cast<BDSCollimator*>(comp);
91 if (coll)
92 {
93 xSizeIn = coll->XApertureIn() / CLHEP::m;
94 ySizeIn = coll->YApertureIn() / CLHEP::m;
95 xSizeOut = coll->XApertureOut() / CLHEP::m;
96 ySizeOut = coll->YApertureOut() / CLHEP::m;
97 if (xSizeOut < 0) // fix default -1 value to be the same as input
98 {xSizeOut = xSizeIn;}
99 if (ySizeOut < 0)
100 {ySizeOut = ySizeIn;}
101 }
102
103 BDSCollimatorJaw* jcoll = dynamic_cast<BDSCollimatorJaw*>(comp);
104 if (jcoll)
105 {
106 jawTiltLeft = jcoll->GetJawTiltLeft() / CLHEP::rad;
107 jawTiltRight = jcoll->GetJawTiltRight() / CLHEP::rad;
108 }
109}
110#endif
Abstract class that represents a component of an accelerator.
A class that holds a fully constructed BDSAcceleratorComponent as well as any information relevant to...
G4double GetChordLength() const
Accessor.
BDSTiltOffset * GetTiltOffset() const
Accessor.
G4String GetMaterial() const
Accessor.
G4String GetName() const
Accessor.
BDSAcceleratorComponent * GetAcceleratorComponent() const
Accessor.
G4String GetType() const
Accessor.
Collimator with only two jaw and no top bit.
Base class for collimators with common construction.
virtual G4double XApertureOut() const
Accessor.
virtual G4double XApertureIn() const
Accessor.
virtual G4double YApertureIn() const
Accessor.
virtual G4double YApertureOut() const
Accessor.
Data stored for each collimator in the model.
BDSOutputROOTEventCollimatorInfo()
Default constructor for ROOT.
A holder for any placement offsets and rotations for a BDSAcceleratorComponent.
G4double GetYOffset() const
Accessor.
G4double GetXOffset() const
Accessor.
G4double GetTilt() const
Accessor.