00001 #include"musrDecay.hh"
00002
00003 #include "G4DynamicParticle.hh"
00004 #include "G4DecayProducts.hh"
00005 #include "G4DecayTable.hh"
00006 #include "G4PhysicsLogVector.hh"
00007 #include "G4ParticleChangeForDecay.hh"
00008 #include "G4VExtDecayer.hh"
00009 #include "G4ThreeVector.hh"
00010 #include "musrMuonDecayChannel.hh"
00011 #include <iomanip>
00012 #include "G4ios.hh"
00013 #include "globals.hh"
00014
00015 G4VParticleChange* musrDecay::DecayIt(const G4Track& aTrack, const G4Step& aStep)
00016 {
00017
00018
00019
00020
00021
00022
00023
00024
00025 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
00026 G4ParticleDefinition* aParticleDef = aParticle->GetDefinition();
00027
00028
00029
00030 if(aParticle->GetDefinition()->GetParticleName()!="mu+")
00031 {
00032 G4ParticleChangeForDecay* k;
00033 k = (G4ParticleChangeForDecay*)G4Decay::DecayIt(aTrack,aStep);
00034 return k ;
00035 }
00036
00038
00039 G4double p_time = aTrack.GetDynamicParticle()->GetPreAssignedDecayProperTime();
00040 G4double tp_time = aTrack.GetProperTime();
00041 m_RemainderLifeTime =p_time-tp_time;
00042
00043
00044 if (aParticleDef->GetPDGStable()) return &pParticleChangeForDecay ;
00045
00046
00047
00048 const G4DecayProducts* o_products = (aParticle->GetPreAssignedDecayProducts());
00049 G4bool isPreAssigned = (o_products != 0);
00050 G4DecayProducts* products = 0;
00051
00052
00053 G4DecayTable *decaytable = aParticleDef->GetDecayTable();
00054
00055
00056 G4bool isExtDecayer = (decaytable == 0);
00057
00058
00059 if ( (decaytable == 0) && !isExtDecayer &&!isPreAssigned ){
00060 #ifdef G4VERBOSE
00061 if (GetVerboseLevel()>0) {
00062 G4cerr << "G4Decay::DoIt : decay table not defined for ";
00063 G4cerr << aParticle->GetDefinition()->GetParticleName()<< G4endl;
00064 }
00065 #endif
00066 pParticleChangeForDecay.SetNumberOfSecondaries(0);
00067
00068 pParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ;
00069 pParticleChangeForDecay.ProposeLocalEnergyDeposit(0.0);
00070
00071 ClearNumberOfInteractionLengthLeft();
00072 return &pParticleChangeForDecay ;
00073 }
00074
00075 if (isPreAssigned) {
00076
00077 products = new G4DecayProducts(*o_products);
00078 } else {
00079
00080
00081
00082
00083
00084 G4VDecayChannel *decaychannel = decaytable->SelectADecayChannel();
00085 if (decaychannel == 0 ){
00086
00087 G4Exception("G4Decay::DoIt : can not determine decay channel ");
00088 } else {
00089 G4int temp = decaychannel->GetVerboseLevel();
00090
00091 #ifdef G4VERBOSE
00092 if (GetVerboseLevel()>1) {
00093 G4cerr << "G4Decay::DoIt : selected decay channel addr:" << decaychannel <<G4endl;
00094 decaychannel->SetVerboseLevel(GetVerboseLevel());
00095 }
00096 #endif
00097
00098
00099
00100 G4ThreeVector parent_polarization = aParticle->GetPolarization();
00101
00102
00103
00104 if(aParticle->GetDefinition()->GetParticleName()=="mu+")
00105 {
00106 musrMuonDecayChannel *muondecaychannel =new musrMuonDecayChannel("mu+",1.00);
00107 if(parent_polarization == G4ThreeVector(0,0,0))
00108 {
00109 products = muondecaychannel->DecayIt(aParticle->GetMass());
00110 }
00111 if(parent_polarization != G4ThreeVector(0,0,0))
00112 {
00113 products = muondecaychannel->DecayItPolarized(aParticle->GetMass(),parent_polarization);
00114 }
00115 }
00116
00117 else products = decaychannel->DecayIt(aParticle->GetMass()) ;
00118
00119
00120
00121 #ifdef G4VERBOSE
00122 if (GetVerboseLevel()>1) {
00123 decaychannel->SetVerboseLevel(temp);
00124 }
00125 #endif
00126 #ifdef G4VERBOSE
00127
00128
00129 #endif
00130 }
00131 }
00132
00133
00134 G4double ParentEnergy = aParticle->GetTotalEnergy();
00135 G4ThreeVector ParentDirection(aParticle->GetMomentumDirection());
00136
00137
00138 G4double energyDeposit = 0.0;
00139 G4double finalGlobalTime = aTrack.GetGlobalTime();
00140 if (aTrack.GetTrackStatus() == fStopButAlive ){
00141
00142 finalGlobalTime += m_RemainderLifeTime;
00143 energyDeposit += aParticle->GetKineticEnergy();
00144 if (isPreAssigned) products->Boost( ParentEnergy, ParentDirection);
00145 } else {
00146
00147 if (!isExtDecayer) products->Boost( ParentEnergy, ParentDirection);
00148 }
00149
00150 G4int numberOfSecondaries = products->entries();
00151
00152 pParticleChangeForDecay.SetNumberOfSecondaries(numberOfSecondaries);
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 G4int index;
00163 G4ThreeVector currentPosition;
00164 const G4TouchableHandle thand = aTrack.GetTouchableHandle();
00165
00166 for (index=0; index < numberOfSecondaries; index++)
00167 {
00168
00169 currentPosition = aTrack.GetPosition();
00170
00171 G4Track* secondary = new G4Track( products->PopProducts(),
00172 finalGlobalTime ,
00173 currentPosition );
00174
00175 secondary->SetGoodForTrackingFlag();
00176 secondary->SetTouchableHandle(thand);
00177
00178 pParticleChangeForDecay.AddSecondary(secondary);
00179 }
00180 delete products;
00181
00182
00183 pParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ;
00184 pParticleChangeForDecay.ProposeLocalEnergyDeposit(energyDeposit);
00185 pParticleChangeForDecay.ProposeGlobalTime( finalGlobalTime );
00186
00187 ClearNumberOfInteractionLengthLeft();
00188
00189 return &pParticleChangeForDecay ;
00190
00191 }