Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4SDParticleFilter.cc
이 파일의 문서화 페이지로 가기
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 // $Id: G4SDParticleFilter.cc 67992 2013-03-13 10:59:57Z gcosmo $
28 //
29 // G4VSensitiveDetector
30 #include "G4SDParticleFilter.hh"
31 #include "G4Step.hh"
32 #include "G4ParticleTable.hh"
33 #include "G4ParticleDefinition.hh"
34 
36 // class description:
37 //
38 // This is the class of a filter to be associated with a
39 // sensitive detector.
40 // This class filters steps by partilce definition.
41 //
42 // Created: 2005-11-14 Tsukasa ASO.
43 //
45 
47  :G4VSDFilter(name)
48 {
49  thePdef.clear();
50  theIonZ.clear();
51  theIonA.clear();
52 }
53 
55  const G4String& particleName)
56  :G4VSDFilter(name)
57 {
58  thePdef.clear();
60  if(!pd)
61  {
62  G4String msg = "Particle <";
63  msg += particleName;
64  msg += "> not found.";
65  G4Exception("G4SDParticleFilter::G4SDParticleFilter",
66  "DetPS0101",FatalException,msg);
67  }
68  thePdef.push_back(pd);
69  theIonZ.clear();
70  theIonA.clear();
71 }
72 
74  const std::vector<G4String>& particleNames)
75  :G4VSDFilter(name)
76 {
77  thePdef.clear();
78  for ( size_t i = 0; i < particleNames.size(); i++){
80  if(!pd)
81  {
82  G4String msg = "Particle <";
83  msg += particleNames[i];
84  msg += "> not found.";
85  G4Exception("G4SDParticleFilter::G4SDParticleFilter",
86  "DetPS0102",FatalException,msg);
87  }
88  thePdef.push_back(pd);
89  theIonZ.clear();
90  theIonA.clear();
91  }
92 }
93 
95  const std::vector<G4ParticleDefinition*>& particleDef)
96  :G4VSDFilter(name), thePdef(particleDef)
97 {
98  for ( size_t i = 0; i < particleDef.size(); i++){
99  if(!particleDef[i]) G4Exception("G4SDParticleFilter::G4SDParticleFilter",
100  "DetPS0103",FatalException,
101  "NULL pointer is found in the given particleDef vector.");
102  }
103  theIonZ.clear();
104  theIonA.clear();
105 }
106 
108 {
109  thePdef.clear();
110  theIonZ.clear();
111  theIonA.clear();
112  }
113 
115 {
116 
117  for ( size_t i = 0; i < thePdef.size(); i++){
118  if ( thePdef[i] == aStep->GetTrack()->GetDefinition() ) return TRUE;
119  }
120 
121  // Ions by Z,A
122  for ( size_t i = 0; i < theIonZ.size(); i++){
123  if ( theIonZ[i] == aStep->GetTrack()->GetDefinition()->GetAtomicNumber()
124  && theIonA[i] == aStep->GetTrack()->GetDefinition()->GetAtomicMass() ){
125  return TRUE;
126  }
127  }
128 
129  return FALSE;
130 }
131 
132 void G4SDParticleFilter::add(const G4String& particleName)
133 {
134  G4ParticleDefinition* pd =
136  if(!pd)
137  {
138  G4String msg = "Particle <";
139  msg += particleName;
140  msg += "> not found.";
141  G4Exception("G4SDParticleFilter::add()",
142  "DetPS0104",FatalException,msg);
143  }
144  for ( size_t i = 0; i < thePdef.size(); i++){
145  if ( thePdef[i] == pd ) return;
146  }
147  thePdef.push_back(pd);
148 }
149 
151  for ( size_t i = 0; i < theIonZ.size(); i++){
152  if ( theIonZ[i] == Z && theIonA[i] == A ){
153  G4cout << "G4SDParticleFilter:: Ion has been already registered."<<G4endl;
154  return;
155  }
156  }
157  theIonZ.push_back(Z);
158  theIonA.push_back(A);
159 }
160 
162  G4cout << "----G4SDParticleFileter particle list------"<<G4endl;
163  for ( size_t i = 0; i < thePdef.size(); i++){
164  G4cout << thePdef[i]->GetParticleName() << G4endl;
165  }
166  for ( size_t i = 0; i < theIonZ.size(); i++){
167  G4cout << " Ion PrtclDef (" << theIonZ[i]<<","<<theIonA[i]<<")"
168  << G4endl;
169  }
170  G4cout << "-------------------------------------------"<<G4endl;
171 }
172 
173 
174 
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
const XML_Char * name
Definition: expat.h:151
G4int GetAtomicNumber() const
static G4ParticleTable * GetParticleTable()
#define G4endl
Definition: G4ios.hh:61
std::vector< G4int > theIonA
G4ParticleDefinition * GetDefinition() const
Float_t Z
bool G4bool
Definition: G4Types.hh:79
void add(const G4String &particleName)
std::vector< G4int > theIonZ
#define FALSE
Definition: globals.hh:52
double A(double temperature)
G4Track * GetTrack() const
#define TRUE
Definition: globals.hh:55
Definition: G4Step.hh:76
G4SDParticleFilter(G4String name)
virtual G4bool Accept(const G4Step *) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
G4int GetAtomicMass() const
G4GLOB_DLL std::ostream G4cout
std::vector< G4ParticleDefinition * > thePdef
void addIon(G4int Z, G4int A)