]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/hough/AliL3HoughDisplay.cxx
Bugfix
[u/mrichter/AliRoot.git] / HLT / hough / AliL3HoughDisplay.cxx
1 // @(#) $Id$
2
3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4 //*-- Copyright &copy 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 "AliL3StandardIncludes.h"
17 #include "AliL3RootTypes.h"
18 #include "AliL3DigitData.h"
19 #include "AliL3Logging.h"
20 #include "AliL3Transform.h"
21 #include "AliL3HoughTrack.h"
22 #include "AliL3TrackArray.h"
23 #include "AliL3MemHandler.h"
24 #include "AliL3HoughDisplay.h"
25 #include "AliL3DigitData.h"
26
27 #if __GNUC__ == 3
28 using namespace std;
29 #endif
30
31 //_____________________________________________________________
32 // Display class for Hough transform code
33
34 ClassImp(AliL3HoughDisplay)
35
36
37 AliL3HoughDisplay::AliL3HoughDisplay()
38 {
39   //default ctor
40   fTracks = 0;
41   fDigitRowData = 0;
42   fNDigitRowData = 0;
43   fShowSlice = -1;
44   fPatch = -1;
45 }
46
47 AliL3HoughDisplay::~AliL3HoughDisplay()
48 {
49   //dtor
50   if(fTracks)
51     delete fTracks;
52 }
53
54 void AliL3HoughDisplay::Init(Char_t *trackfile, Char_t *gfile)
55 {
56   //Init hough display
57   TFile *file = TFile::Open(gfile);
58   if(!file->IsOpen())
59     cerr<<"AliL3HoughDisplay::AliL3HoughDisplay : Geometry file " << gfile << " does not exist"<<endl;
60   fGeom = (TGeometry*)file->Get("AliceGeom");
61   file->Close();
62   
63   fTracks = new AliL3TrackArray();
64   AliL3MemHandler *tfile = new AliL3MemHandler();
65   tfile->SetBinaryInput(trackfile);
66   tfile->Binary2TrackArray(fTracks);
67   tfile->CloseBinaryInput();
68   delete tfile;
69 }
70
71 void AliL3HoughDisplay::GenerateHits(AliL3Track *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=AliL3Transform::GetFirstRow(0); i<AliL3Transform::GetLastRow(5); i++)
77     {
78       if(track->GetCrossingPoint(i,xyz))
79         {
80           AliL3Transform::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 *AliL3HoughDisplay::LoadDigits()
92 {
93   //Load digits  
94   AliL3DigitRowData *tempPt = fDigitRowData;
95   if(!tempPt)
96     {
97       cerr<<"AliL3HoughDisplay::LoadDigits : No data"<<endl;
98       return 0;
99     }
100   
101   UInt_t nrows = AliL3Transform::GetNRows(fPatch);
102   Int_t count=0;
103   for(UInt_t i=0; i<nrows; i++)
104     {
105       count += tempPt->fNDigit;
106       AliL3MemHandler::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       AliL3DigitData *digPt = tempPt->fDigitData;
116       Int_t padrow = (Int_t)tempPt->fRow;
117       for(UInt_t j=0; j<tempPt->fNDigit; j++)
118         {
119           AliL3Transform::Slice2Sector(fShowSlice,padrow,sector,row);
120           AliL3Transform::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       AliL3MemHandler::UpdateRowPointer(tempPt);
125     }
126
127   cout<<"Displaying "<<count<<" digits"<<endl;
128   return pm;
129 }
130
131 void AliL3HoughDisplay::DisplayEvent()
132 {
133   //Display the found tracks.
134   
135   if(!fTracks)
136     {
137       cerr<<"AliL3HoughDisplay::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       AliL3Track *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