1 #include "FairPrimaryGenerator.h"
6 #include "TMCProcess.h"
8 #include "TVirtualMC.h"
17 using std::stringstream;
19 #include <TVirtualMCDecayer.h>
32 : FairGenerator(), fDecayPdgCodes(0), fGeantPdgCodes(0) {
58 if (!
fDecayer) { Fatal(
"Init",
"CbmFastDecayer has no external decayer!!!"); }
89 Error(
"ReadEvent",
"No PrimaryGenerator!");
96 Error(
"ReadEvent",
"Error: No stack found!");
100 Float_t polar[3] = {0, 0, 0};
108 TLorentzVector* mom =
new TLorentzVector();
111 static TClonesArray* particles;
112 if (!particles) particles =
new TClonesArray(
"TParticle", 1000);
117 "nPrimaries = %d and ntracks = %d before fast decayer",
122 primGen->DoTracking(kTRUE);
126 std::vector<int>::iterator it;
129 for (Int_t iTrack = 0; iTrack < nTrackStack; ++iTrack) {
133 Int_t pdg = part->GetPdgCode();
143 if ( part->GetNDaughters() > 0) {
145 "Attention: particle %d is already decayed (code:%d,daughters:%d)!",
147 part->GetStatusCode(),
148 part->GetNDaughters());
153 part->SetStatusCode(11);
156 mom->SetPxPyPzE(part->Px(), part->Py(), part->Pz(), part->Energy());
162 np =
fDecayer->ImportParticles(particles);
165 Int_t* trackIt =
new Int_t[np];
166 Int_t* pParent =
new Int_t[np];
169 "ReadEvent",
"number of products: np = %d for mother: %d", np - 1, pdg);
172 for (
int i = 0;
i < np;
i++) {
179 TParticle* iparticle = 0;
181 for (
int i = 1;
i < np;
i++) {
182 iparticle = (TParticle*) particles->At(
i);
183 Int_t ks = iparticle->GetStatusCode();
184 Int_t pdgd = iparticle->GetPdgCode();
203 origin0[0] = part->Vx();
204 origin0[1] = part->Vy();
205 origin0[2] = part->Vz();
216 for (
int i = 1;
i < np;
i++) {
217 TParticle* iparticle = (TParticle*) particles->At(
i);
218 Int_t kf = iparticle->GetPdgCode();
219 Int_t ksc = iparticle->GetStatusCode();
220 Int_t jpa = iparticle->GetFirstMother()
229 "FirstMother = %d (iparent %d), indicePart = %d, pdg = %d ",
236 och[0] = origin0[0] + iparticle->Vx();
237 och[1] = origin0[1] + iparticle->Vy();
238 och[2] = origin0[2] + iparticle->Vz();
239 pc[0] = iparticle->Px();
240 pc[1] = iparticle->Py();
241 pc[2] = iparticle->Pz();
242 tof = part->T() + iparticle->T();
243 Double_t ee = iparticle->Energy();
249 " Add track %d to primary Generator: pdg=%d with parent=%d and do "
250 "tracking %d (stack primaries: %d, tracks: %d)",
258 primGen->AddTrack(kf,
265 iparent - nTrackStack,
273 if (trackIt)
delete[] trackIt;
274 if (pParent)
delete[] pParent;
278 primGen->DoTracking(kFALSE);
286 stringstream ss(pdgs);
303 stringstream ss(pdgs);