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