Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SDParticleFilter.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28// G4VSensitiveDetector
29#include "G4SDParticleFilter.hh"
30#include "G4Step.hh"
31#include "G4ParticleTable.hh"
33
34////////////////////////////////////////////////////////////////////////////////
35// class description:
36//
37// This is the class of a filter to be associated with a
38// sensitive detector.
39// This class filters steps by partilce definition.
40//
41// Created: 2005-11-14 Tsukasa ASO.
42//
43///////////////////////////////////////////////////////////////////////////////
44
46 :G4VSDFilter(name)
47{
48 thePdef.clear();
49 theIonZ.clear();
50 theIonA.clear();
51}
52
54 const G4String& particleName)
55 :G4VSDFilter(name)
56{
57 thePdef.clear();
59 if(!pd)
60 {
61 G4String msg = "Particle <";
62 msg += particleName;
63 msg += "> not found.";
64 G4Exception("G4SDParticleFilter::G4SDParticleFilter",
65 "DetPS0101",FatalException,msg);
66 }
67 thePdef.push_back(pd);
68 theIonZ.clear();
69 theIonA.clear();
70}
71
73 const std::vector<G4String>& particleNames)
74 :G4VSDFilter(name)
75{
76 thePdef.clear();
77 for ( size_t i = 0; i < particleNames.size(); i++){
79 if(!pd)
80 {
81 G4String msg = "Particle <";
82 msg += particleNames[i];
83 msg += "> not found.";
84 G4Exception("G4SDParticleFilter::G4SDParticleFilter",
85 "DetPS0102",FatalException,msg);
86 }
87 thePdef.push_back(pd);
88 theIonZ.clear();
89 theIonA.clear();
90 }
91}
92
94 const std::vector<G4ParticleDefinition*>& particleDef)
95 :G4VSDFilter(name), thePdef(particleDef)
96{
97 for ( size_t i = 0; i < particleDef.size(); i++){
98 if(!particleDef[i]) G4Exception("G4SDParticleFilter::G4SDParticleFilter",
99 "DetPS0103",FatalException,
100 "NULL pointer is found in the given particleDef vector.");
101 }
102 theIonZ.clear();
103 theIonA.clear();
104}
105
107{
108 thePdef.clear();
109 theIonZ.clear();
110 theIonA.clear();
111 }
112
114{
115
116 for ( size_t i = 0; i < thePdef.size(); i++){
117 if ( thePdef[i] == aStep->GetTrack()->GetDefinition() ) return TRUE;
118 }
119
120 // Ions by Z,A
121 for ( size_t i = 0; i < theIonZ.size(); i++){
122 if ( theIonZ[i] == aStep->GetTrack()->GetDefinition()->GetAtomicNumber()
123 && theIonA[i] == aStep->GetTrack()->GetDefinition()->GetAtomicMass() ){
124 return TRUE;
125 }
126 }
127
128 return FALSE;
129}
130
131void G4SDParticleFilter::add(const G4String& particleName)
132{
135 if(!pd)
136 {
137 G4String msg = "Particle <";
138 msg += particleName;
139 msg += "> not found.";
140 G4Exception("G4SDParticleFilter::add()",
141 "DetPS0104",FatalException,msg);
142 }
143 for ( size_t i = 0; i < thePdef.size(); i++){
144 if ( thePdef[i] == pd ) return;
145 }
146 thePdef.push_back(pd);
147}
148
150 for ( size_t i = 0; i < theIonZ.size(); i++){
151 if ( theIonZ[i] == Z && theIonA[i] == A ){
152 G4cout << "G4SDParticleFilter:: Ion has been already registered."<<G4endl;
153 return;
154 }
155 }
156 theIonZ.push_back(Z);
157 theIonA.push_back(A);
158}
159
161 G4cout << "----G4SDParticleFileter particle list------"<<G4endl;
162 for ( size_t i = 0; i < thePdef.size(); i++){
163 G4cout << thePdef[i]->GetParticleName() << G4endl;
164 }
165 for ( size_t i = 0; i < theIonZ.size(); i++){
166 G4cout << " Ion PrtclDef (" << theIonZ[i]<<","<<theIonA[i]<<")"
167 << G4endl;
168 }
169 G4cout << "-------------------------------------------"<<G4endl;
170}
171
172
173
double A(double temperature)
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define TRUE
Definition: Globals.hh:27
#define FALSE
Definition: Globals.hh:23
G4int GetAtomicNumber() const
G4int GetAtomicMass() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
G4SDParticleFilter(G4String name)
void addIon(G4int Z, G4int A)
void add(const G4String &particleName)
virtual G4bool Accept(const G4Step *) const
Definition: G4Step.hh:62
G4Track * GetTrack() const
G4ParticleDefinition * GetDefinition() const