]>
Commit | Line | Data |
---|---|---|
9e1a0ddb | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
18 | */ | |
19 | ||
20 | #include <iostream.h> | |
21 | ||
22 | #include "AliGenKine.h" | |
23 | #include "AliMCProcess.h" | |
24 | #include "AliMC.h" | |
25 | #include "AliRun.h" | |
26 | #include "AliStack.h" | |
27 | ||
28 | #include <TROOT.h> | |
29 | #include <TTree.h> | |
30 | #include <TDirectory.h> | |
31 | #include <TDatabasePDG.h> | |
32 | #include <TFile.h> | |
33 | #include <TH1.h> | |
34 | #include <TArrayI.h> | |
35 | #include <TClonesArray.h> | |
36 | #include <TObjArray.h> | |
37 | #include <TParticle.h> | |
38 | #include <stdlib.h> | |
39 | ||
40 | ClassImp(AliGenKine) | |
41 | AliGenKine::AliGenKine() | |
42 | :AliGenerator(-1) | |
43 | { | |
44 | // Constructor | |
45 | fName = "Kine"; | |
46 | fTitle = "Primaries from ext. File"; | |
47 | fFileName = NULL; | |
48 | fStack = 0; | |
49 | fNcurrent = 0; | |
50 | // | |
51 | // Read all particles | |
52 | fNpart = -1; | |
53 | fFile = 0; | |
54 | fBaseFile = 0; | |
55 | } | |
56 | ||
57 | AliGenKine::AliGenKine(Int_t npart) | |
58 | :AliGenerator(npart) | |
59 | { | |
60 | // Constructor | |
61 | fName = "Kine"; | |
62 | fTitle = "Primaries from ext. File"; | |
63 | fFileName = NULL; | |
64 | fStack = 0; | |
65 | fNcurrent = 0; | |
66 | fFile = 0; | |
67 | fBaseFile = 0; | |
68 | } | |
69 | ||
70 | //____________________________________________________________ | |
71 | AliGenKine::~AliGenKine() | |
72 | { | |
73 | // Destructor | |
74 | ||
75 | } | |
76 | ||
77 | //____________________________________________________________ | |
78 | ||
79 | //____________________________________________________________ | |
80 | void AliGenKine::Generate() | |
81 | { | |
82 | Float_t polar[3], vpos[3], pmom[3]; | |
83 | // | |
84 | // Connect file and get next event | |
85 | // | |
86 | if (!fBaseFile) { | |
87 | TTree *ali = gAlice->TreeE(); | |
88 | if (ali) fBaseFile = ali->GetCurrentFile(); | |
89 | } | |
90 | ||
91 | if (!fFile) { | |
92 | fFile = new TFile(fFileName); | |
93 | } | |
94 | ||
95 | // cd to file with old kine tree | |
96 | if (fStack) delete fStack; | |
97 | fStack = new AliStack(1000); | |
98 | fFile->cd(); | |
99 | // Connect treeE | |
100 | TTree* treeE = (TTree*)gDirectory->Get("TE"); | |
101 | treeE->SetBranchAddress("Stack", &fStack); | |
102 | // Get next event | |
103 | treeE->GetEntry(fNcurrent); | |
104 | fStack->GetEvent(fNcurrent); | |
105 | // cd back to base file | |
106 | fBaseFile->cd(); | |
107 | // | |
108 | // Read Particles | |
109 | // | |
110 | Int_t ntr; | |
111 | ||
112 | for (Int_t i = 0; i < fStack->GetNtrack(); i++) | |
113 | { | |
114 | TParticle* part = fStack->Particle(i); | |
115 | ||
116 | ||
117 | Int_t pdg = part->GetPdgCode(); | |
118 | // if (pdg == -1) continue; | |
119 | ||
120 | Int_t parent = part->GetFirstMother(); | |
121 | Float_t tof = part->T(); | |
122 | ||
123 | vpos[0] = part->Vx(); | |
124 | vpos[1] = part->Vy(); | |
125 | vpos[2] = part->Vz(); | |
126 | ||
127 | pmom[0] = part->Px(); | |
128 | pmom[1] = part->Py(); | |
129 | pmom[2] = part->Pz(); | |
130 | ||
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); | |
135 | } | |
136 | gAlice->SetHighWaterMark(ntr); | |
137 | fNcurrent++; | |
138 | ||
139 | // cd back to output file | |
140 | ||
141 | } | |
142 | ||
143 | ||
144 | ||
145 | ||
146 | ||
147 | ||
148 | ||
149 |