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