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] [ 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/decay/src/G4DecayWithSpin.cc (Version 11.3.0) and /processes/decay/src/G4DecayWithSpin.cc (Version 9.0.p1)


  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 // -------------------------------------------     26 // ------------------------------------------------------------
 27 //      GEANT 4 class header file                  27 //      GEANT 4 class header file
 28 //                                                 28 //
 29 //      History:                                   29 //      History:
 30 //      17 August 2004  P. Gumplinger, T. MacP     30 //      17 August 2004  P. Gumplinger, T. MacPhail
 31 //      11 April  2008  Kamil Sedlak (PSI), To << 
 32 // -------------------------------------------     31 // ------------------------------------------------------------
 33 //                                                 32 //
 34 #include "G4DecayWithSpin.hh"                      33 #include "G4DecayWithSpin.hh"
 35                                                    34 
 36 #include "G4Step.hh"                               35 #include "G4Step.hh"
 37 #include "G4Track.hh"                              36 #include "G4Track.hh"
 38 #include "G4DecayTable.hh"                         37 #include "G4DecayTable.hh"
 39 #include "G4MuonDecayChannelWithSpin.hh"           38 #include "G4MuonDecayChannelWithSpin.hh"
 40                                                    39 
 41 #include "G4PhysicalConstants.hh"              << 
 42 #include "G4SystemOfUnits.hh"                  << 
 43 #include "G4Vector3D.hh"                           40 #include "G4Vector3D.hh"
 44                                                    41 
 45 #include "G4TransportationManager.hh"              42 #include "G4TransportationManager.hh"
 46 #include "G4PropagatorInField.hh"                  43 #include "G4PropagatorInField.hh"
 47 #include "G4FieldManager.hh"                       44 #include "G4FieldManager.hh"
 48 #include "G4Field.hh"                              45 #include "G4Field.hh"
 49                                                    46 
 50 #include "G4Transform3D.hh"                        47 #include "G4Transform3D.hh"
 51                                                    48 
 52 G4DecayWithSpin::G4DecayWithSpin(const G4Strin <<  49 G4DecayWithSpin::G4DecayWithSpin(const G4String& processName):G4Decay(processName){}
 53 {                                              << 
 54   // set Process Sub Type                      << 
 55   SetProcessSubType(static_cast<int>(DECAY_Wit << 
 56                                                << 
 57 }                                              << 
 58                                                    50 
 59 G4DecayWithSpin::~G4DecayWithSpin(){}              51 G4DecayWithSpin::~G4DecayWithSpin(){}
 60                                                    52 
 61 G4VParticleChange* G4DecayWithSpin::PostStepDo <<  53 G4VParticleChange* G4DecayWithSpin::DecayIt(const G4Track& aTrack, const G4Step& aStep)
 62 {                                                  54 {
 63   if ( (aTrack.GetTrackStatus() == fStopButAli << 
 64        (aTrack.GetTrackStatus() == fStopAndKil << 
 65     fParticleChangeForDecay.Initialize(aTrack) << 
 66     return &fParticleChangeForDecay;           << 
 67   }                                            << 
 68                                                    55 
 69 // get particle                                    56 // get particle
 70   const G4DynamicParticle* aParticle = aTrack.     57   const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
 71   const G4ParticleDefinition* aParticleDef = a <<  58   G4ParticleDefinition* aParticleDef = aParticle->GetDefinition();
 72                                                    59 
 73 // get parent_polarization                         60 // get parent_polarization
 74   G4ThreeVector parent_polarization = aParticl     61   G4ThreeVector parent_polarization = aParticle->GetPolarization();
 75                                                    62 
 76   if(parent_polarization == G4ThreeVector(0,0, <<  63   if(parent_polarization == G4ThreeVector(0,0,0))
                                                   >>  64   {
 77     // Generate random polarization direction      65     // Generate random polarization direction
 78     G4double cost = 1. - 2.*G4UniformRand();   << 
 79     G4double sint = std::sqrt((1.-cost)*(1.+co << 
 80                                                << 
 81     G4double phi = twopi*G4UniformRand();      << 
 82     G4double sinp = std::sin(phi);             << 
 83     G4double cosp = std::cos(phi);             << 
 84                                                << 
 85     G4double px = sint*cosp;                   << 
 86     G4double py = sint*sinp;                   << 
 87     G4double pz = cost;                        << 
 88                                                    66 
 89     parent_polarization.setX(px);              << 
 90     parent_polarization.setY(py);              << 
 91     parent_polarization.setZ(pz);              << 
 92   }                                            << 
 93                                                << 
 94 // decay table                                 << 
 95   G4DecayTable *decaytable = aParticleDef->Get << 
 96   if (decaytable != nullptr) {                 << 
 97     for (G4int ip=0; ip<decaytable->entries(); << 
 98       decaytable->GetDecayChannel(ip)->SetPola << 
 99     }                                          << 
100   }                                            << 
101                                                << 
102   G4ParticleChangeForDecay* pParticleChangeFor << 
103   pParticleChangeForDecay = (G4ParticleChangeF << 
104   pParticleChangeForDecay->ProposePolarization << 
105                                                << 
106   return pParticleChangeForDecay;              << 
107 }                                              << 
108                                                << 
109 G4VParticleChange* G4DecayWithSpin::AtRestDoIt << 
110 {                                              << 
111                                                << 
112 // get particle                                << 
113   const G4DynamicParticle* aParticle = aTrack. << 
114   const G4ParticleDefinition* aParticleDef = a << 
115                                                << 
116 // get parent_polarization                     << 
117   G4ThreeVector parent_polarization = aParticl << 
118                                                << 
119   if(parent_polarization == G4ThreeVector(0,0, << 
120     // Generate random polarization direction  << 
121     G4double cost = 1. - 2.*G4UniformRand();       67     G4double cost = 1. - 2.*G4UniformRand();
122     G4double sint = std::sqrt((1.-cost)*(1.+co     68     G4double sint = std::sqrt((1.-cost)*(1.+cost));
123                                                    69 
124     G4double phi = twopi*G4UniformRand();          70     G4double phi = twopi*G4UniformRand();
125     G4double sinp = std::sin(phi);                 71     G4double sinp = std::sin(phi);
126     G4double cosp = std::cos(phi);                 72     G4double cosp = std::cos(phi);
127                                                    73 
128     G4double px = sint*cosp;                       74     G4double px = sint*cosp;
129     G4double py = sint*sinp;                       75     G4double py = sint*sinp;
130     G4double pz = cost;                            76     G4double pz = cost;
131                                                    77 
132     parent_polarization.setX(px);                  78     parent_polarization.setX(px);
133     parent_polarization.setY(py);                  79     parent_polarization.setY(py);
134     parent_polarization.setZ(pz);                  80     parent_polarization.setZ(pz);
135                                                    81 
136   }else{                                           82   }else{
137                                                    83 
138     G4FieldManager* fieldMgr = aStep.GetTrack(     84     G4FieldManager* fieldMgr = aStep.GetTrack()->GetVolume()->
139                                      GetLogica     85                                      GetLogicalVolume()->GetFieldManager();
140     if (fieldMgr == nullptr) {                 <<  86 
                                                   >>  87     if (!fieldMgr) {
141        G4TransportationManager *transportMgr =     88        G4TransportationManager *transportMgr =
142                          G4TransportationManag     89                          G4TransportationManager::GetTransportationManager();
143        G4PropagatorInField* fFieldPropagator =     90        G4PropagatorInField* fFieldPropagator = 
144                                         transp     91                                         transportMgr->GetPropagatorInField();
145        if (fFieldPropagator) fieldMgr =            92        if (fFieldPropagator) fieldMgr = 
146                                   fFieldPropag     93                                   fFieldPropagator->GetCurrentFieldManager();
147     }                                              94     }
148                                                    95 
149     const G4Field* field = nullptr;            <<  96     const G4Field* field = NULL;
150     if (fieldMgr != nullptr) field = fieldMgr- <<  97     if(fieldMgr)field = fieldMgr->GetDetectorField();
                                                   >>  98 
                                                   >>  99     if (field && !(fieldMgr->DoesFieldChangeEnergy())) {
151                                                   100 
152     if ( field != nullptr ) {                  << 
153        G4double point[4];                         101        G4double point[4];
154        point[0] = (aStep.GetPostStepPoint()->G    102        point[0] = (aStep.GetPostStepPoint()->GetPosition())[0];
155        point[1] = (aStep.GetPostStepPoint()->G    103        point[1] = (aStep.GetPostStepPoint()->GetPosition())[1];
156        point[2] = (aStep.GetPostStepPoint()->G    104        point[2] = (aStep.GetPostStepPoint()->GetPosition())[2];
157        point[3] = aTrack.GetGlobalTime();         105        point[3] = aTrack.GetGlobalTime();
158                                                   106 
159        G4double fieldValue[6] ={ 0., 0., 0., 0 << 107        G4double fieldValue[3];
160        field -> GetFieldValue(point,fieldValue    108        field -> GetFieldValue(point,fieldValue);
                                                   >> 109 
161        G4ThreeVector B(fieldValue[0],fieldValu    110        G4ThreeVector B(fieldValue[0],fieldValue[1],fieldValue[2]);
162                                                   111 
163        // Call the spin precession only for no << 112        parent_polarization = Spin_Precession(aStep,B,fRemainderLifeTime);
164        if (B.mag2() > 0.) parent_polarization  << 
165                                  Spin_Precessi << 
166                                                   113 
167     }                                             114     }
168   }                                               115   }
169                                                   116 
170 // decay table                                    117 // decay table
171   G4DecayTable *decaytable = aParticleDef->Get    118   G4DecayTable *decaytable = aParticleDef->GetDecayTable();
172   if ( decaytable != nullptr) {                << 119 
173     for (G4int ip=0; ip<decaytable->entries(); << 120   if (decaytable) {
174       decaytable->GetDecayChannel(ip)->SetPola << 121      G4MuonDecayChannelWithSpin *decaychannel;
175     }                                          << 122      decaychannel = (G4MuonDecayChannelWithSpin*)decaytable->SelectADecayChannel();
176   }                                            << 123      if (decaychannel) decaychannel->SetPolarization(parent_polarization);
                                                   >> 124   }
177                                                   125 
178   G4ParticleChangeForDecay* pParticleChangeFor    126   G4ParticleChangeForDecay* pParticleChangeForDecay;
                                                   >> 127 
179   pParticleChangeForDecay = (G4ParticleChangeF    128   pParticleChangeForDecay = (G4ParticleChangeForDecay*)G4Decay::DecayIt(aTrack,aStep);
                                                   >> 129 
180   pParticleChangeForDecay->ProposePolarization    130   pParticleChangeForDecay->ProposePolarization(parent_polarization);
181                                                   131 
182   return pParticleChangeForDecay;                 132   return pParticleChangeForDecay;
183                                                   133 
184 }                                                 134 }
185                                                   135 
186 G4ThreeVector G4DecayWithSpin::Spin_Precession    136 G4ThreeVector G4DecayWithSpin::Spin_Precession( const G4Step& aStep,
187                                         G4Thre    137                                         G4ThreeVector B, G4double deltatime )
188 {                                                 138 {
189   G4double Bnorm = std::sqrt(sqr(B[0])  + sqr(    139   G4double Bnorm = std::sqrt(sqr(B[0])  + sqr(B[1]) +sqr(B[2]) );
190                                                   140 
191   G4double q = aStep.GetTrack()->GetDefinition    141   G4double q = aStep.GetTrack()->GetDefinition()->GetPDGCharge();
192   G4double a = 1.165922e-3;                       142   G4double a = 1.165922e-3;
193   G4double s_omega = 8.5062e+7*rad/(s*kilogaus    143   G4double s_omega = 8.5062e+7*rad/(s*kilogauss);
194                                                   144 
195   G4double omega = -(q*s_omega)*(1.+a) * Bnorm    145   G4double omega = -(q*s_omega)*(1.+a) * Bnorm;
196                                                   146 
197   G4double rotationangle = deltatime * omega;     147   G4double rotationangle = deltatime * omega;
198                                                   148 
199   G4Transform3D SpinRotation = G4Rotate3D(rota    149   G4Transform3D SpinRotation = G4Rotate3D(rotationangle,B.unit());
200                                                   150 
201   G4Vector3D Spin = aStep.GetTrack() -> GetPol    151   G4Vector3D Spin = aStep.GetTrack() -> GetPolarization();
202                                                   152 
203   G4Vector3D newSpin = SpinRotation * Spin;       153   G4Vector3D newSpin = SpinRotation * Spin;
204                                                   154 
205 #ifdef G4VERBOSE                                  155 #ifdef G4VERBOSE
206   if (GetVerboseLevel()>2) {                   << 156 
207     G4double normspin = std::sqrt(Spin*Spin);  << 157 //  G4double normspin = std::sqrt(Spin*Spin);
208     G4double normnewspin = std::sqrt(newSpin*n << 158 //  G4double normnewspin = std::sqrt(newSpin*newSpin);
209     //G4double cosalpha = Spin*newSpin/normspi << 159 //  G4double cosalpha = Spin*newSpin/normspin/normnewspin;
210     //G4double alpha = std::acos(cosalpha);    << 160 //  G4double alpha = std::acos(cosalpha);
211                                                << 161 
212     G4cout << "AT REST::: PARAMETERS " << G4en << 162 //  G4cout<< "AT REST::: PARAMETERS\n"
213     G4cout << "Initial spin  : " << Spin  << G << 163 //        << "Initial spin  : " << Spin <<"\n"
214     G4cout << "Delta time    : " << deltatime  << 164 //        << "Delta time    : " << deltatime <<"\n"
215     G4cout << "Rotation angle: " << rotationan << 165 //        << "Rotation angle: " << rotationangle/rad <<"\n"
216     G4cout << "New spin      : " << newSpin  < << 166 //        << "New spin      : " << newSpin <<"\n"
217     G4cout << "Checked norms : " << normspin < << 167 //        << "Checked norms : " << normspin <<" " << normnewspin <<" \n"
218   }                                            << 168 //        << G4endl;
                                                   >> 169 
219 #endif                                            170 #endif
220                                                   171 
221   return newSpin;                                 172   return newSpin;
222                                                   173 
223 }                                              << 
224                                                << 
225 void G4DecayWithSpin::ProcessDescription(std:: << 
226 {                                              << 
227   outFile << GetProcessName()                  << 
228     << ": Decay of particles considering paren << 
229     << "kinematics of daughters are dertermine << 
230 }                                                 174 }
231                                                   175