Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4StokesVector.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: G4StokesVector.cc 108422 2018-02-13 11:17:20Z gcosmo $
27 //
28 // GEANT4 Class file
29 //
30 //
31 // File name: G4StokesVector
32 //
33 // Author: Andreas Schaelicke
34 //
35 // Creation date: 01.05.2005
36 //
37 // Modifications:
38 //
39 // Class Description:
40 //
41 // Provides Stokesvector representation employed in polarized
42 // processes.
43 //
44 #include "G4StokesVector.hh"
45 #include "G4PolarizationHelper.hh"
46 #include "G4PhysicalConstants.hh"
47 #include "Randomize.hh"
48 
56 
58  : G4ThreeVector(),isPhoton(false)
59 {
60 }
61 
63  : G4ThreeVector(v),isPhoton(false)
64 {
65 }
66 
68 {
69  return *this==ZERO;
70 }
71 
72 void G4StokesVector::RotateAz(G4ThreeVector nInteractionFrame,
73  G4ThreeVector particleDirection)
74 {
75  G4ThreeVector yParticleFrame =
76  G4PolarizationHelper::GetParticleFrameY(particleDirection);
77 
78 
79  G4double cosphi=yParticleFrame*nInteractionFrame;
80  if (cosphi>(1.+1.e-8) || cosphi<(-1.-1.e-8)) {
81  G4cout<<" warning G4StokesVector::RotateAz cosphi>1 or cosphi<-1\n"
82  <<" cosphi="<<cosphi<<"\n"
83  <<" zAxis="<<particleDirection<<" ("<<particleDirection.mag()<<")\n"
84  <<" yAxis="<<yParticleFrame<<" ("<<yParticleFrame.mag()<<")\n"
85  <<" nAxis="<<nInteractionFrame<<" ("
86  <<nInteractionFrame.mag()<<")"<<G4endl;
87  }
88  if (cosphi>1.) cosphi=1.;
89  else if (cosphi<-1.) cosphi=-1.;
90 
91 // G4cout<<" cosphi="<<cosphi<<"\n"
92 // <<" zAxis="<<particleDirection<<" ("<<particleDirection.mag()<<")\n"
93 // <<" yAxis="<<yParticleFrame<<" ("<<yParticleFrame.mag()<<","<<(yParticleFrame*particleDirection)<<")\n"
94 // <<" nAxis="<<nInteractionFrame<<" ("
95 // <<nInteractionFrame.mag()<<")"<<G4endl;
96 
97  // G4double hel=sgn(cross(yParticleFrame*nInteractionFrame)*zInteractionFrame);
98  // Why not particleDirection instead of zInteractionFrame ???!!!
99  // -> is the same, since SYSIN is called with p1, and p2 as first parameter!
100  G4double hel=(yParticleFrame.cross(nInteractionFrame)*particleDirection)>0?1.:-1.;
101 
102  G4double sinphi=hel*std::sqrt(1.-cosphi*cosphi);
103  // G4cout<<" sin2 + cos2 -1 = "<<(sinphi*sinphi+cosphi*cosphi-1)<<"\n";
104 
105  RotateAz(cosphi,sinphi);
106 }
107 
108 
110  G4ThreeVector particleDirection)
111 {
112  // note if incomming particle is on z-axis,
113  // we might encounter some nummerical problems, since
114  // nInteratonFrame and yParticleFrame are actually (almost) the same momentum
115  // and the normalization is only good to 10^-12 !
116 
117  G4ThreeVector yParticleFrame =
118  G4PolarizationHelper::GetParticleFrameY(particleDirection);
119  G4double cosphi=yParticleFrame*nInteractionFrame;
120 
121  if (cosphi>1.+1.e-8 || cosphi<-1.-1.e-8) {
122  G4cout<<" warning G4StokesVector::RotateAz cosphi>1 or cosphi<-1\n";
123  }
124  if (cosphi>1.) cosphi=1.;
125  else if (cosphi<-1.)cosphi=-1.;
126 
127  // check sign once more!
128  G4double hel=(yParticleFrame.cross(nInteractionFrame)*particleDirection)>0?1.:-1.;
129  G4double sinphi=hel*std::sqrt(std::fabs(1.-cosphi*cosphi));
130  RotateAz(cosphi,-sinphi);
131 }
132 
134 {
135  if (!isPhoton) {
136  G4double xsi1= cosphi*p1() + sinphi*p2();
137  G4double xsi2= -sinphi*p1() + cosphi*p2();
138  setX(xsi1);
139  setY(xsi2);
140  return;
141  }
142 
143  G4double sin2phi=2.*cosphi*sinphi;
144  G4double cos2phi=cosphi*cosphi-sinphi*sinphi;
145 
146  G4double xsi1= cos2phi*p1() + sin2phi*p2();
147  G4double xsi2= -sin2phi*p1() + cos2phi*p2();
148  setX(xsi1);
149  setY(xsi2);
150 }
151 
153 {
154  G4double bet=getPhi();
155  if (isPhoton) { bet *= 0.5; }
156  return bet;
157 }
158 
160 {
161  G4double costheta=2.*G4UniformRand()-1.;
162  G4double sintheta=std::sqrt(1.-costheta*costheta);
163  G4double aphi =2.*pi*G4UniformRand();
164  setX(std::sin(aphi)*sintheta);
165  setY(std::cos(aphi)*sintheta);
166  setZ(costheta);
167 }
168 
170 {
171  if (G4UniformRand()>0.5) setX(1.);
172  else setX(-1.);
173  setY(0.);
174  setZ(0.);
175 }
176 
178 {
179  setX(0.);
180  if (G4UniformRand()>0.5) setY(1.);
181  else setY(-1.);
182  setZ(0.);
183 }
184 
186 {
187  setX(0.);
188  setY(0.);
189  if (G4UniformRand()>0.5) setZ(1.);
190  else setZ(-1.);
191 }
192 
194 {
195  setZ(-z());
196 }
197 
199 {
200  // delta x = sqrt[ ( <x^2> - <x>^2 )/(n-1) ]
201  G4StokesVector mean=(1./n)*(*this);
202  return G4StokesVector((1./(n-1.)*((1./n)*sum2 - mean.PolSqr()))).PolSqrt();
203 }
204 
206  {return G4ThreeVector(b.x()!=0. ? x()/b.x() : 11111.,
207  b.y()!=0. ? y()/b.y() : 11111.,
208  b.z()!=0. ? z()/b.z() : 11111.);}
G4bool IsZero() const
static const G4StokesVector M1
CLHEP::Hep3Vector G4ThreeVector
static const G4StokesVector P2
G4double GetBeta()
static const G4StokesVector M2
static G4ThreeVector GetParticleFrameY(const G4ThreeVector &)
#define G4endl
Definition: G4ios.hh:61
double getPhi() const
double z() const
G4double p1() const
void setX(double)
G4ThreeVector PolSqr() const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4ThreeVector PolError(const G4StokesVector &sum2, long n)
void setZ(double)
static const G4StokesVector P3
void InvRotateAz(G4ThreeVector nInteractionFrame, G4ThreeVector particleDirection)
#define G4UniformRand()
Definition: Randomize.hh:53
void RotateAz(G4ThreeVector nInteractionFrame, G4ThreeVector particleDirection)
G4ThreeVector PolDiv(const G4StokesVector &)
static const G4StokesVector M3
G4bool isPhoton(G4int ityp)
Hep3Vector cross(const Hep3Vector &) const
static const G4StokesVector ZERO
double mag() const
G4ThreeVector PolSqrt() const
G4GLOB_DLL std::ostream G4cout
double x() const
static const G4StokesVector P1
G4double p2() const
Char_t n[5]
static constexpr double pi
Definition: G4SIunits.hh:75
double y() const
void setY(double)