]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCADisplay.cxx
coding violations and compilation warnings fixed (Sergey)
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCADisplay.cxx
CommitLineData
326c2d4b 1// @(#) $Id$
2//*************************************************************************
3// This file is property of and copyright by the ALICE HLT Project *
4// ALICE Experiment at CERN, All rights reserved. *
5// *
6// Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
7// Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8// for The ALICE HLT Project. *
9// *
10// Permission to use, copy, modify and distribute this software and its *
11// documentation strictly for non-commercial purposes is hereby granted *
12// without fee, provided that the above copyright notice appears in all *
13// copies and that both the copyright notice and this permission notice *
14// appear in the supporting documentation. The authors make no claims *
15// about the suitability of this software for any purpose. It is *
16// provided "as is" without express or implied warranty. *
17//*************************************************************************
18
19#include "AliHLTTPCCADisplay.h"
20
21#include "AliHLTTPCCATracker.h"
dc4788ec 22 //#include "TString.h"
326c2d4b 23#include "Riostream.h"
24#include "TMath.h"
25#include "TStyle.h"
26#include "TCanvas.h"
dc4788ec 27#include <algorithm>
326c2d4b 28
dc4788ec 29ClassImp(AliHLTTPCCADisplay)
326c2d4b 30
31AliHLTTPCCADisplay &AliHLTTPCCADisplay::Instance()
32{
33 // reference to static object
34 static AliHLTTPCCADisplay gAliHLTTPCCADisplay;
35 return gAliHLTTPCCADisplay;
36}
37
dc4788ec 38AliHLTTPCCADisplay::AliHLTTPCCADisplay() : fYX(0), fZX(0), fAsk(1), fSectorView(1), fSector(0),
326c2d4b 39 fCos(1), fSin(0), fZMin(-250), fZMax(250),
40 fRInnerMin(83.65), fRInnerMax(133.3), fROuterMin(133.5), fROuterMax(247.7),
41 fTPCZMin(-250.), fTPCZMax(250), fArc(), fLine(), fPLine(), fMarker(), fBox(), fCrown(), fLatex()
42{
43 // constructor
44}
45
46AliHLTTPCCADisplay::AliHLTTPCCADisplay( const AliHLTTPCCADisplay& )
dc4788ec 47 : fYX(0), fZX(0), fAsk(1), fSectorView(1), fSector(0),
326c2d4b 48 fCos(1), fSin(0), fZMin(-250), fZMax(250),
49 fRInnerMin(83.65), fRInnerMax(133.3), fROuterMin(133.5), fROuterMax(247.7),
50 fTPCZMin(-250.), fTPCZMax(250), fArc(), fLine(), fPLine(), fMarker(), fBox(), fCrown(), fLatex()
51{
52 // dummy
53}
54
55AliHLTTPCCADisplay& AliHLTTPCCADisplay::operator=( const AliHLTTPCCADisplay& )
56{
57 // dummy
58 return *this;
59}
60
61AliHLTTPCCADisplay::~AliHLTTPCCADisplay()
62{
63 // destructor
dc4788ec 64 delete fYX;
65 delete fZX;
326c2d4b 66}
67
68void AliHLTTPCCADisplay::Init()
69{
70 // initialization
71 gStyle->SetCanvasBorderMode(0);
72 gStyle->SetCanvasBorderSize(1);
73 gStyle->SetCanvasColor(0);
dc4788ec 74 fYX = new TCanvas ("YX", "YX window", -1, 0, 600, 600);
75 fZX = new TCanvas ("ZX", "ZX window", -610, 0, 590, 600);
326c2d4b 76 fMarker = TMarker(0.0, 0.0, 6);
77}
78
79void AliHLTTPCCADisplay::Update()
80{
81 // update windows
82 if( !fAsk ) return;
dc4788ec 83 fYX->Update();
84 fZX->Update();
326c2d4b 85}
86
87void AliHLTTPCCADisplay::Clear()
88{
89 // clear windows
dc4788ec 90 fYX->Clear();
91 fZX->Clear();
326c2d4b 92}
93
94void AliHLTTPCCADisplay::Ask()
95{
96 // whait for the pressed key, when "r" pressed, don't ask anymore
97 char symbol;
98 if (fAsk){
99 Update();
dc4788ec 100 std::cout<<"ask> "<<std::endl;
326c2d4b 101 do{
dc4788ec 102 std::cin.get(symbol);
326c2d4b 103 if (symbol == 'r')
104 fAsk = false;
105 } while (symbol != '\n');
106 }
107}
108
109
110void AliHLTTPCCADisplay::SetSectorView()
111{
112 // switch to sector view
113 fSectorView = 1;
114}
115
116void AliHLTTPCCADisplay::SetTPCView()
117{
118 // switch to full TPC view
119 fSectorView = 0;
120 fCos = 1;
121 fSin = 0;
122 fZMin = fTPCZMin;
123 fZMax = fTPCZMax;
124}
125
126void AliHLTTPCCADisplay::SetCurrentSector( AliHLTTPCCATracker *sec )
127{
128 // set reference to the current CA tracker, and read the current sector geometry
129 fSector = sec;
130 if( fSectorView ){
131 fCos = sec->Param().SinAlpha();
132 fSin = - sec->Param().CosAlpha();
133 fZMin = sec->Param().ZMin();
134 fZMax = sec->Param().ZMax();
135 Clear();
136 Double_t r0 = .5*(sec->Param().RMax()+sec->Param().RMin());
137 Double_t dr = .5*(sec->Param().RMax()-sec->Param().RMin());
138 Double_t cx = 0;
139 Double_t cy = r0;
140
dc4788ec 141 fYX->Range(cx-dr, cy-dr, cx+dr, cy+dr);
326c2d4b 142 Double_t cz = .5*(sec->Param().ZMax()+sec->Param().ZMin());
143 Double_t dz = .5*(sec->Param().ZMax()-sec->Param().ZMin())*1.2;
dc4788ec 144 fZX->Range(cz-dz, cy-dr, cz+dz, cy+dr);
326c2d4b 145 }
146}
147
148Int_t AliHLTTPCCADisplay::GetColor( Double_t z ) const
149{
150 // Get color with respect to Z coordinate
151 const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan,
dc4788ec 152 kOrange, kSpring, kTeal, kAzure, kViolet, kPink };
326c2d4b 153
154 Double_t zz = (z-fZMin)/(fZMax-fZMin);
155 Int_t iz = (int) (zz*11);
156 if( iz<0 ) iz = 0;
157 if( iz>10 ) iz = 10;
dc4788ec 158 return kMyColor[iz];
326c2d4b 159}
160
161void AliHLTTPCCADisplay::Global2View( Double_t x, Double_t y, Double_t *xv, Double_t *yv ) const
162{
163 // convert coordinates global->view
164 *xv = x*fCos + y*fSin;
165 *yv = y*fCos - x*fSin;
166}
167
168void AliHLTTPCCADisplay::Sec2View( Double_t x, Double_t y, Double_t *xv, Double_t *yv ) const
169{
170 // convert coordinates sector->view
171 Double_t xg = x*fSector->Param().CosAlpha() - y*fSector->Param().SinAlpha();
172 Double_t yg = y*fSector->Param().CosAlpha() + x*fSector->Param().SinAlpha();
173 *xv = xg*fCos + yg*fSin;
174 *yv = yg*fCos - xg*fSin;
175}
176
177
178void AliHLTTPCCADisplay::DrawTPC()
179{
180 // schematically draw TPC detector
dc4788ec 181 fYX->Range(-fROuterMax, -fROuterMax, fROuterMax, fROuterMax);
182 fYX->Clear();
326c2d4b 183 {
184 fArc.SetLineColor(kBlack);
185 fArc.SetFillStyle(0);
dc4788ec 186 fYX->cd();
326c2d4b 187 for( Int_t iSec=0; iSec<18; iSec++){
188 fCrown.SetLineColor(kBlack);
189 fCrown.SetFillStyle(0);
190 fCrown.DrawCrown(0,0,fRInnerMin, fRInnerMax, 360./18.*iSec, 360./18.*(iSec+1) );
191 fCrown.DrawCrown(0,0,fROuterMin, fROuterMax, 360./18.*iSec, 360./18.*(iSec+1) );
192 }
193 }
dc4788ec 194 fZX->cd();
195 fZX->Range( fTPCZMin, -fROuterMax, fTPCZMax, fROuterMax );
196 fZX->Clear();
326c2d4b 197}
198
199void AliHLTTPCCADisplay::DrawSector( AliHLTTPCCATracker *sec )
200{
201 // draw current the TPC sector
dc4788ec 202 fYX->cd();
326c2d4b 203 Double_t r0 = .5*(sec->Param().RMax()+sec->Param().RMin());
204 Double_t dr = .5*(sec->Param().RMax()-sec->Param().RMin());
205 Double_t cx = r0*sec->Param().CosAlpha();
206 Double_t cy = r0*sec->Param().SinAlpha();
207 Double_t raddeg = 180./3.1415;
208 Double_t a0 = raddeg*.5*(sec->Param().AngleMax() + sec->Param().AngleMin());
209 Double_t da = raddeg*.5*(sec->Param().AngleMax() - sec->Param().AngleMin());
210 if( fSectorView ){
211 cx = 0; cy = r0;
212 a0 = 90.;
213 fLatex.DrawLatex(cx-dr+dr*.05,cy-dr+dr*.05, Form("Sec.%2i",sec->Param().ISec()));
214 }
215 fArc.SetLineColor(kBlack);
216 fArc.SetFillStyle(0);
217 fCrown.SetLineColor(kBlack);
218 fCrown.SetFillStyle(0);
219
220 fCrown.DrawCrown(0,0, sec->Param().RMin(),sec->Param().RMax(), a0-da, a0+da );
221
222 fLine.SetLineColor(kBlack);
223
dc4788ec 224 fZX->cd();
326c2d4b 225
226 Double_t cz = .5*(sec->Param().ZMax()+sec->Param().ZMin());
227 Double_t dz = .5*(sec->Param().ZMax()-sec->Param().ZMin())*1.2;
228 //fLine.DrawLine(cz+dz, cy-dr, cz+dz, cy+dr );
229 if( fSectorView ) fLatex.DrawLatex(cz-dz+dz*.05,cy-dr+dr*.05, Form("Sec.%2i",sec->Param().ISec()));
230}
231
232
233void AliHLTTPCCADisplay::DrawHit( Int_t iRow, Int_t iHit, Int_t color )
234{
235 // draw hit
236 if( !fSector ) return;
237 AliHLTTPCCARow &row = fSector->Rows()[iRow];
238 AliHLTTPCCAHit *h = &(row.Hits()[iHit]);
239 if( color<0 ) color = GetColor( h->Z() );
240
dc4788ec 241 //Double_t dgy = 3.*TMath::Abs(h->ErrY()*fSector->Param().CosAlpha() - fSector->Param().ErrX()*fSector->Param().SinAlpha() );
242 //Double_t dx = fSector->Param().ErrX()*TMath::Sqrt(12.)/2.;
243 //Double_t dy = h->ErrY()*3.;
244 //Double_t dz = h->ErrZ()*3.;
326c2d4b 245 fMarker.SetMarkerColor(color);
246 fArc.SetLineColor(color);
247 fArc.SetFillStyle(0);
248 Double_t vx, vy;
249 Sec2View( row.X(), h->Y(), &vx, &vy );
250
dc4788ec 251 fYX->cd();
252 //if( fSectorView ) fArc.DrawEllipse( vx, vy, dx, dy, 0,360, 90);
253 //else fArc.DrawEllipse( vx, vy, dx, dy, 0,360, fSector->Param().Alpha()*180./3.1415);
326c2d4b 254 fMarker.DrawMarker(vx, vy);
dc4788ec 255 fZX->cd();
256 //if( fSectorView ) fArc.DrawEllipse( h->Z(), vy, dz, dx, 0,360, 90 );
257 //else fArc.DrawEllipse( h->Z(), vy, dz, dgy, 0,360, fSector->Param().Alpha()*180./3.1415);
326c2d4b 258 fMarker.DrawMarker(h->Z(), vy);
259}
260
261void AliHLTTPCCADisplay::DrawCell( Int_t iRow, AliHLTTPCCACell &cell, Int_t width, Int_t color )
262{
263 // draw cell
264 AliHLTTPCCARow &row = fSector->Rows()[iRow];
265 Double_t vx, vy, vdx, vdy;
266 Sec2View(row.X(), cell.Y(), &vx, &vy);
267 Sec2View(0, cell.ErrY()*3, &vdx, &vdy);
268 if( color<0 ) color = GetColor(cell.Z());
269 fLine.SetLineColor(color);
270 fLine.SetLineWidth(width);
dc4788ec 271 fYX->cd();
326c2d4b 272 fLine.DrawLine(vx-vdx,vy-vdy, vx+vdx, vy+vdy );
dc4788ec 273 fZX->cd();
326c2d4b 274 fLine.DrawLine(cell.Z()-3*cell.ErrZ(),vy-vdy, cell.Z()+3*cell.ErrZ(), vy+vdy );
275 fLine.SetLineWidth(1);
276}
277
278void AliHLTTPCCADisplay::DrawCell( Int_t iRow, Int_t iCell, Int_t width, Int_t color )
279{
280 // draw cell
281 AliHLTTPCCARow &row = fSector->Rows()[iRow];
282 DrawCell( iRow, row.Cells()[iCell], width, color );
283}
284
285void AliHLTTPCCADisplay::ConnectCells( Int_t iRow1, AliHLTTPCCACell &cell1,
286 Int_t iRow2, AliHLTTPCCACell &cell2, Int_t color )
287{
288 // connect two cells on display, kind of row is drawing
289 AliHLTTPCCARow &row1 = fSector->Rows()[iRow1];
290 AliHLTTPCCARow &row2 = fSector->Rows()[iRow2];
291
292 AliHLTTPCCAHit &h11 = row1.GetCellHit(cell1,0);
293 AliHLTTPCCAHit &h12 = row1.GetCellHit(cell1,cell1.NHits()-1);
294 AliHLTTPCCAHit &h21 = row2.GetCellHit(cell2,0);
295 AliHLTTPCCAHit &h22= row2.GetCellHit(cell2,cell2.NHits()-1);
296
297 Double_t x11 = row1.X();
298 Double_t x12 = row1.X();
299 Double_t y11 = h11.Y() - h11.ErrY()*3;
300 Double_t y12 = h12.Y() + h12.ErrY()*3;
301 Double_t z11 = h11.Z();
302 Double_t z12 = h12.Z();
303 Double_t x21 = row2.X();
304 Double_t x22 = row2.X();
305 Double_t y21 = h21.Y() - h21.ErrY()*3;
306 Double_t y22 = h22.Y() + h22.ErrY()*3;
307 Double_t z21 = h21.Z();
308 Double_t z22 = h22.Z();
309
310 Double_t vx11, vx12, vy11, vy12, vx21, vx22, vy21, vy22;
311
312 Sec2View(x11,y11, &vx11, &vy11 );
313 Sec2View(x12,y12, &vx12, &vy12 );
314 Sec2View(x21,y21, &vx21, &vy21 );
315 Sec2View(x22,y22, &vx22, &vy22 );
316
317 Double_t lx[] = { vx11, vx12, vx22, vx21, vx11 };
318 Double_t ly[] = { vy11, vy12, vy22, vy21, vy11 };
319 Double_t lz[] = { z11, z12, z22, z21, z11 };
320
321 if( color<0 ) color = GetColor( (z11+z12+z22+z21)/4. );
322 fPLine.SetLineColor(color);
323 fPLine.SetLineWidth(1);
324 //fPLine.SetFillColor(color);
325 fPLine.SetFillStyle(-1);
326
dc4788ec 327 fYX->cd();
326c2d4b 328 fPLine.DrawPolyLine(5, lx, ly );
dc4788ec 329 fZX->cd();
326c2d4b 330 fPLine.DrawPolyLine(5, lz, ly );
331 DrawCell( iRow1, cell1, 1, color );
332 DrawCell( iRow2, cell2, 1, color );
333}
334
335
326c2d4b 336void AliHLTTPCCADisplay::DrawTrack( AliHLTTPCCATrack &track, Int_t color )
337{
338 // draw track
326c2d4b 339
dc4788ec 340 if( track.NCells()<2 ) return;
341 int width = 3;
326c2d4b 342 Double_t b = -5;
343
dc4788ec 344 AliHLTTPCCADisplayTmpCell *vCells = new AliHLTTPCCADisplayTmpCell[track.NCells()];
345
326c2d4b 346 AliHLTTPCCATrackPar t = track.Param();
347 for( Int_t iCell=0; iCell<track.NCells(); iCell++ ){
348 AliHLTTPCCACell &c = fSector->GetTrackCell(track,iCell);
349 AliHLTTPCCARow &row = fSector->GetTrackCellRow(track,iCell);
350 Double_t xyz[3] = {row.X(), c.Y(), c.Z()};
dc4788ec 351 if( iCell==0 ) t.TransportBz(-5, xyz);
352 vCells[iCell].Index() = iCell;
353 vCells[iCell].S() = t.GetDsToPointBz(-5.,xyz);
326c2d4b 354 }
dc4788ec 355 sort(vCells, vCells + track.NCells(), AliHLTTPCCADisplayTmpCell::CompareCellDS );
326c2d4b 356 t.Normalize();
357 const Double_t kCLight = 0.000299792458;
358 Double_t bc = b*kCLight;
359 Double_t pt = sqrt(t.Par()[3]*t.Par()[3] +t.Par()[4]*t.Par()[4] );
360 //Double_t p = sqrt(pt*pt +t.Par()[5]*t.Par()[5] );
361 Double_t q = t.Par()[6];
362
363 //for( Int_t iCell=0; iCell<track.fNCells-1; iCell++ )
364 {
dc4788ec 365 AliHLTTPCCACell &c1 = fSector->GetTrackCell(track,vCells[0].Index());
366 AliHLTTPCCACell &c2 = fSector->GetTrackCell(track,vCells[track.NCells()-1].Index());
367 AliHLTTPCCARow &row1 = fSector->GetTrackCellRow(track,vCells[0].Index());
368 AliHLTTPCCARow &row2 = fSector->GetTrackCellRow(track,vCells[track.NCells()-1].Index());
369 Double_t x1, y1, z1, x2, y2, z2;
370 {
371 Double_t xyz[3] = {row1.X(), c1.Y(), c1.Z()};
372 t.TransportBz(-5, xyz);
373 x1 = t.Par()[0]; y1 = t.Par()[1]; z1 = t.Par()[2];
374 }
375 {
376 Double_t xyz[3] = {row2.X(), c2.Y(), c2.Z()};
377 t.TransportBz(-5, xyz);
378 x2 = t.Par()[0]; y2 = t.Par()[1]; z2 = t.Par()[2];
379 }
380
381 if( color<0 ) color = GetColor( (z1+z2)/2. );
326c2d4b 382 Double_t vx1, vy1, vx2, vy2;
dc4788ec 383 Sec2View(x1, y1, &vx1, &vy1 );
384 Sec2View(x2, y2, &vx2, &vy2 );
326c2d4b 385
386 fLine.SetLineColor( color );
dc4788ec 387 fLine.SetLineWidth( width );
326c2d4b 388
dd94bda2 389 if( TMath::Abs(q)>.1 ){
326c2d4b 390 Double_t qq = pt/q;
391
392 Double_t xc = t.Par()[0] + qq*t.Par()[4]/pt/bc;
393 Double_t yc = t.Par()[1] - qq*t.Par()[3]/pt/bc;
4b3014af 394 Double_t r = TMath::Abs(qq)/TMath::Abs(bc);
326c2d4b 395
396 Double_t vx, vy;
397 Sec2View( xc, yc, &vx, &vy );
398
399 Double_t a1 = TMath::ATan2(vy1-vy, vx1-vx)/TMath::Pi()*180.;
400 Double_t a2 = TMath::ATan2(vy2-vy, vx2-vx)/TMath::Pi()*180.;
401 Double_t da= a2-a1;
402 if( da>=180 ) da=360-da;
403 if( da<=-180 ) da=360-da;
404 a1 = a2-da;
405 fArc.SetFillStyle(0);
406 fArc.SetLineColor(color);
dc4788ec 407 fArc.SetLineWidth(width);
326c2d4b 408
dc4788ec 409 fYX->cd();
326c2d4b 410
411 fArc.DrawArc(vx,vy,r, a1,a2,"only");
412 } else {
dc4788ec 413 fYX->cd();
326c2d4b 414 fLine.DrawLine(vx1,vy1, vx2, vy2 );
415 }
dc4788ec 416
326c2d4b 417 }
418
419 for( Int_t iCell=0; iCell<track.NCells()-1; iCell++ ){
420
dc4788ec 421 AliHLTTPCCACell &c1 = fSector->GetTrackCell(track,vCells[iCell].Index());
422 AliHLTTPCCACell &c2 = fSector->GetTrackCell(track,vCells[iCell+1].Index());
423 AliHLTTPCCARow &row1 = fSector->GetTrackCellRow(track,vCells[iCell].Index());
424 AliHLTTPCCARow &row2 = fSector->GetTrackCellRow(track,vCells[iCell+1].Index());
425 ConnectCells( fSector->GetTrackCellIRow(track,vCells[iCell].Index()),c1,
426 fSector->GetTrackCellIRow(track,vCells[iCell+1].Index()),c2, color );
326c2d4b 427 Double_t x1, y1, z1, x2, y2, z2;
428 {
429 Double_t xyz[3] = {row1.X(), c1.Y(), c1.Z()};
430 t.TransportBz(-5, xyz);
431 x1 = t.Par()[0]; y1 = t.Par()[1]; z1 = t.Par()[2];
432 }
433 {
434 Double_t xyz[3] = {row2.X(), c2.Y(), c2.Z()};
435 t.TransportBz(-5, xyz);
436 x2 = t.Par()[0]; y2 = t.Par()[1]; z2 = t.Par()[2];
437 }
438
439 Double_t vx1, vy1, vx2, vy2;
440 Sec2View(x1, y1, &vx1, &vy1 );
441 Sec2View(x2, y2, &vx2, &vy2 );
442
443 fLine.SetLineColor(color);
dc4788ec 444 fLine.SetLineWidth(width);
326c2d4b 445
dc4788ec 446 fZX->cd();
326c2d4b 447 fLine.DrawLine(z1,vy1, z2, vy2 );
448 }
449 fLine.SetLineWidth(1);
dc4788ec 450 delete[] vCells;
326c2d4b 451}
452