G4Decay::DecayIt() implemention.
89{
90
91
92
93
94
95
96
98
99
100 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
101 const G4PrimaryParticle* aPrimaryParticle = aParticle->GetPrimaryParticle();
102
103
104 const G4DecayProducts* o_products = (aParticle->GetPreAssignedDecayProducts());
105 G4bool isPreAssigned = (o_products != nullptr);
106 G4DecayProducts* products = nullptr;
107
108 if (isPreAssigned) {
109
110 products = new G4DecayProducts(*o_products);
111 } else {
112
113 G4ExceptionDescription ed;
114 ed << "LongLivedNeutral particle:"
115 << " decay probability exist but no pre-assigned decay products defined "
116 << "- the particle will be killed;\n";
117 G4Exception("G4LongLivedNeutralDecay::DecayIt ",
118 "DECAY101", JustWarning, ed);
119
121
124
125 ClearNumberOfInteractionLengthLeft();
127 }
128
129
130 G4double ParentEnergy = aPrimaryParticle->GetTotalEnergy();
131 G4double ParentMass = aPrimaryParticle->GetMass();
132 if (ParentEnergy < ParentMass) {
133 G4ExceptionDescription ed;
134 ed << "Total Energy is less than its mass - increased the energy"
135 << "\n Particle: " << "LongLivedNeutral"
136 << "\n Energy:" << ParentEnergy / MeV << "[MeV]"
137 << "\n Mass:" << ParentMass / MeV << "[MeV]";
138 G4Exception("G4LongLivedNeutralDecay::DecayIt ",
139 "DECAY102", JustWarning, ed);
140 ParentEnergy = ParentMass;
141 }
142
143 G4ThreeVector ParentDirection(aPrimaryParticle->GetMomentumDirection());
144
145
146 const G4DynamicParticle dParticle(aPrimaryParticle->GetParticleDefinition(),
147 aPrimaryParticle->GetMomentumDirection(),
148 aPrimaryParticle->GetKineticEnergy(),
149 aPrimaryParticle->GetMass());
150
151 products->SetParentParticle(dParticle);
152
153 G4double energyDeposit = 0.0;
154 G4double finalGlobalTime = aTrack.GetGlobalTime();
155 G4double finalLocalTime = aTrack.GetLocalTime();
156 if (aTrack.GetTrackStatus() == fStopButAlive) {
157
160 energyDeposit += aPrimaryParticle->GetKineticEnergy();
161 products->Boost(ParentEnergy, ParentDirection);
162 } else {
163
164 products->Boost(ParentEnergy, ParentDirection);
165 }
166
167
168 G4int numberOfSecondaries = products->entries();
170#ifdef G4VERBOSE
171 if (GetVerboseLevel() > 1) {
172 G4cout << "G4LongLivedNeutralDecay::DoIt : Decay vertex :";
173 G4cout << " Time: " << finalGlobalTime / ns << "[ns]";
174 G4cout << " proper time: " << finalLocalTime / ns << "[ns]";
175 G4cout << " X:" << (aTrack.GetPosition()).getX() / cm << "[cm]";
176 G4cout << " Y:" << (aTrack.GetPosition()).getY() / cm << "[cm]";
177 G4cout << " Z:" << (aTrack.GetPosition()).getZ() / cm << "[cm]";
178 G4cout << G4endl;
179 G4cout << "G4LongLivedNeutralDecay::DoIt : decay products in Lab. Frame" << G4endl;
180 products->DumpInfo();
181 }
182#endif
183
184 G4int index;
185 G4ThreeVector currentPosition;
186 const G4TouchableHandle thand = aTrack.GetTouchableHandle();
187 for (index = 0; index < numberOfSecondaries; index++) {
188
189 currentPosition = aTrack.GetPosition();
190
191 G4Track* secondary = new G4Track(products->PopProducts(),
192 finalGlobalTime,
193 currentPosition);
194
195 secondary->SetGoodForTrackingFlag();
196 secondary->SetTouchableHandle(thand);
197
199 }
200 delete products;
201
202
206
207
208 ClearNumberOfInteractionLengthLeft();
209
211}