]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/src/AliL3Display.cxx
Standard include file to include different files for different compiler versions.
[u/mrichter/AliRoot.git] / HLT / src / AliL3Display.cxx
CommitLineData
a3039c91 1//$Id$
2
b661165c 3// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4//*-- Copyright &copy ASV
108615fc 5
6#include <TCanvas.h>
7#include <TView.h>
8#include <TPolyMarker3D.h>
9#include <TPolyLine3D.h>
10#include <TH2.h>
11#include <TTree.h>
7d3726a4 12#include <TNode.h>
13#include <TGeometry.h>
14#include <TShape.h>
4e03c52a 15#include <TParticle.h>
95a00d93 16#include <TFile.h>
108615fc 17
95a00d93 18#include "AliL3Display.h"
a3039c91 19#ifdef use_aliroot
4e03c52a 20#include "AliRun.h"
108615fc 21#include "AliSimDigits.h"
22#include "AliTPCParam.h"
a3039c91 23#endif
108615fc 24#include "AliL3Transform.h"
25#include "AliL3Track.h"
26#include "AliL3TrackArray.h"
27#include "AliL3SpacePointData.h"
95a00d93 28#include "AliL3MemHandler.h"
108615fc 29#include "AliL3Logging.h"
95a00d93 30
108615fc 31
b661165c 32//_____________________________________________________________
108615fc 33// AliL3Display
b661165c 34//
108615fc 35// Simple display class for the Level3 tracker.
36
37ClassImp(AliL3Display)
38
39AliL3Display::AliL3Display()
40{
41 fGeom = NULL;
42 fTracks = NULL;
43}
44
eeddc64d 45AliL3Display::AliL3Display(Int_t *slice,Char_t *gfile)
108615fc 46{
47 //Ctor. Specify which slices you want to look at.
48
eeddc64d 49 TFile *file = new TFile(gfile);
7d3726a4 50 if(!file) printf("NO FILE\n");
cf63f233 51 if(!file->IsOpen())
108615fc 52 LOG(AliL3Log::kError,"AliL3Display::AliL3Display","File Open")
eeddc64d 53 <<"Geometry file " << gfile << " does not exist"<<ENDLOG;
108615fc 54
55 fGeom = (TGeometry*)file->Get("AliceGeom");
56 fMinSlice = slice[0];
57 fMaxSlice = slice[1];
58
59 file->Close();
60 delete file;
61}
62
63AliL3Display::~AliL3Display()
64{
65
66 if(fTracks)
67 delete fTracks;
108615fc 68}
69
4e03c52a 70void AliL3Display::Setup(Char_t *trackfile,Char_t *path)
108615fc 71{
72 //Read in the hit and track information from produced files.
73
ef79795d 74 AliL3Transform::Init(path);
108615fc 75 Char_t fname[256];
95a00d93 76 AliL3MemHandler *clusterfile[36][6];
108615fc 77 for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
78 {
8f924a46 79 for(Int_t p=0; p<6; p++)
108615fc 80 {
95a00d93 81 clusterfile[s][p] = new AliL3MemHandler();
4e03c52a 82 sprintf(fname,"%spoints_%d_%d.raw",path,s,p);
108615fc 83 if(!clusterfile[s][p]->SetBinaryInput(fname))
84 {
85 LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
86 <<"Inputfile "<<fname<<" does not exist"<<ENDLOG;
7d3726a4 87 delete clusterfile[s][p];
88 clusterfile[s][p] = 0;
89 continue;
108615fc 90 }
91 fClusters[s][p] = (AliL3SpacePointData*)clusterfile[s][p]->Allocate();
92 clusterfile[s][p]->Binary2Memory(fNcl[s][p],fClusters[s][p]);
93 clusterfile[s][p]->CloseBinaryInput();
94 }
95 }
96
97
95a00d93 98 AliL3MemHandler *tfile = new AliL3MemHandler();
108615fc 99 if(!tfile->SetBinaryInput(trackfile))
100 {
101 LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
102 <<"Inputfile "<<trackfile<<" does not exist"<<ENDLOG;
103 return;
104 }
105 fTracks = new AliL3TrackArray();
106 tfile->Binary2TrackArray(fTracks);
107 tfile->CloseBinaryInput();
108 delete tfile;
109
110}
111
4499ed26 112void AliL3Display::DisplayTracks(Int_t min_hits,Bool_t x3don,Float_t thr)
108615fc 113{
114 //Display the found tracks.
115
116 TCanvas *c1 = new TCanvas("c1","",700,700);
117 c1->cd();
7d3726a4 118
108615fc 119 TView *v = new TView(1);
120 v->SetRange(-430,-560,-430,430,560,1710);
121 c1->Clear();
4e03c52a 122 c1->SetFillColor(1);
4499ed26 123 c1->SetTheta(45.);
108615fc 124 c1->SetPhi(0.);
7d3726a4 125
108615fc 126 Int_t ntracks = fTracks->GetNTracks();
127 TPolyLine3D *line = new TPolyLine3D[ntracks];
ae97a0b9 128 Float_t xcl[176];
129 Float_t ycl[176];
130 Float_t zcl[176];
7d3726a4 131
108615fc 132 for(Int_t j=0; j<ntracks; j++)
133 {
134 AliL3Track *gtrack = fTracks->GetCheckedTrack(j);
4499ed26 135 if(!gtrack) continue;
136 if(gtrack->GetPt()<thr) continue;
108615fc 137 Int_t nHits = gtrack->GetNHits();
138 UInt_t *hitnum = gtrack->GetHitNumbers();
139 if(nHits < min_hits) continue;
140 TPolyMarker3D *pm = new TPolyMarker3D(nHits);
c6fa4f1e 141 Int_t hitcount=0;
108615fc 142 for(Int_t h=0; h<nHits; h++)
143 {
144 UInt_t id=hitnum[h];
145 Int_t slice = (id>>25) & 0x7f;
146 Int_t patch = (id>>22) & 0x7;
147 UInt_t pos = id&0x3fffff;
108615fc 148 AliL3SpacePointData *points = fClusters[slice][patch];
4e03c52a 149 if(slice < fMinSlice || slice > fMaxSlice)
150 continue;
151
108615fc 152 if(!points) {
153 LOG(AliL3Log::kError,"AliL3Display::DisplayTracks","Clusterarray")
154 <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
155 continue;
156 }
157 if(pos>=fNcl[slice][patch]) {printf("Error \n"); continue;}
4e03c52a 158 Float_t xyz_tmp[3];
159 xyz_tmp[0] = points[pos].fX;
160 xyz_tmp[1] = points[pos].fY;
161 xyz_tmp[2] = points[pos].fZ;
162
163 xcl[h] = xyz_tmp[0];
164 ycl[h] = xyz_tmp[1];
165 zcl[h] = xyz_tmp[2];
7d3726a4 166
108615fc 167 pm->SetPoint(h,xcl[h],ycl[h],zcl[h]);
c6fa4f1e 168 hitcount++;
108615fc 169 }
c6fa4f1e 170 if(hitcount==0) continue;
7d3726a4 171 pm->SetMarkerColor(2);
4e03c52a 172 pm->Draw();
108615fc 173 TPolyLine3D *current_line = &(line[j]);
174 current_line = new TPolyLine3D(nHits,xcl,ycl,zcl,"");
175
a3039c91 176 current_line->SetLineColor(4);
108615fc 177 current_line->Draw("same");
7d3726a4 178
108615fc 179 }
4499ed26 180
a3039c91 181 //Take this if you want black&white display for printing.
182 Char_t fname[256];
183 Int_t i;
184 Int_t color = 1;
185 c1->SetFillColor(10);
186 for(i=0; i<10; i++)
7d3726a4 187 {
a3039c91 188 sprintf(fname,"LS0%d",i);
189 fGeom->GetNode(fname)->SetLineColor(color);
190 sprintf(fname,"US0%d",i);
191 fGeom->GetNode(fname)->SetLineColor(color);
7d3726a4 192 }
a3039c91 193 for(i=10; i<18; i++)
7d3726a4 194 {
a3039c91 195 sprintf(fname,"LS%d",i);
196 fGeom->GetNode(fname)->SetLineColor(color);
197 sprintf(fname,"US%d",i);
198 fGeom->GetNode(fname)->SetLineColor(color);
7d3726a4 199 }
4499ed26 200
108615fc 201 fGeom->Draw("same");
202
eeddc64d 203 if(x3don) c1->x3d();
108615fc 204
205}
206
eeddc64d 207void AliL3Display::DisplayClusters(Bool_t x3don)
108615fc 208{
209 //Display all clusters.
210
211 TCanvas *c1 = new TCanvas("c1","",700,700);
212 c1->cd();
eeddc64d 213
108615fc 214 TView *v = new TView(1);
215 v->SetRange(-430,-560,-430,430,560,1710);
216 c1->Clear();
217 c1->SetFillColor(1);
218 c1->SetTheta(90.);
219 c1->SetPhi(0.);
220
221 for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
222 {
8f924a46 223 for(Int_t p=0;p<6;p++)
108615fc 224 {
225 AliL3SpacePointData *points = fClusters[s][p];
226 if(!points) continue;
227 Int_t npoints = fNcl[s][p];
228 TPolyMarker3D *pm = new TPolyMarker3D(npoints);
229
230 Float_t xyz[3];
4e03c52a 231 for(Int_t i=0; i<npoints; i++)
232 {
233
234 xyz[0] = points[i].fX;
235 xyz[1] = points[i].fY;
236 xyz[2] = points[i].fZ;
237
238 pm->SetPoint(i,xyz[0],xyz[1],xyz[2]);
239
240 }
108615fc 241 pm->SetMarkerColor(2);
242 pm->Draw("");
243 }
244 }
245 fGeom->Draw("same");
246
eeddc64d 247 if(x3don) c1->x3d();
108615fc 248}
249
250
eeddc64d 251void AliL3Display::DisplayAll(Int_t min_hits,Bool_t x3don)
108615fc 252{
253 //Display tracks & all hits.
254
108615fc 255 TCanvas *c1 = new TCanvas("c1","",700,700);
256 c1->cd();
257 TView *v = new TView(1);
258 v->SetRange(-430,-560,-430,430,560,1710);
259 c1->Clear();
260 c1->SetFillColor(1);
494fad94 261 c1->SetTheta(90.);
108615fc 262 c1->SetPhi(0.);
263
264 for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
265 {
c6fa4f1e 266 for(Int_t p=0;p<6;p++)
108615fc 267 {
268 AliL3SpacePointData *points = fClusters[s][p];
269 if(!points) continue;
270 Int_t npoints = fNcl[s][p];
271 TPolyMarker3D *pm = new TPolyMarker3D(npoints);
272
273 Float_t xyz[3];
274 for(Int_t i=0; i<npoints; i++){
275 xyz[0] = points[i].fX;
276 xyz[1] = points[i].fY;
277 xyz[2] = points[i].fZ;
a3039c91 278
108615fc 279 pm->SetPoint(i,xyz[0],xyz[1],xyz[2]);
280
281 }
282 pm->SetMarkerColor(2);
283 pm->Draw("");
284 }
285 }
286
287 Int_t ntracks = fTracks->GetNTracks();
288 TPolyLine3D *line = new TPolyLine3D[ntracks];
ae97a0b9 289 Float_t xcl[176];
290 Float_t ycl[176];
291 Float_t zcl[176];
108615fc 292
108615fc 293 for(Int_t j=0; j<ntracks; j++)
294 {
295 AliL3Track *gtrack = fTracks->GetCheckedTrack(j);
296 if(!gtrack) continue;
297 Int_t nHits = gtrack->GetNHits();
298 UInt_t *hitnum = gtrack->GetHitNumbers();
299 if(nHits < min_hits) continue;
300 TPolyMarker3D *pm = new TPolyMarker3D(nHits);
c6fa4f1e 301 Int_t hitcount=0;
108615fc 302 for(Int_t h=0; h<nHits; h++)
303 {
304 UInt_t id=hitnum[h];
305 Int_t slice = (id>>25) & 0x7f;
306 Int_t patch = (id>>22) & 0x7;
307 UInt_t pos = id&0x3fffff;
c6fa4f1e 308 if(slice < fMinSlice || slice > fMaxSlice)
309 continue;
108615fc 310
311 AliL3SpacePointData *points = fClusters[slice][patch];
108615fc 312 if(!points) {
313 LOG(AliL3Log::kError,"AliL3Display::DisplayTracks","Clusterarray")
314 <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
315 continue;
316 }
317 if(pos>=fNcl[slice][patch]) {printf("Error \n"); continue;}
318 xcl[h] = points[pos].fX;
319 ycl[h] = points[pos].fY;
320 zcl[h] = points[pos].fZ;
321 pm->SetPoint(h,xcl[h],ycl[h],zcl[h]);
c6fa4f1e 322 hitcount++;
108615fc 323 }
c6fa4f1e 324 if(hitcount==0) continue;
108615fc 325 pm->SetMarkerColor(3);
326 pm->Draw();
327 TPolyLine3D *current_line = &(line[j]);
328 current_line = new TPolyLine3D(nHits,xcl,ycl,zcl,"");
108615fc 329 current_line->SetLineColor(4);
a3039c91 330 current_line->SetLineWidth(2);
108615fc 331 current_line->Draw("same");
332 }
a3039c91 333
a3039c91 334 Char_t fname[256];
335 Int_t i;
336 Int_t color = 1;
337 c1->SetFillColor(10);
338 for(i=0; i<10; i++)
339 {
340 sprintf(fname,"LS0%d",i);
341 fGeom->GetNode(fname)->SetLineColor(color);
342 sprintf(fname,"US0%d",i);
343 fGeom->GetNode(fname)->SetLineColor(color);
344 }
345 for(i=10; i<18; i++)
346 {
347 sprintf(fname,"LS%d",i);
348 fGeom->GetNode(fname)->SetLineColor(color);
349 sprintf(fname,"US%d",i);
350 fGeom->GetNode(fname)->SetLineColor(color);
351 }
352
108615fc 353 fGeom->Draw("same");
354
eeddc64d 355 if(x3don) c1->x3d();
108615fc 356}
357
7d3726a4 358void AliL3Display::DisplayClusterRow(Int_t slice,Int_t padrow,Char_t *digitsFile,Char_t *type)
108615fc 359{
360 //Display the found clusters on this row together with the raw data.
361
a3039c91 362#ifdef use_aliroot
108615fc 363 TFile *file = new TFile(digitsFile);
364 AliTPCParam *param = (AliTPCParam*)file->Get("75x40_100x60");
f5b4a1ae 365 TTree *TD=(TTree*)file->Get("TreeD_75x40_100x60_0");
108615fc 366 AliSimDigits da, *digits=&da;
367 TD->GetBranch("Segment")->SetAddress(&digits); //Return pointer to branch segment.
108615fc 368
369 Int_t sector,row;
494fad94 370 AliL3Transform::Slice2Sector(slice,padrow,sector,row);
108615fc 371 Int_t npads = param->GetNPads(sector,row);
372 Int_t ntimes = param->GetMaxTBin();
373 TH2F *histdig = new TH2F("histdig","",npads,0,npads-1,ntimes,0,ntimes-1);
374 TH2F *histfast = new TH2F("histfast","",npads,0,npads-1,ntimes,0,ntimes-1);
4e03c52a 375 TH2F *histpart = new TH2F("histpart","",npads,0,npads-1,ntimes,0,ntimes-1);
376
108615fc 377
378 Int_t sectors_by_rows=(Int_t)TD->GetEntries();
379 Int_t i;
380 for (i=0; i<sectors_by_rows; i++) {
381 if (!TD->GetEvent(i)) continue;
382 Int_t sec,ro;
383 param->AdjustSectorRow(digits->GetID(),sec,ro);
384
385 if(sec != sector) continue;
386 if(ro < row) continue;
387 if(ro != row) break;
388 printf("sector %d row %d\n",sec,ro);
389 digits->First();
390 while (digits->Next()) {
391 Int_t it=digits->CurrentRow(), ip=digits->CurrentColumn();
392 Short_t dig = digits->GetDigit(it,ip);
393 if(dig<=param->GetZeroSup()) continue;
cf63f233 394 /*
108615fc 395 if(it < param->GetMaxTBin()-1 && it > 0)
396 if(digits->GetDigit(it+1,ip) <= param->GetZeroSup()
397 && digits->GetDigit(it-1,ip) <= param->GetZeroSup())
398 continue;
cf63f233 399 */
108615fc 400 histdig->Fill(ip,it,dig);
401 }
402 }
403
4e03c52a 404 /*file->cd();
405 AliRun *gAlice = (AliRun*)file->Get("gAlice");
406 gAlice->GetEvent(0);
407 TClonesArray *fParticles=gAlice->Particles();
408 TParticle *part = (TParticle*)fParticles->UncheckedAt(0);
409 AliL3Evaluate *eval = new AliL3Evaluate();
410 Float_t xyz_cross[3];
411 */
cf63f233 412
8f924a46 413 for(Int_t p=0;p<6;p++)
108615fc 414 {
415 AliL3SpacePointData *points = fClusters[slice][p];
416 if(!points) continue;
cf63f233 417
108615fc 418 Int_t npoints = fNcl[slice][p];
419 Float_t xyz[3];
420 for(Int_t i=0; i<npoints; i++)
421 {
422 if(points[i].fPadRow != padrow) continue;
423 xyz[0] = points[i].fX;
424 xyz[1] = points[i].fY;
425 xyz[2] = points[i].fZ;
494fad94 426 AliL3Transform::Global2Raw(xyz,sector,row);
4e03c52a 427 histfast->Fill(xyz[1],xyz[2],1);
108615fc 428
4e03c52a 429
cf63f233 430 }
431
432 }
433
7d3726a4 434 TCanvas *c1 = new TCanvas("c1","",900,900);
108615fc 435 c1->cd();
436 histdig->Draw();
108615fc 437 histfast->SetMarkerColor(2);
438 histfast->SetMarkerStyle(4);
4e03c52a 439 histpart->SetMarkerColor(2);
440 histpart->SetMarkerStyle(3);
441
442 histdig->GetXaxis()->SetTitle("Pad #");
443 histdig->GetYaxis()->SetTitle("Timebin #");
7d3726a4 444 histdig->Draw(type);
108615fc 445 histfast->Draw("psame");
4e03c52a 446 //histpart->Draw("psame");
a3039c91 447
448#endif
449 return;
108615fc 450}
a3039c91 451