BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSLine.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 "BDSDebug.hh"
20#include "BDSLine.hh"
21
22#include <vector>
23
24BDSLine::BDSLine(G4String nameIn):
25 BDSAcceleratorComponent(nameIn,0,0,"line")
26{;}
27
29{line.push_back(component);}
30
31G4double BDSLine::GetArcLength() const
32{
33 G4double result = 0;
34 for (auto component : *this)
35 {result += component->GetArcLength();}
36 return result;
37}
38
40{
41 G4double result = 0;
42 for (auto component : *this)
43 {result += component->GetChordLength();}
44 return result;
45}
46
47std::set<G4LogicalVolume*> BDSLine::GetAcceleratorVacuumLogicalVolumes() const
48{
49 std::set<G4LogicalVolume*> result;
50 for (auto component : *this)
51 {
52 auto vlvs = component->GetAcceleratorVacuumLogicalVolumes();
53 result.insert(vlvs.begin(), vlvs.end());
54 }
55 return result;
56}
57
58std::set<G4LogicalVolume*> BDSLine::GetAcceleratorMaterialLogicalVolumes() const
59{
60 std::set<G4LogicalVolume*> result;
61 for (auto component : *this)
62 {
63 auto vlvs = component->GetAcceleratorMaterialLogicalVolumes();
64 result.insert(vlvs.begin(), vlvs.end());
65 }
66 return result;
67}
68
70{
71 for (auto component : *this)
72 {
73#ifdef BDSDEBUG
74 G4cout << __METHOD_NAME__ << "Initialising component named: " << component->GetName() << G4endl;
75#endif
76 component->Initialise();
77 }
78}
79
80void BDSLine::SetBiasVacuumList(const std::list<std::string>& biasVacuumListIn)
81{
82 BDSAcceleratorComponent::SetBiasVacuumList(biasVacuumListIn); // set if for this object
83 for (auto component : *this)
84 {component->SetBiasVacuumList(biasVacuumListIn);}
85}
86
87void BDSLine::SetBiasMaterialList(const std::list<std::string>& biasMaterialListIn)
88{
90 for (auto component : *this)
91 {component->SetBiasMaterialList(biasMaterialListIn);}
92}
93
94void BDSLine::SetRegion(const G4String& regionIn)
95{
96 BDSAcceleratorComponent::SetRegion(regionIn); // set it for this object
97 for (auto component: *this)
98 {component->SetRegion(regionIn);}
99}
100
Abstract class that represents a component of an accelerator.
virtual void SetBiasVacuumList(const std::list< std::string > &biasVacuumListIn)
Copy the bias list to this element.
virtual void SetBiasMaterialList(const std::list< std::string > &biasMaterialListIn)
Copy the bias list to this element.
virtual void SetRegion(const G4String &regionIn)
Set the region name for this component.
virtual void SetBiasVacuumList(const std::list< std::string > &biasVacuumList)
Copy the bias list to each component.
Definition: BDSLine.cc:80
virtual std::set< G4LogicalVolume * > GetAcceleratorVacuumLogicalVolumes() const
Re-implement from BDSAcceleratorComponent.
Definition: BDSLine.cc:47
virtual void SetBiasMaterialList(const std::list< std::string > &biasMaterialList)
Copy the bias list to each component.
Definition: BDSLine.cc:87
virtual void Initialise()
Definition: BDSLine.cc:69
virtual void SetRegion(const G4String &region)
Set the region name for each component.
Definition: BDSLine.cc:94
virtual std::set< G4LogicalVolume * > GetAcceleratorMaterialLogicalVolumes() const
Re-implement from BDSAcceleratorComponent.
Definition: BDSLine.cc:58
BDSLineVector line
Member vector to store components.
Definition: BDSLine.hh:45
void AddComponent(BDSAcceleratorComponent *component)
Add a component to the line.
Definition: BDSLine.cc:28
virtual G4double GetArcLength() const
Override base class method as BDSAcceleratorComponent::chordLength etc variables are const and we app...
Definition: BDSLine.cc:31
virtual G4double GetChordLength() const
Override base class method as BDSAcceleratorComponent::chordLength etc variables are const and we app...
Definition: BDSLine.cc:39