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