]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveDet/AliEveTRDData.cxx
Corrected list of libraries to resolve all symbols
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTRDData.cxx
CommitLineData
d810d0de 1// $Id$
2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
fd31e9de 9
a879a24a 10#include "TROOT.h"
5998b164 11#include "TStyle.h"
a4197d2e 12#include "TVector.h"
13#include "TLinearFitter.h"
a879a24a 14#include "TCanvas.h"
a1d14acd 15#include "TGeoMatrix.h"
5998b164 16#include "TGeoManager.h"
b3d20a1c 17
6983e87a 18#include "TEveTrans.h"
b3d20a1c 19#include "TEveManager.h"
20
b9df0156 21#include "AliEveEventManager.h"
6983e87a 22
d810d0de 23#include "AliEveTRDData.h"
24#include "AliEveTRDModuleImp.h"
b3d20a1c 25#include "AliEveTRDLoader.h"
26#include "AliEveTRDLoaderImp.h"
a282bf09 27
c742ee6b 28#include "AliGeomManager.h"
1fbca246 29#include "AliESDtrack.h"
6983e87a 30#include "AliLog.h"
a4197d2e 31#include "AliPID.h"
32#include "AliTrackPointArray.h"
57ce0047 33#include "AliRieman.h"
6983e87a 34
edf0c4a0 35#include "AliTRDhit.h"
36#include "AliTRDcluster.h"
6983e87a 37#include "AliTRDseedV1.h"
98b9b8b2 38#include "AliTRDtrackletMCM.h"
a879a24a 39#include "AliTRDtrackletWord.h"
98b9b8b2 40#include "AliTRDmcmSim.h"
6983e87a 41#include "AliTRDtrackV1.h"
a4197d2e 42#include "AliTRDtrackerV1.h"
a282bf09 43#include "AliTRDpadPlane.h"
a4197d2e 44#include "AliTRDdigitsManager.h"
a879a24a 45#include "AliTRDmcmSim.h"
20301585 46#include "AliTRDarrayADC.h"
0d9ef37b 47#include "AliTRDSignalIndex.h"
a282bf09 48#include "AliTRDgeometry.h"
6983e87a 49#include "AliTRDtransform.h"
a4197d2e 50#include "AliTRDReconstructor.h"
51#include "AliTRDrecoParam.h"
a282bf09 52
d810d0de 53ClassImp(AliEveTRDHits)
54ClassImp(AliEveTRDDigits)
55ClassImp(AliEveTRDClusters)
6983e87a 56ClassImp(AliEveTRDTracklet)
57ClassImp(AliEveTRDTrack)
a879a24a 58ClassImp(AliEveTRDTrackletOnline)
59ClassImp(AliEveTRDmcm)
a282bf09 60
61///////////////////////////////////////////////////////////
fd31e9de 62///////////// AliEveTRDDigits /////////////////////
a282bf09 63///////////////////////////////////////////////////////////
64
fd31e9de 65//______________________________________________________________________________
5998b164 66AliEveTRDDigits::AliEveTRDDigits(AliEveTRDChamber *p)
67 :TEveQuadSet("digits", "")
68 ,fParent(p)
a15e6d7d 69{
a9063c0d 70 // Constructor.
5998b164 71 SetOwnIds(kTRUE);
72 gStyle->SetPalette(1, 0);
73 SetPalette(new TEveRGBAPalette(0, 512));
527ceac3 74 Reset(TEveQuadSet::kQT_RectangleYZ, kFALSE, 32);
a15e6d7d 75}
a282bf09 76
fd31e9de 77//______________________________________________________________________________
6983e87a 78AliEveTRDDigits::~AliEveTRDDigits()
a282bf09 79{
6983e87a 80// AliInfo(GetTitle());
a282bf09 81}
82
6983e87a 83//______________________________________________________________________________
84void AliEveTRDDigits::SetData(AliTRDdigitsManager *digits)
85{
86 // Set data source.
87
c742ee6b 88 Int_t det(fParent->GetID());
20301585 89 AliTRDarrayADC *data = digits->GetDigits(det);
90 if(!data->GetDim()) return;
0d9ef37b 91 data->Expand();
92
93 AliTRDSignalIndex *indexes = digits->GetIndexes(det);
94 if(!indexes->IsAllocated()) digits->BuildIndexes(det);
95
5998b164 96 Double_t scale, dy, dz;
527ceac3 97 Int_t ly = AliTRDgeometry::GetLayer(det),
5998b164 98 stk = AliTRDgeometry::GetStack(det),
99 sec = AliTRDgeometry::GetSector(det),
100 vid = AliGeomManager::LayerToVolUID(AliGeomManager::kTRD1 + ly, stk + AliTRDgeometry::Nstack() * sec);
7e2dd929 101 SetNameTitle(Form("digits%03d", det), Form("D-%03d [%02d_%d_%d]", det, sec, stk, ly));
5998b164 102 Short_t sig[7]={0,0,0,10,0,0,0};
103
104 AliTRDtransform transform(det);
105 AliTRDpadPlane *pp(fParent->fGeo->GetPadPlane(ly, stk));
0d9ef37b 106
527ceac3 107 Int_t row, col;
5998b164 108 AliTRDcluster c;
0d9ef37b 109 indexes->ResetCounters();
110 while (indexes->NextRCIndex(row, col)){
5998b164 111 dz = pp->GetRowSize(row);
112 dy = pp->GetColSize(col);
527ceac3 113 Short_t *const adc = data->GetDataAddress(row,col);
114 for (Int_t time(0); time<30; time++){
115 if(data->IsPadCorrupted(row, col, time)) break;
116 if(adc[time] <= 1) continue;
5998b164 117 new (&c) AliTRDcluster(det, col, row, time, sig, vid);
118 transform.Transform(&c);
119
527ceac3 120 scale = adc[time] < 512 ? adc[time]/512. : 1.;
121 AddQuad(c.GetY()-0.5*dy, c.GetZ()-0.5*dz*scale, c.GetX(), dy*0.95, dz*scale);
36f3e126 122 QuadValue(Int_t(adc[time]));
7e2dd929 123 QuadId(new TNamed(Form("ADC %d", adc[time]), Form("det[%3d(%02d_%d_%d)] col[%3d] row[%2d] tb[%2d]", det, sec, stk, ly, col, row, time)));
0d9ef37b 124 }
125 }
5998b164 126
127 // rotate to global coordinates
128 RefitPlex();
129 TEveTrans& t = RefMainTrans();
527ceac3 130 t.SetRotByAngles((sec+.5)*AliTRDgeometry::GetAlpha(), 0.,0.);
6983e87a 131}
132
133
c742ee6b 134// //______________________________________________________________________________
135// void AliEveTRDDigits::Paint(Option_t *option)
136// {
137// // Paint the object.
138//
139// if(fParent->GetDigitsBox()) fBoxes.Paint(option);
140// else TEveQuadSet::Paint(option);
141// }
a282bf09 142
5998b164 143// //______________________________________________________________________________
144// void AliEveTRDDigits::Reset()
145// {
146// // Reset raw and visual data.
147//
148// TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
149// // MT fBoxes.fBoxes.clear();
150// fData.Reset();
151// }
a282bf09 152
153///////////////////////////////////////////////////////////
fd31e9de 154///////////// AliEveTRDHits /////////////////////
a282bf09 155///////////////////////////////////////////////////////////
156
fd31e9de 157//______________________________________________________________________________
a4197d2e 158AliEveTRDHits::AliEveTRDHits() : TEvePointSet("hits", 20)
a15e6d7d 159{
160 // Constructor.
a4197d2e 161 SetMarkerSize(.1);
b3d20a1c 162 SetMarkerColor(kGreen);
a4197d2e 163 SetOwnIds(kTRUE);
6983e87a 164}
165
166//______________________________________________________________________________
167AliEveTRDHits::~AliEveTRDHits()
168{
169 //AliInfo(GetTitle());
a15e6d7d 170}
a282bf09 171
fd31e9de 172//______________________________________________________________________________
d810d0de 173void AliEveTRDHits::PointSelected(Int_t n)
edf0c4a0 174{
a15e6d7d 175 // Handle an individual point selection from GL.
176
004e0620 177 AliTRDhit *h = NULL;
a969af30 178 if(!(h = dynamic_cast<AliTRDhit*>(GetPointId(n)))) return;
179 printf("Id[%3d] Det[%3d] Reg[%c] TR[%c] Q[%3d] MC[%d] t[%f]\n",
180 n, h->GetDetector(),
181 h->FromAmplification() ? 'A' : 'D',
182 h->FromTRphoton() ? 'y' : 'n',
183 h->GetCharge(), h->GetTrack(), h->GetTime());
a282bf09 184}
185
edf0c4a0 186
187///////////////////////////////////////////////////////////
6983e87a 188///////////// AliEveTRDClusters /////////////////////
edf0c4a0 189///////////////////////////////////////////////////////////
190
fd31e9de 191//______________________________________________________________________________
a4197d2e 192AliEveTRDClusters::AliEveTRDClusters():AliEveTRDHits()
a15e6d7d 193{
194 // Constructor.
6983e87a 195 SetName("clusters");
a4197d2e 196
5524a724 197 SetMarkerSize(.4);
a4197d2e 198 SetMarkerStyle(24);
5524a724 199 SetMarkerColor(kGray);
a4197d2e 200 SetOwnIds(kTRUE);
a15e6d7d 201}
edf0c4a0 202
fd31e9de 203//______________________________________________________________________________
d810d0de 204void AliEveTRDClusters::PointSelected(Int_t n)
edf0c4a0 205{
a15e6d7d 206 // Handle an individual point selection from GL.
207
fd31e9de 208 AliTRDcluster *c = dynamic_cast<AliTRDcluster*>(GetPointId(n));
ce239ca6 209 if(!c) return;
210 c->Print();
211 Emit("PointSelected(Int_t)", n);
fd31e9de 212 // Bool_t AliCluster::GetGlobalCov(Float_t* cov) const
213 // Bool_t AliCluster::GetGlobalXYZ(Float_t* xyz) const
214 // Float_t AliCluster::GetSigmaY2() const
215 // Float_t AliCluster::GetSigmaYZ() const
216 // Float_t AliCluster::GetSigmaZ2() const
edf0c4a0 217}
218
57d55fae 219//______________________________________________________________________________
220void AliEveTRDClusters::Print(Option_t *o) const
221{
004e0620 222 AliTRDcluster *c = NULL;
57d55fae 223
224 for(Int_t n = GetN(); n--;){
225 if(!(c = dynamic_cast<AliTRDcluster*>(GetPointId(n)))) continue;
226 c->Print(o);
227 }
228}
229
b3d20a1c 230//______________________________________________________________________________
ea41d018 231void AliEveTRDClusters::Load(const Char_t *w) const
b3d20a1c 232{
233 Int_t typ = -1;
234 if(strcmp(w, "hit")==0) typ = 0;
235 else if(strcmp(w, "dig")==0) typ = 1;
236 else if(strcmp(w, "cls")==0) typ = 2;
883dc828 237 else if(strcmp(w, "tlt")==0) typ = 3;
238 else if(strcmp(w, "all")==0) typ = 4;
b3d20a1c 239 else{
240 AliInfo("The following arguments are accepted:");
241 AliInfo(" \"hit\" : loading of MC hits");
242 AliInfo(" \"dig\" : loading of digits");
243 AliInfo(" \"cls\" : loading of reconstructed clusters");
883dc828 244 AliInfo(" \"tlt\" : loading of online tracklets");
245 AliInfo(" \"all\" : loading everything available");
b3d20a1c 246 return;
247 }
248
004e0620 249 AliTRDcluster *c = NULL;
b3d20a1c 250 Int_t n = 0;
251 while((n = GetN() && !(c = dynamic_cast<AliTRDcluster*>(GetPointId(n))))) n++;
252 if(!c) return;
253
254 Int_t det = c->GetDetector();
09487f16 255 AliEveTRDLoader *loader(NULL);
b3d20a1c 256 switch(typ){
a2125de9 257 case 0:
b3d20a1c 258 loader = new AliEveTRDLoader("Hits");
a2125de9 259 if(!loader->Open("TRD.Hits.root")){
260 delete loader;
261 return;
b3d20a1c 262 }
a2125de9 263 break;
b3d20a1c 264 case 1:
a2125de9 265 loader = new AliEveTRDLoader("Digits");
266 if(!loader->Open("TRD.Digits.root")){
267 delete loader;
268 return;
b3d20a1c 269 }
a2125de9 270 break;
b3d20a1c 271 case 2:
a2125de9 272 loader = new AliEveTRDLoader("Clusters");
273 if(!loader->Open("TRD.RecPoints.root")){
274 delete loader;
275 return;
883dc828 276 }
a2125de9 277 break;
883dc828 278 case 3:
a2125de9 279 loader = new AliEveTRDLoader("Tracklets");
280 if(!loader->Open("TRD.Tracklets.root")){
281 delete loader;
282 return;
b3d20a1c 283 }
a2125de9 284 break;
285 case 4:
286 loader = new AliEveTRDLoaderSim("MC"); // Assume MC data. Try to load via run loader
287 if(!loader->Open("galice.root")){
288 delete loader; loader=NULL;
289 // Assume measured data. Try to load data types individualy
290 Int_t failed(0);
291 loader = new AliEveTRDLoader("Data");
292 if(!loader->Open("TRD.Digits.root")) failed++;
293 if(!loader->Open("TRD.RecPoints.root")) failed++;
294 if(!loader->Open("TRD.Tracklets.root")) failed++;
295 if(failed==3){delete loader;loader=NULL;}
296 }else loader->SetDataType(AliEveTRDLoader::kTRDHits | AliEveTRDLoader::kTRDDigits | AliEveTRDLoader::kTRDClusters);
297 break;
b3d20a1c 298 default: return;
299 }
09487f16 300 if(!loader) return;
b3d20a1c 301
527ceac3 302 loader->AddChambers(AliTRDgeometry::GetSector(det),AliTRDgeometry::GetStack(det), AliTRDgeometry::GetLayer(det));
b3d20a1c 303 // load first event
883dc828 304 if(!loader->GoToEvent(AliEveEventManager::GetCurrent()->GetEventId())) AliWarning(Form("No data loaded for event %d", AliEveEventManager::GetCurrent()->GetEventId()));
b3d20a1c 305 // register loader with alieve
527ceac3 306 gEve->AddElement(loader->GetChamber(det), *(BeginParents()));
b3d20a1c 307 //loader->SpawnEditor();
308 gEve->Redraw3D();
309}
310
edf0c4a0 311///////////////////////////////////////////////////////////
6983e87a 312///////////// AliEveTRDTracklet /////////////////////
edf0c4a0 313///////////////////////////////////////////////////////////
edf0c4a0 314
6983e87a 315//______________________________________________________________________________
a4197d2e 316AliEveTRDTracklet::AliEveTRDTracklet(AliTRDseedV1 *trklt):TEveLine()
004e0620 317 ,fClusters(NULL)
a282bf09 318{
6983e87a 319 // Constructor.
320 SetName("tracklet");
a4197d2e 321
883dc828 322 if(!gGeoManager) AliEveEventManager::AssertGeometry();
a4197d2e 323 SetUserData(trklt);
4f7bd6c9 324 // init tracklet line
325 Int_t sec = AliTRDgeometry::GetSector(trklt->GetDetector());
326 Float_t alpha((0.5+sec)*AliTRDgeometry::GetAlpha()),
327 cphi(TMath::Cos(alpha)),
328 sphi(TMath::Sin(alpha));
a7cc0364 329 Float_t dx;
330 Float_t x0 = trklt->GetX0();
331 Float_t y0 = trklt->GetYref(0);
332 Float_t z0 = trklt->GetZref(0);
333 Float_t dydx = trklt->GetYref(1);
334 Float_t dzdx = trklt->GetZref(1);
5998b164 335 Float_t tilt = trklt->GetTilt();
a4197d2e 336 Float_t g[3];
004e0620 337 AliTRDcluster *c = NULL;
c624c106 338 for(Int_t ic=0; ic<AliTRDseedV1::kNclusters; ic++){
a4197d2e 339 if(!(c = trklt->GetClusters(ic))) continue;
57d55fae 340 if(!fClusters) AddElement(fClusters = new AliEveTRDClusters());
a7cc0364 341 dx = x0 - c->GetX();
342 //Float_t yt = y0 - dx*dydx;
343 Float_t zt = z0 - dx*dzdx;
57ce0047 344 // backup yc - for testing purposes
345 Float_t yc = c->GetY();
346 c->SetY(yc-tilt*(c->GetZ()-zt));
4f7bd6c9 347
348 // Ben: Temporary(?) fix -> Issue with wrongly set flag "fIsMisaligned" of AliCluster
349 // Changes can be undone ofter the issue with the flag has been solved
350 //c->GetGlobalXYZ(g);
351
352 // The following code for the trasformation local-to-global is just adapted from
353 // AliTRDgeometry::RotateBack(...)
354
355 // tracking to global coordinates transformation
356 Float_t loc[3] = { c->GetX(), c->GetY(), c->GetZ() };
357 g[0] = loc[0] * cphi - loc[1] * sphi;
358 g[1] = loc[0] * sphi + loc[1] * cphi;
359 g[2] = loc[2];
360 // Ben: End of fix
527ceac3 361 Int_t id = fClusters->SetNextPoint(g[0], g[1], g[2]);
57ce0047 362 c->SetY(yc);
a4197d2e 363 fClusters->SetPointId(id, new AliTRDcluster(*c));
364 }
a7cc0364 365 if(fClusters){
527ceac3 366 fClusters->SetName("TC clusters");
367 fClusters->SetTitle(Form("N[%d]", trklt->GetN()));
a7cc0364 368 fClusters->SetMarkerColor(kMagenta);
369 }
a4197d2e 370
527ceac3 371 SetTitle(Form("Det[%d] RC[%c] Layer[%d] P[%7.3f]", trklt->GetDetector(), trklt->IsRowCross()?'y':'n', trklt->GetPlane(), trklt->GetMomentum()));
5524a724 372 SetLineColor(kRed);
a4197d2e 373 //SetOwnIds(kTRUE);
374
aecbd636 375 //trklt->Fit(kTRUE);
a7cc0364 376 y0 = trklt->GetYfit(0);
377 dydx = trklt->GetYfit(1);
4f7bd6c9 378 Double_t xg(x0 * cphi - y0 * sphi),
379 yg(x0 * sphi + y0 * cphi);
57ce0047 380 SetPoint(0, xg, yg, z0);
381 //SetPoint(0, x0, y0, z0);
57d55fae 382
383
a7cc0364 384 dx = .5*AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght();
385 x0 -= dx;
386 y0 -= dydx*dx,
387 z0 -= dzdx*dx;
4f7bd6c9 388 xg = x0 * cphi - y0 * sphi;
389 yg = x0 * sphi + y0 * cphi;
a7cc0364 390 SetPoint(1, xg, yg, z0);
57ce0047 391 //SetPoint(1, x0, y0, z0);
a4197d2e 392}
393
98b9b8b2 394
395AliEveTRDTracklet::~AliEveTRDTracklet()
396{
98b9b8b2 397
98b9b8b2 398}
399
a4197d2e 400//______________________________________________________________________________
57d55fae 401void AliEveTRDTracklet::Print(Option_t *o) const
a4197d2e 402{
403 AliTRDseedV1 *tracklet = (AliTRDseedV1*)GetUserData();
57d55fae 404 if(!tracklet) return;
405 tracklet->Print(o);
a282bf09 406}
407
edf0c4a0 408///////////////////////////////////////////////////////////
6983e87a 409///////////// AliEveTRDTrack /////////////////////
edf0c4a0 410///////////////////////////////////////////////////////////
6983e87a 411
412//______________________________________________________________________________
baee73d3 413AliEveTRDTrack::AliEveTRDTrack(AliTRDtrackV1 *trk)
414 :TEveLine()
415 ,fTrackState(0)
416 ,fESDStatus(0)
417 ,fAlpha(0.)
004e0620 418 ,fPoints(NULL)
419 ,fRim(NULL)
edf0c4a0 420{
a15e6d7d 421 // Constructor.
a4197d2e 422 SetUserData(trk);
57d55fae 423 SetName("");
424
5998b164 425// AliTRDtrackerV1::SetNTimeBins(24);
baee73d3 426
57ce0047 427 fRim = new AliRieman(trk->GetNumberOfClusters());
004e0620 428 AliTRDseedV1 *tracklet = NULL;
7bc3159a 429 for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
430 if(!(tracklet = trk->GetTracklet(il))) continue;
a4197d2e 431 if(!tracklet->IsOK()) continue;
baee73d3 432 AddElement(new AliEveTRDTracklet(tracklet));
a4197d2e 433
0495887f 434// tracklet->ResetClusterIter(kFALSE);
435// while((c = tracklet->PrevCluster())){
527ceac3 436// AliTRDcluster *c(NULL);
5998b164 437/* for(Int_t ic=AliTRDseedV1::kNtb; ic--;){
0495887f 438 if(!(c=tracklet->GetClusters(ic))) continue;
57ce0047 439 Float_t xc = c->GetX();
440 Float_t yc = c->GetY();
441 Float_t zc = c->GetZ();
442 Float_t zt = tracklet->GetZref(0) - (tracklet->GetX0()-xc)*tracklet->GetZref(1);
443 yc -= tracklet->GetTilt()*(zc-zt);
0495887f 444 fRim->AddPoint(xc, yc, zc, .05, 2.3);
5998b164 445 }*/
57ce0047 446 }
0495887f 447 if(trk->GetNumberOfTracklets()>1) fRim->Update();
baee73d3 448 SetStatus(fTrackState);
449}
a4197d2e 450
baee73d3 451//______________________________________________________________________________
452AliEveTRDTrack::~AliEveTRDTrack()
453{
004e0620 454 if(fPoints) delete [] fPoints; fPoints = NULL;
baee73d3 455 //delete dynamic_cast<AliTRDtrackV1*>(GetUserData());
a4197d2e 456}
457
14eef4aa 458//______________________________________________________________________________
459void AliEveTRDTrack::Print(Option_t *o) const
460{
461 AliTRDtrackV1 *track = (AliTRDtrackV1*)GetUserData();
462 if(!track) return;
463 track->Print(o);
464}
baee73d3 465
a4197d2e 466//______________________________________________________________________________
baee73d3 467void AliEveTRDTrack::SetStatus(UChar_t s)
a4197d2e 468{
baee73d3 469 // nothing to be done
470 if(fPoints && fTrackState == s) return;
5998b164 471 //return;
baee73d3 472 const Int_t nc = AliTRDtrackV1::kMAXCLUSTERSPERTRACK;
ce239ca6 473 AliTRDtrackV1 *trk(NULL);
474 if(!(trk=static_cast<AliTRDtrackV1*>(GetUserData()))) {
475 AliError("Failed casting data to TRD track.");
476 return;
477 }
baee73d3 478
479 Bool_t BUILD = kFALSE;
480 if(!fPoints){
481 fPoints = new AliTrackPoint[nc];
482
b0042d44 483 // define the radial span of the track in the TRD
484 Double_t xmin = -1., xmax = -1.;
485 Int_t det = 0;
004e0620 486 AliTRDseedV1 *trklt = NULL;
487 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
b0042d44 488 if(!(trklt = trk->GetTracklet(ily))) continue;
489 if(xmin<0.) xmin = trklt->GetX0() - AliTRDgeometry::CamHght() - AliTRDgeometry::CdrHght();
004e0620 490 if(trklt->GetX0()>xmax) xmax = trklt->GetX0();
b0042d44 491 det = trklt->GetDetector();
492 }
493 Int_t sec = det/AliTRDgeometry::kNdets;
494 fAlpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5); //trk->GetAlpha()
baee73d3 495
b0042d44 496 Double_t dx =(xmax - xmin)/nc;
baee73d3 497 for(Int_t ip=0; ip<nc; ip++){
b0042d44 498 fPoints[ip].SetXYZ(xmin, 0., 0.);
499 xmin+=dx;
baee73d3 500 }
501 BUILD = kTRUE;
502 }
503
504 // select track model
505 if(BUILD || ((s&12) != (fTrackState&12))){
506 if(TESTBIT(s, kTrackCosmics)){
507 //printf("Straight track\n");
004e0620 508 AliTRDtrackerV1::FitLine(trk, NULL, kFALSE, nc, fPoints);
baee73d3 509 } else {
510 if(TESTBIT(s, kTrackModel)){
511 //printf("Kalman track\n");
004e0620 512 if(trk->GetNumberOfTracklets() >=4) AliTRDtrackerV1::FitKalman(trk, NULL, kFALSE, nc, fPoints);
baee73d3 513 } else {
5998b164 514 //printf("Rieman track rim[%p] nc[%d]\n", (void*)fRim, nc);
515 //if(trk->GetNumberOfTracklets() >=4) AliTRDtrackerV1::FitRiemanTilt(trk, NULL, kTRUE, nc, fPoints);
004e0620 516 Float_t x = 0.;
57ce0047 517 for(Int_t ip = nc; ip--;){
518 x = fPoints[ip].GetX();
5998b164 519 //printf("%2d x[%f] y[%f] z[%f]\n", ip, x, fRim->GetYat(x), fRim->GetZat(x));
57ce0047 520 fPoints[ip].SetXYZ(x, fRim->GetYat(x), fRim->GetZat(x));
004e0620 521 }
baee73d3 522 }
523 }
a4197d2e 524
baee73d3 525 Float_t global[3];
004e0620 526 for(Int_t ip=0; ip<nc; ip++){
baee73d3 527 fPoints[ip].Rotate(-fAlpha).GetXYZ(global);
528 SetPoint(ip, global[0], global[1], global[2]);
5998b164 529 //printf("*** %2d x[%f] y[%f] z[%f]\n", ip, global[0], global[1], global[2]);
530
baee73d3 531 }
532 SetSmooth(kTRUE);
533 }
534
535 // set color
536 if(BUILD || ((s&3) != (fTrackState&3))){
537 if(TESTBIT(s, kSource)){
538 //printf("Source color\n");
539 if(fESDStatus&AliESDtrack::kTRDin){
540 SetMarkerColor(kGreen);
541 SetLineColor(kGreen);
542 } else {
543 SetMarkerColor(kMagenta);
544 SetLineColor(kMagenta);
545 }
546 } else {
9443fb9d 547 if(TESTBIT(s, kPID) == AliTRDpidUtil::kLQ){
baee73d3 548 //printf("PID color kLQPID\n");
549 //trk->GetReconstructor()->SetOption("!nn");
550 } else {
551 //printf("PID color kNNPID\n");
552 //trk->GetReconstructor()->SetOption("nn");
553 }
ce239ca6 554 //trk->CookPID();
baee73d3 555
556 Int_t species = 0; Float_t pid = 0.;
377ec156 557 for(Int_t is=0; is<AliPID::kSPECIES; ++is)
baee73d3 558 if(trk->GetPID(is) > pid){
559 pid = trk->GetPID(is);
377ec156 560 species = (AliPID::EParticleType) is;
baee73d3 561 }
562 switch(species){
563 case AliPID::kElectron:
564 SetMarkerColor(kRed);
565 SetLineColor(kRed);
566 break;
567 default:
568 SetMarkerColor(kBlue);
569 SetLineColor(kBlue);
570 break;
571 }
572 }
573 SetLineWidth(2);
574 }
575
a6e0ebfe 576 const Char_t *model = "line";
baee73d3 577 if(!TESTBIT(s, kTrackCosmics)){
578 if(TESTBIT(s, kTrackModel)) model = "kalman";
579 else model = "rieman";
580 }
581 Int_t species = 0; Float_t pid = 0.;
582 for(Int_t is=0; is<AliPID::kSPECIES; is++)
583 if(trk->GetPID(is) > pid){
584 pid = trk->GetPID(is);
585 species = is;
586 }
edf0c4a0 587
57d55fae 588 SetTitle(Form(
589 "Tracklets[%d] Clusters[%d]\n"
590 "Reconstruction Source[%s]\n"
591 "PID[%4.1f %4.1f %4.1f %4.1f %4.1f]\n"
592 "MC[%d]", trk->GetNumberOfTracklets(), trk->GetNumberOfClusters(), fESDStatus&AliESDtrack::kTRDin ? "barrel" : "sa",
593 1.E2*trk->GetPID(0), 1.E2*trk->GetPID(1),
594 1.E2*trk->GetPID(2), 1.E2*trk->GetPID(3), 1.E2*trk->GetPID(4), trk->GetLabel()));
595
596 if(GetName()){
90ae0503 597 char id[6]; snprintf(id, 6, "%s", GetName());
57d55fae 598 SetName(Form("%s %s", id, AliPID::ParticleName(species)));
599 }
baee73d3 600
601 // save track status
602 fTrackState = s;
603}
a879a24a 604
527ceac3 605//______________________________________________________________________________
ea41d018 606void AliEveTRDTrack::Load(const Char_t *what) const
527ceac3 607{
90ae0503 608// Spread downwards to tracklets the command "what"
609
610 const AliEveTRDTracklet* trklt(NULL);
611 TEveElement::List_ci itrklt=BeginChildren();
527ceac3 612 while(itrklt!=EndChildren()){
90ae0503 613 if((trklt = dynamic_cast<const AliEveTRDTracklet*>(*itrklt))) trklt->Load(what);
527ceac3 614 itrklt++;
615 }
616}
617
90ae0503 618//______________________________________________________________________________
a879a24a 619AliEveTRDTrackletOnline::AliEveTRDTrackletOnline(AliTRDtrackletMCM *tracklet) :
620 TEveLine(),
621 fDetector(-1),
622 fROB(-1),
623 fMCM(-1)
624{
625 AliTRDtrackletMCM *trkl = new AliTRDtrackletMCM(*tracklet);
626 SetUserData(trkl);
627
628 fDetector = trkl->GetDetector();
629 fROB = trkl->GetROB();
630 fMCM = trkl->GetMCM();
631
a1d14acd 632 SetName("sim. tracklet");
a879a24a 633 SetTitle(Form("Det: %i, ROB: %i, MCM: %i, Label: %i\n0x%08x",
634 trkl->GetDetector(), trkl->GetROB(), trkl->GetMCM(), trkl->GetLabel(),
635 trkl->GetTrackletWord()));
a428533a 636 SetLineColor(kGreen);
a1d14acd 637 SetLineWidth(3);
a879a24a 638
a1d14acd 639 AliTRDgeometry geo;
640 TGeoHMatrix *matrix = geo.GetClusterMatrix(trkl->GetDetector());
a879a24a 641
a1d14acd 642 fDetector = trkl->GetDetector();
643 fROB = trkl->GetROB();
644 fMCM = trkl->GetMCM();
645
a879a24a 646 Float_t length = 3.;
647 Double_t x[3];
648 Double_t p[3];
a1d14acd 649 Double_t p2[3];
650 x[0] = AliTRDgeometry::AnodePos();
a879a24a 651 x[1] = trkl->GetY();
a1d14acd 652 x[2] = trkl->GetLocalZ();
a879a24a 653
a1d14acd 654 matrix->LocalToMaster(x, p);
655 geo.RotateBack(trkl->GetDetector(), p, p2);
656 SetPoint(0, p2[0], p2[1], p2[2]);
a879a24a 657
658 x[0] -= length;
a428533a 659 x[1] -= length * trkl->GetdYdX();
a1d14acd 660 matrix->LocalToMaster(x, p);
661 p[2] *= p[0] / (p[0] + length);
662 geo.RotateBack(trkl->GetDetector(), p, p2);
663 SetPoint(1, p2[0], p2[1], p2[2]);
a879a24a 664}
665
666AliEveTRDTrackletOnline::AliEveTRDTrackletOnline(AliTRDtrackletWord *tracklet) :
667 TEveLine(),
668 fDetector(-1),
669 fROB(-1),
670 fMCM(-1)
671{
672 AliTRDtrackletWord *trkl = new AliTRDtrackletWord(*tracklet);
673 SetUserData(trkl);
674
a879a24a 675 fDetector = trkl->GetDetector();
a1d14acd 676 fROB = trkl->GetROB();
677 fMCM = trkl->GetMCM();
a879a24a 678
a1d14acd 679 SetName("raw tracklet");
a879a24a 680 SetTitle(Form("Det: %i, ROB: %i, MCM: %i, Label: %i\n0x%08x",
681 trkl->GetDetector(), fROB, fMCM, -1,
682 trkl->GetTrackletWord()));
683 SetLineColor(kRed);
a1d14acd 684 SetLineWidth(3);
a879a24a 685
a1d14acd 686 AliTRDgeometry geo;
687 TGeoHMatrix *matrix = geo.GetClusterMatrix(trkl->GetDetector());
a879a24a 688
689 Float_t length = 3.;
690 Double_t x[3];
691 Double_t p[3];
a1d14acd 692 Double_t p2[3];
693 x[0] = AliTRDgeometry::AnodePos();
a879a24a 694 x[1] = trkl->GetY();
a1d14acd 695 x[2] = trkl->GetLocalZ();
a879a24a 696
a1d14acd 697 matrix->LocalToMaster(x, p);
698 geo.RotateBack(trkl->GetDetector(), p, p2);
699 SetPoint(0, p2[0], p2[1], p2[2]);
a879a24a 700
701 x[0] -= length;
a428533a 702 x[1] -= length * trkl->GetdYdX();
a1d14acd 703 matrix->LocalToMaster(x, p);
704 p[2] *= p[0] / (p[0] + length);
705 geo.RotateBack(trkl->GetDetector(), p, p2);
706 SetPoint(1, p2[0], p2[1], p2[2]);
a879a24a 707}
708
709AliEveTRDTrackletOnline::~AliEveTRDTrackletOnline()
710{
a1d14acd 711 delete ((AliTRDtrackletBase*) GetUserData());
712 SetUserData(0x0);
a879a24a 713}
714
715void AliEveTRDTrackletOnline::ShowMCM(Option_t *opt) const
716{
717 if (fDetector < 0 || fROB < 0 || fMCM < 0)
718 return;
719
720 AliEveTRDmcm *evemcm = new AliEveTRDmcm();
721 evemcm->Init(fDetector, fROB, fMCM);
722 evemcm->LoadDigits();
723 evemcm->Draw(opt);
724
004e0620 725 TEveElementList *mcmlist = NULL;
a879a24a 726 if (gEve->GetCurrentEvent())
727 mcmlist = (TEveElementList*) gEve->GetCurrentEvent()->FindChild("TRD MCMs");
728 if (!mcmlist) {
729 mcmlist = new TEveElementList("TRD MCMs");
730 gEve->AddElement(mcmlist);
731 }
732 gEve->AddElement(evemcm, mcmlist);
733}
734
735
736AliEveTRDmcm::AliEveTRDmcm() :
737 TEveElement(),
738 TNamed(),
739 fMCM(new AliTRDmcmSim())
740{
741 SetName("MCM");
742 SetTitle("Unknown MCM");
743}
744
745AliEveTRDmcm::~AliEveTRDmcm()
746{
747 delete fMCM;
748}
749
750Bool_t AliEveTRDmcm::Init(Int_t det, Int_t rob, Int_t mcm)
751{
752 SetName(Form("MCM: Det. %i, ROB %i, MCM %i", det, rob, mcm));
753 SetTitle(Form("MCM: Det. %i, ROB %i, MCM %i", det, rob, mcm));
754 fMCM->Init(det, rob, mcm);
755 fMCM->Reset();
756 return kTRUE;
757}
758
759Bool_t AliEveTRDmcm::LoadDigits()
760{
761 AliRunLoader *rl = AliEveEventManager::AssertRunLoader();
762 return fMCM->LoadMCM(rl, fMCM->GetDetector(),
763 fMCM->GetRobPos(), fMCM->GetMcmPos());
764}
765
766Bool_t AliEveTRDmcm::Filter()
767{
768 fMCM->Filter();
769 return kTRUE;
770}
771
772Bool_t AliEveTRDmcm::Tracklet()
773{
774 fMCM->Tracklet();
775 return kTRUE;
776}
777
778void AliEveTRDmcm::Draw(Option_t* option)
779{
780 const char *mcmname = Form("mcm_%i_%i_%i", fMCM->GetDetector(),
781 fMCM->GetRobPos(), fMCM->GetMcmPos());
782
783 TCanvas *c = dynamic_cast<TCanvas*> (gROOT->FindObject(mcmname));
784 if (!c)
785 c = gEve->AddCanvasTab("TRD MCM");
786 c->SetTitle(Form("MCM %i on ROB %i of det. %i",
787 fMCM->GetMcmPos(), fMCM->GetRobPos(), fMCM->GetDetector()));
788 c->SetName(mcmname);
789 c->cd();
790 fMCM->Draw(option);
791}
792
793Bool_t AliEveTRDmcm::AssignPointer(const char* ptrname)
794{
c51e9ba0 795 gROOT->ProcessLine(Form("AliTRDmcmSim* %s = (AliTRDmcmSim *)%p", ptrname, (void*)fMCM));
a879a24a 796 return kTRUE;
797}