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