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