Geant4
v4-10.4-release
메인 페이지
관련된 페이지
모듈
네임스페이스
클래스
파일들
파일 목록
파일 멤버
모두
클래스
네임스페이스들
파일들
함수
변수
타입정의
열거형 타입
열거형 멤버
Friends
매크로
그룹들
페이지들
source
visualization
modeling
src
G4TrajectoryChargeFilter.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
// $Id: G4TrajectoryChargeFilter.cc 66373 2012-12-18 09:41:34Z gcosmo $
27
//
28
// Filter trajectories according to charge. Only registered
29
// charges will pass the filter.
30
//
31
// Jane Tinslay May 2006
32
//
33
#include "
G4TrajectoryChargeFilter.hh
"
34
#include <sstream>
35
36
G4TrajectoryChargeFilter::G4TrajectoryChargeFilter
(
const
G4String
&
name
)
37
:
G4SmartFilter
<
G4VTrajectory
>(name)
38
{}
39
40
G4TrajectoryChargeFilter::~G4TrajectoryChargeFilter
() {}
41
42
bool
43
G4TrajectoryChargeFilter::Evaluate
(
const
G4VTrajectory
& traj)
const
44
{
45
G4double
charge = traj.
GetCharge
();
46
47
if
(
GetVerbose
())
G4cout
<<
"G4TrajectoryChargeFilter processing trajectory with charge: "
<<charge<<
G4endl
;
48
49
MyCharge
myCharge;
50
51
if
(charge>0.) myCharge =
Positive
;
52
else
if
(charge<0.) myCharge =
Negative
;
53
else
myCharge =
Neutral
;
54
55
std::vector<MyCharge>::const_iterator iter = std::find(
fCharges
.begin(),
fCharges
.end(), myCharge);
56
57
// Fail if charge not registered
58
if
(iter ==
fCharges
.end())
return
false
;
59
60
return
true
;
61
}
62
63
void
64
G4TrajectoryChargeFilter::Add
(
const
G4String
& charge)
65
{
66
MyCharge
myCharge;
67
68
if
(!
ConvertToCharge
(charge, myCharge)) {
69
G4ExceptionDescription
ed;
70
ed <<
"Invalid charge "
<<charge;
71
G4Exception
72
(
"G4TrajectoryChargeFilter::Add(const G4String& charge)"
,
73
"modeling0115"
,
JustWarning
, ed);
74
return
;
75
}
76
77
return
Add
(myCharge);
78
}
79
80
void
81
G4TrajectoryChargeFilter::Add
(
const
MyCharge
& charge)
82
{
83
fCharges
.push_back(charge);
84
}
85
86
void
87
G4TrajectoryChargeFilter::Print
(std::ostream& ostr)
const
88
{
89
ostr<<
"Charges registered: "
<<
G4endl
;
90
std::vector<MyCharge>::const_iterator iter =
fCharges
.begin();
91
92
while
(iter !=
fCharges
.end()) {
93
ostr<<*iter<<
G4endl
;
94
iter++;
95
}
96
}
97
98
void
99
G4TrajectoryChargeFilter::Clear
()
100
{
101
// Clear registered charge vector
102
fCharges
.clear();
103
}
104
105
G4bool
106
G4TrajectoryChargeFilter::ConvertToCharge
(
const
G4String
&
string
,
MyCharge
& myCharge)
107
{
108
bool
result
(
true
);
109
110
G4int
charge;
111
std::istringstream is(
string
.c_str());
112
is >> charge;
113
114
switch
(charge) {
115
case
1:
116
myCharge =
G4TrajectoryChargeFilter::Positive
;
117
break
;
118
case
0:
119
myCharge =
G4TrajectoryChargeFilter::Neutral
;
120
break
;
121
case
-1:
122
myCharge =
G4TrajectoryChargeFilter::Negative
;
123
break
;
124
default
:
125
result =
false
;
126
}
127
128
return
result
;
129
}
name
const XML_Char * name
Definition:
expat.h:151
G4SmartFilter< G4VTrajectory >::GetVerbose
G4bool GetVerbose() const
G4ExceptionDescription
std::ostringstream G4ExceptionDescription
Definition:
G4Exception.hh:45
G4TrajectoryChargeFilter::Neutral
Definition:
G4TrajectoryChargeFilter.hh:63
G4endl
#define G4endl
Definition:
G4ios.hh:61
G4TrajectoryChargeFilter::Add
void Add(const G4String &particle)
Definition:
G4TrajectoryChargeFilter.cc:64
G4String
Definition:
examples/extended/parallel/TopC/ParN02/AnnotatedFiles/G4String.hh:45
G4TrajectoryChargeFilter::Evaluate
virtual bool Evaluate(const G4VTrajectory &) const
Definition:
G4TrajectoryChargeFilter.cc:43
G4SmartFilter
Definition:
G4SmartFilter.hh:39
G4TrajectoryChargeFilter.hh
JustWarning
Definition:
G4ExceptionSeverity.hh:64
G4double
double G4double
Definition:
G4Types.hh:76
G4bool
bool G4bool
Definition:
G4Types.hh:79
G4VTrajectory::GetCharge
virtual G4double GetCharge() const =0
G4TrajectoryChargeFilter::Print
virtual void Print(std::ostream &ostr) const
Definition:
G4TrajectoryChargeFilter.cc:87
G4TrajectoryChargeFilter::ConvertToCharge
G4bool ConvertToCharge(const G4String &, MyCharge &)
Definition:
G4TrajectoryChargeFilter.cc:106
result
G4double G4ParticleHPJENDLHEData::G4double result
Definition:
G4ParticleHPJENDLHEData.cc:257
G4TrajectoryChargeFilter::MyCharge
MyCharge
Definition:
G4TrajectoryChargeFilter.hh:63
G4Exception
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition:
G4Exception.hh:65
G4int
int G4int
Definition:
G4Types.hh:78
G4TrajectoryChargeFilter::G4TrajectoryChargeFilter
G4TrajectoryChargeFilter(const G4String &name="Unspecified")
Definition:
G4TrajectoryChargeFilter.cc:36
G4TrajectoryChargeFilter::Negative
Definition:
G4TrajectoryChargeFilter.hh:63
G4cout
G4GLOB_DLL std::ostream G4cout
G4VTrajectory
Definition:
G4VTrajectory.hh:57
G4TrajectoryChargeFilter::~G4TrajectoryChargeFilter
virtual ~G4TrajectoryChargeFilter()
Definition:
G4TrajectoryChargeFilter.cc:40
G4TrajectoryChargeFilter::Positive
Definition:
G4TrajectoryChargeFilter.hh:63
G4TrajectoryChargeFilter::fCharges
std::vector< MyCharge > fCharges
Definition:
G4TrajectoryChargeFilter.hh:70
G4TrajectoryChargeFilter::Clear
virtual void Clear()
Definition:
G4TrajectoryChargeFilter.cc:99
다음에 의해 생성됨 :
1.8.5