| 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 | // ------------------------------------------------------------
|
|---|
| 27 | // GEANT 4 class header file
|
|---|
| 28 | //
|
|---|
| 29 | // History:
|
|---|
| 30 | // 17 August 2004 P. Gumplinger, T. MacPhail
|
|---|
| 31 | // ------------------------------------------------------------
|
|---|
| 32 | //
|
|---|
| 33 | #include "G4DecayWithSpin.hh"
|
|---|
| 34 |
|
|---|
| 35 | #include "G4Step.hh"
|
|---|
| 36 | #include "G4Track.hh"
|
|---|
| 37 | #include "G4DecayTable.hh"
|
|---|
| 38 | #include "G4MuonDecayChannelWithSpin.hh"
|
|---|
| 39 |
|
|---|
| 40 | #include "G4Vector3D.hh"
|
|---|
| 41 |
|
|---|
| 42 | #include "G4TransportationManager.hh"
|
|---|
| 43 | #include "G4PropagatorInField.hh"
|
|---|
| 44 | #include "G4FieldManager.hh"
|
|---|
| 45 | #include "G4Field.hh"
|
|---|
| 46 |
|
|---|
| 47 | #include "G4Transform3D.hh"
|
|---|
| 48 |
|
|---|
| 49 | G4DecayWithSpin::G4DecayWithSpin(const G4String& processName):G4Decay(processName){}
|
|---|
| 50 |
|
|---|
| 51 | G4DecayWithSpin::~G4DecayWithSpin(){}
|
|---|
| 52 |
|
|---|
| 53 | G4VParticleChange* G4DecayWithSpin::DecayIt(const G4Track& aTrack, const G4Step& aStep)
|
|---|
| 54 | {
|
|---|
| 55 |
|
|---|
| 56 | // get particle
|
|---|
| 57 | const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
|
|---|
| 58 | G4ParticleDefinition* aParticleDef = aParticle->GetDefinition();
|
|---|
| 59 |
|
|---|
| 60 | // get parent_polarization
|
|---|
| 61 | G4ThreeVector parent_polarization = aParticle->GetPolarization();
|
|---|
| 62 |
|
|---|
| 63 | if(parent_polarization == G4ThreeVector(0,0,0))
|
|---|
| 64 | {
|
|---|
| 65 | // Generate random polarization direction
|
|---|
| 66 |
|
|---|
| 67 | G4double cost = 1. - 2.*G4UniformRand();
|
|---|
| 68 | G4double sint = std::sqrt((1.-cost)*(1.+cost));
|
|---|
| 69 |
|
|---|
| 70 | G4double phi = twopi*G4UniformRand();
|
|---|
| 71 | G4double sinp = std::sin(phi);
|
|---|
| 72 | G4double cosp = std::cos(phi);
|
|---|
| 73 |
|
|---|
| 74 | G4double px = sint*cosp;
|
|---|
| 75 | G4double py = sint*sinp;
|
|---|
| 76 | G4double pz = cost;
|
|---|
| 77 |
|
|---|
| 78 | parent_polarization.setX(px);
|
|---|
| 79 | parent_polarization.setY(py);
|
|---|
| 80 | parent_polarization.setZ(pz);
|
|---|
| 81 |
|
|---|
| 82 | }else{
|
|---|
| 83 |
|
|---|
| 84 | G4FieldManager* fieldMgr = aStep.GetTrack()->GetVolume()->
|
|---|
| 85 | GetLogicalVolume()->GetFieldManager();
|
|---|
| 86 |
|
|---|
| 87 | if (!fieldMgr) {
|
|---|
| 88 | G4TransportationManager *transportMgr =
|
|---|
| 89 | G4TransportationManager::GetTransportationManager();
|
|---|
| 90 | G4PropagatorInField* fFieldPropagator =
|
|---|
| 91 | transportMgr->GetPropagatorInField();
|
|---|
| 92 | if (fFieldPropagator) fieldMgr =
|
|---|
| 93 | fFieldPropagator->GetCurrentFieldManager();
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | const G4Field* field = NULL;
|
|---|
| 97 | if(fieldMgr)field = fieldMgr->GetDetectorField();
|
|---|
| 98 |
|
|---|
| 99 | if (field && !(fieldMgr->DoesFieldChangeEnergy())) {
|
|---|
| 100 |
|
|---|
| 101 | G4double point[4];
|
|---|
| 102 | point[0] = (aStep.GetPostStepPoint()->GetPosition())[0];
|
|---|
| 103 | point[1] = (aStep.GetPostStepPoint()->GetPosition())[1];
|
|---|
| 104 | point[2] = (aStep.GetPostStepPoint()->GetPosition())[2];
|
|---|
| 105 | point[3] = aTrack.GetGlobalTime();
|
|---|
| 106 |
|
|---|
| 107 | G4double fieldValue[3];
|
|---|
| 108 | field -> GetFieldValue(point,fieldValue);
|
|---|
| 109 |
|
|---|
| 110 | G4ThreeVector B(fieldValue[0],fieldValue[1],fieldValue[2]);
|
|---|
| 111 |
|
|---|
| 112 | parent_polarization = Spin_Precession(aStep,B,fRemainderLifeTime);
|
|---|
| 113 |
|
|---|
| 114 | }
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | // decay table
|
|---|
| 118 | G4DecayTable *decaytable = aParticleDef->GetDecayTable();
|
|---|
| 119 |
|
|---|
| 120 | if (decaytable) {
|
|---|
| 121 | G4MuonDecayChannelWithSpin *decaychannel;
|
|---|
| 122 | decaychannel = (G4MuonDecayChannelWithSpin*)decaytable->SelectADecayChannel();
|
|---|
| 123 | if (decaychannel) decaychannel->SetPolarization(parent_polarization);
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | G4ParticleChangeForDecay* pParticleChangeForDecay;
|
|---|
| 127 |
|
|---|
| 128 | pParticleChangeForDecay = (G4ParticleChangeForDecay*)G4Decay::DecayIt(aTrack,aStep);
|
|---|
| 129 |
|
|---|
| 130 | pParticleChangeForDecay->ProposePolarization(parent_polarization);
|
|---|
| 131 |
|
|---|
| 132 | return pParticleChangeForDecay;
|
|---|
| 133 |
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | G4ThreeVector G4DecayWithSpin::Spin_Precession( const G4Step& aStep,
|
|---|
| 137 | G4ThreeVector B, G4double deltatime )
|
|---|
| 138 | {
|
|---|
| 139 | G4double Bnorm = std::sqrt(sqr(B[0]) + sqr(B[1]) +sqr(B[2]) );
|
|---|
| 140 |
|
|---|
| 141 | G4double q = aStep.GetTrack()->GetDefinition()->GetPDGCharge();
|
|---|
| 142 | G4double a = 1.165922e-3;
|
|---|
| 143 | G4double s_omega = 8.5062e+7*rad/(s*kilogauss);
|
|---|
| 144 |
|
|---|
| 145 | G4double omega = -(q*s_omega)*(1.+a) * Bnorm;
|
|---|
| 146 |
|
|---|
| 147 | G4double rotationangle = deltatime * omega;
|
|---|
| 148 |
|
|---|
| 149 | G4Transform3D SpinRotation = G4Rotate3D(rotationangle,B.unit());
|
|---|
| 150 |
|
|---|
| 151 | G4Vector3D Spin = aStep.GetTrack() -> GetPolarization();
|
|---|
| 152 |
|
|---|
| 153 | G4Vector3D newSpin = SpinRotation * Spin;
|
|---|
| 154 |
|
|---|
| 155 | #ifdef G4VERBOSE
|
|---|
| 156 | if (GetVerboseLevel()>2) {
|
|---|
| 157 | G4double normspin = std::sqrt(Spin*Spin);
|
|---|
| 158 | G4double normnewspin = std::sqrt(newSpin*newSpin);
|
|---|
| 159 | //G4double cosalpha = Spin*newSpin/normspin/normnewspin;
|
|---|
| 160 | //G4double alpha = std::acos(cosalpha);
|
|---|
| 161 |
|
|---|
| 162 | G4cout << "AT REST::: PARAMETERS " << G4endl;
|
|---|
| 163 | G4cout << "Initial spin : " << Spin << G4endl;
|
|---|
| 164 | G4cout << "Delta time : " << deltatime << G4endl;
|
|---|
| 165 | G4cout << "Rotation angle: " << rotationangle/rad << G4endl;
|
|---|
| 166 | G4cout << "New spin : " << newSpin << G4endl;
|
|---|
| 167 | G4cout << "Checked norms : " << normspin <<" " << normnewspin << G4endl;
|
|---|
| 168 | }
|
|---|
| 169 | #endif
|
|---|
| 170 |
|
|---|
| 171 | return newSpin;
|
|---|
| 172 |
|
|---|
| 173 | }
|
|---|