BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSImportanceVolumeStore.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 "BDSImportanceVolumeStore.hh"
19
20#include "globals.hh"
21#include "G4VPhysicalVolume.hh"
22
23#include <algorithm>
24#include <iomanip>
25#include <ostream>
26#include <set>
27
28BDSImportanceVolumeStore::BDSImportanceVolumeStore(){;}
29
30BDSImportanceVolumeStore::~BDSImportanceVolumeStore(){;}
31
32void BDSImportanceVolumeStore::AddPVolume(const G4GeometryCell& cell)
33{
34 BDSSetGeometryCell::iterator it = geometryCells.find(cell);
35 if (it != geometryCells.end())
36 {
37 G4cout << "BDSImportanceVolumeStore::AddPVolume: cell already stored" << G4endl;
38 return;
39 }
40 geometryCells.insert(cell);
41}
42
43
44const G4VPhysicalVolume* BDSImportanceVolumeStore::GetPVolume(G4int index) const
45{
46 const G4GeometryCell& cell = *std::next(geometryCells.begin(), index);
47 const G4VPhysicalVolume* pvol = &cell.GetPhysicalVolume();
48 if (!pvol)
49 {G4cout << "BDSImportanceVolumeStore::GetPVolume: no physical volume for cell: " << index << ", found" << G4endl;}
50 return pvol;
51}
52
53std::ostream& operator<< (std::ostream& out, BDSImportanceVolumeStore const& ivs)
54{
55 auto flagsCache(out.flags());
56 out << "BDSImportanceVolumeStore: " << &ivs << G4endl;
57 out << "PV pointer / name / replica #" << G4endl;
58 for (const auto& cell : ivs)
59 {
60 const G4VPhysicalVolume* pv = &cell.GetPhysicalVolume();
61 auto rn = cell.GetReplicaNumber();
62 out << pv << " "
63 << std::left << std::setw(20) << pv->GetName() << " "
64 << rn << " " << G4endl;
65 }
66 out.flags(flagsCache);
67 return out;
68}
Registry of importance values.
const G4VPhysicalVolume * GetPVolume(G4int index) const
Get stores physical volume from index.
void AddPVolume(const G4GeometryCell &cell)
Add geometry cell to the store.
BDSSetGeometryCell geometryCells
std::set<G4GeometryCell, G4GeometryCellComp> from typedef above.