BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSParallelWorldPlacementFields.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 "BDSAcceleratorModel.hh"
19#include "BDSDetectorConstruction.hh"
20#include "BDSException.hh"
21#include "BDSGlobalConstants.hh"
22#include "BDSNavigatorPlacements.hh"
23#include "BDSParallelWorldPlacementFields.hh"
24
25#include "G4LogicalVolume.hh"
26#include "G4PVPlacement.hh"
27#include "G4String.hh"
28#include "G4Types.hh"
29#include "G4VisAttributes.hh"
30#include "G4VPhysicalVolume.hh"
31
32#include <vector>
33
34
35BDSParallelWorldPlacementFields::BDSParallelWorldPlacementFields(const G4String& name):
36 G4VUserParallelWorld("PlacementFieldsWorld_" + name),
37 pfWorldVis(nullptr)
38{;}
39
40BDSParallelWorldPlacementFields::~BDSParallelWorldPlacementFields()
41{
42 // we leak all the placements as g4 is incredibly slow to delete
43 // them as it deregisters them - g4 will clean up
44 //for (auto placement : placements)
45 // {delete placement;}
46 delete pfWorldVis;
47}
48
50{
53 G4VPhysicalVolume* pfWorld = GetWorld();
54 G4LogicalVolume* pfWorldLV = pfWorld->GetLogicalVolume();
55
58
59 pfWorldVis = new G4VisAttributes(*(globals->VisibleDebugVisAttr()));
60 pfWorldVis->SetForceWireframe(true);//just wireframe so we can see inside it
61 pfWorldLV->SetVisAttributes(pfWorldVis);
62
63 G4bool checkOverlaps = globals->CheckOverlaps();
64 const auto& placementsToMake = BDSAcceleratorModel::Instance()->PlacementFieldPWPlacements();
65 for (const auto& placement : placementsToMake)
66 {
67 // record placements for cleaning up at destruction.
68 G4PVPlacement* pl = new G4PVPlacement(placement.transform,
69 placement.name,
70 placement.lvToPlace,
71 pfWorld,
72 false,
73 placement.copyNumber,
74 checkOverlaps);
75 placements.push_back(pl);
76 }
77}
const std::vector< BDSPlacementToMake > & PlacementFieldPWPlacements() const
Access field volumes for parallel world.
A class that holds global options and constants.
static BDSGlobalConstants * Instance()
Access method.
static void AttachWorldVolumeToNavigator(G4VPhysicalVolume *worldPVIn)
Setup the navigator w.r.t. to a world volume - typically real world.
std::vector< G4VPhysicalVolume * > placements
Cache of the placements to clean up at the end.