1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
22 #include "AliGenKine.h"
23 #include "AliMCProcess.h"
30 #include <TDirectory.h>
31 #include <TDatabasePDG.h>
35 #include <TClonesArray.h>
36 #include <TObjArray.h>
37 #include <TParticle.h>
41 AliGenKine::AliGenKine()
46 fTitle = "Primaries from ext. File";
57 AliGenKine::AliGenKine(Int_t npart)
62 fTitle = "Primaries from ext. File";
70 //____________________________________________________________
71 AliGenKine::~AliGenKine()
77 //____________________________________________________________
79 //____________________________________________________________
80 void AliGenKine::Generate()
82 Float_t polar[3], vpos[3], pmom[3];
84 // Connect file and get next event
87 TTree *ali = gAlice->TreeE();
88 if (ali) fBaseFile = ali->GetCurrentFile();
92 fFile = new TFile(fFileName);
95 // cd to file with old kine tree
96 if (fStack) delete fStack;
97 fStack = new AliStack(1000);
100 TTree* treeE = (TTree*)gDirectory->Get("TE");
101 treeE->SetBranchAddress("Stack", &fStack);
103 treeE->GetEntry(fNcurrent);
104 fStack->GetEvent(fNcurrent);
105 // cd back to base file
112 for (Int_t i = 0; i < fStack->GetNtrack(); i++)
114 TParticle* part = fStack->Particle(i);
117 Int_t pdg = part->GetPdgCode();
118 // if (pdg == -1) continue;
120 Int_t parent = part->GetFirstMother();
121 Float_t tof = part->T();
123 vpos[0] = part->Vx();
124 vpos[1] = part->Vy();
125 vpos[2] = part->Vz();
127 pmom[0] = part->Px();
128 pmom[1] = part->Py();
129 pmom[2] = part->Pz();
131 printf("\n %d %d %d %f", i, fStack->GetNtrack(), part->GetPdgCode(), pmom[2]);
132 gAlice->SetTrack(fTrackIt, parent, pdg, pmom, vpos, polar,
133 tof, kPPrimary, ntr);
134 gAlice->KeepTrack(ntr);
136 gAlice->SetHighWaterMark(ntr);
139 // cd back to output file