]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/hough/AliHLTHoughDisplay.cxx
Bug fix: The lego plots are now updated in the same canvas.
[u/mrichter/AliRoot.git] / HLT / hough / AliHLTHoughDisplay.cxx
CommitLineData
3e87ef69 1// @(#) $Id$
1ed2ff53 2
b1886074 3// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
3e87ef69 4//*-- Copyright &copy ALICE HLT Group
db739bef 5
e06900d5 6
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
4aa41877 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"
b1886074 26
5929c18d 27#if __GNUC__ >= 3
3e87ef69 28using namespace std;
29#endif
30
b1886074 31//_____________________________________________________________
32// Display class for Hough transform code
db739bef 33
4aa41877 34ClassImp(AliHLTHoughDisplay)
db739bef 35
36
4aa41877 37AliHLTHoughDisplay::AliHLTHoughDisplay()
db739bef 38{
bd2f8772 39 //default ctor
db739bef 40 fTracks = 0;
b1886074 41 fDigitRowData = 0;
42 fNDigitRowData = 0;
43 fShowSlice = -1;
44 fPatch = -1;
db739bef 45}
46
4aa41877 47AliHLTHoughDisplay::~AliHLTHoughDisplay()
db739bef 48{
bd2f8772 49 //dtor
1ed2ff53 50 if(fTracks)
51 delete fTracks;
db739bef 52}
53
4aa41877 54void AliHLTHoughDisplay::Init(Char_t *trackfile, Char_t *gfile)
db739bef 55{
bd2f8772 56 //Init hough display
da010058 57 TFile *file = TFile::Open(gfile);
db739bef 58 if(!file->IsOpen())
4aa41877 59 cerr<<"AliHLTHoughDisplay::AliHLTHoughDisplay : Geometry file " << gfile << " does not exist"<<endl;
db739bef 60 fGeom = (TGeometry*)file->Get("AliceGeom");
61 file->Close();
1ed2ff53 62
4aa41877 63 fTracks = new AliHLTTrackArray();
64 AliHLTMemHandler *tfile = new AliHLTMemHandler();
1ed2ff53 65 tfile->SetBinaryInput(trackfile);
66 tfile->Binary2TrackArray(fTracks);
67 tfile->CloseBinaryInput();
68 delete tfile;
db739bef 69}
70
4aa41877 71void AliHLTHoughDisplay::GenerateHits(AliHLTTrack *track,Float_t *x,Float_t *y,Float_t *z,Int_t &n)
db739bef 72{
bd2f8772 73 //Generate hits according to the track parameters
db739bef 74 n=0;
75 Float_t xyz[3];
4aa41877 76 for(Int_t i=AliHLTTransform::GetFirstRow(0); i<AliHLTTransform::GetLastRow(5); i++)
db739bef 77 {
78 if(track->GetCrossingPoint(i,xyz))
79 {
4aa41877 80 AliHLTTransform::Local2Global(xyz,0);
db739bef 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
4aa41877 91TPolyMarker3D *AliHLTHoughDisplay::LoadDigits()
b1886074 92{
bd2f8772 93 //Load digits
4aa41877 94 AliHLTDigitRowData *tempPt = fDigitRowData;
b1886074 95 if(!tempPt)
96 {
4aa41877 97 cerr<<"AliHLTHoughDisplay::LoadDigits : No data"<<endl;
b1886074 98 return 0;
99 }
100
4aa41877 101 UInt_t nrows = AliHLTTransform::GetNRows(fPatch);
b1886074 102 Int_t count=0;
103 for(UInt_t i=0; i<nrows; i++)
104 {
105 count += tempPt->fNDigit;
4aa41877 106 AliHLTMemHandler::UpdateRowPointer(tempPt);
b1886074 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 {
4aa41877 115 AliHLTDigitData *digPt = tempPt->fDigitData;
b1886074 116 Int_t padrow = (Int_t)tempPt->fRow;
117 for(UInt_t j=0; j<tempPt->fNDigit; j++)
118 {
4aa41877 119 AliHLTTransform::Slice2Sector(fShowSlice,padrow,sector,row);
120 AliHLTTransform::Raw2Global(xyz,sector,row,(Int_t)digPt->fPad,(Int_t)digPt->fTime);
b1886074 121 pm->SetPoint(count,xyz[0],xyz[1],xyz[2]);
122 count++;
123 }
4aa41877 124 AliHLTMemHandler::UpdateRowPointer(tempPt);
b1886074 125 }
126
127 cout<<"Displaying "<<count<<" digits"<<endl;
128 return pm;
129}
130
4aa41877 131void AliHLTHoughDisplay::DisplayEvent()
db739bef 132{
133 //Display the found tracks.
134
135 if(!fTracks)
136 {
4aa41877 137 cerr<<"AliHLTHoughDisplay::DisplayTracks() : No tracks"<<endl;
db739bef 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);
b1886074 146
db739bef 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 {
4aa41877 159 AliHLTTrack *track = fTracks->GetCheckedTrack(j);
db739bef 160 if(!track) continue;
1ed2ff53 161 track->CalculateHelix();
db739bef 162 GenerateHits(track,x,y,z,n);
163 TPolyMarker3D *pm = new TPolyMarker3D(n);
1ed2ff53 164
db739bef 165 for(Int_t h=0; h<n; h++)
166 pm->SetPoint(h,x[h],y[h],z[h]);
167
1ed2ff53 168 pm->SetMarkerColor(2);
db739bef 169 pm->Draw();
bd2f8772 170 TPolyLine3D *currentline = &(line[j]);
171 currentline = new TPolyLine3D(n,x,y,z,"");
172 currentline->SetLineColor(4);
173 currentline->Draw("same");
db739bef 174
175 }
176
b1886074 177 if(fShowSlice>=0)
178 {
179 TPolyMarker3D *pm = LoadDigits();
180 pm->SetMarkerColor(2);
181 pm->Draw("same");
182 }
183
1ed2ff53 184 cout<<"Displaying...."<<endl;
db739bef 185 fGeom->Draw("same");
da010058 186 c1->x3d();
db739bef 187}
1ed2ff53 188
da010058 189