]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveDet/AliEveTRDData.cxx
fix coverity
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTRDData.cxx
CommitLineData
d810d0de 1// $Id$
2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
fd31e9de 9
a879a24a 10#include "TROOT.h"
5998b164 11#include "TStyle.h"
a4197d2e 12#include "TVector.h"
13#include "TLinearFitter.h"
a879a24a 14#include "TCanvas.h"
a1d14acd 15#include "TGeoMatrix.h"
5998b164 16#include "TGeoManager.h"
b3d20a1c 17
6983e87a 18#include "TEveTrans.h"
b3d20a1c 19#include "TEveManager.h"
20
21#include "EveBase/AliEveEventManager.h"
6983e87a 22
d810d0de 23#include "AliEveTRDData.h"
24#include "AliEveTRDModuleImp.h"
b3d20a1c 25#include "AliEveTRDLoader.h"
26#include "AliEveTRDLoaderImp.h"
a282bf09 27
c742ee6b 28#include "AliGeomManager.h"
1fbca246 29#include "AliESDtrack.h"
6983e87a 30#include "AliLog.h"
a4197d2e 31#include "AliPID.h"
32#include "AliTrackPointArray.h"
57ce0047 33#include "AliRieman.h"
6983e87a 34
edf0c4a0 35#include "AliTRDhit.h"
36#include "AliTRDcluster.h"
6983e87a 37#include "AliTRDseedV1.h"
98b9b8b2 38#include "AliTRDtrackletMCM.h"
a879a24a 39#include "AliTRDtrackletWord.h"
98b9b8b2 40#include "AliTRDmcmSim.h"
6983e87a 41#include "AliTRDtrackV1.h"
a4197d2e 42#include "AliTRDtrackerV1.h"
a282bf09 43#include "AliTRDpadPlane.h"
a4197d2e 44#include "AliTRDdigitsManager.h"
a879a24a 45#include "AliTRDmcmSim.h"
20301585 46#include "AliTRDarrayADC.h"
0d9ef37b 47#include "AliTRDSignalIndex.h"
a282bf09 48#include "AliTRDgeometry.h"
6983e87a 49#include "AliTRDtransform.h"
a4197d2e 50#include "AliTRDReconstructor.h"
51#include "AliTRDrecoParam.h"
a282bf09 52
d810d0de 53ClassImp(AliEveTRDHits)
54ClassImp(AliEveTRDDigits)
55ClassImp(AliEveTRDClusters)
6983e87a 56ClassImp(AliEveTRDTracklet)
57ClassImp(AliEveTRDTrack)
a879a24a 58ClassImp(AliEveTRDTrackletOnline)
59ClassImp(AliEveTRDmcm)
a282bf09 60
61///////////////////////////////////////////////////////////
fd31e9de 62///////////// AliEveTRDDigits /////////////////////
a282bf09 63///////////////////////////////////////////////////////////
64
fd31e9de 65//______________________________________________________________________________
5998b164 66AliEveTRDDigits::AliEveTRDDigits(AliEveTRDChamber *p)
67 :TEveQuadSet("digits", "")
68 ,fParent(p)
a15e6d7d 69{
a9063c0d 70 // Constructor.
5998b164 71 SetOwnIds(kTRUE);
72 gStyle->SetPalette(1, 0);
73 SetPalette(new TEveRGBAPalette(0, 512));
527ceac3 74 Reset(TEveQuadSet::kQT_RectangleYZ, kFALSE, 32);
a15e6d7d 75}
a282bf09 76
fd31e9de 77//______________________________________________________________________________
6983e87a 78AliEveTRDDigits::~AliEveTRDDigits()
a282bf09 79{
6983e87a 80// AliInfo(GetTitle());
a282bf09 81}
82
6983e87a 83//______________________________________________________________________________
84void AliEveTRDDigits::SetData(AliTRDdigitsManager *digits)
85{
86 // Set data source.
87
c742ee6b 88 Int_t det(fParent->GetID());
20301585 89 AliTRDarrayADC *data = digits->GetDigits(det);
90 if(!data->GetDim()) return;
0d9ef37b 91 data->Expand();
92
93 AliTRDSignalIndex *indexes = digits->GetIndexes(det);
94 if(!indexes->IsAllocated()) digits->BuildIndexes(det);
95
5998b164 96 Double_t scale, dy, dz;
527ceac3 97 Int_t ly = AliTRDgeometry::GetLayer(det),
5998b164 98 stk = AliTRDgeometry::GetStack(det),
99 sec = AliTRDgeometry::GetSector(det),
100 vid = AliGeomManager::LayerToVolUID(AliGeomManager::kTRD1 + ly, stk + AliTRDgeometry::Nstack() * sec);
7e2dd929 101 SetNameTitle(Form("digits%03d", det), Form("D-%03d [%02d_%d_%d]", det, sec, stk, ly));
5998b164 102 Short_t sig[7]={0,0,0,10,0,0,0};
103
104 AliTRDtransform transform(det);
105 AliTRDpadPlane *pp(fParent->fGeo->GetPadPlane(ly, stk));
0d9ef37b 106
527ceac3 107 Int_t row, col;
5998b164 108 AliTRDcluster c;
0d9ef37b 109 indexes->ResetCounters();
110 while (indexes->NextRCIndex(row, col)){
5998b164 111 dz = pp->GetRowSize(row);
112 dy = pp->GetColSize(col);
527ceac3 113 Short_t *const adc = data->GetDataAddress(row,col);
114 for (Int_t time(0); time<30; time++){
115 if(data->IsPadCorrupted(row, col, time)) break;
116 if(adc[time] <= 1) continue;
5998b164 117 new (&c) AliTRDcluster(det, col, row, time, sig, vid);
118 transform.Transform(&c);
119
527ceac3 120 scale = adc[time] < 512 ? adc[time]/512. : 1.;
121 AddQuad(c.GetY()-0.5*dy, c.GetZ()-0.5*dz*scale, c.GetX(), dy*0.95, dz*scale);
36f3e126 122 QuadValue(Int_t(adc[time]));
7e2dd929 123 QuadId(new TNamed(Form("ADC %d", adc[time]), Form("det[%3d(%02d_%d_%d)] col[%3d] row[%2d] tb[%2d]", det, sec, stk, ly, col, row, time)));
0d9ef37b 124 }
125 }
5998b164 126
127 // rotate to global coordinates
128 RefitPlex();
129 TEveTrans& t = RefMainTrans();
527ceac3 130 t.SetRotByAngles((sec+.5)*AliTRDgeometry::GetAlpha(), 0.,0.);
6983e87a 131}
132
133
c742ee6b 134// //______________________________________________________________________________
135// void AliEveTRDDigits::Paint(Option_t *option)
136// {
137// // Paint the object.
138//
139// if(fParent->GetDigitsBox()) fBoxes.Paint(option);
140// else TEveQuadSet::Paint(option);
141// }
a282bf09 142
5998b164 143// //______________________________________________________________________________
144// void AliEveTRDDigits::Reset()
145// {
146// // Reset raw and visual data.
147//
148// TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
149// // MT fBoxes.fBoxes.clear();
150// fData.Reset();
151// }
a282bf09 152
153///////////////////////////////////////////////////////////
fd31e9de 154///////////// AliEveTRDHits /////////////////////
a282bf09 155///////////////////////////////////////////////////////////
156
fd31e9de 157//______________________________________________________________________________
a4197d2e 158AliEveTRDHits::AliEveTRDHits() : TEvePointSet("hits", 20)
a15e6d7d 159{
160 // Constructor.
a4197d2e 161 SetMarkerSize(.1);
b3d20a1c 162 SetMarkerColor(kGreen);
a4197d2e 163 SetOwnIds(kTRUE);
6983e87a 164}
165
166//______________________________________________________________________________
167AliEveTRDHits::~AliEveTRDHits()
168{
169 //AliInfo(GetTitle());
a15e6d7d 170}
a282bf09 171
fd31e9de 172//______________________________________________________________________________
d810d0de 173void AliEveTRDHits::PointSelected(Int_t n)
edf0c4a0 174{
a15e6d7d 175 // Handle an individual point selection from GL.
176
004e0620 177 AliTRDhit *h = NULL;
a969af30 178 if(!(h = dynamic_cast<AliTRDhit*>(GetPointId(n)))) return;
179 printf("Id[%3d] Det[%3d] Reg[%c] TR[%c] Q[%3d] MC[%d] t[%f]\n",
180 n, h->GetDetector(),
181 h->FromAmplification() ? 'A' : 'D',
182 h->FromTRphoton() ? 'y' : 'n',
183 h->GetCharge(), h->GetTrack(), h->GetTime());
a282bf09 184}
185
edf0c4a0 186
187///////////////////////////////////////////////////////////
6983e87a 188///////////// AliEveTRDClusters /////////////////////
edf0c4a0 189///////////////////////////////////////////////////////////
190
fd31e9de 191//______________________________________________________________________________
a4197d2e 192AliEveTRDClusters::AliEveTRDClusters():AliEveTRDHits()
a15e6d7d 193{
194 // Constructor.
6983e87a 195 SetName("clusters");
a4197d2e 196
5524a724 197 SetMarkerSize(.4);
a4197d2e 198 SetMarkerStyle(24);
5524a724 199 SetMarkerColor(kGray);
a4197d2e 200 SetOwnIds(kTRUE);
a15e6d7d 201}
edf0c4a0 202
fd31e9de 203//______________________________________________________________________________
d810d0de 204void AliEveTRDClusters::PointSelected(Int_t n)
edf0c4a0 205{
a15e6d7d 206 // Handle an individual point selection from GL.
207
fd31e9de 208 AliTRDcluster *c = dynamic_cast<AliTRDcluster*>(GetPointId(n));
ce239ca6 209 if(!c) return;
210 c->Print();
211 Emit("PointSelected(Int_t)", n);
fd31e9de 212 // Bool_t AliCluster::GetGlobalCov(Float_t* cov) const
213 // Bool_t AliCluster::GetGlobalXYZ(Float_t* xyz) const
214 // Float_t AliCluster::GetSigmaY2() const
215 // Float_t AliCluster::GetSigmaYZ() const
216 // Float_t AliCluster::GetSigmaZ2() const
edf0c4a0 217}
218
57d55fae 219//______________________________________________________________________________
220void AliEveTRDClusters::Print(Option_t *o) const
221{
004e0620 222 AliTRDcluster *c = NULL;
57d55fae 223
224 for(Int_t n = GetN(); n--;){
225 if(!(c = dynamic_cast<AliTRDcluster*>(GetPointId(n)))) continue;
226 c->Print(o);
227 }
228}
229
b3d20a1c 230//______________________________________________________________________________
527ceac3 231void AliEveTRDClusters::Load(Char_t *w) const
b3d20a1c 232{
233 Int_t typ = -1;
234 if(strcmp(w, "hit")==0) typ = 0;
235 else if(strcmp(w, "dig")==0) typ = 1;
236 else if(strcmp(w, "cls")==0) typ = 2;
237 else if(strcmp(w, "all")==0) typ = 3;
238 else{
239 AliInfo("The following arguments are accepted:");
240 AliInfo(" \"hit\" : loading of MC hits");
241 AliInfo(" \"dig\" : loading of digits");
242 AliInfo(" \"cls\" : loading of reconstructed clusters");
243 AliInfo(" \"all\" : loading of MC hits+digits+clusters");
244 return;
245 }
246
004e0620 247 AliTRDcluster *c = NULL;
b3d20a1c 248 Int_t n = 0;
249 while((n = GetN() && !(c = dynamic_cast<AliTRDcluster*>(GetPointId(n))))) n++;
250 if(!c) return;
251
252 Int_t det = c->GetDetector();
004e0620 253 AliEveTRDLoader *loader = NULL;
b3d20a1c 254 switch(typ){
255 case 0:
256 loader = new AliEveTRDLoader("Hits");
257 if(!loader->Open("TRD.Hits.root")){
258 delete loader;
259 return;
260 }
261 loader->SetDataType(AliEveTRDLoader::kTRDHits);
262 break;
263 case 1:
264 loader = new AliEveTRDLoader("Digits");
265 if(!loader->Open("TRD.Digits.root")){
266 delete loader;
267 return;
268 }
269 loader->SetDataType(AliEveTRDLoader::kTRDDigits);
270 break;
271 case 2:
272 loader = new AliEveTRDLoader("Clusters");
273 if(!loader->Open("TRD.RecPoints.root")){
274 delete loader;
275 return;
276 }
277 loader->SetDataType(AliEveTRDLoader::kTRDClusters);
278 break;
279 case 3:
280 loader = new AliEveTRDLoaderSim("MC");
281 if(!loader->Open("galice.root")){
282 delete loader;
283 return;
284 }
285 loader->SetDataType(AliEveTRDLoader::kTRDHits | AliEveTRDLoader::kTRDDigits | AliEveTRDLoader::kTRDClusters);
286 break;
287 default: return;
288 }
289
527ceac3 290 loader->AddChambers(AliTRDgeometry::GetSector(det),AliTRDgeometry::GetStack(det), AliTRDgeometry::GetLayer(det));
b3d20a1c 291 // load first event
292 loader->GoToEvent(AliEveEventManager::GetCurrent()->GetEventId());
293
294 // register loader with alieve
527ceac3 295 gEve->AddElement(loader->GetChamber(det), *(BeginParents()));
b3d20a1c 296 //loader->SpawnEditor();
297 gEve->Redraw3D();
298}
299
edf0c4a0 300///////////////////////////////////////////////////////////
6983e87a 301///////////// AliEveTRDTracklet /////////////////////
edf0c4a0 302///////////////////////////////////////////////////////////
edf0c4a0 303
6983e87a 304//______________________________________________________________________________
a4197d2e 305AliEveTRDTracklet::AliEveTRDTracklet(AliTRDseedV1 *trklt):TEveLine()
004e0620 306 ,fClusters(NULL)
a282bf09 307{
6983e87a 308 // Constructor.
309 SetName("tracklet");
a4197d2e 310
7c487dfd 311 if(!gGeoManager){
312 AliEveEventManager::AssertGeometry();
313 AliInfo(Form("gGeo[%p] Closed[%c]", (void*)gGeoManager, gGeoManager->IsClosed()?'y':'n'));
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.;
377ec156 535 for(Int_t is=0; is<AliPID::kSPECIES; ++is)
baee73d3 536 if(trk->GetPID(is) > pid){
537 pid = trk->GetPID(is);
377ec156 538 species = (AliPID::EParticleType) is;
baee73d3 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 }
edf0c4a0 565
57d55fae 566 SetTitle(Form(
567 "Tracklets[%d] Clusters[%d]\n"
568 "Reconstruction Source[%s]\n"
569 "PID[%4.1f %4.1f %4.1f %4.1f %4.1f]\n"
570 "MC[%d]", trk->GetNumberOfTracklets(), trk->GetNumberOfClusters(), fESDStatus&AliESDtrack::kTRDin ? "barrel" : "sa",
571 1.E2*trk->GetPID(0), 1.E2*trk->GetPID(1),
572 1.E2*trk->GetPID(2), 1.E2*trk->GetPID(3), 1.E2*trk->GetPID(4), trk->GetLabel()));
573
574 if(GetName()){
90ae0503 575 char id[6]; snprintf(id, 6, "%s", GetName());
57d55fae 576 SetName(Form("%s %s", id, AliPID::ParticleName(species)));
577 }
baee73d3 578
579 // save track status
580 fTrackState = s;
581}
a879a24a 582
527ceac3 583//______________________________________________________________________________
584void AliEveTRDTrack::Load(Char_t *what) const
585{
90ae0503 586// Spread downwards to tracklets the command "what"
587
588 const AliEveTRDTracklet* trklt(NULL);
589 TEveElement::List_ci itrklt=BeginChildren();
527ceac3 590 while(itrklt!=EndChildren()){
90ae0503 591 if((trklt = dynamic_cast<const AliEveTRDTracklet*>(*itrklt))) trklt->Load(what);
527ceac3 592 itrklt++;
593 }
594}
595
90ae0503 596//______________________________________________________________________________
a879a24a 597AliEveTRDTrackletOnline::AliEveTRDTrackletOnline(AliTRDtrackletMCM *tracklet) :
598 TEveLine(),
599 fDetector(-1),
600 fROB(-1),
601 fMCM(-1)
602{
603 AliTRDtrackletMCM *trkl = new AliTRDtrackletMCM(*tracklet);
604 SetUserData(trkl);
605
606 fDetector = trkl->GetDetector();
607 fROB = trkl->GetROB();
608 fMCM = trkl->GetMCM();
609
a1d14acd 610 SetName("sim. tracklet");
a879a24a 611 SetTitle(Form("Det: %i, ROB: %i, MCM: %i, Label: %i\n0x%08x",
612 trkl->GetDetector(), trkl->GetROB(), trkl->GetMCM(), trkl->GetLabel(),
613 trkl->GetTrackletWord()));
a428533a 614 SetLineColor(kGreen);
a1d14acd 615 SetLineWidth(3);
a879a24a 616
a1d14acd 617 AliTRDgeometry geo;
618 TGeoHMatrix *matrix = geo.GetClusterMatrix(trkl->GetDetector());
a879a24a 619
a1d14acd 620 fDetector = trkl->GetDetector();
621 fROB = trkl->GetROB();
622 fMCM = trkl->GetMCM();
623
a879a24a 624 Float_t length = 3.;
625 Double_t x[3];
626 Double_t p[3];
a1d14acd 627 Double_t p2[3];
628 x[0] = AliTRDgeometry::AnodePos();
a879a24a 629 x[1] = trkl->GetY();
a1d14acd 630 x[2] = trkl->GetLocalZ();
a879a24a 631
a1d14acd 632 matrix->LocalToMaster(x, p);
633 geo.RotateBack(trkl->GetDetector(), p, p2);
634 SetPoint(0, p2[0], p2[1], p2[2]);
a879a24a 635
636 x[0] -= length;
a428533a 637 x[1] -= length * trkl->GetdYdX();
a1d14acd 638 matrix->LocalToMaster(x, p);
639 p[2] *= p[0] / (p[0] + length);
640 geo.RotateBack(trkl->GetDetector(), p, p2);
641 SetPoint(1, p2[0], p2[1], p2[2]);
a879a24a 642}
643
644AliEveTRDTrackletOnline::AliEveTRDTrackletOnline(AliTRDtrackletWord *tracklet) :
645 TEveLine(),
646 fDetector(-1),
647 fROB(-1),
648 fMCM(-1)
649{
650 AliTRDtrackletWord *trkl = new AliTRDtrackletWord(*tracklet);
651 SetUserData(trkl);
652
a879a24a 653 fDetector = trkl->GetDetector();
a1d14acd 654 fROB = trkl->GetROB();
655 fMCM = trkl->GetMCM();
a879a24a 656
a1d14acd 657 SetName("raw tracklet");
a879a24a 658 SetTitle(Form("Det: %i, ROB: %i, MCM: %i, Label: %i\n0x%08x",
659 trkl->GetDetector(), fROB, fMCM, -1,
660 trkl->GetTrackletWord()));
661 SetLineColor(kRed);
a1d14acd 662 SetLineWidth(3);
a879a24a 663
a1d14acd 664 AliTRDgeometry geo;
665 TGeoHMatrix *matrix = geo.GetClusterMatrix(trkl->GetDetector());
a879a24a 666
667 Float_t length = 3.;
668 Double_t x[3];
669 Double_t p[3];
a1d14acd 670 Double_t p2[3];
671 x[0] = AliTRDgeometry::AnodePos();
a879a24a 672 x[1] = trkl->GetY();
a1d14acd 673 x[2] = trkl->GetLocalZ();
a879a24a 674
a1d14acd 675 matrix->LocalToMaster(x, p);
676 geo.RotateBack(trkl->GetDetector(), p, p2);
677 SetPoint(0, p2[0], p2[1], p2[2]);
a879a24a 678
679 x[0] -= length;
a428533a 680 x[1] -= length * trkl->GetdYdX();
a1d14acd 681 matrix->LocalToMaster(x, p);
682 p[2] *= p[0] / (p[0] + length);
683 geo.RotateBack(trkl->GetDetector(), p, p2);
684 SetPoint(1, p2[0], p2[1], p2[2]);
a879a24a 685}
686
687AliEveTRDTrackletOnline::~AliEveTRDTrackletOnline()
688{
a1d14acd 689 delete ((AliTRDtrackletBase*) GetUserData());
690 SetUserData(0x0);
a879a24a 691}
692
693void AliEveTRDTrackletOnline::ShowMCM(Option_t *opt) const
694{
695 if (fDetector < 0 || fROB < 0 || fMCM < 0)
696 return;
697
698 AliEveTRDmcm *evemcm = new AliEveTRDmcm();
699 evemcm->Init(fDetector, fROB, fMCM);
700 evemcm->LoadDigits();
701 evemcm->Draw(opt);
702
004e0620 703 TEveElementList *mcmlist = NULL;
a879a24a 704 if (gEve->GetCurrentEvent())
705 mcmlist = (TEveElementList*) gEve->GetCurrentEvent()->FindChild("TRD MCMs");
706 if (!mcmlist) {
707 mcmlist = new TEveElementList("TRD MCMs");
708 gEve->AddElement(mcmlist);
709 }
710 gEve->AddElement(evemcm, mcmlist);
711}
712
713
714AliEveTRDmcm::AliEveTRDmcm() :
715 TEveElement(),
716 TNamed(),
717 fMCM(new AliTRDmcmSim())
718{
719 SetName("MCM");
720 SetTitle("Unknown MCM");
721}
722
723AliEveTRDmcm::~AliEveTRDmcm()
724{
725 delete fMCM;
726}
727
728Bool_t AliEveTRDmcm::Init(Int_t det, Int_t rob, Int_t mcm)
729{
730 SetName(Form("MCM: Det. %i, ROB %i, MCM %i", det, rob, mcm));
731 SetTitle(Form("MCM: Det. %i, ROB %i, MCM %i", det, rob, mcm));
732 fMCM->Init(det, rob, mcm);
733 fMCM->Reset();
734 return kTRUE;
735}
736
737Bool_t AliEveTRDmcm::LoadDigits()
738{
739 AliRunLoader *rl = AliEveEventManager::AssertRunLoader();
740 return fMCM->LoadMCM(rl, fMCM->GetDetector(),
741 fMCM->GetRobPos(), fMCM->GetMcmPos());
742}
743
744Bool_t AliEveTRDmcm::Filter()
745{
746 fMCM->Filter();
747 return kTRUE;
748}
749
750Bool_t AliEveTRDmcm::Tracklet()
751{
752 fMCM->Tracklet();
753 return kTRUE;
754}
755
756void AliEveTRDmcm::Draw(Option_t* option)
757{
758 const char *mcmname = Form("mcm_%i_%i_%i", fMCM->GetDetector(),
759 fMCM->GetRobPos(), fMCM->GetMcmPos());
760
761 TCanvas *c = dynamic_cast<TCanvas*> (gROOT->FindObject(mcmname));
762 if (!c)
763 c = gEve->AddCanvasTab("TRD MCM");
764 c->SetTitle(Form("MCM %i on ROB %i of det. %i",
765 fMCM->GetMcmPos(), fMCM->GetRobPos(), fMCM->GetDetector()));
766 c->SetName(mcmname);
767 c->cd();
768 fMCM->Draw(option);
769}
770
771Bool_t AliEveTRDmcm::AssignPointer(const char* ptrname)
772{
c51e9ba0 773 gROOT->ProcessLine(Form("AliTRDmcmSim* %s = (AliTRDmcmSim *)%p", ptrname, (void*)fMCM));
a879a24a 774 return kTRUE;
775}