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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/polarisation/src/G4StokesVector.cc (Version 11.3.0) and /processes/electromagnetic/polarisation/src/G4StokesVector.cc (Version 2.0)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // Geant4 Class file                              
 27 //                                                
 28 // File name:     G4StokesVector                  
 29 //                                                
 30 // Author:        Andreas Schaelicke              
 31 //                                                
 32 // Class Description:                             
 33 //   Provides Stokes vector representation emp    
 34                                                   
 35 #include "G4StokesVector.hh"                      
 36                                                   
 37 #include "G4PolarizationHelper.hh"                
 38 #include "Randomize.hh"                           
 39                                                   
 40 const G4StokesVector G4StokesVector::ZERO =       
 41   G4StokesVector(G4ThreeVector(0., 0., 0.));      
 42 const G4StokesVector G4StokesVector::P1 =         
 43   G4StokesVector(G4ThreeVector(1., 0., 0.));      
 44 const G4StokesVector G4StokesVector::P2 =         
 45   G4StokesVector(G4ThreeVector(0., 1., 0.));      
 46 const G4StokesVector G4StokesVector::P3 =         
 47   G4StokesVector(G4ThreeVector(0., 0., 1.));      
 48 const G4StokesVector G4StokesVector::M1 =         
 49   G4StokesVector(G4ThreeVector(-1., 0., 0.));     
 50 const G4StokesVector G4StokesVector::M2 =         
 51   G4StokesVector(G4ThreeVector(0., -1., 0.));     
 52 const G4StokesVector G4StokesVector::M3 =         
 53   G4StokesVector(G4ThreeVector(0., 0., -1.));     
 54                                                   
 55 G4StokesVector::G4StokesVector()                  
 56   : G4ThreeVector()                               
 57   , fIsPhoton(false)                              
 58 {}                                                
 59                                                   
 60 G4StokesVector::G4StokesVector(const G4ThreeVe    
 61   : G4ThreeVector(v)                              
 62   , fIsPhoton(false)                              
 63 {}                                                
 64                                                   
 65 G4bool G4StokesVector::IsZero() const { return    
 66                                                   
 67 void G4StokesVector::RotateAz(G4ThreeVector nI    
 68                               G4ThreeVector pa    
 69 {                                                 
 70   G4ThreeVector yParticleFrame =                  
 71     G4PolarizationHelper::GetParticleFrameY(pa    
 72                                                   
 73   G4double cosphi = yParticleFrame * nInteract    
 74   if(cosphi > (1. + 1.e-8) || cosphi < (-1. -     
 75   {                                               
 76     G4ExceptionDescription ed;                    
 77     ed << " warning G4StokesVector::RotateAz      
 78        << " cosphi=" << cosphi << "\n"            
 79        << " zAxis=" << particleDirection << "     
 80        << ")\n"                                   
 81        << " yAxis=" << yParticleFrame << " ("     
 82        << " nAxis=" << nInteractionFrame << "     
 83        << ")\n";                                  
 84     G4Exception("G4StokesVector::RotateAz", "p    
 85   }                                               
 86   if(cosphi > 1.)                                 
 87     cosphi = 1.;                                  
 88   else if(cosphi < -1.)                           
 89     cosphi = -1.;                                 
 90                                                   
 91   G4double hel =                                  
 92     (yParticleFrame.cross(nInteractionFrame) *    
 93                                                   
 94                                                   
 95   G4double sinphi = hel * std::sqrt(1. - cosph    
 96                                                   
 97   RotateAz(cosphi, sinphi);                       
 98 }                                                 
 99                                                   
100 void G4StokesVector::InvRotateAz(G4ThreeVector    
101                                  G4ThreeVector    
102 {                                                 
103   // note if incoming particle is on z-axis,      
104   // we might encounter some nummerical proble    
105   // nInteratonFrame and yParticleFrame are ac    
106   // and the normalization is only good to 10^    
107                                                   
108   G4ThreeVector yParticleFrame =                  
109     G4PolarizationHelper::GetParticleFrameY(pa    
110   G4double cosphi = yParticleFrame * nInteract    
111                                                   
112   if(cosphi > 1. + 1.e-8 || cosphi < -1. - 1.e    
113   {                                               
114     G4ExceptionDescription ed;                    
115     ed << " warning G4StokesVector::RotateAz      
116     G4Exception("G4StokesVector::InvRotateAz",    
117   }                                               
118   if(cosphi > 1.)                                 
119     cosphi = 1.;                                  
120   else if(cosphi < -1.)                           
121     cosphi = -1.;                                 
122                                                   
123   // check sign once more!                        
124   G4double hel =                                  
125     (yParticleFrame.cross(nInteractionFrame) *    
126                                                   
127   G4double sinphi = hel * std::sqrt(std::fabs(    
128   RotateAz(cosphi, -sinphi);                      
129 }                                                 
130                                                   
131 void G4StokesVector::RotateAz(G4double cosphi,    
132 {                                                 
133   if(!fIsPhoton)                                  
134   {                                               
135     G4double xsi1 = cosphi * p1() + sinphi * p    
136     G4double xsi2 = -sinphi * p1() + cosphi *     
137     setX(xsi1);                                   
138     setY(xsi2);                                   
139     return;                                       
140   }                                               
141                                                   
142   G4double sin2phi = 2. * cosphi * sinphi;        
143   G4double cos2phi = cosphi * cosphi - sinphi     
144                                                   
145   G4double xsi1 = cos2phi * p1() + sin2phi * p    
146   G4double xsi2 = -sin2phi * p1() + cos2phi *     
147   setX(xsi1);                                     
148   setY(xsi2);                                     
149 }                                                 
150                                                   
151 G4double G4StokesVector::GetBeta()                
152 {                                                 
153   G4double bet = getPhi();                        
154   if(fIsPhoton)                                   
155   {                                               
156     bet *= 0.5;                                   
157   }                                               
158   return bet;                                     
159 }                                                 
160                                                   
161 void G4StokesVector::DiceUniform()                
162 {                                                 
163   G4double costheta = 2. * G4UniformRand() - 1    
164   G4double sintheta = std::sqrt(1. - costheta     
165   G4double aphi     = 2. * CLHEP::pi * G4Unifo    
166   setX(std::sin(aphi) * sintheta);                
167   setY(std::cos(aphi) * sintheta);                
168   setZ(costheta);                                 
169 }                                                 
170                                                   
171 void G4StokesVector::DiceP1()                     
172 {                                                 
173   if(G4UniformRand() > 0.5)                       
174     setX(1.);                                     
175   else                                            
176     setX(-1.);                                    
177   setY(0.);                                       
178   setZ(0.);                                       
179 }                                                 
180                                                   
181 void G4StokesVector::DiceP2()                     
182 {                                                 
183   setX(0.);                                       
184   if(G4UniformRand() > 0.5)                       
185     setY(1.);                                     
186   else                                            
187     setY(-1.);                                    
188   setZ(0.);                                       
189 }                                                 
190                                                   
191 void G4StokesVector::DiceP3()                     
192 {                                                 
193   setX(0.);                                       
194   setY(0.);                                       
195   if(G4UniformRand() > 0.5)                       
196     setZ(1.);                                     
197   else                                            
198     setZ(-1.);                                    
199 }                                                 
200                                                   
201 void G4StokesVector::FlipP3() { setZ(-z()); }     
202                                                   
203 G4ThreeVector G4StokesVector::PolError(const G    
204 {                                                 
205   // delta x = sqrt[ ( <x^2> - <x>^2 )/(n-1) ]    
206   G4ThreeVector mean   = (1. / n) * G4ThreeVec    
207   G4ThreeVector polsqr = G4StokesVector(mean).    
208   G4ThreeVector result =                          
209     G4StokesVector((1. / (n - 1.) * ((1. / n)     
210   return result;                                  
211 }                                                 
212                                                   
213 G4ThreeVector G4StokesVector::PolDiv(const G4S    
214 {                                                 
215   return G4ThreeVector(b.x() != 0. ? x() / b.x    
216                        b.y() != 0. ? y() / b.y    
217                        b.z() != 0. ? z() / b.z    
218 }                                                 
219