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) 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 "BDSOutputROOTEventCavityInfo.hh"
19
20#ifndef __ROOTBUILD__
21#include "BDSAcceleratorComponent.hh"
22#include "BDSBeamlineElement.hh"
23#include "BDSCavityElement.hh"
24#include "BDSCavityInfo.hh"
25#include "BDSCavityType.hh"
26#include "BDSFieldInfo.hh"
27#include "BDSMagnetStrength.hh"
28#include "BDSTiltOffset.hh"
29
30#include "CLHEP/Units/SystemOfUnits.h"
31#endif
32
34
36 componentName(""),
37 componentType(""),
38 length(0),
39 tilt(0),
40 efield(0),
41 gradient(0),
42 frequency(0),
43 phase(0),
44 material(""),
45 cavityType(""),
46 irisRadius(0),
47 thickness(0),
48 equatorRadius(0),
49 halfCellLength(0),
50 numberOfPoints(0),
51 numberOfCells(0),
52 equatorHorizontalAxis(0),
53 equatorVerticalAxis(0),
54 irisHorizontalAxis(0),
55 irisVerticalAxis(0),
56 tangentLineAngle(0)
57{;}
58
59BDSOutputROOTEventCavityInfo::~BDSOutputROOTEventCavityInfo()
60{;}
61
62void BDSOutputROOTEventCavityInfo::Flush()
63{
64 componentName = "";
65 componentType = "";
66 length = 0;
67 tilt = 0;
68 efield = 0;
69 gradient = 0;
70 frequency = 0;
71 phase = 0;
72 material = "";
73 cavityType = "";
74 irisRadius = 0;
75 thickness = 0;
76 equatorRadius = 0;
77 halfCellLength = 0;
78 numberOfPoints = 0;
79 numberOfCells = 0;
80 equatorHorizontalAxis = 0;
81 equatorVerticalAxis = 0;
82 irisHorizontalAxis = 0;
83 irisVerticalAxis = 0;
84 tangentLineAngle = 0;
85}
86
87#ifndef __ROOTBUILD__
88void BDSOutputROOTEventCavityInfo::Fill(const BDSBeamlineElement* element)
89{
90 componentName = element->GetName();
91 componentType = element->GetType();
92 length = element->GetChordLength() / CLHEP::m;
93 const BDSTiltOffset* to = element->GetTiltOffset();
94 if (to)
95 {tilt = to->GetTilt() / CLHEP::rad;}
96 else
97 {tilt = 0;}
98 material = element->GetMaterial();
99
101 BDSCavityElement* cav = dynamic_cast<BDSCavityElement*>(comp);
102 const BDSFieldInfo* fieldInfo = cav->GetFieldInfo();
103 const BDSCavityInfo* cavInfo = cav->GetCavityInfo();
104 if (fieldInfo)
105 {
106 const BDSMagnetStrength* ms = fieldInfo->MagnetStrength();
107 efield = (*ms)["efield"]/BDSMagnetStrength::Unit("efield");
108 frequency = (*ms)["frequency"]/BDSMagnetStrength::Unit("frequency");
109 phase = (*ms)["phase"]/BDSMagnetStrength::Unit("phase");
110 }
111 if (cavInfo)
112 {
113 cavityType = cavInfo->cavityType.ToString(); //BDS::DetermineCavityType(cavInfo->cavityType);
114 irisRadius = cavInfo->irisRadius;
115 thickness = cavInfo->thickness;
116 equatorRadius = cavInfo->equatorRadius;
117 halfCellLength = cavInfo->halfCellLength;
118 numberOfPoints = cavInfo->numberOfPoints;
119 numberOfCells = cavInfo->numberOfCells;
120 equatorHorizontalAxis = cavInfo->equatorHorizontalAxis;
121 equatorVerticalAxis = cavInfo->equatorVerticalAxis;
122 irisHorizontalAxis = cavInfo->irisHorizontalAxis;
123 irisVerticalAxis = cavInfo->irisVerticalAxis;
124 tangentLineAngle = cavInfo->tangentLineAngle;
125 }
126}
127#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.
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.
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.