make loader more tolerant to missing files
[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
21#include "EveBase/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
fd31e9de 83//______________________________________________________________________________
6983e87a 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;
237 else if(strcmp(w, "all")==0) typ = 3;
238 else{
239 AliInfo("The following arguments are accepted:");
240 AliInfo(" \"hit\" : loading of MC hits");
241 AliInfo(" \"dig\" : loading of digits");
242 AliInfo(" \"cls\" : loading of reconstructed clusters");
243 AliInfo(" \"all\" : loading of MC hits+digits+clusters");
244 return;
245 }
246
004e0620 247 AliTRDcluster *c = NULL;
b3d20a1c 248 Int_t n = 0;
249 while((n = GetN() && !(c = dynamic_cast<AliTRDcluster*>(GetPointId(n))))) n++;
250 if(!c) return;
251
252 Int_t det = c->GetDetector();
09487f16 253 AliEveTRDLoader *loader(NULL);
b3d20a1c 254 switch(typ){
09487f16 255 case 3:
256 loader = new AliEveTRDLoaderSim("MC");
257 if(!loader->Open("galice.root")) delete loader;
258 else{
259 loader->SetDataType(AliEveTRDLoader::kTRDHits | AliEveTRDLoader::kTRDDigits | AliEveTRDLoader::kTRDClusters);
260 break;
261 }
b3d20a1c 262 case 0:
263 loader = new AliEveTRDLoader("Hits");
09487f16 264 if(!loader->Open("TRD.Hits.root")) delete loader;
265 else{
266 loader->SetDataType(AliEveTRDLoader::kTRDHits);
267 if(typ!=3) break;
b3d20a1c 268 }
b3d20a1c 269 case 1:
09487f16 270 if(!loader) loader = new AliEveTRDLoader("Digits");
271 if(!loader->Open("TRD.Digits.root")){
272 if(typ==1) delete loader;
273 } else {
274 loader->SetDataType(AliEveTRDLoader::kTRDDigits);
275 if(typ!=3) break;
b3d20a1c 276 }
b3d20a1c 277 case 2:
09487f16 278 if(!loader) loader = new AliEveTRDLoader("Clusters");
279 if(!loader->Open("TRD.RecPoints.root")){
280 if(typ ==2) delete loader;
281 } else {
282 loader->SetDataType(AliEveTRDLoader::kTRDClusters);
283 break;
b3d20a1c 284 }
b3d20a1c 285 default: return;
286 }
09487f16 287 if(!loader) return;
b3d20a1c 288
527ceac3 289 loader->AddChambers(AliTRDgeometry::GetSector(det),AliTRDgeometry::GetStack(det), AliTRDgeometry::GetLayer(det));
b3d20a1c 290 // load first event
291 loader->GoToEvent(AliEveEventManager::GetCurrent()->GetEventId());
292
293 // register loader with alieve
527ceac3 294 gEve->AddElement(loader->GetChamber(det), *(BeginParents()));
b3d20a1c 295 //loader->SpawnEditor();
296 gEve->Redraw3D();
297}
298
edf0c4a0 299///////////////////////////////////////////////////////////
6983e87a 300///////////// AliEveTRDTracklet /////////////////////
edf0c4a0 301///////////////////////////////////////////////////////////
edf0c4a0 302
6983e87a 303//______________________________________________________________________________
a4197d2e 304AliEveTRDTracklet::AliEveTRDTracklet(AliTRDseedV1 *trklt):TEveLine()
004e0620 305 ,fClusters(NULL)
a282bf09 306{
6983e87a 307 // Constructor.
308 SetName("tracklet");
a4197d2e 309
7c487dfd 310 if(!gGeoManager){
311 AliEveEventManager::AssertGeometry();
312 AliInfo(Form("gGeo[%p] Closed[%c]", (void*)gGeoManager, gGeoManager->IsClosed()?'y':'n'));
313 }
a4197d2e 314 SetUserData(trklt);
4f7bd6c9 315 // init tracklet line
316 Int_t sec = AliTRDgeometry::GetSector(trklt->GetDetector());
317 Float_t alpha((0.5+sec)*AliTRDgeometry::GetAlpha()),
318 cphi(TMath::Cos(alpha)),
319 sphi(TMath::Sin(alpha));
a7cc0364 320 Float_t dx;
321 Float_t x0 = trklt->GetX0();
322 Float_t y0 = trklt->GetYref(0);
323 Float_t z0 = trklt->GetZref(0);
324 Float_t dydx = trklt->GetYref(1);
325 Float_t dzdx = trklt->GetZref(1);
5998b164 326 Float_t tilt = trklt->GetTilt();
a4197d2e 327 Float_t g[3];
004e0620 328 AliTRDcluster *c = NULL;
c624c106 329 for(Int_t ic=0; ic<AliTRDseedV1::kNclusters; ic++){
a4197d2e 330 if(!(c = trklt->GetClusters(ic))) continue;
57d55fae 331 if(!fClusters) AddElement(fClusters = new AliEveTRDClusters());
a7cc0364 332 dx = x0 - c->GetX();
333 //Float_t yt = y0 - dx*dydx;
334 Float_t zt = z0 - dx*dzdx;
57ce0047 335 // backup yc - for testing purposes
336 Float_t yc = c->GetY();
337 c->SetY(yc-tilt*(c->GetZ()-zt));
4f7bd6c9 338
339 // Ben: Temporary(?) fix -> Issue with wrongly set flag "fIsMisaligned" of AliCluster
340 // Changes can be undone ofter the issue with the flag has been solved
341 //c->GetGlobalXYZ(g);
342
343 // The following code for the trasformation local-to-global is just adapted from
344 // AliTRDgeometry::RotateBack(...)
345
346 // tracking to global coordinates transformation
347 Float_t loc[3] = { c->GetX(), c->GetY(), c->GetZ() };
348 g[0] = loc[0] * cphi - loc[1] * sphi;
349 g[1] = loc[0] * sphi + loc[1] * cphi;
350 g[2] = loc[2];
351 // Ben: End of fix
527ceac3 352 Int_t id = fClusters->SetNextPoint(g[0], g[1], g[2]);
57ce0047 353 c->SetY(yc);
a4197d2e 354 fClusters->SetPointId(id, new AliTRDcluster(*c));
355 }
a7cc0364 356 if(fClusters){
527ceac3 357 fClusters->SetName("TC clusters");
358 fClusters->SetTitle(Form("N[%d]", trklt->GetN()));
a7cc0364 359 fClusters->SetMarkerColor(kMagenta);
360 }
a4197d2e 361
527ceac3 362 SetTitle(Form("Det[%d] RC[%c] Layer[%d] P[%7.3f]", trklt->GetDetector(), trklt->IsRowCross()?'y':'n', trklt->GetPlane(), trklt->GetMomentum()));
5524a724 363 SetLineColor(kRed);
a4197d2e 364 //SetOwnIds(kTRUE);
365
aecbd636 366 //trklt->Fit(kTRUE);
a7cc0364 367 y0 = trklt->GetYfit(0);
368 dydx = trklt->GetYfit(1);
4f7bd6c9 369 Double_t xg(x0 * cphi - y0 * sphi),
370 yg(x0 * sphi + y0 * cphi);
57ce0047 371 SetPoint(0, xg, yg, z0);
372 //SetPoint(0, x0, y0, z0);
57d55fae 373
374
a7cc0364 375 dx = .5*AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght();
376 x0 -= dx;
377 y0 -= dydx*dx,
378 z0 -= dzdx*dx;
4f7bd6c9 379 xg = x0 * cphi - y0 * sphi;
380 yg = x0 * sphi + y0 * cphi;
a7cc0364 381 SetPoint(1, xg, yg, z0);
57ce0047 382 //SetPoint(1, x0, y0, z0);
a4197d2e 383}
384
98b9b8b2 385
386AliEveTRDTracklet::~AliEveTRDTracklet()
387{
98b9b8b2 388
98b9b8b2 389}
390
a4197d2e 391//______________________________________________________________________________
57d55fae 392void AliEveTRDTracklet::Print(Option_t *o) const
a4197d2e 393{
394 AliTRDseedV1 *tracklet = (AliTRDseedV1*)GetUserData();
57d55fae 395 if(!tracklet) return;
396 tracklet->Print(o);
a282bf09 397}
398
edf0c4a0 399///////////////////////////////////////////////////////////
6983e87a 400///////////// AliEveTRDTrack /////////////////////
edf0c4a0 401///////////////////////////////////////////////////////////
6983e87a 402
403//______________________________________________________________________________
baee73d3 404AliEveTRDTrack::AliEveTRDTrack(AliTRDtrackV1 *trk)
405 :TEveLine()
406 ,fTrackState(0)
407 ,fESDStatus(0)
408 ,fAlpha(0.)
004e0620 409 ,fPoints(NULL)
410 ,fRim(NULL)
edf0c4a0 411{
a15e6d7d 412 // Constructor.
a4197d2e 413 SetUserData(trk);
57d55fae 414 SetName("");
415
5998b164 416// AliTRDtrackerV1::SetNTimeBins(24);
baee73d3 417
57ce0047 418 fRim = new AliRieman(trk->GetNumberOfClusters());
004e0620 419 AliTRDseedV1 *tracklet = NULL;
7bc3159a 420 for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
421 if(!(tracklet = trk->GetTracklet(il))) continue;
a4197d2e 422 if(!tracklet->IsOK()) continue;
baee73d3 423 AddElement(new AliEveTRDTracklet(tracklet));
a4197d2e 424
0495887f 425// tracklet->ResetClusterIter(kFALSE);
426// while((c = tracklet->PrevCluster())){
527ceac3 427// AliTRDcluster *c(NULL);
5998b164 428/* for(Int_t ic=AliTRDseedV1::kNtb; ic--;){
0495887f 429 if(!(c=tracklet->GetClusters(ic))) continue;
57ce0047 430 Float_t xc = c->GetX();
431 Float_t yc = c->GetY();
432 Float_t zc = c->GetZ();
433 Float_t zt = tracklet->GetZref(0) - (tracklet->GetX0()-xc)*tracklet->GetZref(1);
434 yc -= tracklet->GetTilt()*(zc-zt);
0495887f 435 fRim->AddPoint(xc, yc, zc, .05, 2.3);
5998b164 436 }*/
57ce0047 437 }
0495887f 438 if(trk->GetNumberOfTracklets()>1) fRim->Update();
baee73d3 439 SetStatus(fTrackState);
440}
a4197d2e 441
baee73d3 442//______________________________________________________________________________
443AliEveTRDTrack::~AliEveTRDTrack()
444{
004e0620 445 if(fPoints) delete [] fPoints; fPoints = NULL;
baee73d3 446 //delete dynamic_cast<AliTRDtrackV1*>(GetUserData());
a4197d2e 447}
448
14eef4aa 449//______________________________________________________________________________
450void AliEveTRDTrack::Print(Option_t *o) const
451{
452 AliTRDtrackV1 *track = (AliTRDtrackV1*)GetUserData();
453 if(!track) return;
454 track->Print(o);
455}
baee73d3 456
a4197d2e 457//______________________________________________________________________________
baee73d3 458void AliEveTRDTrack::SetStatus(UChar_t s)
a4197d2e 459{
baee73d3 460 // nothing to be done
461 if(fPoints && fTrackState == s) return;
5998b164 462 //return;
baee73d3 463 const Int_t nc = AliTRDtrackV1::kMAXCLUSTERSPERTRACK;
ce239ca6 464 AliTRDtrackV1 *trk(NULL);
465 if(!(trk=static_cast<AliTRDtrackV1*>(GetUserData()))) {
466 AliError("Failed casting data to TRD track.");
467 return;
468 }
baee73d3 469
470 Bool_t BUILD = kFALSE;
471 if(!fPoints){
472 fPoints = new AliTrackPoint[nc];
473
b0042d44 474 // define the radial span of the track in the TRD
475 Double_t xmin = -1., xmax = -1.;
476 Int_t det = 0;
004e0620 477 AliTRDseedV1 *trklt = NULL;
478 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
b0042d44 479 if(!(trklt = trk->GetTracklet(ily))) continue;
480 if(xmin<0.) xmin = trklt->GetX0() - AliTRDgeometry::CamHght() - AliTRDgeometry::CdrHght();
004e0620 481 if(trklt->GetX0()>xmax) xmax = trklt->GetX0();
b0042d44 482 det = trklt->GetDetector();
483 }
484 Int_t sec = det/AliTRDgeometry::kNdets;
485 fAlpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5); //trk->GetAlpha()
baee73d3 486
b0042d44 487 Double_t dx =(xmax - xmin)/nc;
baee73d3 488 for(Int_t ip=0; ip<nc; ip++){
b0042d44 489 fPoints[ip].SetXYZ(xmin, 0., 0.);
490 xmin+=dx;
baee73d3 491 }
492 BUILD = kTRUE;
493 }
494
495 // select track model
496 if(BUILD || ((s&12) != (fTrackState&12))){
497 if(TESTBIT(s, kTrackCosmics)){
498 //printf("Straight track\n");
004e0620 499 AliTRDtrackerV1::FitLine(trk, NULL, kFALSE, nc, fPoints);
baee73d3 500 } else {
501 if(TESTBIT(s, kTrackModel)){
502 //printf("Kalman track\n");
004e0620 503 if(trk->GetNumberOfTracklets() >=4) AliTRDtrackerV1::FitKalman(trk, NULL, kFALSE, nc, fPoints);
baee73d3 504 } else {
5998b164 505 //printf("Rieman track rim[%p] nc[%d]\n", (void*)fRim, nc);
506 //if(trk->GetNumberOfTracklets() >=4) AliTRDtrackerV1::FitRiemanTilt(trk, NULL, kTRUE, nc, fPoints);
004e0620 507 Float_t x = 0.;
57ce0047 508 for(Int_t ip = nc; ip--;){
509 x = fPoints[ip].GetX();
5998b164 510 //printf("%2d x[%f] y[%f] z[%f]\n", ip, x, fRim->GetYat(x), fRim->GetZat(x));
57ce0047 511 fPoints[ip].SetXYZ(x, fRim->GetYat(x), fRim->GetZat(x));
004e0620 512 }
baee73d3 513 }
514 }
a4197d2e 515
baee73d3 516 Float_t global[3];
004e0620 517 for(Int_t ip=0; ip<nc; ip++){
baee73d3 518 fPoints[ip].Rotate(-fAlpha).GetXYZ(global);
519 SetPoint(ip, global[0], global[1], global[2]);
5998b164 520 //printf("*** %2d x[%f] y[%f] z[%f]\n", ip, global[0], global[1], global[2]);
521
baee73d3 522 }
523 SetSmooth(kTRUE);
524 }
525
526 // set color
527 if(BUILD || ((s&3) != (fTrackState&3))){
528 if(TESTBIT(s, kSource)){
529 //printf("Source color\n");
530 if(fESDStatus&AliESDtrack::kTRDin){
531 SetMarkerColor(kGreen);
532 SetLineColor(kGreen);
533 } else {
534 SetMarkerColor(kMagenta);
535 SetLineColor(kMagenta);
536 }
537 } else {
9443fb9d 538 if(TESTBIT(s, kPID) == AliTRDpidUtil::kLQ){
baee73d3 539 //printf("PID color kLQPID\n");
540 //trk->GetReconstructor()->SetOption("!nn");
541 } else {
542 //printf("PID color kNNPID\n");
543 //trk->GetReconstructor()->SetOption("nn");
544 }
ce239ca6 545 //trk->CookPID();
baee73d3 546
547 Int_t species = 0; Float_t pid = 0.;
377ec156 548 for(Int_t is=0; is<AliPID::kSPECIES; ++is)
baee73d3 549 if(trk->GetPID(is) > pid){
550 pid = trk->GetPID(is);
377ec156 551 species = (AliPID::EParticleType) is;
baee73d3 552 }
553 switch(species){
554 case AliPID::kElectron:
555 SetMarkerColor(kRed);
556 SetLineColor(kRed);
557 break;
558 default:
559 SetMarkerColor(kBlue);
560 SetLineColor(kBlue);
561 break;
562 }
563 }
564 SetLineWidth(2);
565 }
566
a6e0ebfe 567 const Char_t *model = "line";
baee73d3 568 if(!TESTBIT(s, kTrackCosmics)){
569 if(TESTBIT(s, kTrackModel)) model = "kalman";
570 else model = "rieman";
571 }
572 Int_t species = 0; Float_t pid = 0.;
573 for(Int_t is=0; is<AliPID::kSPECIES; is++)
574 if(trk->GetPID(is) > pid){
575 pid = trk->GetPID(is);
576 species = is;
577 }
edf0c4a0 578
57d55fae 579 SetTitle(Form(
580 "Tracklets[%d] Clusters[%d]\n"
581 "Reconstruction Source[%s]\n"
582 "PID[%4.1f %4.1f %4.1f %4.1f %4.1f]\n"
583 "MC[%d]", trk->GetNumberOfTracklets(), trk->GetNumberOfClusters(), fESDStatus&AliESDtrack::kTRDin ? "barrel" : "sa",
584 1.E2*trk->GetPID(0), 1.E2*trk->GetPID(1),
585 1.E2*trk->GetPID(2), 1.E2*trk->GetPID(3), 1.E2*trk->GetPID(4), trk->GetLabel()));
586
587 if(GetName()){
90ae0503 588 char id[6]; snprintf(id, 6, "%s", GetName());
57d55fae 589 SetName(Form("%s %s", id, AliPID::ParticleName(species)));
590 }
baee73d3 591
592 // save track status
593 fTrackState = s;
594}
a879a24a 595
527ceac3 596//______________________________________________________________________________
ea41d018 597void AliEveTRDTrack::Load(const Char_t *what) const
527ceac3 598{
90ae0503 599// Spread downwards to tracklets the command "what"
600
601 const AliEveTRDTracklet* trklt(NULL);
602 TEveElement::List_ci itrklt=BeginChildren();
527ceac3 603 while(itrklt!=EndChildren()){
90ae0503 604 if((trklt = dynamic_cast<const AliEveTRDTracklet*>(*itrklt))) trklt->Load(what);
527ceac3 605 itrklt++;
606 }
607}
608
90ae0503 609//______________________________________________________________________________
a879a24a 610AliEveTRDTrackletOnline::AliEveTRDTrackletOnline(AliTRDtrackletMCM *tracklet) :
611 TEveLine(),
612 fDetector(-1),
613 fROB(-1),
614 fMCM(-1)
615{
616 AliTRDtrackletMCM *trkl = new AliTRDtrackletMCM(*tracklet);
617 SetUserData(trkl);
618
619 fDetector = trkl->GetDetector();
620 fROB = trkl->GetROB();
621 fMCM = trkl->GetMCM();
622
a1d14acd 623 SetName("sim. tracklet");
a879a24a 624 SetTitle(Form("Det: %i, ROB: %i, MCM: %i, Label: %i\n0x%08x",
625 trkl->GetDetector(), trkl->GetROB(), trkl->GetMCM(), trkl->GetLabel(),
626 trkl->GetTrackletWord()));
a428533a 627 SetLineColor(kGreen);
a1d14acd 628 SetLineWidth(3);
a879a24a 629
a1d14acd 630 AliTRDgeometry geo;
631 TGeoHMatrix *matrix = geo.GetClusterMatrix(trkl->GetDetector());
a879a24a 632
a1d14acd 633 fDetector = trkl->GetDetector();
634 fROB = trkl->GetROB();
635 fMCM = trkl->GetMCM();
636
a879a24a 637 Float_t length = 3.;
638 Double_t x[3];
639 Double_t p[3];
a1d14acd 640 Double_t p2[3];
641 x[0] = AliTRDgeometry::AnodePos();
a879a24a 642 x[1] = trkl->GetY();
a1d14acd 643 x[2] = trkl->GetLocalZ();
a879a24a 644
a1d14acd 645 matrix->LocalToMaster(x, p);
646 geo.RotateBack(trkl->GetDetector(), p, p2);
647 SetPoint(0, p2[0], p2[1], p2[2]);
a879a24a 648
649 x[0] -= length;
a428533a 650 x[1] -= length * trkl->GetdYdX();
a1d14acd 651 matrix->LocalToMaster(x, p);
652 p[2] *= p[0] / (p[0] + length);
653 geo.RotateBack(trkl->GetDetector(), p, p2);
654 SetPoint(1, p2[0], p2[1], p2[2]);
a879a24a 655}
656
657AliEveTRDTrackletOnline::AliEveTRDTrackletOnline(AliTRDtrackletWord *tracklet) :
658 TEveLine(),
659 fDetector(-1),
660 fROB(-1),
661 fMCM(-1)
662{
663 AliTRDtrackletWord *trkl = new AliTRDtrackletWord(*tracklet);
664 SetUserData(trkl);
665
a879a24a 666 fDetector = trkl->GetDetector();
a1d14acd 667 fROB = trkl->GetROB();
668 fMCM = trkl->GetMCM();
a879a24a 669
a1d14acd 670 SetName("raw tracklet");
a879a24a 671 SetTitle(Form("Det: %i, ROB: %i, MCM: %i, Label: %i\n0x%08x",
672 trkl->GetDetector(), fROB, fMCM, -1,
673 trkl->GetTrackletWord()));
674 SetLineColor(kRed);
a1d14acd 675 SetLineWidth(3);
a879a24a 676
a1d14acd 677 AliTRDgeometry geo;
678 TGeoHMatrix *matrix = geo.GetClusterMatrix(trkl->GetDetector());
a879a24a 679
680 Float_t length = 3.;
681 Double_t x[3];
682 Double_t p[3];
a1d14acd 683 Double_t p2[3];
684 x[0] = AliTRDgeometry::AnodePos();
a879a24a 685 x[1] = trkl->GetY();
a1d14acd 686 x[2] = trkl->GetLocalZ();
a879a24a 687
a1d14acd 688 matrix->LocalToMaster(x, p);
689 geo.RotateBack(trkl->GetDetector(), p, p2);
690 SetPoint(0, p2[0], p2[1], p2[2]);
a879a24a 691
692 x[0] -= length;
a428533a 693 x[1] -= length * trkl->GetdYdX();
a1d14acd 694 matrix->LocalToMaster(x, p);
695 p[2] *= p[0] / (p[0] + length);
696 geo.RotateBack(trkl->GetDetector(), p, p2);
697 SetPoint(1, p2[0], p2[1], p2[2]);
a879a24a 698}
699
700AliEveTRDTrackletOnline::~AliEveTRDTrackletOnline()
701{
a1d14acd 702 delete ((AliTRDtrackletBase*) GetUserData());
703 SetUserData(0x0);
a879a24a 704}
705
706void AliEveTRDTrackletOnline::ShowMCM(Option_t *opt) const
707{
708 if (fDetector < 0 || fROB < 0 || fMCM < 0)
709 return;
710
711 AliEveTRDmcm *evemcm = new AliEveTRDmcm();
712 evemcm->Init(fDetector, fROB, fMCM);
713 evemcm->LoadDigits();
714 evemcm->Draw(opt);
715
004e0620 716 TEveElementList *mcmlist = NULL;
a879a24a 717 if (gEve->GetCurrentEvent())
718 mcmlist = (TEveElementList*) gEve->GetCurrentEvent()->FindChild("TRD MCMs");
719 if (!mcmlist) {
720 mcmlist = new TEveElementList("TRD MCMs");
721 gEve->AddElement(mcmlist);
722 }
723 gEve->AddElement(evemcm, mcmlist);
724}
725
726
727AliEveTRDmcm::AliEveTRDmcm() :
728 TEveElement(),
729 TNamed(),
730 fMCM(new AliTRDmcmSim())
731{
732 SetName("MCM");
733 SetTitle("Unknown MCM");
734}
735
736AliEveTRDmcm::~AliEveTRDmcm()
737{
738 delete fMCM;
739}
740
741Bool_t AliEveTRDmcm::Init(Int_t det, Int_t rob, Int_t mcm)
742{
743 SetName(Form("MCM: Det. %i, ROB %i, MCM %i", det, rob, mcm));
744 SetTitle(Form("MCM: Det. %i, ROB %i, MCM %i", det, rob, mcm));
745 fMCM->Init(det, rob, mcm);
746 fMCM->Reset();
747 return kTRUE;
748}
749
750Bool_t AliEveTRDmcm::LoadDigits()
751{
752 AliRunLoader *rl = AliEveEventManager::AssertRunLoader();
753 return fMCM->LoadMCM(rl, fMCM->GetDetector(),
754 fMCM->GetRobPos(), fMCM->GetMcmPos());
755}
756
757Bool_t AliEveTRDmcm::Filter()
758{
759 fMCM->Filter();
760 return kTRUE;
761}
762
763Bool_t AliEveTRDmcm::Tracklet()
764{
765 fMCM->Tracklet();
766 return kTRUE;
767}
768
769void AliEveTRDmcm::Draw(Option_t* option)
770{
771 const char *mcmname = Form("mcm_%i_%i_%i", fMCM->GetDetector(),
772 fMCM->GetRobPos(), fMCM->GetMcmPos());
773
774 TCanvas *c = dynamic_cast<TCanvas*> (gROOT->FindObject(mcmname));
775 if (!c)
776 c = gEve->AddCanvasTab("TRD MCM");
777 c->SetTitle(Form("MCM %i on ROB %i of det. %i",
778 fMCM->GetMcmPos(), fMCM->GetRobPos(), fMCM->GetDetector()));
779 c->SetName(mcmname);
780 c->cd();
781 fMCM->Draw(option);
782}
783
784Bool_t AliEveTRDmcm::AssignPointer(const char* ptrname)
785{
c51e9ba0 786 gROOT->ProcessLine(Form("AliTRDmcmSim* %s = (AliTRDmcmSim *)%p", ptrname, (void*)fMCM));
a879a24a 787 return kTRUE;
788}