BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSOutputROOTEventCavityInfo.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 "BDSOutputROOTEventCavityInfo.hh"
20
21#ifndef __ROOTBUILD__
22#include "BDSAcceleratorComponent.hh"
23#include "BDSBeamlineElement.hh"
24#include "BDSCavityElement.hh"
25#include "BDSCavityInfo.hh"
26#include "BDSCavityType.hh"
27#include "BDSFieldInfo.hh"
28#include "BDSMagnetStrength.hh"
29#include "BDSTiltOffset.hh"
30
31#include "CLHEP/Units/SystemOfUnits.h"
32#endif
33
35
37 componentName(""),
38 componentType(""),
39 length(0),
40 tilt(0),
41 efield(0),
42 gradient(0),
43 frequency(0),
44 phase(0),
45 material(""),
46 cavityType(""),
47 irisRadius(0),
48 thickness(0),
49 equatorRadius(0),
50 halfCellLength(0),
51 numberOfPoints(0),
52 numberOfCells(0),
53 equatorHorizontalAxis(0),
54 equatorVerticalAxis(0),
55 irisHorizontalAxis(0),
56 irisVerticalAxis(0),
57 tangentLineAngle(0)
58{;}
59
60BDSOutputROOTEventCavityInfo::~BDSOutputROOTEventCavityInfo()
61{;}
62
63void BDSOutputROOTEventCavityInfo::Flush()
64{
65 componentName = "";
66 componentType = "";
67 length = 0;
68 tilt = 0;
69 efield = 0;
70 gradient = 0;
71 frequency = 0;
72 phase = 0;
73 material = "";
74 cavityType = "";
75 irisRadius = 0;
76 thickness = 0;
77 equatorRadius = 0;
78 halfCellLength = 0;
79 numberOfPoints = 0;
80 numberOfCells = 0;
81 equatorHorizontalAxis = 0;
82 equatorVerticalAxis = 0;
83 irisHorizontalAxis = 0;
84 irisVerticalAxis = 0;
85 tangentLineAngle = 0;
86}
87
88#ifndef __ROOTBUILD__
89void BDSOutputROOTEventCavityInfo::Fill(const BDSBeamlineElement* element)
90{
91 componentName = element->GetName();
92 componentType = element->GetType();
93 length = element->GetChordLength() / CLHEP::m;
94 const BDSTiltOffset* to = element->GetTiltOffset();
95 if (to)
96 {tilt = to->GetTilt() / CLHEP::rad;}
97 else
98 {tilt = 0;}
99 material = element->GetMaterial();
100
102 BDSCavityElement* cav = dynamic_cast<BDSCavityElement*>(comp);
103 const BDSFieldInfo* fieldInfo = cav->GetFieldInfo();
104 const BDSCavityInfo* cavInfo = cav->GetCavityInfo();
105 if (fieldInfo)
106 {
107 const BDSMagnetStrength* ms = fieldInfo->MagnetStrength();
108 efield = (*ms)["efield"]/BDSMagnetStrength::Unit("efield");
109 frequency = (*ms)["frequency"]/BDSMagnetStrength::Unit("frequency");
110 phase = (*ms)["phase"]/BDSMagnetStrength::Unit("phase");
111 }
112 if (cavInfo)
113 {
114 cavityType = cavInfo->cavityType.ToString(); //BDS::DetermineCavityType(cavInfo->cavityType);
115 irisRadius = cavInfo->irisRadius;
116 thickness = cavInfo->thickness;
117 equatorRadius = cavInfo->equatorRadius;
118 halfCellLength = cavInfo->halfCellLength;
119 numberOfPoints = cavInfo->numberOfPoints;
120 numberOfCells = cavInfo->numberOfCells;
121 equatorHorizontalAxis = cavInfo->equatorHorizontalAxis;
122 equatorVerticalAxis = cavInfo->equatorVerticalAxis;
123 irisHorizontalAxis = cavInfo->irisHorizontalAxis;
124 irisVerticalAxis = cavInfo->irisVerticalAxis;
125 tangentLineAngle = cavInfo->tangentLineAngle;
126 }
127}
128#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.
RF Cavity. Uses factories to construct appropriate geometry.
Holder for all Geometrical information required to create an RF cavity.
G4double equatorRadius
Equator radius - half width of widest part.
G4double equatorVerticalAxis
Equator ellipse vertical semi-axis.
G4double tangentLineAngle
Tangent angle.
G4double irisRadius
Iris radius - half width of narrowest part.
BDSCavityType cavityType
Cavity type.
G4double irisVerticalAxis
Iris ellipse vertical semi-axis.
G4int numberOfCells
Number of cells per cavity.
G4int numberOfPoints
G4double irisHorizontalAxis
Iris ellipse horizontal semi-axis.
G4double equatorHorizontalAxis
Equator ellipse horizontal semi-axis.
G4double halfCellLength
Half cell length.
G4double thickness
Thickness of wall material.
All info required to build complete field of any type.
Definition: BDSFieldInfo.hh:66
BDSMagnetStrength * MagnetStrength() const
Accessor.
Efficient storage of magnet strengths.
static G4double Unit(const G4String &key)
Access a unit factor for a given key.
Data stored for each cavity in the model.
BDSOutputROOTEventCavityInfo()
Default constructor for ROOT.
A holder for any placement offsets and rotations for a BDSAcceleratorComponent.
G4double GetTilt() const
Accessor.