BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSSDFilterMaterial.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 "BDSSDFilterMaterial.hh"
20
21#include "G4LogicalVolume.hh"
22#include "G4Step.hh"
23#include "G4StepPoint.hh"
24#include "G4String.hh"
25#include "G4Track.hh"
26#include "G4Types.hh"
27#include "G4VPhysicalVolume.hh"
28
29#include <algorithm>
30#include <vector>
31
33 const std::vector<G4Material*>& materialsIn,
34 G4bool inclusiveIn):
35 G4VSDFilter(name),
36 materials(materialsIn),
37 inclusive(inclusiveIn)
38{;}
39
40BDSSDFilterMaterial::~BDSSDFilterMaterial()
41{;}
42
43G4bool BDSSDFilterMaterial::Accept(const G4Step* aStep) const
44{
45 // get the step in the mass world
46 const G4Step* realWorldStep = aStep->GetTrack()->GetStep();
47
48 // get the material of the logical volume
49 G4LogicalVolume* stepLV = realWorldStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
50 G4Material* stepMaterial = stepLV->GetMaterial();
51
52 G4bool found = std::find(materials.begin(), materials.end(), stepMaterial) != materials.end();
53 return inclusive ? found : !found;
54}
virtual G4bool Accept(const G4Step *aStep) const
Whether the step will be accepted or rejected.
BDSSDFilterMaterial(const G4String &name, const std::vector< G4Material * > &materialsIn, G4bool inclusiveIn)