Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4KineticTrack.cc
Go to the documentation of this file.
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// -----------------------------------------------------------------------------
28// GEANT 4 class implementation file
29//
30// History: first implementation, A. Feliciello, 20th May 1998
31// -----------------------------------------------------------------------------
32
33#include "globals.hh"
34#include "G4ios.hh"
35//#include <cmath>
36
37#include "Randomize.hh"
39#include "G4ThreeVector.hh"
40#include "G4LorentzVector.hh"
41#include "G4KineticTrack.hh"
44#include "G4DecayTable.hh"
46#include "G4DecayProducts.hh"
47#include "G4LorentzRotation.hh"
48#include "G4SampleResonance.hh"
49#include "G4Integrator.hh"
50#include "G4KaonZero.hh"
51#include "G4KaonZeroShort.hh"
52#include "G4KaonZeroLong.hh"
53#include "G4AntiKaonZero.hh"
54
55#include "G4HadTmpUtil.hh"
56
57//
58// Some static clobal for integration
59//
60
61static G4ThreadLocal G4double G4KineticTrack_Gmass, G4KineticTrack_xmass1;
62
63//
64// Default constructor
65//
66
68 theDefinition(0),
69 theFormationTime(0),
70 thePosition(0),
71 the4Momentum(0),
72 theFermi3Momentum(0),
73 theTotal4Momentum(0),
74 theNucleon(0),
75 nChannels(0),
76 theActualMass(0),
77 theActualWidth(0),
78 theDaughterMass(0),
79 theDaughterWidth(0),
80 theStateToNucleus(undefined),
81 theProjectilePotential(0)
82{
83////////////////
84// DEBUG //
85////////////////
86
87/*
88 G4cerr << G4endl << G4endl << G4endl;
89 G4cerr << " G4KineticTrack default constructor invoked! \n";
90 G4cerr << " =========================================== \n" << G4endl;
91*/
92}
93
94
95
96//
97// Copy constructor
98//
99
101{
102 theDefinition = right.GetDefinition();
103 theFormationTime = right.GetFormationTime();
104 thePosition = right.GetPosition();
105 the4Momentum = right.GetTrackingMomentum();
106 theFermi3Momentum = right.theFermi3Momentum;
107 theTotal4Momentum = right.theTotal4Momentum;
108 theNucleon=right.theNucleon;
109 nChannels = right.GetnChannels();
110 theActualMass = right.GetActualMass();
111 theActualWidth = new G4double[nChannels];
112 for (G4int i = 0; i < nChannels; i++)
113 {
114 theActualWidth[i] = right.theActualWidth[i];
115 }
116 theDaughterMass = 0;
117 theDaughterWidth = 0;
118 theStateToNucleus=right.theStateToNucleus;
119 theProjectilePotential=right.theProjectilePotential;
120
121////////////////
122// DEBUG //
123////////////////
124
125/*
126 G4cerr << G4endl << G4endl << G4endl;
127 G4cerr << " G4KineticTrack copy constructor invoked! \n";
128 G4cerr << " ======================================== \n" <<G4endl;
129*/
130}
131
132
133//
134// By argument constructor
135//
136
138 G4double aFormationTime,
139 const G4ThreeVector& aPosition,
140 const G4LorentzVector& a4Momentum) :
141 theDefinition(aDefinition),
142 theFormationTime(aFormationTime),
143 thePosition(aPosition),
144 the4Momentum(a4Momentum),
145 theFermi3Momentum(0),
146 theTotal4Momentum(a4Momentum),
147 theNucleon(0),
148 theStateToNucleus(undefined),
149 theProjectilePotential(0)
150{
151 if(G4KaonZero::KaonZero() == theDefinition ||
152 G4AntiKaonZero::AntiKaonZero() == theDefinition)
153 {
154 if(G4UniformRand()<0.5)
155 {
156 theDefinition = G4KaonZeroShort::KaonZeroShort();
157 }
158 else
159 {
160 theDefinition = G4KaonZeroLong::KaonZeroLong();
161 }
162 }
163
164//
165// Get the number of decay channels
166//
167
168 G4DecayTable* theDecayTable = theDefinition->GetDecayTable();
169 if (theDecayTable != 0)
170 {
171 nChannels = theDecayTable->entries();
172
173 }
174 else
175 {
176 nChannels = 0;
177 }
178
179//
180// Get the actual mass value
181//
182
183 theActualMass = GetActualMass();
184
185//
186// Create an array to Store the actual partial widths
187// of the decay channels
188//
189
190 theDaughterMass = 0;
191 theDaughterWidth = 0;
192 theActualWidth = 0;
193 G4bool * theDaughterIsShortLived = 0;
194
195 if(nChannels!=0) theActualWidth = new G4double[nChannels];
196
197 // cout << " ****CONSTR*** ActualMass ******* " << theActualMass << G4endl;
198 G4int index;
199 for (index = nChannels - 1; index >= 0; --index)
200 {
201 G4VDecayChannel* theChannel = theDecayTable->GetDecayChannel(index);
202 G4int nDaughters = theChannel->GetNumberOfDaughters();
203 G4double theMotherWidth;
204 if (nDaughters == 2 || nDaughters == 3)
205 {
206 G4double thePoleMass = theDefinition->GetPDGMass();
207 theMotherWidth = theDefinition->GetPDGWidth();
208 G4double thePoleWidth = theChannel->GetBR()*theMotherWidth;
209 const G4ParticleDefinition* aDaughter;
210 theDaughterMass = new G4double[nDaughters];
211 theDaughterWidth = new G4double[nDaughters];
212 theDaughterIsShortLived = new G4bool[nDaughters];
213 for (G4int n = 0; n < nDaughters; ++n)
214 {
215 aDaughter = theChannel->GetDaughter(n);
216 theDaughterMass[n] = aDaughter->GetPDGMass();
217 theDaughterWidth[n] = aDaughter->GetPDGWidth();
218 theDaughterIsShortLived[n] = aDaughter->IsShortLived();
219 }
220
221//
222// Check whether both the decay products are stable
223//
224
225 G4double theActualMom = 0.0;
226 G4double thePoleMom = 0.0;
227 G4SampleResonance aSampler;
228 if (nDaughters==2)
229 {
230 if ( !theDaughterIsShortLived[0] && !theDaughterIsShortLived[1] )
231 {
232
233 // G4cout << G4endl << "Both the " << nDaughters <<
234 // " decay products are stable!";
235 // cout << " LB: Both decay products STABLE !" << G4endl;
236 // cout << " parent: " << theChannel->GetParentName() << G4endl;
237 // cout << " particle1: " << theChannel->GetDaughterName(0) << G4endl;
238 // cout << " particle2: " << theChannel->GetDaughterName(1) << G4endl;
239
240 theActualMom = EvaluateCMMomentum(theActualMass,
241 theDaughterMass);
242 thePoleMom = EvaluateCMMomentum(thePoleMass,
243 theDaughterMass);
244 // cout << G4endl;
245 // cout << " LB: ActualMass/DaughterMass " << theActualMass << " " << theDaughterMass << G4endl;
246 // cout << " LB: ActualMom " << theActualMom << G4endl;
247 // cout << " LB: PoleMom " << thePoleMom << G4endl;
248 // cout << G4endl;
249 }
250 else if ( !theDaughterIsShortLived[0] && theDaughterIsShortLived[1] )
251 {
252
253 // G4cout << G4endl << "Only the first of the " << nDaughters <<" decay products is stable!";
254 // cout << " LB: only the first decay product is STABLE !" << G4endl;
255 // cout << " parent: " << theChannel->GetParentName() << G4endl;
256 // cout << " particle1: " << theChannel->GetDaughterName(0) << G4endl;
257 // cout << " particle2: " << theChannel->GetDaughterName(1) << G4endl;
258
259// global variable definition
260 G4double lowerLimit = aSampler.GetMinimumMass(theChannel->GetDaughter(1));
261 theActualMom = IntegrateCMMomentum(lowerLimit);
262 thePoleMom = IntegrateCMMomentum(lowerLimit, thePoleMass);
263 // cout << " LB Parent Mass = " << G4KineticTrack_Gmass << G4endl;
264 // cout << " LB Actual Mass = " << theActualMass << G4endl;
265 // cout << " LB Daughter1 Mass = " << G4KineticTrack_Gmass1 << G4endl;
266 // cout << " LB Daughter2 Mass = " << G4KineticTrack_Gmass2 << G4endl;
267 // cout << " The Actual Momentum = " << theActualMom << G4endl;
268 // cout << " The Pole Momentum = " << thePoleMom << G4endl;
269 // cout << G4endl;
270
271 }
272 else if ( theDaughterIsShortLived[0] && !theDaughterIsShortLived[1] )
273 {
274
275 // G4cout << G4endl << "Only the second of the " << nDaughters <<
276 // " decay products is stable!";
277 // cout << " LB: only the second decay product is STABLE !" << G4endl;
278 // cout << " parent: " << theChannel->GetParentName() << G4endl;
279 // cout << " particle1: " << theChannel->GetDaughterName(0) << G4endl;
280 // cout << " particle2: " << theChannel->GetDaughterName(1) << G4endl;
281
282//
283// Swap the content of the theDaughterMass and theDaughterWidth arrays!!!
284//
285
286 G4SwapObj(theDaughterMass, theDaughterMass + 1);
287 G4SwapObj(theDaughterWidth, theDaughterWidth + 1);
288
289// global variable definition
290 G4double lowerLimit = aSampler.GetMinimumMass(theChannel->GetDaughter(0));
291 theActualMom = IntegrateCMMomentum(lowerLimit);
292 thePoleMom = IntegrateCMMomentum(lowerLimit, thePoleMass);
293 // cout << " LB Parent Mass = " << G4KineticTrack_Gmass << G4endl;
294 // cout << " LB Actual Mass = " << theActualMass << G4endl;
295 // cout << " LB Daughter1 Mass = " << G4KineticTrack_Gmass1 << G4endl;
296 // cout << " LB Daughter2 Mass = " << G4KineticTrack_Gmass2 << G4endl;
297 // cout << " The Actual Momentum = " << theActualMom << G4endl;
298 // cout << " The Pole Momentum = " << thePoleMom << G4endl;
299 // cout << G4endl;
300
301 }
302 else if ( theDaughterIsShortLived[0] && theDaughterIsShortLived[1] )
303 {
304
305// G4cout << G4endl << "Both the " << nDaughters <<
306// " decay products are resonances!";
307 // cout << " LB: both decay products are RESONANCES !" << G4endl;
308 // cout << " parent: " << theChannel->GetParentName() << G4endl;
309 // cout << " particle1: " << theChannel->GetDaughterName(0) << G4endl;
310 // cout << " particle2: " << theChannel->GetDaughterName(1) << G4endl;
311
312// global variable definition
313 G4KineticTrack_Gmass = theActualMass;
314 theActualMom = IntegrateCMMomentum2();
315 G4KineticTrack_Gmass = thePoleMass;
316 thePoleMom = IntegrateCMMomentum2();
317 // cout << " LB Parent Mass = " << G4KineticTrack_Gmass << G4endl;
318 // cout << " LB Daughter1 Mass = " << G4KineticTrack_Gmass1 << G4endl;
319 // cout << " LB Daughter2 Mass = " << G4KineticTrack_Gmass2 << G4endl;
320 // cout << " The Actual Momentum = " << theActualMom << G4endl;
321 // cout << " The Pole Momentum = " << thePoleMom << G4endl;
322 // cout << G4endl;
323
324 }
325 }
326 else // (nDaughter==3)
327 {
328
329 G4int nShortLived = 0;
330 if ( theDaughterIsShortLived[0] )
331 {
332 ++nShortLived;
333 }
334 if ( theDaughterIsShortLived[1] )
335 {
336 ++nShortLived;
337 G4SwapObj(theDaughterMass, theDaughterMass + 1);
338 G4SwapObj(theDaughterWidth, theDaughterWidth + 1);
339 }
340 if ( theDaughterIsShortLived[2] )
341 {
342 ++nShortLived;
343 G4SwapObj(theDaughterMass, theDaughterMass + 2);
344 G4SwapObj(theDaughterWidth, theDaughterWidth + 2);
345 }
346 if ( nShortLived == 0 )
347 {
348 theDaughterMass[1]+=theDaughterMass[2];
349 theActualMom = EvaluateCMMomentum(theActualMass,
350 theDaughterMass);
351 thePoleMom = EvaluateCMMomentum(thePoleMass,
352 theDaughterMass);
353 }
354// else if ( nShortLived == 1 )
355 else if ( nShortLived >= 1 )
356 {
357 // need the shortlived particle in slot 1! (very bad style...)
358 G4SwapObj(theDaughterMass, theDaughterMass + 1);
359 G4SwapObj(theDaughterWidth, theDaughterWidth + 1);
360 theDaughterMass[0] += theDaughterMass[2];
361 theActualMom = IntegrateCMMomentum(0.0);
362 thePoleMom = IntegrateCMMomentum(0.0, thePoleMass);
363 }
364// else
365// {
366// throw G4HadronicException(__FILE__, __LINE__, ("can't handle more than one shortlived in 3 particle output channel");
367// }
368
369 }
370
371 //if(nDaughters<3) theChannel->GetAngularMomentum();
372 G4double theMassRatio = thePoleMass / theActualMass;
373 G4double theMomRatio = theActualMom / thePoleMom;
374 // VI 11.06.2015: for l=0 one not need use pow
375 //G4double l=0;
376 //theActualWidth[index] = thePoleWidth * theMassRatio *
377 // std::pow(theMomRatio, (2 * l + 1)) *
378 // (1.2 / (1+ 0.2*std::pow(theMomRatio, (2 * l))));
379 theActualWidth[index] = thePoleWidth * theMassRatio *
380 theMomRatio;
381 delete [] theDaughterMass;
382 theDaughterMass = 0;
383 delete [] theDaughterWidth;
384 theDaughterWidth = 0;
385 delete [] theDaughterIsShortLived;
386 theDaughterIsShortLived = 0;
387 }
388
389 else // nDaughter = 1 ( e.g. K0 decays 50% to Kshort, 50% Klong
390 {
391 theMotherWidth = theDefinition->GetPDGWidth();
392 theActualWidth[index] = theChannel->GetBR()*theMotherWidth;
393 }
394 }
395
396////////////////
397// DEBUG //
398////////////////
399
400// for (G4int y = nChannels - 1; y >= 0; --y)
401// {
402// G4cout << G4endl << theActualWidth[y];
403// }
404// G4cout << G4endl << G4endl << G4endl;
405
406 /*
407 G4cerr << G4endl << G4endl << G4endl;
408 G4cerr << " G4KineticTrack by argument constructor invoked! \n";
409 G4cerr << " =============================================== \n" << G4endl;
410 */
411
412}
413
415 const G4ThreeVector& aPosition,
416 const G4LorentzVector& a4Momentum)
417 : theDefinition(nucleon->GetDefinition()),
418 theFormationTime(0),
419 thePosition(aPosition),
420 the4Momentum(a4Momentum),
421 theFermi3Momentum(nucleon->GetMomentum()),
422 theNucleon(nucleon),
423 nChannels(0),
424 theActualMass(nucleon->GetDefinition()->GetPDGMass()),
425 theActualWidth(0),
426 theDaughterMass(0),
427 theDaughterWidth(0),
428 theStateToNucleus(undefined),
429 theProjectilePotential(0)
430{
431 theFermi3Momentum.setE(0);
432 Set4Momentum(a4Momentum);
433}
434
435
437{
438 if (theActualWidth != 0) delete [] theActualWidth;
439 if (theDaughterMass != 0) delete [] theDaughterMass;
440 if (theDaughterWidth != 0) delete [] theDaughterWidth;
441}
442
443
444
446{
447 if (this != &right)
448 {
449 theDefinition = right.GetDefinition();
450 theFormationTime = right.GetFormationTime();
451 the4Momentum = right.the4Momentum;
452 the4Momentum = right.GetTrackingMomentum();
453 theFermi3Momentum = right.theFermi3Momentum;
454 theTotal4Momentum = right.theTotal4Momentum;
455 theNucleon=right.theNucleon;
456 theStateToNucleus=right.theStateToNucleus;
457 if (theActualWidth != 0) delete [] theActualWidth;
458 nChannels = right.GetnChannels();
459 theActualWidth = new G4double[nChannels];
460 for (G4int i = 0; i < nChannels; ++i) theActualWidth[i] = right.theActualWidth[i];
461 }
462 return *this;
463}
464
465
466
468{
469 return (this == & right);
470}
471
472
473
475{
476 return (this != & right);
477}
478
479
480
482{
483//
484// Select a possible decay channel
485//
486/*
487 G4int index1;
488 for (index1 = nChannels - 1; index1 >= 0; --index1)
489 G4cout << "DECAY Actual Width IND/ActualW " << index1 << " " << theActualWidth[index1] << G4endl;
490 G4cout << "DECAY Actual Mass " << theActualMass << G4endl;
491*/
492 const G4ParticleDefinition* thisDefinition = this->GetDefinition();
493 if(!thisDefinition)
494 {
495 G4cerr << "Error condition encountered in G4KineticTrack::Decay()"<<G4endl;
496 G4cerr << " track has no particle definition associated."<<G4endl;
497 return 0;
498 }
499 G4DecayTable* theDecayTable = thisDefinition->GetDecayTable();
500 if(!theDecayTable)
501 {
502 G4cerr << "Error condition encountered in G4KineticTrack::Decay()"<<G4endl;
503 G4cerr << " particle definition has no decay table associated."<<G4endl;
504 G4cerr << " particle was "<<thisDefinition->GetParticleName()<<G4endl;
505 return 0;
506 }
507
508 G4int chargeBalance = G4lrint(theDefinition->GetPDGCharge() );
509 G4int baryonBalance = G4lrint(theDefinition->GetBaryonNumber() );
510 G4LorentzVector energyMomentumBalance(Get4Momentum());
511 G4double theTotalActualWidth = this->EvaluateTotalActualWidth();
512 if (theTotalActualWidth !=0)
513 {
514
515 //AR-16Aug2016 : Repeat the sampling of the decay channel until is
516 // kinematically above threshold or a max number of attempts is reached
517 G4bool isChannelBelowThreshold = true;
518 const G4int maxNumberOfLoops = 10000;
519 G4int loopCounter = 0;
520
521 G4int chosench;
522 G4String theParentName;
523 G4double theParentMass;
524 G4double theBR;
525 G4int theNumberOfDaughters;
526 G4String theDaughtersName1;
527 G4String theDaughtersName2;
528 G4String theDaughtersName3;
529 G4String theDaughtersName4;
530 G4double masses[4]={0.,0.,0.,0.};
531
532 do {
533
534 G4double theSumActualWidth = 0.0;
535 G4double* theCumActualWidth = new G4double[nChannels]{};
536 for (G4int index = nChannels - 1; index >= 0; --index)
537 {
538 theSumActualWidth += theActualWidth[index];
539 theCumActualWidth[index] = theSumActualWidth;
540 // cout << "DECAY Cum. Width " << index << " " << theCumActualWidth[index] << G4endl;
541 }
542 // cout << "DECAY Total Width " << theSumActualWidth << G4endl;
543 // cout << "DECAY Total Width " << theTotalActualWidth << G4endl;
544 G4double r = theTotalActualWidth * G4UniformRand();
545 G4VDecayChannel* theDecayChannel(0);
546 chosench=-1;
547 for (G4int index = nChannels - 1; index >= 0; --index)
548 {
549 if (r < theCumActualWidth[index])
550 {
551 theDecayChannel = theDecayTable->GetDecayChannel(index);
552 // cout << "DECAY SELECTED CHANNEL" << index << G4endl;
553 chosench=index;
554 break;
555 }
556 }
557
558 delete [] theCumActualWidth;
559
560 if(!theDecayChannel)
561 {
562 G4cerr << "Error condition encountered in G4KineticTrack::Decay()"<<G4endl;
563 G4cerr << " decay channel has 0x0 channel associated."<<G4endl;
564 G4cerr << " particle was "<<thisDefinition->GetParticleName()<<G4endl;
565 G4cerr << " channel index "<< chosench << "of "<<nChannels<<"channels"<<G4endl;
566 return 0;
567 }
568 theParentName = theDecayChannel->GetParentName();
569 theParentMass = this->GetActualMass();
570 theBR = theActualWidth[chosench];
571 // cout << "**BR*** DECAYNEW " << theBR << G4endl;
572 theNumberOfDaughters = theDecayChannel->GetNumberOfDaughters();
573 theDaughtersName1 = "";
574 theDaughtersName2 = "";
575 theDaughtersName3 = "";
576 theDaughtersName4 = "";
577
578 for (G4int i=0; i < 4; ++i) masses[i]=0.;
579 G4int shortlivedDaughters[4];
580 G4int numberOfShortliveds(0);
581 G4double SumLongLivedMass(0);
582 for (G4int aD=0; aD < theNumberOfDaughters ; ++aD)
583 {
584 const G4ParticleDefinition* aDaughter = theDecayChannel->GetDaughter(aD);
585 masses[aD] = aDaughter->GetPDGMass();
586 if ( aDaughter->IsShortLived() )
587 {
588 shortlivedDaughters[numberOfShortliveds]=aD;
589 ++numberOfShortliveds;
590 } else {
591 SumLongLivedMass += aDaughter->GetPDGMass();
592 }
593
594 }
595 switch (theNumberOfDaughters)
596 {
597 case 0:
598 break;
599 case 1:
600 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
601 theDaughtersName2 = "";
602 theDaughtersName3 = "";
603 theDaughtersName4 = "";
604 break;
605 case 2:
606 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
607 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
608 theDaughtersName3 = "";
609 theDaughtersName4 = "";
610 if ( numberOfShortliveds == 1)
611 { G4SampleResonance aSampler;
612 G4double massmax=theParentMass - SumLongLivedMass;
613 const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[0]);
614 masses[shortlivedDaughters[0]]= aSampler.SampleMass(aDaughter,massmax);
615 } else if ( numberOfShortliveds == 2) {
616 // choose masses one after the other, start with randomly choosen
617 G4int zero= (G4UniformRand() > 0.5) ? 0 : 1;
618 G4int one = 1-zero;
619 G4SampleResonance aSampler;
620 G4double massmax=theParentMass - aSampler.GetMinimumMass(theDecayChannel->GetDaughter(shortlivedDaughters[one]));
621 const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[zero]);
622 masses[shortlivedDaughters[zero]]=aSampler.SampleMass(aDaughter,massmax);
623 massmax=theParentMass - masses[shortlivedDaughters[zero]];
624 aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[one]);
625 masses[shortlivedDaughters[one]]=aSampler.SampleMass(aDaughter,massmax);
626 }
627 break;
628 case 3:
629 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
630 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
631 theDaughtersName3 = theDecayChannel->GetDaughterName(2);
632 theDaughtersName4 = "";
633 if ( numberOfShortliveds == 1)
634 { G4SampleResonance aSampler;
635 G4double massmax=theParentMass - SumLongLivedMass;
636 const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[0]);
637 masses[shortlivedDaughters[0]]= aSampler.SampleMass(aDaughter,massmax);
638 }
639 break;
640 default:
641 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
642 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
643 theDaughtersName3 = theDecayChannel->GetDaughterName(2);
644 theDaughtersName4 = theDecayChannel->GetDaughterName(3);
645 if ( numberOfShortliveds == 1)
646 { G4SampleResonance aSampler;
647 G4double massmax=theParentMass - SumLongLivedMass;
648 const G4ParticleDefinition * aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[0]);
649 masses[shortlivedDaughters[0]]= aSampler.SampleMass(aDaughter,massmax);
650 }
651 if ( theNumberOfDaughters > 4 ) {
653 ed << "More than 4 decay daughters: kept only the first 4" << G4endl;
654 G4Exception( "G4KineticTrack::Decay()", "KINTRK5", JustWarning, ed );
655 }
656 break;
657 }
658
659 //AR-16Aug2016 : Check whether the sum of the masses of the daughters is smaller than the parent mass.
660 // If this is still not the case, but the max number of attempts has been reached,
661 // then the subsequent call thePhaseSpaceDecayChannel.DecayIt() will throw an exception.
662 G4double sumDaughterMasses = 0.0;
663 for (G4int i=0; i < 4; ++i) sumDaughterMasses += masses[i];
664 if ( theParentMass - sumDaughterMasses > 0.0 ) isChannelBelowThreshold = false;
665
666 } while ( isChannelBelowThreshold && ++loopCounter < maxNumberOfLoops ); /* Loop checking, 16.08.2016, A.Ribon */
667
668//
669// Get the decay products List
670//
671
672 G4GeneralPhaseSpaceDecay thePhaseSpaceDecayChannel(theParentName,
673 theParentMass,
674 theBR,
675 theNumberOfDaughters,
676 theDaughtersName1,
677 theDaughtersName2,
678 theDaughtersName3,
679 theDaughtersName4,
680 masses);
681 G4DecayProducts* theDecayProducts = thePhaseSpaceDecayChannel.DecayIt();
682 if(!theDecayProducts)
683 {
685 ed << "Error condition encountered: phase-space decay failed." << G4endl
686 << "\t the decaying particle is: " << thisDefinition->GetParticleName() << G4endl
687 << "\t the channel index is: "<< chosench << " of "<< nChannels << "channels" << G4endl
688 << "\t " << theNumberOfDaughters << " daughter particles: "
689 << theDaughtersName1 << " " << theDaughtersName2 << " " << theDaughtersName3 << " "
690 << theDaughtersName4 << G4endl;
691 G4Exception( "G4KineticTrack::Decay ", "HAD_KINTRACK_001", JustWarning, ed );
692 return 0;
693 }
694
695//
696// Create the kinetic track List associated to the decay products
697//
698 G4LorentzRotation toMoving(Get4Momentum().boostVector());
699 G4DynamicParticle* theDynamicParticle;
700 G4double formationTime = 0.0;
702 G4LorentzVector momentum;
703 G4LorentzVector momentumBalanceCMS(0);
704 G4KineticTrackVector* theDecayProductList = new G4KineticTrackVector;
705 G4int dEntries = theDecayProducts->entries();
706 const G4ParticleDefinition * aProduct = 0;
707 for (G4int i=dEntries; i > 0; --i)
708 {
709 theDynamicParticle = theDecayProducts->PopProducts();
710 aProduct = theDynamicParticle->GetDefinition();
711 chargeBalance -= G4lrint(aProduct->GetPDGCharge() );
712 baryonBalance -= G4lrint(aProduct->GetBaryonNumber() );
713 momentumBalanceCMS += theDynamicParticle->Get4Momentum();
714 momentum = toMoving*theDynamicParticle->Get4Momentum();
715 energyMomentumBalance -= momentum;
716 theDecayProductList->push_back(new G4KineticTrack (aProduct,
717 formationTime,
718 position,
719 momentum));
720 delete theDynamicParticle;
721 }
722 delete theDecayProducts;
723 if(std::getenv("DecayEnergyBalanceCheck"))
724 std::cout << "DEBUGGING energy balance in cms and lab, charge baryon balance : "
725 << momentumBalanceCMS << " "
726 <<energyMomentumBalance << " "
727 <<chargeBalance<<" "
728 <<baryonBalance<<" "
729 <<G4endl;
730 return theDecayProductList;
731 }
732 else
733 {
734 return 0;
735 }
736}
737
738G4double G4KineticTrack::IntegrandFunction1(G4double xmass) const
739{
740 G4double mass = theActualMass; /* the actual mass value */
741 G4double mass1 = theDaughterMass[0];
742 G4double mass2 = theDaughterMass[1];
743 G4double gamma2 = theDaughterWidth[1];
744
745 G4double result = (1. / (2 * mass)) *
746 std::sqrt(std::max((((mass * mass) - (mass1 + xmass) * (mass1 + xmass)) *
747 ((mass * mass) - (mass1 - xmass) * (mass1 - xmass))),0.0)) *
748 BrWig(gamma2, mass2, xmass);
749 return result;
750}
751
752G4double G4KineticTrack::IntegrandFunction2(G4double xmass) const
753{
754 G4double mass = theDefinition->GetPDGMass(); /* the pole mass value */
755 G4double mass1 = theDaughterMass[0];
756 G4double mass2 = theDaughterMass[1];
757 G4double gamma2 = theDaughterWidth[1];
758 G4double result = (1. / (2 * mass)) *
759 std::sqrt(std::max((((mass * mass) - (mass1 + xmass) * (mass1 + xmass)) *
760 ((mass * mass) - (mass1 - xmass) * (mass1 - xmass))),0.0)) *
761 BrWig(gamma2, mass2, xmass);
762 return result;
763}
764
765G4double G4KineticTrack::IntegrandFunction3(G4double xmass) const
766{
767 const G4double mass = G4KineticTrack_Gmass; /* the actual mass value */
768// const G4double mass1 = theDaughterMass[0];
769 const G4double mass2 = theDaughterMass[1];
770 const G4double gamma2 = theDaughterWidth[1];
771
772 const G4double result = (1. / (2 * mass)) *
773 std::sqrt(((mass * mass) - (G4KineticTrack_xmass1 + xmass) * (G4KineticTrack_xmass1 + xmass)) *
774 ((mass * mass) - (G4KineticTrack_xmass1 - xmass) * (G4KineticTrack_xmass1 - xmass))) *
775 BrWig(gamma2, mass2, xmass);
776 return result;
777}
778
779G4double G4KineticTrack::IntegrandFunction4(G4double xmass) const
780{
781 const G4double mass = G4KineticTrack_Gmass;
782 const G4double mass1 = theDaughterMass[0];
783 const G4double gamma1 = theDaughterWidth[0];
784// const G4double mass2 = theDaughterMass[1];
785
786 G4KineticTrack_xmass1 = xmass;
787
788 const G4double theLowerLimit = 0.0;
789 const G4double theUpperLimit = mass - xmass;
790 const G4int nIterations = 100;
791
792 G4Integrator<const G4KineticTrack, G4double(G4KineticTrack::*)(G4double) const> integral;
793 G4double result = BrWig(gamma1, mass1, xmass)*
794 integral.Simpson(this, &G4KineticTrack::IntegrandFunction3, theLowerLimit, theUpperLimit, nIterations);
795
796 return result;
797}
798
799G4double G4KineticTrack::IntegrateCMMomentum(const G4double theLowerLimit) const
800{
801 const G4double theUpperLimit = theActualMass - theDaughterMass[0];
802 const G4int nIterations = 100;
803
804 if (theLowerLimit>=theUpperLimit) return 0.0;
805
806 G4Integrator<const G4KineticTrack, G4double(G4KineticTrack::*)(G4double) const> integral;
807 G4double theIntegralOverMass2 = integral.Simpson(this, &G4KineticTrack::IntegrandFunction1,
808 theLowerLimit, theUpperLimit, nIterations);
809 return theIntegralOverMass2;
810}
811
812G4double G4KineticTrack::IntegrateCMMomentum(const G4double theLowerLimit, const G4double poleMass) const
813{
814 const G4double theUpperLimit = poleMass - theDaughterMass[0];
815 const G4int nIterations = 100;
816
817 if (theLowerLimit>=theUpperLimit) return 0.0;
818
819 G4Integrator<const G4KineticTrack, G4double(G4KineticTrack::*)(G4double) const> integral;
820 const G4double theIntegralOverMass2 = integral.Simpson(this, &G4KineticTrack::IntegrandFunction2,
821 theLowerLimit, theUpperLimit, nIterations);
822 return theIntegralOverMass2;
823}
824
825
826G4double G4KineticTrack::IntegrateCMMomentum2() const
827{
828 const G4double theLowerLimit = 0.0;
829 const G4double theUpperLimit = theActualMass;
830 const G4int nIterations = 100;
831
832 if (theLowerLimit>=theUpperLimit) return 0.0;
833
834 G4Integrator<const G4KineticTrack, G4double(G4KineticTrack::*)(G4double) const> integral;
835 G4double theIntegralOverMass2 = integral.Simpson(this, &G4KineticTrack::IntegrandFunction4,
836 theLowerLimit, theUpperLimit, nIterations);
837 return theIntegralOverMass2;
838}
839
840
841
842
843
844
845
846
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
#define G4UniformRand()
Definition: Randomize.hh:52
static G4AntiKaonZero * AntiKaonZero()
G4int entries() const
G4DynamicParticle * PopProducts()
G4VDecayChannel * GetDecayChannel(G4int index) const
G4int entries() const
G4ParticleDefinition * GetDefinition() const
G4LorentzVector Get4Momentum() const
virtual G4DecayProducts * DecayIt(G4double mass=0.0)
static G4KaonZeroLong * KaonZeroLong()
static G4KaonZeroShort * KaonZeroShort()
static G4KaonZero * KaonZero()
Definition: G4KaonZero.cc:103
G4double GetFormationTime() const
G4KineticTrackVector * Decay()
G4KineticTrack & operator=(const G4KineticTrack &right)
G4bool operator!=(const G4KineticTrack &right) const
void Set4Momentum(const G4LorentzVector &a4Momentum)
G4int GetnChannels() const
const G4ThreeVector & GetPosition() const
const G4ParticleDefinition * GetDefinition() const
G4bool operator==(const G4KineticTrack &right) const
const G4LorentzVector & GetTrackingMomentum() const
G4double BrWig(const G4double Gamma, const G4double rmass, const G4double mass) const
const G4LorentzVector & Get4Momentum() const
G4double GetActualMass() const
G4double GetPDGWidth() const
G4double GetPDGCharge() const
G4DecayTable * GetDecayTable() const
const G4String & GetParticleName() const
G4double SampleMass(const G4double poleMass, const G4double gamma, const G4double minMass, const G4double maxMass) const
G4double GetMinimumMass(const G4ParticleDefinition *p) const
G4double GetBR() const
const G4String & GetParentName() const
G4int GetNumberOfDaughters() const
G4ParticleDefinition * GetDaughter(G4int anIndex)
const G4String & GetDaughterName(G4int anIndex) const
void G4SwapObj(T *a, T *b)
Definition: templates.hh:112
int G4lrint(double ad)
Definition: templates.hh:134
#define G4ThreadLocal
Definition: tls.hh:77