Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: G4PolarizedAnnihilationModel.cc,v 1.4 2006/11/17 14:14:20 vnivanch Exp $ >> 27 // GEANT4 tag $Name: geant4-08-03-patch-01 $ >> 28 // 26 // ------------------------------------------- 29 // ------------------------------------------------------------------- 27 // 30 // 28 // Geant4 Class file << 31 // GEANT4 Class file >> 32 // 29 // 33 // 30 // File name: G4PolarizedAnnihilationModel 34 // File name: G4PolarizedAnnihilationModel 31 // 35 // 32 // Author: Andreas Schaelicke 36 // Author: Andreas Schaelicke 33 // 37 // >> 38 // Creation date: 01.05.2005 >> 39 // >> 40 // Modifications: >> 41 // 18-07-06 use newly calculated cross sections (P. Starovoitov) >> 42 // 21-08-06 update interface (A. Schaelicke) >> 43 // 17-11-06 add protection agaist e+ zero energy PostStep (V.Ivanchenko) >> 44 // >> 45 // 34 // Class Description: 46 // Class Description: 35 // Implementation of polarized gamma Annihil << 47 // >> 48 // Implementation of polarized gamma Annihilation scattering on free electron >> 49 // 36 50 >> 51 // ------------------------------------------------------------------- 37 #include "G4PolarizedAnnihilationModel.hh" 52 #include "G4PolarizedAnnihilationModel.hh" 38 << 39 #include "G4Gamma.hh" << 40 #include "G4ParticleChangeForGamma.hh" << 41 #include "G4PhysicalConstants.hh" << 42 #include "G4PolarizationHelper.hh" << 43 #include "G4PolarizationManager.hh" 53 #include "G4PolarizationManager.hh" 44 #include "G4PolarizedAnnihilationXS.hh" << 54 #include "G4PolarizationHelper.hh" 45 #include "G4StokesVector.hh" 55 #include "G4StokesVector.hh" 46 #include "G4TrackStatus.hh" << 56 #include "G4PolarizedAnnihilationCrossSection.hh" >> 57 #include "G4ParticleChangeForGamma.hh" >> 58 #include "G4Gamma.hh" 47 59 48 G4PolarizedAnnihilationModel::G4PolarizedAnnih << 60 G4PolarizedAnnihilationModel::G4PolarizedAnnihilationModel(const G4ParticleDefinition* p, 49 const G4ParticleDefinition* p, const G4Strin << 61 const G4String& nam) 50 : G4eeToTwoGammaModel(p, nam) << 62 : G4eeToTwoGammaModel(p,nam),crossSectionCalculator(0) 51 , fCrossSectionCalculator(nullptr) << 52 , fParticleChange(nullptr) << 53 , fVerboseLevel(0) << 54 { 63 { 55 fCrossSectionCalculator = new G4PolarizedAn << 64 crossSectionCalculator=new G4PolarizedAnnihilationCrossSection(); 56 fBeamPolarization = G4StokesVector::Z << 57 fTargetPolarization = G4StokesVector::Z << 58 fFinalGamma1Polarization = G4StokesVector::Z << 59 fFinalGamma2Polarization = G4StokesVector::Z << 60 } 65 } 61 66 62 //....oooOO0OOooo........oooOO0OOooo........oo << 63 G4PolarizedAnnihilationModel::~G4PolarizedAnni 67 G4PolarizedAnnihilationModel::~G4PolarizedAnnihilationModel() 64 { 68 { 65 delete fCrossSectionCalculator; << 69 if (crossSectionCalculator) delete crossSectionCalculator; 66 } 70 } 67 71 68 //....oooOO0OOooo........oooOO0OOooo........oo << 69 void G4PolarizedAnnihilationModel::Initialise( << 70 << 71 { << 72 G4eeToTwoGammaModel::Initialise(part, dv); << 73 if(fParticleChange) << 74 { << 75 return; << 76 } << 77 fParticleChange = GetParticleChangeForGamma( << 78 } << 79 << 80 //....oooOO0OOooo........oooOO0OOooo........oo << 81 G4double G4PolarizedAnnihilationModel::Compute 72 G4double G4PolarizedAnnihilationModel::ComputeCrossSectionPerElectron( 82 G4double kinEnergy) << 73 const G4ParticleDefinition* pd, >> 74 G4double kinEnergy, >> 75 G4double cut, >> 76 G4double emax) 83 { 77 { 84 // cross section from base model << 78 G4double xs = G4eeToTwoGammaModel::ComputeCrossSectionPerElectron(pd,kinEnergy, 85 G4double xs = G4eeToTwoGammaModel::ComputeCr << 79 cut,emax); 86 80 87 G4double polzz = fBeamPolarization.z() * fTa << 81 G4double polzz = theBeamPolarization.z()*theTargetPolarization.z(); 88 G4double poltt = fBeamPolarization.x() * fTa << 82 G4double poltt = theBeamPolarization.x()*theTargetPolarization.x() 89 fBeamPolarization.y() * fTa << 83 + theBeamPolarization.y()*theTargetPolarization.y(); 90 if(polzz != 0 || poltt != 0) << 84 if (polzz!=0 || poltt!=0) { 91 { << 85 G4double xval,lasym,tasym; 92 G4double xval, lasym, tasym; << 86 ComputeAsymmetriesPerElectron(kinEnergy,xval,lasym,tasym); 93 ComputeAsymmetriesPerElectron(kinEnergy, x << 87 xs*=(1.+polzz*lasym+poltt*tasym); 94 xs *= (1. + polzz * lasym + poltt * tasym) << 95 } 88 } 96 89 97 return xs; 90 return xs; 98 } 91 } 99 92 100 //....oooOO0OOooo........oooOO0OOooo........oo << 93 void G4PolarizedAnnihilationModel::ComputeAsymmetriesPerElectron(G4double ene, 101 void G4PolarizedAnnihilationModel::ComputeAsym << 94 G4double & valueX, 102 G4double ene, G4double& valueX, G4double& va << 95 G4double & valueA, >> 96 G4double & valueT) 103 { 97 { 104 // *** calculate asymmetries 98 // *** calculate asymmetries 105 G4double gam = 1. + ene / electron_mass_c2; << 99 G4double gam = 1. + ene/electron_mass_c2; 106 G4double xs0 = fCrossSectionCalculator->Tota << 100 G4double xs0=crossSectionCalculator->TotalXSection(0.,1.,gam, 107 0., 1., gam, G4StokesVector::ZERO, G4Stoke << 101 G4StokesVector::ZERO, 108 G4double xsA = fCrossSectionCalculator->Tota << 102 G4StokesVector::ZERO); 109 0., 1., gam, G4StokesVector::P3, G4StokesV << 103 G4double xsA=crossSectionCalculator->TotalXSection(0.,1.,gam, 110 G4double xsT1 = fCrossSectionCalculator->Tot << 104 G4StokesVector::P3, 111 0., 1., gam, G4StokesVector::P1, G4StokesV << 105 G4StokesVector::P3); 112 G4double xsT2 = fCrossSectionCalculator->Tot << 106 G4double xsT1=crossSectionCalculator->TotalXSection(0.,1.,gam, 113 0., 1., gam, G4StokesVector::P2, G4StokesV << 107 G4StokesVector::P1, 114 G4double xsT = 0.5 * (xsT1 + xsT2); << 108 G4StokesVector::P1); 115 << 109 G4double xsT2=crossSectionCalculator->TotalXSection(0.,1.,gam, 116 valueX = xs0; << 110 G4StokesVector::P2, 117 valueA = xsA / xs0 - 1.; << 111 G4StokesVector::P2); 118 valueT = xsT / xs0 - 1.; << 112 G4double xsT=0.5*(xsT1+xsT2); 119 << 113 120 if((valueA < -1) || (1 < valueA)) << 114 valueX=xs0; 121 { << 115 valueA=xsA/xs0-1.; 122 G4ExceptionDescription ed; << 116 valueT=xsT/xs0-1.; 123 ed << " ERROR PolarizedAnnihilationPS::Com << 117 // G4cout<<valueX<<"\t"<<valueA<<"\t"<<valueT<<" energy = "<<gam<<G4endl; 124 ed << " something wrong in total cross sec << 118 if ( (valueA < -1) || (1 < valueA)) { 125 ed << " LONG: " << valueX << "\t" << value << 119 G4cout<< " ERROR PolarizedAnnihilationPS::ComputeAsymmetries \n"; 126 << " energy = " << gam << G4endl; << 120 G4cout<< " something wrong in total cross section calculation (valueA)\n"; 127 G4Exception("G4PolarizedAnnihilationModel: << 121 G4cout<<"*********** LONG "<<valueX<<"\t"<<valueA<<"\t"<<valueT<<" energy = "<<gam<<G4endl; 128 "pol004", JustWarning, ed); << 129 } 122 } 130 if((valueT < -1) || (1 < valueT)) << 123 if ( (valueT < -1) || (1 < valueT)) { 131 { << 124 G4cout<< " ERROR PolarizedAnnihilationPS::ComputeAsymmetries \n"; 132 G4ExceptionDescription ed; << 125 G4cout<< " something wrong in total cross section calculation (valueT)\n"; 133 ed << " ERROR PolarizedAnnihilationPS::Com << 126 G4cout<<"****** TRAN "<<valueX<<"\t"<<valueA<<"\t"<<valueT<<" energy = "<<gam<<G4endl; 134 ed << " something wrong in total cross sec << 135 ed << " TRAN: " << valueX << "\t" << value << 136 << " energy = " << gam << G4endl; << 137 G4Exception("G4PolarizedAnnihilationModel: << 138 "pol005", JustWarning, ed); << 139 } 127 } 140 } 128 } 141 129 142 void G4PolarizedAnnihilationModel::SampleSecon << 143 std::vector<G4DynamicParticle*>* fvect, cons << 144 const G4DynamicParticle* dp, G4double, G4dou << 145 { << 146 const G4Track* aTrack = fParticleChange->Get << 147 130 148 // kill primary << 131 149 fParticleChange->SetProposedKineticEnergy(0. << 132 150 fParticleChange->ProposeTrackStatus(fStopAnd << 133 std::vector<G4DynamicParticle*>* G4PolarizedAnnihilationModel::SampleSecondaries( >> 134 const G4MaterialCutsCouple* /*couple*/, >> 135 const G4DynamicParticle* dp, >> 136 G4double /*tmin*/, >> 137 G4double /*maxEnergy*/) >> 138 { >> 139 G4ParticleChangeForGamma* fParticleChange >> 140 = dynamic_cast<G4ParticleChangeForGamma*>(pParticleChange); >> 141 const G4Track * aTrack = fParticleChange->GetCurrentTrack(); 151 142 152 // V.Ivanchenko add protection against zero 143 // V.Ivanchenko add protection against zero kin energy >> 144 std::vector<G4DynamicParticle*>* fvect = new std::vector<G4DynamicParticle*>; 153 G4double PositKinEnergy = dp->GetKineticEner 145 G4double PositKinEnergy = dp->GetKineticEnergy(); 154 146 155 if(PositKinEnergy == 0.0) << 147 if(PositKinEnergy < DBL_MIN) { 156 { << 148 157 G4double cosTeta = 2. * G4UniformRand() - << 149 G4double cosTeta = 2.*G4UniformRand()-1.; 158 G4double sinTeta = std::sqrt((1.0 - cosTet << 150 G4double sinTeta = std::sqrt((1.0 - cosTeta)*(1.0 + cosTeta)); 159 G4double phi = twopi * G4UniformRand() 151 G4double phi = twopi * G4UniformRand(); 160 G4ThreeVector dir(sinTeta * std::cos(phi), << 152 G4ThreeVector dir(sinTeta*std::cos(phi), sinTeta*std::sin(phi), cosTeta); 161 cosTeta); << 153 fvect->push_back( new G4DynamicParticle(G4Gamma::Gamma(), dir, electron_mass_c2)); 162 fvect->push_back( << 154 fvect->push_back( new G4DynamicParticle(G4Gamma::Gamma(),-dir, electron_mass_c2)); 163 new G4DynamicParticle(G4Gamma::Gamma(), << 155 return fvect; 164 fvect->push_back( << 165 new G4DynamicParticle(G4Gamma::Gamma(), << 166 return; << 167 } 156 } 168 157 169 // *** obtain and save target and beam polar 158 // *** obtain and save target and beam polarization *** 170 G4PolarizationManager* polarizationManager = << 159 G4PolarizationManager * polarizationManager = G4PolarizationManager::GetInstance(); 171 G4PolarizationManager::GetInstance(); << 172 160 173 // obtain polarization of the beam 161 // obtain polarization of the beam 174 fBeamPolarization = G4StokesVector(aTrack->G << 162 theBeamPolarization = aTrack->GetPolarization(); 175 163 176 // obtain polarization of the media 164 // obtain polarization of the media 177 G4VPhysicalVolume* aPVolume = aTrack->Get << 165 G4VPhysicalVolume* aPVolume = aTrack->GetVolume(); 178 G4LogicalVolume* aLVolume = aPVolume->G << 166 G4LogicalVolume* aLVolume = aPVolume->GetLogicalVolume(); 179 const G4bool targetIsPolarized = polarizatio 167 const G4bool targetIsPolarized = polarizationManager->IsPolarized(aLVolume); 180 fTargetPolarization = polarizationManager->G << 168 theTargetPolarization = polarizationManager->GetVolumePolarization(aLVolume); 181 << 182 if(fVerboseLevel >= 1) << 183 { << 184 G4cout << "G4PolarizedComptonModel::Sample << 185 << aLVolume->GetName() << G4endl; << 186 } << 187 169 188 // transfer target electron polarization in 170 // transfer target electron polarization in frame of positron 189 if(targetIsPolarized) << 171 if (targetIsPolarized) 190 fTargetPolarization.rotateUz(dp->GetMoment << 172 theTargetPolarization.rotateUz(dp->GetMomentumDirection()); 191 << 173 192 G4ParticleMomentum PositDirection = dp->GetM 174 G4ParticleMomentum PositDirection = dp->GetMomentumDirection(); 193 175 194 // polar asymmetry: 176 // polar asymmetry: 195 G4double polarization = fBeamPolarization.p3 << 177 G4double polarization = theBeamPolarization.p3()*theTargetPolarization.p3(); 196 178 197 G4double gamam1 = PositKinEnergy / electron_ << 179 G4double gamam1 = PositKinEnergy/electron_mass_c2; 198 G4double gama = gamam1 + 1., gamap1 = gamam1 << 180 G4double gama = gamam1+1. , gamap1 = gamam1+2.; 199 G4double sqgrate = std::sqrt(gamam1 / gamap1 << 181 G4double sqgrate = std::sqrt(gamam1/gamap1)/2. , sqg2m1 = std::sqrt(gamam1*gamap1); 200 sqg2m1 = std::sqrt(gamam1 * gamap1 << 201 182 202 // limits of the energy sampling 183 // limits of the energy sampling 203 G4double epsilmin = 0.5 - sqgrate, epsilmax << 184 G4double epsilmin = 0.5 - sqgrate , epsilmax = 0.5 + sqgrate; 204 G4double epsilqot = epsilmax / epsilmin; << 185 G4double epsilqot = epsilmax/epsilmin; 205 << 186 206 // sample the energy rate of the created gam << 187 // 207 // note: for polarized partices, the actual << 188 // sample the energy rate of the created gammas >> 189 // note: for polarized partices, the actual dicing strategy 208 // will depend on the energy, and the 190 // will depend on the energy, and the degree of polarization !! >> 191 // 209 G4double epsil; 192 G4double epsil; 210 G4double gmax = 1. + std::fabs(polarization) << 193 G4double gmax=1. + std::fabs(polarization); // crude estimate >> 194 >> 195 G4bool check_range=true; 211 196 212 fCrossSectionCalculator->Initialize(epsilmin << 197 crossSectionCalculator->Initialize(epsilmin, gama, 0., theBeamPolarization, theTargetPolarization); 213 fTargetP << 198 if (crossSectionCalculator->DiceEpsilon()<0) { 214 if(fCrossSectionCalculator->DiceEpsilon() < << 199 G4cout<<"ERROR in PolarizedAnnihilationPS::PostStepDoIt\n" 215 { << 200 <<"epsilmin DiceRoutine not appropriate ! "<<crossSectionCalculator->DiceEpsilon()<<G4endl; 216 G4ExceptionDescription ed; << 201 check_range=false; 217 ed << "ERROR in PolarizedAnnihilationPS::P << 218 << "epsilmin DiceRoutine not appropriat << 219 << fCrossSectionCalculator->DiceEpsilon << 220 G4Exception("G4PolarizedAnnihilationModel: << 221 JustWarning, ed); << 222 } 202 } 223 203 224 fCrossSectionCalculator->Initialize(epsilmax << 204 crossSectionCalculator->Initialize(epsilmax, gama, 0., theBeamPolarization, theTargetPolarization); 225 fTargetP << 205 if (crossSectionCalculator->DiceEpsilon()<0) { 226 if(fCrossSectionCalculator->DiceEpsilon() < << 206 G4cout<<"ERROR in PolarizedAnnihilationPS::PostStepDoIt\n" 227 { << 207 <<"epsilmax DiceRoutine not appropriate ! "<<crossSectionCalculator->DiceEpsilon()<<G4endl; 228 G4ExceptionDescription ed; << 208 check_range=false; 229 ed << "ERROR in PolarizedAnnihilationPS::P << 230 << "epsilmax DiceRoutine not appropriat << 231 << fCrossSectionCalculator->DiceEpsilon << 232 G4Exception("G4PolarizedAnnihilationModel: << 233 JustWarning, ed); << 234 } 209 } 235 210 236 G4int ncount = 0; << 211 G4int ncount=0; 237 G4double trejectmax = 0.; << 212 G4double trejectmax=0.; 238 G4double treject; 213 G4double treject; 239 214 240 do << 215 241 { << 216 do { 242 epsil = epsilmin * std::pow(epsilqot, G4Un << 217 // 243 << 218 epsil = epsilmin*std::pow(epsilqot,G4UniformRand()); 244 fCrossSectionCalculator->Initialize(epsil, << 219 245 fTarge << 220 crossSectionCalculator->Initialize(epsil, gama, 0., theBeamPolarization, theTargetPolarization,1); 246 << 221 247 treject = fCrossSectionCalculator->DiceEps << 222 treject = crossSectionCalculator->DiceEpsilon(); 248 treject *= epsil; << 223 treject*=epsil; 249 << 224 250 if(treject > gmax || treject < 0.) << 225 if (treject>gmax || treject<0.) 251 { << 226 G4cout<<"ERROR in PolarizedAnnihilationPS::PostStepDoIt\n" 252 G4ExceptionDescription ed; << 227 <<" eps ("<<epsil<<") rejection does not work properly: "<<treject<<G4endl; 253 ed << "ERROR in PolarizedAnnihilationPS: << 254 << " eps (" << epsil << 255 << ") rejection does not work properl << 256 G4Exception("G4PolarizedAnnihilationMode << 257 JustWarning, ed); << 258 } << 259 ++ncount; 228 ++ncount; 260 if(treject > trejectmax) << 229 if (treject>trejectmax) trejectmax=treject; 261 trejectmax = treject; << 230 if (ncount>1000) { 262 if(ncount > 1000) << 231 G4cout<<"WARNING in PolarizedAnnihilationPS::PostStepDoIt\n" 263 { << 232 <<"eps dicing very inefficient ="<<trejectmax/gmax 264 G4ExceptionDescription ed; << 233 <<", "<<treject/gmax<<". For secondary energy = "<<epsil<<" "<<ncount<<G4endl; 265 ed << "WARNING in PolarizedAnnihilation << 266 << "eps dicing very inefficient =" << << 267 << treject / gmax << ". For secondar << 268 << ncount << G4endl; << 269 G4Exception("G4PolarizedAnnihilationMode << 270 JustWarning, ed); << 271 break; 234 break; 272 } 235 } 273 236 274 // Loop checking, 03-Aug-2015, Vladimir Iv << 237 } while( treject < gmax*G4UniformRand() ); 275 } while(treject < gmax * G4UniformRand()); << 276 238 >> 239 // 277 // scattered Gamma angles. ( Z - axis along 240 // scattered Gamma angles. ( Z - axis along the parent positron) 278 G4double cost = (epsil * gamap1 - 1.) / (eps << 241 // 279 G4double sint = std::sqrt((1. + cost) * (1. << 242 >> 243 G4double cost = (epsil*gamap1-1.)/(epsil*sqg2m1); >> 244 G4double sint = std::sqrt((1.+cost)*(1.-cost)); 280 G4double phi = 0.; 245 G4double phi = 0.; 281 G4double beamTrans = << 246 G4double beamTrans = std::sqrt(sqr(theBeamPolarization.p1()) + sqr(theBeamPolarization.p2())); 282 std::sqrt(sqr(fBeamPolarization.p1()) + sq << 247 G4double targetTrans = std::sqrt(sqr(theTargetPolarization.p1()) + sqr(theTargetPolarization.p2())); 283 G4double targetTrans = << 284 std::sqrt(sqr(fTargetPolarization.p1()) + << 285 << 286 do << 287 { << 288 phi = twopi * G4UniformRand(); << 289 fCrossSectionCalculator->Initialize(epsil, << 290 fTarge << 291 << 292 G4double gdiced = fCrossSectionCalculator- << 293 gdiced += fCrossSectionCalculator->getVar( << 294 fTargetPolarization.p3(); << 295 gdiced += 1. * << 296 (std::fabs(fCrossSectionCalculat << 297 std::fabs(fCrossSectionCalculat << 298 beamTrans * targetTrans; << 299 gdiced += 1. * std::fabs(fCrossSectionCalc << 300 (std::fabs(fBeamPolarization.p3( << 301 std::fabs(fTargetPolarization.p << 302 << 303 G4double gdist = fCrossSectionCalculator-> << 304 gdist += fCrossSectionCalculator->getVar(3 << 305 fTargetPolarization.p3(); << 306 gdist += fCrossSectionCalculator->getVar(1 << 307 (std::cos(phi) * fBeamPolarizatio << 308 std::sin(phi) * fBeamPolarizatio << 309 (std::cos(phi) * fTargetPolarizat << 310 std::sin(phi) * fTargetPolarizat << 311 gdist += fCrossSectionCalculator->getVar(2 << 312 (std::cos(phi) * fBeamPolarizatio << 313 std::sin(phi) * fBeamPolarizatio << 314 (std::cos(phi) * fTargetPolarizat << 315 std::sin(phi) * fTargetPolarizat << 316 gdist += << 317 fCrossSectionCalculator->getVar(4) * << 318 (std::cos(phi) * fBeamPolarization.p3() << 319 std::cos(phi) * fBeamPolarization.p1() << 320 std::sin(phi) * fBeamPolarization.p3() << 321 std::sin(phi) * fBeamPolarization.p2() << 322 << 323 treject = gdist / gdiced; << 324 if(treject > 1. + 1.e-10 || treject < 0) << 325 { << 326 G4ExceptionDescription ed; << 327 ed << "!!!ERROR in PolarizedAnnihilation << 328 << " phi rejection does not work prop << 329 G4cout << " gdiced = " << gdiced << G4en << 330 G4cout << " gdist = " << gdist << G4endl << 331 G4cout << " epsil = " << epsil << G4endl << 332 G4Exception("G4PolarizedAnnihilationMode << 333 JustWarning, ed); << 334 } << 335 248 336 if(treject < 1.e-3) << 249 // G4cout<<"phi dicing START"<<G4endl; 337 { << 250 do{ 338 G4ExceptionDescription ed; << 251 phi = twopi * G4UniformRand(); 339 ed << "!!!ERROR in PolarizedAnnihilation << 252 crossSectionCalculator->Initialize(epsil, gama, 0., theBeamPolarization, theTargetPolarization,2); 340 << " phi rejection does not work prop << 253 341 G4cout << " gdiced=" << gdiced << " gd << 254 G4double gdiced =crossSectionCalculator->getVar(0); 342 G4cout << " epsil = " << epsil << G4endl << 255 gdiced += crossSectionCalculator->getVar(3)*theBeamPolarization.p3()*theTargetPolarization.p3(); 343 G4Exception("G4PolarizedAnnihilationMode << 256 gdiced += 1.*(std::fabs(crossSectionCalculator->getVar(1)) 344 JustWarning, ed); << 257 + std::fabs(crossSectionCalculator->getVar(2)))*beamTrans*targetTrans; 345 } << 258 gdiced += 1.*std::fabs(crossSectionCalculator->getVar(4)) >> 259 *(std::fabs(theBeamPolarization.p3())*targetTrans + std::fabs(theTargetPolarization.p3())*beamTrans); >> 260 >> 261 G4double gdist = crossSectionCalculator->getVar(0); >> 262 gdist += crossSectionCalculator->getVar(3)*theBeamPolarization.p3()*theTargetPolarization.p3(); >> 263 gdist += crossSectionCalculator->getVar(1)*(std::cos(phi)*theBeamPolarization.p1() >> 264 + std::sin(phi)*theBeamPolarization.p2()) >> 265 *(std::cos(phi)*theTargetPolarization.p1() >> 266 + std::sin(phi)*theTargetPolarization.p2()); >> 267 gdist += crossSectionCalculator->getVar(2)*(std::cos(phi)*theBeamPolarization.p2() >> 268 - std::sin(phi)*theBeamPolarization.p1()) >> 269 *(std::cos(phi)*theTargetPolarization.p2() >> 270 - std::sin(phi)*theTargetPolarization.p1()); >> 271 gdist += crossSectionCalculator->getVar(4) >> 272 *(std::cos(phi)*theBeamPolarization.p3()*theTargetPolarization.p1() >> 273 + std::cos(phi)*theBeamPolarization.p1()*theTargetPolarization.p3() >> 274 + std::sin(phi)*theBeamPolarization.p3()*theTargetPolarization.p2() >> 275 + std::sin(phi)*theBeamPolarization.p2()*theTargetPolarization.p3()); >> 276 >> 277 treject = gdist/gdiced; >> 278 //G4cout<<" treject = "<<treject<<" at phi = "<<phi<<G4endl; >> 279 if (treject>1.+1.e-10 || treject<0){ >> 280 G4cout<<"!!!ERROR in PolarizedAnnihilationPS::PostStepDoIt\n" >> 281 <<" phi rejection does not work properly: "<<treject<<G4endl; >> 282 G4cout<<" gdiced = "<<gdiced<<G4endl; >> 283 G4cout<<" gdist = "<<gdist<<G4endl; >> 284 G4cout<<" epsil = "<<epsil<<G4endl; >> 285 } >> 286 >> 287 if (treject<1.e-3) { >> 288 G4cout<<"!!!ERROR in PolarizedAnnihilationPS::PostStepDoIt\n" >> 289 <<" phi rejection does not work properly: "<<treject<<"\n"; >> 290 G4cout<<" gdiced="<<gdiced<<" gdist="<<gdist<<"\n"; >> 291 G4cout<<" epsil = "<<epsil<<G4endl; >> 292 } 346 293 347 // Loop checking, 03-Aug-2015, Vladimir Iv << 294 } while( treject < G4UniformRand() ); 348 } while(treject < G4UniformRand()); << 295 // G4cout<<"phi dicing END"<<G4endl; 349 296 350 G4double dirx = sint * std::cos(phi); << 297 G4double dirx = sint*std::cos(phi) , diry = sint*std::sin(phi) , dirz = cost; 351 G4double diry = sint * std::sin(phi); << 352 G4double dirz = cost; << 353 298 >> 299 // 354 // kinematic of the created pair 300 // kinematic of the created pair 355 G4double TotalAvailableEnergy = PositKinEner << 301 // 356 G4double Phot1Energy = epsil * Tota << 302 G4double TotalAvailableEnergy = PositKinEnergy + 2*electron_mass_c2; 357 G4double Phot2Energy = (1. - epsil) << 303 G4double Phot1Energy = epsil*TotalAvailableEnergy; >> 304 G4double Phot2Energy =(1.-epsil)*TotalAvailableEnergy; 358 305 359 // *** prepare calculation of polarization t 306 // *** prepare calculation of polarization transfer *** 360 G4ThreeVector Phot1Direction(dirx, diry, dir << 307 G4ThreeVector Phot1Direction (dirx, diry, dirz); 361 308 362 // get interaction frame 309 // get interaction frame 363 G4ThreeVector nInteractionFrame = << 310 G4ThreeVector nInteractionFrame = 364 G4PolarizationHelper::GetFrame(PositDirect << 311 G4PolarizationHelper::GetFrame(PositDirection,Phot1Direction); 365 << 312 366 // define proper in-plane and out-of-plane c 313 // define proper in-plane and out-of-plane component of initial spins 367 fBeamPolarization.InvRotateAz(nInteractionFr << 314 theBeamPolarization.InvRotateAz(nInteractionFrame,PositDirection); 368 fTargetPolarization.InvRotateAz(nInteraction << 315 theTargetPolarization.InvRotateAz(nInteractionFrame,PositDirection); 369 316 370 // calculate spin transfere matrix 317 // calculate spin transfere matrix 371 318 372 fCrossSectionCalculator->Initialize(epsil, g << 319 crossSectionCalculator->Initialize(epsil,gama,phi,theBeamPolarization,theTargetPolarization,2); 373 fTargetP << 374 320 375 Phot1Direction.rotateUz(PositDirection); << 321 // ********************************************************************** 376 // create G4DynamicParticle object for the p << 322 377 G4DynamicParticle* aParticle1 = << 323 Phot1Direction.rotateUz(PositDirection); 378 new G4DynamicParticle(G4Gamma::Gamma(), Ph << 324 // create G4DynamicParticle object for the particle1 379 fFinalGamma1Polarization = fCrossSectionCalc << 325 G4DynamicParticle* aParticle1= new G4DynamicParticle (G4Gamma::Gamma(), 380 G4double n1 = fFinalGamma1Polar << 326 Phot1Direction, Phot1Energy); 381 if(n1 > 1.) << 327 finalGamma1Polarization=crossSectionCalculator->GetPol2(); 382 { << 328 G4double n1=finalGamma1Polarization.mag2(); 383 G4ExceptionDescription ed; << 329 if (n1>1) { 384 ed << "ERROR: PolarizedAnnihilation Polari << 330 G4cout<<"ERROR: PolarizedAnnihilation Polarization Vector at epsil = " 385 << epsil << " is too large!!! \n" << 331 <<epsil<<" is too large!!! \n" 386 << "annihi pol1= " << fFinalGamma1Polar << 332 <<"annihi pol1= "<<finalGamma1Polarization<<", ("<<n1<<")\n"; 387 fFinalGamma1Polarization *= 1. / std::sqrt << 333 finalGamma1Polarization+=1./std::sqrt(n1); 388 G4Exception("G4PolarizedAnnihilationModel: << 389 JustWarning, ed); << 390 } 334 } 391 335 392 // define polarization of first final state 336 // define polarization of first final state photon 393 fFinalGamma1Polarization.SetPhoton(); << 337 finalGamma1Polarization.SetPhoton(); 394 fFinalGamma1Polarization.RotateAz(nInteracti << 338 finalGamma1Polarization.RotateAz(nInteractionFrame,Phot1Direction); 395 aParticle1->SetPolarization(fFinalGamma1Pola << 339 aParticle1->SetPolarization(finalGamma1Polarization.p1(), 396 fFinalGamma1Pola << 340 finalGamma1Polarization.p2(), 397 fFinalGamma1Pola << 341 finalGamma1Polarization.p3()); 398 342 399 fvect->push_back(aParticle1); 343 fvect->push_back(aParticle1); 400 344 >> 345 401 // ***************************************** 346 // ********************************************************************** 402 347 403 G4double Eratio = Phot1Energy / Phot2Energy; << 348 G4double Eratio= Phot1Energy/Phot2Energy; 404 G4double PositP = << 349 G4double PositP= std::sqrt(PositKinEnergy*(PositKinEnergy+2.*electron_mass_c2)); 405 std::sqrt(PositKinEnergy * (PositKinEnergy << 350 G4ThreeVector Phot2Direction (-dirx*Eratio, -diry*Eratio, 406 G4ThreeVector Phot2Direction(-dirx * Eratio, << 351 (PositP-dirz*Phot1Energy)/Phot2Energy); 407 (PositP - dirz << 352 Phot2Direction.rotateUz(PositDirection); 408 Phot2Direction.rotateUz(PositDirection); << 353 // create G4DynamicParticle object for the particle2 409 // create G4DynamicParticle object for the p << 354 G4DynamicParticle* aParticle2= new G4DynamicParticle (G4Gamma::Gamma(), 410 G4DynamicParticle* aParticle2 = << 355 Phot2Direction, Phot2Energy); 411 new G4DynamicParticle(G4Gamma::Gamma(), Ph << 412 356 413 // define polarization of second final state 357 // define polarization of second final state photon 414 fFinalGamma2Polarization = fCrossSectionCalc << 358 finalGamma2Polarization=crossSectionCalculator->GetPol3(); 415 G4double n2 = fFinalGamma2Polar << 359 G4double n2=finalGamma2Polarization.mag2(); 416 if(n2 > 1.) << 360 if (n2>1) { 417 { << 361 G4cout<<"ERROR: PolarizedAnnihilation Polarization Vector at epsil = "<<epsil<<" is too large!!! \n"; 418 G4ExceptionDescription ed; << 362 G4cout<<"annihi pol2= "<<finalGamma2Polarization<<", ("<<n2<<")\n"; 419 ed << "ERROR: PolarizedAnnihilation Polari << 363 420 << epsil << " is too large!!! \n"; << 364 finalGamma2Polarization+=1./std::sqrt(n2); 421 ed << "annihi pol2= " << fFinalGamma2Polar << 422 << 423 G4Exception("G4PolarizedAnnihilationModel: << 424 JustWarning, ed); << 425 fFinalGamma2Polarization *= 1. / std::sqrt << 426 } 365 } 427 fFinalGamma2Polarization.SetPhoton(); << 366 finalGamma2Polarization.SetPhoton(); 428 fFinalGamma2Polarization.RotateAz(nInteracti << 367 finalGamma2Polarization.RotateAz(nInteractionFrame,Phot2Direction); 429 aParticle2->SetPolarization(fFinalGamma2Pola << 368 aParticle2->SetPolarization(finalGamma2Polarization.p1(), 430 fFinalGamma2Pola << 369 finalGamma2Polarization.p2(), 431 fFinalGamma2Pola << 370 finalGamma2Polarization.p3()); 432 371 433 fvect->push_back(aParticle2); 372 fvect->push_back(aParticle2); >> 373 >> 374 return fvect; 434 } 375 } 435 376