]>
Commit | Line | Data |
---|---|---|
1b446896 | 1 | |
2 | #include "AliHBTReader.h" | |
3 | ||
4 | ClassImp(AliHBTReaderITSv1) | |
5 | ||
6 | AliHBTReaderITSv1::AliHBTReaderITSv1(const Char_t* goodtracksfilename): | |
7 | fGoodITSTracksFileName(goodtracksfilename) | |
8 | ||
9 | { | |
10 | fParticles = new AliHBTRun(); | |
11 | fTracks = new AliHBTRun(); | |
12 | fIsRead = kFALSE; | |
13 | } | |
14 | AliHBTReaderITSv1::AliHBTReaderITSv1() | |
15 | { | |
16 | delete fParticles; | |
17 | delete fTracks; | |
18 | } | |
19 | AliHBTEvent* AliHBTReaderITSv1::GetParticleEvent(Int_t n) | |
20 | { | |
21 | //returns Nth event with simulated particles | |
22 | if (!fIsRead) Read(fParticles,fTracks); | |
23 | return fParticles->GetEvent(n); | |
24 | } | |
25 | /********************************************************************/ | |
26 | AliHBTEvent* AliHBTReaderITSv1::GetTrackEvent(Int_t n) | |
27 | { | |
28 | //returns Nth event with reconstructed tracks | |
29 | if (!fIsRead) Read(fParticles,fTracks); | |
30 | return fTracks->GetEvent(n); | |
31 | } | |
32 | /********************************************************************/ | |
33 | ||
34 | Int_t AliHBTReaderITSv1::GetNumberOfPartEvents() | |
35 | { | |
36 | //returns number of events of particles | |
37 | if (!fIsRead) Read(fParticles,fTracks); | |
38 | return fParticles->GetNumberOfEvents(); | |
39 | } | |
40 | ||
41 | /********************************************************************/ | |
42 | Int_t AliHBTReaderITSv1::GetNumberOfTrackEvents() | |
43 | { | |
44 | //returns number of events of tracks | |
45 | if (!fIsRead) Read(fParticles,fTracks); | |
46 | return fTracks->GetNumberOfEvents(); | |
47 | } | |
48 | /********************************************************************/ | |
49 | ||
50 | Int_t AliHBTReaderITSv1::Read(AliHBTRun* particles, AliHBTRun *tracks) | |
51 | { | |
52 | AliGoodTracksITSv1 *goodITStracks = new AliGoodTracksITSv1(fGoodITSTracksFileName); | |
53 | ||
54 | if (!goodITStracks) | |
55 | { | |
56 | Error("AliHBTReaderITSv1::Read","Exiting due to problems with opening files. Errorcode %d",i); | |
57 | return 1; | |
58 | } | |
59 | for (Int_t currentEvent = 0; currentEvent < goodITStracks->fNevents; currentEvent++) | |
60 | { | |
61 | for(Int_t i =0; i<goodITStracks->fGoodInEvent[currentEvent]; i++) | |
62 | { | |
63 | const struct GoodTrackITSv1 & gt = goodTPCTracks->GetTrack(currentEvent,i); | |
64 | ||
65 | if(Pass(gt.code)) continue; | |
66 | ||
67 | Double_t mass = TDatabasePDG::Instance()->GetParticle(gt.code)->Mass(); | |
68 | Double_t pEtot = TMath::Sqrt(gt.px*gt.px + gt.py*gt.py + gt.pz*gt.pz + mass*mass); | |
69 | ||
70 | AliHBTParticle* part = new AliHBTParticle(gt.code, gt.px, gt.py, gt.pz, pEtot, gt.x, gt.y, gt.z, 0.0); | |
71 | if(Pass(part)) { delete part; continue;} | |
72 | ||
73 | Double_t tEtot = TMath::Sqrt( gt.pxg*gt.pxg + gt.pyg*gt.pyg + gt.pzg*gt.pzg + mass*mass); | |
74 | ||
75 | AliHBTParticle* track = new AliHBTParticle(gt.code, gt.pxg, gt.pyg , gt.pzg, tEtot, 0., 0., 0., 0.); | |
76 | if(Pass(track)) { delete track;continue;} | |
77 | ||
78 | particles->AddParticle(currentEvent,part); | |
79 | tracks->AddParticle(currentEvent,track); | |
80 | } | |
81 | } | |
82 | delete goodITStracks; | |
83 | fIsRead = kTRUE; | |
84 | return 0; | |
85 | ||
86 | } | |
87 | /********************************************************************/ | |
88 | ||
89 | /********************************************************************/ | |
90 | /********************************************************************/ | |
91 | /********************************************************************/ | |
92 | ||
93 | ||
94 | AliGoodTracksITSv1::~AliGoodTracksITSv1() | |
95 | { | |
96 | delete [] fGoodInEvent; | |
97 | for (Int_t i = 0;i<fNevents;i++) | |
98 | delete [] fData[i]; | |
99 | delete [] fData; | |
100 | } | |
101 | /********************************************************************/ | |
102 | AliGoodTracksITSv1::AliGoodTracksITSv1(const TString& infilename) | |
103 | { | |
104 | ||
105 | cout<<"AliGoodTracksITSv1::AliGoodTracksITSv1() ....\n"; | |
106 | ||
107 | ||
108 | fNevents = 0; | |
109 | Int_t maxevents = 500; | |
110 | ||
111 | ifstream in(infilename.Data()); | |
112 | ||
113 | if(!in) | |
114 | { | |
115 | cerr<<"Can not open file with Good ITSv1 Tracks named:"<<infilename.Data()<<endl; | |
116 | delete this; | |
117 | return; | |
118 | } | |
119 | ||
120 | ||
121 | fGoodInEvent = new Int_t[maxevents]; | |
122 | fData = new struct GoodTrack* [maxevents]; | |
123 | ||
124 | Int_t i; | |
125 | Int_t lastevent = 0; | |
126 | fGoodInEvent[0] =0; | |
127 | fData[0] = new struct GoodTrack[50000]; | |
128 | ||
129 | Int_t evno; | |
130 | while(in>>evno) | |
131 | { | |
132 | if(lastevent>evno) | |
133 | { | |
134 | for(i = lastevent;i<=evno;i++) | |
135 | { | |
136 | fGoodInEvent[i] =0; | |
137 | fData[i] = new struct GoodTrack[50000]; | |
138 | } | |
139 | lastevent = evno; | |
140 | } | |
141 | if(fGoodInEvent[evno]>=50000) | |
142 | { | |
143 | cerr<<"AliGoodTracksITSv1::AliGoodTracksITSv1() : Not enough place in the array\n"; | |
144 | continue; | |
145 | } | |
146 | in>>fData[evno][fGoodInEvent[evno]].lab; | |
147 | in>>fData[evno][fGoodInEvent[evno]].code; | |
148 | in>>fData[evno][fGoodInEvent[evno]].px; | |
149 | in>>fData[evno][fGoodInEvent[evno]].py; | |
150 | in>>fData[evno][fGoodInEvent[evno]].pz; | |
151 | in>>fData[evno][fGoodInEvent[evno]].x; | |
152 | in>>fData[evno][fGoodInEvent[evno]].y; | |
153 | in>>fData[evno][fGoodInEvent[evno]].z; | |
154 | ||
155 | /* cout<<evno<<" "; | |
156 | cout<<fData[evno][fGoodInEvent[evno]].lab; | |
157 | cout<<" ";cout<<fData[evno][fGoodInEvent[evno]].code; | |
158 | cout<<" ";cout<<fData[evno][fGoodInEvent[evno]].px; | |
159 | cout<<" ";cout<<fData[evno][fGoodInEvent[evno]].py; | |
160 | cout<<" ";cout<<fData[evno][fGoodInEvent[evno]].pz; | |
161 | cout<<" ";cout<<fData[evno][fGoodInEvent[evno]].x; | |
162 | cout<<" ";cout<<fData[evno][fGoodInEvent[evno]].y; | |
163 | cout<<" ";cout<<fData[evno][fGoodInEvent[evno]].z; | |
164 | cout<<"\n"; | |
165 | */ | |
166 | fGoodInEvent[evno]++; | |
167 | } | |
168 | fNevents = evno+1; | |
169 | in.close(); | |
170 | cout<<"AliGoodTracksITSv1::AliGoodTracksITSv1() .... Done\n"; | |
171 | } | |
172 | ||
173 | ||
174 | ||
175 | const GoodTrack& AliGoodTracksITSv1::GetTrack(Int_t event, Int_t n) const | |
176 | { | |
177 | ||
178 | if( (event>fNevents) || (event<0)) | |
179 | { | |
180 | gROOT->Fatal("AliGoodTracksITSv1::GetTrack","No such Event %d",event); | |
181 | } | |
182 | if( (n>fGoodInEvent[event]) || (n<0)) | |
183 | { | |
184 | gROOT->Fatal("AliGoodTracksITSv1::GetTrack","No such Good TPC Track %d",n); | |
185 | } | |
186 | return fData[event][n]; | |
187 | ||
188 | } |