]>
Commit | Line | Data |
---|---|---|
41229b87 | 1 | // $Id$ |
2 | // Category: physics | |
3 | // | |
4 | // See the class description in the header file. | |
5 | ||
6 | #include "AliDecayer.h" | |
7 | ||
8 | #include "TG4ExtDecayer.h" | |
9 | #include "TG4ParticlesManager.h" | |
10 | #include "TG4G3Units.h" | |
11 | ||
12 | #include <G4DynamicParticle.hh> | |
13 | #include <G4DecayProducts.hh> | |
14 | #include <G4DecayTable.hh> | |
15 | #include <G4ParticleTable.hh> | |
16 | #include <G4DynamicParticle.hh> | |
17 | #include <G4Track.hh> | |
18 | ||
19 | #include <TParticle.h> | |
20 | #include <TLorentzVector.h> | |
21 | #include <TClonesArray.h> | |
22 | ||
23 | #include <math.h> | |
24 | ||
25 | // constructor | |
26 | TG4ExtDecayer::TG4ExtDecayer(AliDecayer* externalDecayer) | |
27 | : G4VExtDecayer("TG4ExtDecayer"), | |
28 | fExternalDecayer(externalDecayer), | |
29 | fVerboseLevel(0) { | |
30 | // | |
31 | fDecayProductsArray = new TClonesArray("TParticle", 1000); | |
32 | fParticlesManager = TG4ParticlesManager::Instance(); | |
33 | } | |
34 | ||
35 | TG4ExtDecayer::~TG4ExtDecayer() { | |
36 | // | |
37 | delete fDecayProductsArray; | |
38 | } | |
39 | ||
40 | // public methods | |
41 | ||
42 | G4DecayProducts* TG4ExtDecayer::ImportDecayProducts(const G4Track& track) | |
43 | { | |
44 | // check if external decayer is defined | |
45 | if (!fExternalDecayer) { | |
46 | #ifdef G4VERBOSE | |
47 | G4cerr << "TG4ExtDecayer::ImportDecayProducts: " << G4endl | |
48 | << " No fExternalDecayer is defined." << G4endl; | |
49 | #endif | |
50 | return 0; | |
51 | } | |
52 | ||
53 | // get particle momentum | |
54 | G4ThreeVector momentum = track.GetMomentum(); | |
55 | G4double mag = momentum.mag(); | |
56 | TLorentzVector p; | |
57 | p[0] = momentum.x()/mag; | |
58 | p[1] = momentum.x()/mag; | |
59 | p[2] = momentum.x()/mag; | |
60 | p[3] = mag/TG4G3Units::Energy(); | |
61 | ||
62 | // get particle PDG | |
63 | // ask TG4ParticlesManager to get PDG encoding | |
64 | // (in order to get PDG from extended TDatabasePDG | |
65 | // in case the standard PDG code is not defined) | |
66 | G4ParticleDefinition* particleDef = track.GetDefinition(); | |
67 | G4int pdgEncoding = fParticlesManager->GetPDGEncodingFast(particleDef); | |
68 | ||
69 | // let AliDecayer decay the particle | |
70 | // and import the decay products | |
71 | fExternalDecayer->Decay(pdgEncoding, &p); | |
72 | G4int nofParticles | |
73 | = fExternalDecayer->ImportParticles(fDecayProductsArray); | |
74 | ||
75 | if (fVerboseLevel>0) | |
76 | G4cout << "nofParticles: " << nofParticles << G4endl; | |
77 | ||
78 | // convert decay products TParticle type | |
79 | // to G4DecayProducts | |
80 | G4DecayProducts* decayProducts | |
81 | = new G4DecayProducts(*(track.GetDynamicParticle())); | |
82 | ||
83 | G4int counter = 0; | |
84 | for (G4int i=0; i<nofParticles; i++) { | |
85 | ||
86 | // get particle from TClonesArray | |
87 | TParticle* particle | |
88 | = fParticlesManager->GetParticle(fDecayProductsArray, i); | |
89 | ||
90 | G4int status = particle->GetStatusCode(); | |
91 | G4int pdg = particle->GetPdgCode(); | |
92 | if ( status>0 && status<11 && | |
93 | abs(pdg)!=12 && abs(pdg)!=14 && abs(pdg)!=16 ) { | |
94 | // pass to tracking final particles only; | |
95 | // skip neutrinos | |
96 | ||
97 | if (fVerboseLevel>0) | |
98 | G4cout << " " << i << "th particle PDG: " << pdg << " "; | |
99 | ||
100 | // create G4DynamicParticle | |
101 | G4DynamicParticle* dynamicParticle | |
102 | = fParticlesManager->CreateDynamicParticle(particle); | |
103 | ||
104 | if (dynamicParticle) { | |
105 | ||
106 | if (fVerboseLevel>0) | |
107 | G4cout << " G4 particle name: " | |
108 | << dynamicParticle->GetDefinition()->GetParticleName() | |
109 | << G4endl; | |
110 | ||
111 | // add dynamicParticle to decayProducts | |
112 | decayProducts->PushProducts(dynamicParticle); | |
113 | ||
114 | counter++; | |
115 | } | |
116 | } | |
117 | } | |
118 | if (fVerboseLevel>0) | |
119 | G4cout << "nofParticles for tracking: " << counter << G4endl; | |
120 | ||
121 | return decayProducts; | |
122 | } | |
123 |