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