]>
Commit | Line | Data |
---|---|---|
1 | // @(#) $Id$ | |
2 | ||
3 | // Author: Anders Vestbo <mailto:vestbo@fi.uib.no> | |
4 | //*-- Copyright © ALICE HLT Group | |
5 | ||
6 | ||
7 | #include <TCanvas.h> | |
8 | #include <TView.h> | |
9 | #include <TPolyMarker3D.h> | |
10 | #include <TPolyLine3D.h> | |
11 | #include <TNode.h> | |
12 | #include <TGeometry.h> | |
13 | #include <TShape.h> | |
14 | #include <TFile.h> | |
15 | ||
16 | #include "AliHLTStandardIncludes.h" | |
17 | #include "AliHLTRootTypes.h" | |
18 | #include "AliHLTDigitData.h" | |
19 | #include "AliHLTLogging.h" | |
20 | #include "AliHLTTransform.h" | |
21 | #include "AliHLTHoughTrack.h" | |
22 | #include "AliHLTTrackArray.h" | |
23 | #include "AliHLTMemHandler.h" | |
24 | #include "AliHLTHoughDisplay.h" | |
25 | #include "AliHLTDigitData.h" | |
26 | ||
27 | #if __GNUC__ >= 3 | |
28 | using namespace std; | |
29 | #endif | |
30 | ||
31 | //_____________________________________________________________ | |
32 | // Display class for Hough transform code | |
33 | ||
34 | ClassImp(AliHLTHoughDisplay) | |
35 | ||
36 | ||
37 | AliHLTHoughDisplay::AliHLTHoughDisplay() | |
38 | { | |
39 | //default ctor | |
40 | fTracks = 0; | |
41 | fDigitRowData = 0; | |
42 | fNDigitRowData = 0; | |
43 | fShowSlice = -1; | |
44 | fPatch = -1; | |
45 | } | |
46 | ||
47 | AliHLTHoughDisplay::~AliHLTHoughDisplay() | |
48 | { | |
49 | //dtor | |
50 | if(fTracks) | |
51 | delete fTracks; | |
52 | } | |
53 | ||
54 | void AliHLTHoughDisplay::Init(Char_t *trackfile, Char_t *gfile) | |
55 | { | |
56 | //Init hough display | |
57 | TFile *file = TFile::Open(gfile); | |
58 | if(!file->IsOpen()) | |
59 | cerr<<"AliHLTHoughDisplay::AliHLTHoughDisplay : Geometry file " << gfile << " does not exist"<<endl; | |
60 | fGeom = (TGeometry*)file->Get("AliceGeom"); | |
61 | file->Close(); | |
62 | ||
63 | fTracks = new AliHLTTrackArray(); | |
64 | AliHLTMemHandler *tfile = new AliHLTMemHandler(); | |
65 | tfile->SetBinaryInput(trackfile); | |
66 | tfile->Binary2TrackArray(fTracks); | |
67 | tfile->CloseBinaryInput(); | |
68 | delete tfile; | |
69 | } | |
70 | ||
71 | void AliHLTHoughDisplay::GenerateHits(AliHLTTrack *track,Float_t *x,Float_t *y,Float_t *z,Int_t &n) | |
72 | { | |
73 | //Generate hits according to the track parameters | |
74 | n=0; | |
75 | Float_t xyz[3]; | |
76 | for(Int_t i=AliHLTTransform::GetFirstRow(0); i<AliHLTTransform::GetLastRow(5); i++) | |
77 | { | |
78 | if(track->GetCrossingPoint(i,xyz)) | |
79 | { | |
80 | AliHLTTransform::Local2Global(xyz,0); | |
81 | x[n] = xyz[0]; | |
82 | y[n] = xyz[1]; | |
83 | z[n] = xyz[2]; | |
84 | n++; | |
85 | } | |
86 | else | |
87 | break; | |
88 | } | |
89 | } | |
90 | ||
91 | TPolyMarker3D *AliHLTHoughDisplay::LoadDigits() | |
92 | { | |
93 | //Load digits | |
94 | AliHLTDigitRowData *tempPt = fDigitRowData; | |
95 | if(!tempPt) | |
96 | { | |
97 | cerr<<"AliHLTHoughDisplay::LoadDigits : No data"<<endl; | |
98 | return 0; | |
99 | } | |
100 | ||
101 | UInt_t nrows = AliHLTTransform::GetNRows(fPatch); | |
102 | Int_t count=0; | |
103 | for(UInt_t i=0; i<nrows; i++) | |
104 | { | |
105 | count += tempPt->fNDigit; | |
106 | AliHLTMemHandler::UpdateRowPointer(tempPt); | |
107 | } | |
108 | tempPt = fDigitRowData; | |
109 | TPolyMarker3D *pm = new TPolyMarker3D(count); | |
110 | Float_t xyz[3]; | |
111 | Int_t sector,row; | |
112 | count=0; | |
113 | for(UInt_t i=0; i<nrows; i++) | |
114 | { | |
115 | AliHLTDigitData *digPt = tempPt->fDigitData; | |
116 | Int_t padrow = (Int_t)tempPt->fRow; | |
117 | for(UInt_t j=0; j<tempPt->fNDigit; j++) | |
118 | { | |
119 | AliHLTTransform::Slice2Sector(fShowSlice,padrow,sector,row); | |
120 | AliHLTTransform::Raw2Global(xyz,sector,row,(Int_t)digPt->fPad,(Int_t)digPt->fTime); | |
121 | pm->SetPoint(count,xyz[0],xyz[1],xyz[2]); | |
122 | count++; | |
123 | } | |
124 | AliHLTMemHandler::UpdateRowPointer(tempPt); | |
125 | } | |
126 | ||
127 | cout<<"Displaying "<<count<<" digits"<<endl; | |
128 | return pm; | |
129 | } | |
130 | ||
131 | void AliHLTHoughDisplay::DisplayEvent() | |
132 | { | |
133 | //Display the found tracks. | |
134 | ||
135 | if(!fTracks) | |
136 | { | |
137 | cerr<<"AliHLTHoughDisplay::DisplayTracks() : No tracks"<<endl; | |
138 | return; | |
139 | } | |
140 | ||
141 | TCanvas *c1 = new TCanvas("c1","",700,700); | |
142 | c1->cd(); | |
143 | ||
144 | TView *v = new TView(1); | |
145 | v->SetRange(-430,-560,-430,430,560,1710); | |
146 | ||
147 | c1->Clear(); | |
148 | c1->SetFillColor(1); | |
149 | c1->SetTheta(90.); | |
150 | c1->SetPhi(0.); | |
151 | ||
152 | Int_t ntracks = fTracks->GetNTracks(); | |
153 | TPolyLine3D *line = new TPolyLine3D[ntracks]; | |
154 | ||
155 | Int_t n; | |
156 | Float_t x[176],y[176],z[176]; | |
157 | for(Int_t j=0; j<ntracks; j++) | |
158 | { | |
159 | AliHLTTrack *track = fTracks->GetCheckedTrack(j); | |
160 | if(!track) continue; | |
161 | track->CalculateHelix(); | |
162 | GenerateHits(track,x,y,z,n); | |
163 | TPolyMarker3D *pm = new TPolyMarker3D(n); | |
164 | ||
165 | for(Int_t h=0; h<n; h++) | |
166 | pm->SetPoint(h,x[h],y[h],z[h]); | |
167 | ||
168 | pm->SetMarkerColor(2); | |
169 | pm->Draw(); | |
170 | TPolyLine3D *currentline = &(line[j]); | |
171 | currentline = new TPolyLine3D(n,x,y,z,""); | |
172 | currentline->SetLineColor(4); | |
173 | currentline->Draw("same"); | |
174 | ||
175 | } | |
176 | ||
177 | if(fShowSlice>=0) | |
178 | { | |
179 | TPolyMarker3D *pm = LoadDigits(); | |
180 | pm->SetMarkerColor(2); | |
181 | pm->Draw("same"); | |
182 | } | |
183 | ||
184 | cout<<"Displaying...."<<endl; | |
185 | fGeom->Draw("same"); | |
186 | c1->x3d(); | |
187 | } | |
188 | ||
189 |