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) 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 "BDSImportanceVolumeStore.hh"
20
21#include "globals.hh"
22#include "G4VPhysicalVolume.hh"
23
24#include <algorithm>
25#include <iomanip>
26#include <ostream>
27#include <set>
28
29BDSImportanceVolumeStore::BDSImportanceVolumeStore(){;}
30
31BDSImportanceVolumeStore::~BDSImportanceVolumeStore(){;}
32
33void BDSImportanceVolumeStore::AddPVolume(const G4GeometryCell& cell)
34{
35 BDSSetGeometryCell::iterator it = geometryCells.find(cell);
36 if (it != geometryCells.end())
37 {
38 G4cout << "BDSImportanceVolumeStore::AddPVolume: cell already stored" << G4endl;
39 return;
40 }
41 geometryCells.insert(cell);
42}
43
44
45const G4VPhysicalVolume* BDSImportanceVolumeStore::GetPVolume(G4int index) const
46{
47 const G4GeometryCell& cell = *std::next(geometryCells.begin(), index);
48 const G4VPhysicalVolume* pvol = &cell.GetPhysicalVolume();
49 if (!pvol)
50 {G4cout << "BDSImportanceVolumeStore::GetPVolume: no physical volume for cell: " << index << ", found" << G4endl;}
51 return pvol;
52}
53
54std::ostream& operator<< (std::ostream& out, BDSImportanceVolumeStore const& ivs)
55{
56 auto flagsCache(out.flags());
57 out << "BDSImportanceVolumeStore: " << &ivs << G4endl;
58 out << "PV pointer / name / replica #" << G4endl;
59 for (const auto& cell : ivs)
60 {
61 const G4VPhysicalVolume* pv = &cell.GetPhysicalVolume();
62 auto rn = cell.GetReplicaNumber();
63 out << pv << " "
64 << std::left << std::setw(20) << pv->GetName() << " "
65 << rn << " " << G4endl;
66 }
67 out.flags(flagsCache);
68 return out;
69}
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.