]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/hough/AliL3HoughDisplay.cxx
Checking in latest changes.
[u/mrichter/AliRoot.git] / HLT / hough / AliL3HoughDisplay.cxx
CommitLineData
b1886074 1// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
2//*-- Copyright &copy ASV
db739bef 3
b1886074 4#include <iostream.h>
db739bef 5#include <TCanvas.h>
6#include <TView.h>
7#include <TPolyMarker3D.h>
8#include <TPolyLine3D.h>
9#include <TNode.h>
10#include <TGeometry.h>
11#include <TShape.h>
12#include <TFile.h>
13
14#include "AliL3Transform.h"
15#include "AliL3HoughTrack.h"
16#include "AliL3TrackArray.h"
db739bef 17#include "AliL3HoughDisplay.h"
18#include "AliL3Defs.h"
b1886074 19#include "AliL3MemHandler.h"
20
21//_____________________________________________________________
22// Display class for Hough transform code
db739bef 23
24ClassImp(AliL3HoughDisplay)
25
26
27AliL3HoughDisplay::AliL3HoughDisplay()
28{
db739bef 29
30 fTracks = 0;
b1886074 31 fDigitRowData = 0;
32 fNDigitRowData = 0;
33 fShowSlice = -1;
34 fPatch = -1;
db739bef 35 Init();
36}
37
38AliL3HoughDisplay::~AliL3HoughDisplay()
39{
40 if(fTransform)
41 delete fTransform;
42}
43
44void AliL3HoughDisplay::Init()
45{
46 TFile *file = TFile::Open("/prog/alice/data/GEO/alice.geom");
47 if(!file->IsOpen())
b1886074 48 cerr<<"AliL3HoughDisplay::AliL3HoughDisplay : Geometry file alice.geom does not exist"<<endl;
db739bef 49 fGeom = (TGeometry*)file->Get("AliceGeom");
50 file->Close();
51 fTransform = new AliL3Transform();
52}
53
54
55void AliL3HoughDisplay::GenerateHits(AliL3HoughTrack *track,Float_t *x,Float_t *y,Float_t *z,Int_t &n)
56{
57 n=0;
58 Float_t xyz[3];
59 Int_t slice = track->GetSlice();
60 for(Int_t i=track->GetFirstRow(); i<track->GetLastRow(); i++)
61 {
62 if(track->GetCrossingPoint(i,xyz))
63 {
64 fTransform->Local2Global(xyz,slice);
65 x[n] = xyz[0];
66 y[n] = xyz[1];
67 z[n] = xyz[2];
68 n++;
69 }
70 else
71 break;
72 }
73}
74
b1886074 75TPolyMarker3D *AliL3HoughDisplay::LoadDigits()
76{
77
78 AliL3DigitRowData *tempPt = fDigitRowData;
79 if(!tempPt)
80 {
81 cerr<<"AliL3HoughDisplay::LoadDigits : No data"<<endl;
82 return 0;
83 }
84
85 Int_t nrows = NRows[fPatch][1] - NRows[fPatch][0] + 1;
86 Int_t count=0;
87 for(UInt_t i=0; i<nrows; i++)
88 {
89 count += tempPt->fNDigit;
90 AliL3MemHandler::UpdateRowPointer(tempPt);
91 }
92 tempPt = fDigitRowData;
93 TPolyMarker3D *pm = new TPolyMarker3D(count);
94 Float_t xyz[3];
95 Int_t sector,row;
96 count=0;
97 for(UInt_t i=0; i<nrows; i++)
98 {
99 AliL3DigitData *digPt = tempPt->fDigitData;
100 Int_t padrow = (Int_t)tempPt->fRow;
101 for(UInt_t j=0; j<tempPt->fNDigit; j++)
102 {
103 fTransform->Slice2Sector(fShowSlice,padrow,sector,row);
104 fTransform->Raw2Global(xyz,sector,row,(Int_t)digPt->fPad,(Int_t)digPt->fTime);
105 pm->SetPoint(count,xyz[0],xyz[1],xyz[2]);
106 count++;
107 }
108 AliL3MemHandler::UpdateRowPointer(tempPt);
109 }
110
111 cout<<"Displaying "<<count<<" digits"<<endl;
112 return pm;
113}
114
115void AliL3HoughDisplay::DisplayEvent()
db739bef 116{
117 //Display the found tracks.
118
119 if(!fTracks)
120 {
121 printf("AliL3HoughDisplay::DisplayTracks() : No tracks\n");
122 return;
123 }
124
125 TCanvas *c1 = new TCanvas("c1","",700,700);
126 c1->cd();
127
128 TView *v = new TView(1);
129 v->SetRange(-430,-560,-430,430,560,1710);
b1886074 130
db739bef 131 c1->Clear();
132 c1->SetFillColor(1);
133 c1->SetTheta(90.);
134 c1->SetPhi(0.);
135
136 Int_t ntracks = fTracks->GetNTracks();
137 TPolyLine3D *line = new TPolyLine3D[ntracks];
138
139 Int_t n;
140 Float_t x[176],y[176],z[176];
141 for(Int_t j=0; j<ntracks; j++)
142 {
143 AliL3HoughTrack *track = (AliL3HoughTrack*)fTracks->GetCheckedTrack(j);
144 if(!track) continue;
145 GenerateHits(track,x,y,z,n);
146 TPolyMarker3D *pm = new TPolyMarker3D(n);
147 for(Int_t h=0; h<n; h++)
148 pm->SetPoint(h,x[h],y[h],z[h]);
149
b1886074 150 pm->SetMarkerColor(1);
db739bef 151 pm->Draw();
152 TPolyLine3D *current_line = &(line[j]);
153 current_line = new TPolyLine3D(n,x,y,z,"");
154 current_line->SetLineColor(1);
155 current_line->Draw("same");
156
157 }
158
b1886074 159 if(fShowSlice>=0)
160 {
161 TPolyMarker3D *pm = LoadDigits();
162 pm->SetMarkerColor(2);
163 pm->Draw("same");
164 }
165
db739bef 166 fGeom->Draw("same");
167 c1->x3d();
168}