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