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