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) 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 "BDSOutputROOTEventCollimatorInfo.hh"
20
21#ifndef __ROOTBUILD__
22#include "BDSAcceleratorComponent.hh"
23#include "BDSBeamlineElement.hh"
24#include "BDSCollimator.hh"
25#include "BDSCollimatorJaw.hh"
26#include "BDSTiltOffset.hh"
27
28#include "CLHEP/Units/SystemOfUnits.h"
29#endif
30
32
34 componentName(""),
35 componentType(""),
36 length(0),
37 tilt(0),
38 offsetX(0),
39 offsetY(0),
40 material(""),
41 xSizeIn(0),
42 ySizeIn(0),
43 xSizeOut(0),
44 ySizeOut(0),
45 jawTiltLeft(0),
46 jawTiltRight(0)
47{;}
48
49BDSOutputROOTEventCollimatorInfo::~BDSOutputROOTEventCollimatorInfo()
50{;}
51
52void BDSOutputROOTEventCollimatorInfo::Flush()
53{
54 componentName = "";
55 componentType = "";
56 length = 0;
57 tilt = 0;
58 offsetX = 0;
59 offsetY = 0;
60 material = "";
61 xSizeIn = 0;
62 ySizeIn = 0;
63 xSizeOut = 0;
64 ySizeOut = 0;
65 jawTiltLeft = 0;
66 jawTiltRight = 0;
67}
68
69#ifndef __ROOTBUILD__
70void BDSOutputROOTEventCollimatorInfo::Fill(const BDSBeamlineElement* element)
71{
72 componentName = element->GetName();
73 componentType = element->GetType();
74 length = element->GetChordLength() / CLHEP::m;
75 const BDSTiltOffset* to = element->GetTiltOffset();
76 if (to)
77 {
78 tilt = to->GetTilt() / CLHEP::rad;
79 offsetX = to->GetXOffset() / CLHEP::m;
80 offsetY = to->GetYOffset() / CLHEP::m;
81 }
82 else
83 {
84 tilt = 0;
85 offsetX = 0;
86 offsetY = 0;
87 }
88 material = element->GetMaterial();
89
91 BDSCollimator* coll = dynamic_cast<BDSCollimator*>(comp);
92 if (coll)
93 {
94 xSizeIn = coll->XApertureIn() / CLHEP::m;
95 ySizeIn = coll->YApertureIn() / CLHEP::m;
96 xSizeOut = coll->XApertureOut() / CLHEP::m;
97 ySizeOut = coll->YApertureOut() / CLHEP::m;
98 if (xSizeOut < 0) // fix default -1 value to be the same as input
99 {xSizeOut = xSizeIn;}
100 if (ySizeOut < 0)
101 {ySizeOut = ySizeIn;}
102 }
103
104 BDSCollimatorJaw* jcoll = dynamic_cast<BDSCollimatorJaw*>(comp);
105 if (jcoll)
106 {
107 jawTiltLeft = jcoll->GetJawTiltLeft() / CLHEP::rad;
108 jawTiltRight = jcoll->GetJawTiltRight() / CLHEP::rad;
109 }
110}
111#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.