86{
87 if(
fParticleGun->GetParticleDefinition()->GetParticleName() !=
88 "opticalphoton")
89 {
90 G4ExceptionDescription ed;
91 ed << "Warning: the particleGun is not an opticalphoton";
92 G4Exception("OpNovicePrimaryGeneratorAction::SetOptPhotonPolar()",
93 "OpNovice_010", JustWarning, ed);
94 return;
95 }
96
97 G4ThreeVector normal(1., 0., 0.);
98 G4ThreeVector kphoton =
fParticleGun->GetParticleMomentumDirection();
99 G4ThreeVector product = normal.cross(kphoton);
100 G4double modul2 = product * product;
101
102 G4ThreeVector e_perpend(0., 0., 1.);
103 if(modul2 > 0.)
104 e_perpend = (1. / std::sqrt(modul2)) * product;
105 G4ThreeVector e_paralle = e_perpend.cross(kphoton);
106
107 G4ThreeVector polar =
108 std::cos(angle) * e_paralle + std::sin(angle) * e_perpend;
110}