]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/hough/AliL3HoughDisplay.cxx
added data source and sink base components
[u/mrichter/AliRoot.git] / HLT / hough / AliL3HoughDisplay.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
1708d94a 16#include "AliL3StandardIncludes.h"
17#include "AliL3RootTypes.h"
18#include "AliL3DigitData.h"
e06900d5 19#include "AliL3Logging.h"
db739bef 20#include "AliL3Transform.h"
21#include "AliL3HoughTrack.h"
22#include "AliL3TrackArray.h"
b1886074 23#include "AliL3MemHandler.h"
e06900d5 24#include "AliL3HoughDisplay.h"
4feb6a26 25#include "AliL3DigitData.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
34ClassImp(AliL3HoughDisplay)
35
36
37AliL3HoughDisplay::AliL3HoughDisplay()
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
47AliL3HoughDisplay::~AliL3HoughDisplay()
48{
bd2f8772 49 //dtor
1ed2ff53 50 if(fTracks)
51 delete fTracks;
db739bef 52}
53
da010058 54void AliL3HoughDisplay::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())
da010058 59 cerr<<"AliL3HoughDisplay::AliL3HoughDisplay : Geometry file " << gfile << " does not exist"<<endl;
db739bef 60 fGeom = (TGeometry*)file->Get("AliceGeom");
61 file->Close();
1ed2ff53 62
63 fTracks = new AliL3TrackArray();
64 AliL3MemHandler *tfile = new AliL3MemHandler();
65 tfile->SetBinaryInput(trackfile);
66 tfile->Binary2TrackArray(fTracks);
67 tfile->CloseBinaryInput();
68 delete tfile;
db739bef 69}
70
1ed2ff53 71void AliL3HoughDisplay::GenerateHits(AliL3Track *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];
1ed2ff53 76 for(Int_t i=AliL3Transform::GetFirstRow(0); i<AliL3Transform::GetLastRow(5); i++)
db739bef 77 {
78 if(track->GetCrossingPoint(i,xyz))
79 {
1ed2ff53 80 AliL3Transform::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
b1886074 91TPolyMarker3D *AliL3HoughDisplay::LoadDigits()
92{
bd2f8772 93 //Load digits
b1886074 94 AliL3DigitRowData *tempPt = fDigitRowData;
95 if(!tempPt)
96 {
97 cerr<<"AliL3HoughDisplay::LoadDigits : No data"<<endl;
98 return 0;
99 }
100
1ed2ff53 101 UInt_t nrows = AliL3Transform::GetNRows(fPatch);
b1886074 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 {
4ab9f8f0 119 AliL3Transform::Slice2Sector(fShowSlice,padrow,sector,row);
120 AliL3Transform::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 }
124 AliL3MemHandler::UpdateRowPointer(tempPt);
125 }
126
127 cout<<"Displaying "<<count<<" digits"<<endl;
128 return pm;
129}
130
131void AliL3HoughDisplay::DisplayEvent()
db739bef 132{
133 //Display the found tracks.
134
135 if(!fTracks)
136 {
1ed2ff53 137 cerr<<"AliL3HoughDisplay::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 {
1ed2ff53 159 AliL3Track *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