]>
Commit | Line | Data |
---|---|---|
108615fc | 1 | //Author: Anders Strand Vestbo |
2 | //Last Modified: 12.01.2001 | |
3 | ||
4 | #include <TCanvas.h> | |
5 | #include <TView.h> | |
6 | #include <TPolyMarker3D.h> | |
7 | #include <TPolyLine3D.h> | |
8 | #include <TH2.h> | |
9 | #include <TTree.h> | |
10 | ||
11 | #include "AliSimDigits.h" | |
12 | #include "AliTPCParam.h" | |
13 | #include "AliL3Transform.h" | |
14 | #include "AliL3Track.h" | |
15 | #include "AliL3TrackArray.h" | |
16 | #include "AliL3SpacePointData.h" | |
17 | #include "AliL3FileHandler.h" | |
18 | #include "AliL3Logging.h" | |
19 | #include "AliL3Display.h" | |
20 | ||
21 | // AliL3Display | |
22 | // Simple display class for the Level3 tracker. | |
23 | ||
24 | ClassImp(AliL3Display) | |
25 | ||
26 | AliL3Display::AliL3Display() | |
27 | { | |
28 | fGeom = NULL; | |
29 | fTracks = NULL; | |
30 | } | |
31 | ||
32 | AliL3Display::AliL3Display(Int_t *slice) | |
33 | { | |
34 | //Ctor. Specify which slices you want to look at. | |
35 | ||
36 | TFile *file = new TFile("alice.geom"); | |
37 | if(file->IsOpen()) | |
38 | LOG(AliL3Log::kError,"AliL3Display::AliL3Display","File Open") | |
39 | <<"Geometry file alice.geom does not exist"<<ENDLOG; | |
40 | ||
41 | fGeom = (TGeometry*)file->Get("AliceGeom"); | |
42 | fMinSlice = slice[0]; | |
43 | fMaxSlice = slice[1]; | |
44 | ||
45 | file->Close(); | |
46 | delete file; | |
47 | } | |
48 | ||
49 | AliL3Display::~AliL3Display() | |
50 | { | |
51 | ||
52 | if(fTracks) | |
53 | delete fTracks; | |
54 | ||
55 | } | |
56 | ||
57 | void AliL3Display::Setup(Char_t *trackfile) | |
58 | { | |
59 | //Read in the hit and track information from produced files. | |
60 | ||
61 | Char_t fname[256]; | |
62 | AliL3FileHandler *clusterfile[36][5]; | |
63 | for(Int_t s=fMinSlice; s<=fMaxSlice; s++) | |
64 | { | |
65 | for(Int_t p=0; p<5; p++) | |
66 | { | |
67 | clusterfile[s][p] = new AliL3FileHandler(); | |
68 | sprintf(fname,"points_%d_%d.raw",s,p); | |
69 | if(!clusterfile[s][p]->SetBinaryInput(fname)) | |
70 | { | |
71 | LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open") | |
72 | <<"Inputfile "<<fname<<" does not exist"<<ENDLOG; | |
73 | return; | |
74 | } | |
75 | fClusters[s][p] = (AliL3SpacePointData*)clusterfile[s][p]->Allocate(); | |
76 | clusterfile[s][p]->Binary2Memory(fNcl[s][p],fClusters[s][p]); | |
77 | clusterfile[s][p]->CloseBinaryInput(); | |
78 | } | |
79 | } | |
80 | ||
81 | ||
82 | AliL3FileHandler *tfile = new AliL3FileHandler(); | |
83 | if(!tfile->SetBinaryInput(trackfile)) | |
84 | { | |
85 | LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open") | |
86 | <<"Inputfile "<<trackfile<<" does not exist"<<ENDLOG; | |
87 | return; | |
88 | } | |
89 | fTracks = new AliL3TrackArray(); | |
90 | tfile->Binary2TrackArray(fTracks); | |
91 | tfile->CloseBinaryInput(); | |
92 | delete tfile; | |
93 | ||
94 | } | |
95 | ||
96 | void AliL3Display::DisplayTracks(Int_t min_hits) | |
97 | { | |
98 | //Display the found tracks. | |
99 | ||
100 | TCanvas *c1 = new TCanvas("c1","",700,700); | |
101 | c1->cd(); | |
102 | TView *v = new TView(1); | |
103 | v->SetRange(-430,-560,-430,430,560,1710); | |
104 | c1->Clear(); | |
105 | c1->SetFillColor(1); | |
106 | c1->SetTheta(90.); | |
107 | c1->SetPhi(0.); | |
108 | ||
109 | Int_t ntracks = fTracks->GetNTracks(); | |
110 | TPolyLine3D *line = new TPolyLine3D[ntracks]; | |
111 | Float_t xcl[174]; | |
112 | Float_t ycl[174]; | |
113 | Float_t zcl[174]; | |
114 | ||
115 | for(Int_t j=0; j<ntracks; j++) | |
116 | { | |
117 | AliL3Track *gtrack = fTracks->GetCheckedTrack(j); | |
118 | if(!gtrack) continue; | |
119 | Int_t nHits = gtrack->GetNHits(); | |
120 | UInt_t *hitnum = gtrack->GetHitNumbers(); | |
121 | if(nHits < min_hits) continue; | |
122 | TPolyMarker3D *pm = new TPolyMarker3D(nHits); | |
123 | for(Int_t h=0; h<nHits; h++) | |
124 | { | |
125 | UInt_t id=hitnum[h]; | |
126 | Int_t slice = (id>>25) & 0x7f; | |
127 | Int_t patch = (id>>22) & 0x7; | |
128 | UInt_t pos = id&0x3fffff; | |
129 | ||
130 | AliL3SpacePointData *points = fClusters[slice][patch]; | |
131 | ||
132 | if(!points) { | |
133 | LOG(AliL3Log::kError,"AliL3Display::DisplayTracks","Clusterarray") | |
134 | <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG; | |
135 | continue; | |
136 | } | |
137 | if(pos>=fNcl[slice][patch]) {printf("Error \n"); continue;} | |
138 | xcl[h] = points[pos].fX; | |
139 | ycl[h] = points[pos].fY; | |
140 | zcl[h] = points[pos].fZ; | |
141 | pm->SetPoint(h,xcl[h],ycl[h],zcl[h]); | |
142 | } | |
143 | pm->SetMarkerColor(3); | |
144 | pm->Draw(); | |
145 | TPolyLine3D *current_line = &(line[j]); | |
146 | current_line = new TPolyLine3D(nHits,xcl,ycl,zcl,""); | |
147 | ||
148 | current_line->SetLineColor(4); | |
149 | current_line->Draw("same"); | |
150 | } | |
151 | ||
152 | fGeom->Draw("same"); | |
153 | ||
154 | c1->x3d(); | |
155 | ||
156 | } | |
157 | ||
158 | void AliL3Display::DisplayClusters() | |
159 | { | |
160 | //Display all clusters. | |
161 | ||
162 | TCanvas *c1 = new TCanvas("c1","",700,700); | |
163 | c1->cd(); | |
164 | TView *v = new TView(1); | |
165 | v->SetRange(-430,-560,-430,430,560,1710); | |
166 | c1->Clear(); | |
167 | c1->SetFillColor(1); | |
168 | c1->SetTheta(90.); | |
169 | c1->SetPhi(0.); | |
170 | ||
171 | for(Int_t s=fMinSlice; s<=fMaxSlice; s++) | |
172 | { | |
173 | for(Int_t p=0;p<1;p++) | |
174 | { | |
175 | AliL3SpacePointData *points = fClusters[s][p]; | |
176 | if(!points) continue; | |
177 | Int_t npoints = fNcl[s][p]; | |
178 | TPolyMarker3D *pm = new TPolyMarker3D(npoints); | |
179 | ||
180 | Float_t xyz[3]; | |
181 | for(Int_t i=0; i<npoints; i++){ | |
182 | xyz[0] = points[i].fX; | |
183 | xyz[1] = points[i].fY; | |
184 | xyz[2] = points[i].fZ; | |
185 | ||
186 | pm->SetPoint(i,xyz[0],xyz[1],xyz[2]); | |
187 | ||
188 | } | |
189 | pm->SetMarkerColor(2); | |
190 | pm->Draw(""); | |
191 | } | |
192 | } | |
193 | fGeom->Draw("same"); | |
194 | ||
195 | c1->x3d(); | |
196 | } | |
197 | ||
198 | ||
199 | void AliL3Display::DisplayAll(Int_t min_hits) | |
200 | { | |
201 | //Display tracks & all hits. | |
202 | ||
203 | ||
204 | TCanvas *c1 = new TCanvas("c1","",700,700); | |
205 | c1->cd(); | |
206 | TView *v = new TView(1); | |
207 | v->SetRange(-430,-560,-430,430,560,1710); | |
208 | c1->Clear(); | |
209 | c1->SetFillColor(1); | |
210 | c1->SetTheta(90.); | |
211 | c1->SetPhi(0.); | |
212 | ||
213 | for(Int_t s=fMinSlice; s<=fMaxSlice; s++) | |
214 | { | |
215 | for(Int_t p=0;p<1;p++) | |
216 | { | |
217 | AliL3SpacePointData *points = fClusters[s][p]; | |
218 | if(!points) continue; | |
219 | Int_t npoints = fNcl[s][p]; | |
220 | TPolyMarker3D *pm = new TPolyMarker3D(npoints); | |
221 | ||
222 | Float_t xyz[3]; | |
223 | for(Int_t i=0; i<npoints; i++){ | |
224 | xyz[0] = points[i].fX; | |
225 | xyz[1] = points[i].fY; | |
226 | xyz[2] = points[i].fZ; | |
227 | ||
228 | pm->SetPoint(i,xyz[0],xyz[1],xyz[2]); | |
229 | ||
230 | } | |
231 | pm->SetMarkerColor(2); | |
232 | pm->Draw(""); | |
233 | } | |
234 | } | |
235 | ||
236 | Int_t ntracks = fTracks->GetNTracks(); | |
237 | TPolyLine3D *line = new TPolyLine3D[ntracks]; | |
238 | Float_t xcl[174]; | |
239 | Float_t ycl[174]; | |
240 | Float_t zcl[174]; | |
241 | ||
242 | ||
243 | for(Int_t j=0; j<ntracks; j++) | |
244 | { | |
245 | AliL3Track *gtrack = fTracks->GetCheckedTrack(j); | |
246 | if(!gtrack) continue; | |
247 | Int_t nHits = gtrack->GetNHits(); | |
248 | UInt_t *hitnum = gtrack->GetHitNumbers(); | |
249 | if(nHits < min_hits) continue; | |
250 | TPolyMarker3D *pm = new TPolyMarker3D(nHits); | |
251 | for(Int_t h=0; h<nHits; h++) | |
252 | { | |
253 | UInt_t id=hitnum[h]; | |
254 | Int_t slice = (id>>25) & 0x7f; | |
255 | Int_t patch = (id>>22) & 0x7; | |
256 | UInt_t pos = id&0x3fffff; | |
257 | ||
258 | AliL3SpacePointData *points = fClusters[slice][patch]; | |
259 | ||
260 | if(!points) { | |
261 | LOG(AliL3Log::kError,"AliL3Display::DisplayTracks","Clusterarray") | |
262 | <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG; | |
263 | continue; | |
264 | } | |
265 | if(pos>=fNcl[slice][patch]) {printf("Error \n"); continue;} | |
266 | xcl[h] = points[pos].fX; | |
267 | ycl[h] = points[pos].fY; | |
268 | zcl[h] = points[pos].fZ; | |
269 | pm->SetPoint(h,xcl[h],ycl[h],zcl[h]); | |
270 | } | |
271 | pm->SetMarkerColor(3); | |
272 | pm->Draw(); | |
273 | TPolyLine3D *current_line = &(line[j]); | |
274 | current_line = new TPolyLine3D(nHits,xcl,ycl,zcl,""); | |
275 | ||
276 | current_line->SetLineColor(4); | |
277 | current_line->Draw("same"); | |
278 | } | |
279 | ||
280 | fGeom->Draw("same"); | |
281 | ||
282 | c1->x3d(); | |
283 | ||
284 | } | |
285 | ||
286 | void AliL3Display::DisplayClusterRow(Int_t slice,Int_t padrow,Char_t *digitsFile) | |
287 | { | |
288 | //Display the found clusters on this row together with the raw data. | |
289 | ||
290 | ||
291 | TFile *file = new TFile(digitsFile); | |
292 | AliTPCParam *param = (AliTPCParam*)file->Get("75x40_100x60"); | |
293 | TTree *TD=(TTree*)file->Get("TreeD_75x40_100x60"); | |
294 | AliSimDigits da, *digits=&da; | |
295 | TD->GetBranch("Segment")->SetAddress(&digits); //Return pointer to branch segment. | |
296 | AliL3Transform *transform = new AliL3Transform(); | |
297 | ||
298 | Int_t sector,row; | |
299 | transform->Slice2Sector(slice,padrow,sector,row); | |
300 | Int_t npads = param->GetNPads(sector,row); | |
301 | Int_t ntimes = param->GetMaxTBin(); | |
302 | TH2F *histdig = new TH2F("histdig","",npads,0,npads-1,ntimes,0,ntimes-1); | |
303 | TH2F *histfast = new TH2F("histfast","",npads,0,npads-1,ntimes,0,ntimes-1); | |
304 | ||
305 | Int_t sectors_by_rows=(Int_t)TD->GetEntries(); | |
306 | Int_t i; | |
307 | for (i=0; i<sectors_by_rows; i++) { | |
308 | if (!TD->GetEvent(i)) continue; | |
309 | Int_t sec,ro; | |
310 | param->AdjustSectorRow(digits->GetID(),sec,ro); | |
311 | ||
312 | if(sec != sector) continue; | |
313 | if(ro < row) continue; | |
314 | if(ro != row) break; | |
315 | printf("sector %d row %d\n",sec,ro); | |
316 | digits->First(); | |
317 | while (digits->Next()) { | |
318 | Int_t it=digits->CurrentRow(), ip=digits->CurrentColumn(); | |
319 | Short_t dig = digits->GetDigit(it,ip); | |
320 | if(dig<=param->GetZeroSup()) continue; | |
321 | if(it < param->GetMaxTBin()-1 && it > 0) | |
322 | if(digits->GetDigit(it+1,ip) <= param->GetZeroSup() | |
323 | && digits->GetDigit(it-1,ip) <= param->GetZeroSup()) | |
324 | continue; | |
325 | ||
326 | histdig->Fill(ip,it,dig); | |
327 | } | |
328 | } | |
329 | ||
330 | ||
331 | for(Int_t p=0;p<1;p++) | |
332 | { | |
333 | AliL3SpacePointData *points = fClusters[slice][p]; | |
334 | if(!points) continue; | |
335 | ||
336 | Int_t npoints = fNcl[slice][p]; | |
337 | Float_t xyz[3]; | |
338 | for(Int_t i=0; i<npoints; i++) | |
339 | { | |
340 | if(points[i].fPadRow != padrow) continue; | |
341 | xyz[0] = points[i].fX; | |
342 | xyz[1] = points[i].fY; | |
343 | xyz[2] = points[i].fZ; | |
344 | transform->Global2Raw(xyz,sector,row); | |
345 | histfast->Fill((Int_t)xyz[1],(Int_t)xyz[2],1); | |
346 | ||
347 | } | |
348 | ||
349 | } | |
350 | ||
351 | TCanvas *c1 = new TCanvas("c1","",2); | |
352 | c1->cd(); | |
353 | histdig->Draw(); | |
354 | ||
355 | histfast->SetMarkerColor(2); | |
356 | histfast->SetMarkerStyle(4); | |
357 | ||
358 | histdig->GetXaxis()->SetTitle("Pad"); | |
359 | histdig->GetYaxis()->SetTitle("Time"); | |
360 | histdig->Draw("hist"); | |
361 | histfast->Draw("psame"); | |
362 | ||
363 | } |