]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveDet/AliEveTRDData.cxx
add print-out for MC hits
[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
a4197d2e 10#include "TVector.h"
11#include "TLinearFitter.h"
6983e87a 12#include "TEveTrans.h"
13
d810d0de 14#include "AliEveTRDData.h"
15#include "AliEveTRDModuleImp.h"
a282bf09 16
6983e87a 17#include "AliLog.h"
a4197d2e 18#include "AliPID.h"
19#include "AliTrackPointArray.h"
6983e87a 20
edf0c4a0 21#include "AliTRDhit.h"
22#include "AliTRDcluster.h"
6983e87a 23#include "AliTRDseedV1.h"
24#include "AliTRDtrackV1.h"
a4197d2e 25#include "AliTRDtrackerV1.h"
a282bf09 26#include "AliTRDpadPlane.h"
a4197d2e 27#include "AliTRDdigitsManager.h"
0d9ef37b 28#include "AliTRDdataArrayDigits.h"
29#include "AliTRDSignalIndex.h"
a282bf09 30#include "AliTRDgeometry.h"
6983e87a 31#include "AliTRDtransform.h"
a4197d2e 32#include "AliTRDReconstructor.h"
33#include "AliTRDrecoParam.h"
a282bf09 34
d810d0de 35ClassImp(AliEveTRDHits)
36ClassImp(AliEveTRDDigits)
37ClassImp(AliEveTRDClusters)
6983e87a 38ClassImp(AliEveTRDTracklet)
39ClassImp(AliEveTRDTrack)
a282bf09 40
41///////////////////////////////////////////////////////////
fd31e9de 42///////////// AliEveTRDDigits /////////////////////
a282bf09 43///////////////////////////////////////////////////////////
44
fd31e9de 45//______________________________________________________________________________
46AliEveTRDDigits::AliEveTRDDigits(AliEveTRDChamber *p) :
47 TEveQuadSet("digits", ""), fParent(p), fBoxes(), fData()
a15e6d7d 48{
49 // Constructor.
50}
a282bf09 51
fd31e9de 52//______________________________________________________________________________
6983e87a 53AliEveTRDDigits::~AliEveTRDDigits()
a282bf09 54{
6983e87a 55// AliInfo(GetTitle());
a282bf09 56}
57
fd31e9de 58//______________________________________________________________________________
d810d0de 59void AliEveTRDDigits::ComputeRepresentation()
a282bf09 60{
84aff7a4 61 // Calculate digits representation according to user settings. The
62 // user can set the following parameters:
63 // - digits scale (log/lin)
64 // - digits threshold
65 // - digits apparence (quads/boxes)
66
0d9ef37b 67 if(!fData.HasData()){
68 return;
69 }
70
6983e87a 71 TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
51346b82 72
6983e87a 73 Double_t scale, dy, dz;
74 Int_t q, color;
0d9ef37b 75 Int_t nrows = fData.GetNrow(),
76 ncols = fData.GetNcol(),
77 ntbs = fData.GetNtime(),
6983e87a 78 det = fParent->GetID();
79 Float_t threshold = fParent->GetDigitsThreshold();
a282bf09 80
6983e87a 81 AliTRDtransform transform(det);
82 AliTRDgeometry *geo = fParent->fGeo;
7bc3159a 83 AliTRDpadPlane *pp = geo->GetPadPlane(geo->GetLayer(det), geo->GetStack(det));
51346b82 84
6983e87a 85 // express position in tracking coordinates
84aff7a4 86 fData.Expand();
6983e87a 87 for (Int_t ir = 0; ir < nrows; ir++) {
88 dz = pp->GetRowSize(ir);
89 for (Int_t ic = 0; ic < ncols; ic++) {
90 dy = pp->GetColSize(ic);
91 for (Int_t it = 0; it < ntbs; it++) {
92 q = fData.GetDataUnchecked(ir, ic, it);
93 if (q < threshold) continue;
94
95 Double_t x[6] = {0., 0., Double_t(q), 0., 0., 0.};
96 Int_t roc[3] = {ir, ic, 0};
97 Bool_t out = kTRUE;
98 transform.Transform(&x[0], &roc[0], UInt_t(it), out, 0);
99
100 scale = q < 512 ? q/512. : 1.;
101 color = 50+int(scale*50.);
102
103 AddQuad(x[1]-.45*dy, x[2]-.5*dz*scale, x[0], .9*dy, dz*scale);
104 QuadValue(q);
fbc350a3 105 QuadColor(color);
6983e87a 106 QuadId(new TNamed(Form("Charge%d", q), "dummy title"));
84aff7a4 107 } // end time loop
108 } // end col loop
109 } // end row loop
110 fData.Compress(1);
6983e87a 111
112 // rotate to global coordinates
113 //RefitPlex();
114 TEveTrans& t = RefMainTrans();
115 t.SetRotByAngles((geo->GetSector(det)+.5)*AliTRDgeometry::GetAlpha(), 0.,0.);
a282bf09 116}
117
6983e87a 118//______________________________________________________________________________
119void AliEveTRDDigits::SetData(AliTRDdigitsManager *digits)
120{
121 // Set data source.
122
0d9ef37b 123 Int_t det = fParent->GetID();
124 AliTRDdataArrayDigits *data = digits->GetDigits(det);
125 if(!data->HasData()) return;
126 data->Expand();
127
128 AliTRDSignalIndex *indexes = digits->GetIndexes(det);
129 if(!indexes->IsAllocated()) digits->BuildIndexes(det);
130
131 if(!fData.HasData()) fData.Allocate(data->GetNrow(), data->GetNcol(), data->GetNtime());
132 fData.Expand();
133
134 Int_t row, col, time, adc;
135 indexes->ResetCounters();
136 while (indexes->NextRCIndex(row, col)){
137 indexes->ResetTbinCounter();
138 while (indexes->NextTbinIndex(time)){
139 if(data->IsPadCorrupted(row, col, time)){
140 // we should mark this position
141 break;
6983e87a 142 }
0d9ef37b 143 adc = data->GetData(row, col, time);
144 if(adc <= 1) continue;
145 fData.SetDataUnchecked(row, col, time, adc);
146 //fIndex->AddIndexTBin(row,col,time);
147 //printf("\tr[%d] c[%d] t[%d] ADC[%d]\n", row, col, time, adc);
148 }
149 }
150 fData.Compress(1);
6983e87a 151}
152
153
fd31e9de 154//______________________________________________________________________________
d810d0de 155void AliEveTRDDigits::Paint(Option_t *option)
a282bf09 156{
a15e6d7d 157 // Paint the object.
158
fd31e9de 159 if(fParent->GetDigitsBox()) fBoxes.Paint(option);
160 else TEveQuadSet::Paint(option);
a282bf09 161}
162
fd31e9de 163//______________________________________________________________________________
d810d0de 164void AliEveTRDDigits::Reset()
a282bf09 165{
a15e6d7d 166 // Reset raw and visual data.
167
6983e87a 168 TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
fd31e9de 169 // MT fBoxes.fBoxes.clear();
170 fData.Reset();
a282bf09 171}
172
173///////////////////////////////////////////////////////////
fd31e9de 174///////////// AliEveTRDHits /////////////////////
a282bf09 175///////////////////////////////////////////////////////////
176
fd31e9de 177//______________________________________________________________________________
a4197d2e 178AliEveTRDHits::AliEveTRDHits() : TEvePointSet("hits", 20)
a15e6d7d 179{
180 // Constructor.
a4197d2e 181 SetMarkerSize(.1);
182 SetMarkerColor(2);
183 SetOwnIds(kTRUE);
6983e87a 184}
185
186//______________________________________________________________________________
187AliEveTRDHits::~AliEveTRDHits()
188{
189 //AliInfo(GetTitle());
a15e6d7d 190}
a282bf09 191
fd31e9de 192//______________________________________________________________________________
d810d0de 193void AliEveTRDHits::PointSelected(Int_t n)
edf0c4a0 194{
a15e6d7d 195 // Handle an individual point selection from GL.
196
a969af30 197 AliTRDhit *h = 0x0;
198 if(!(h = dynamic_cast<AliTRDhit*>(GetPointId(n)))) return;
199 printf("Id[%3d] Det[%3d] Reg[%c] TR[%c] Q[%3d] MC[%d] t[%f]\n",
200 n, h->GetDetector(),
201 h->FromAmplification() ? 'A' : 'D',
202 h->FromTRphoton() ? 'y' : 'n',
203 h->GetCharge(), h->GetTrack(), h->GetTime());
a282bf09 204}
205
edf0c4a0 206
207///////////////////////////////////////////////////////////
6983e87a 208///////////// AliEveTRDClusters /////////////////////
edf0c4a0 209///////////////////////////////////////////////////////////
210
fd31e9de 211//______________________________________________________________________________
a4197d2e 212AliEveTRDClusters::AliEveTRDClusters():AliEveTRDHits()
a15e6d7d 213{
214 // Constructor.
6983e87a 215 SetName("clusters");
a4197d2e 216
5524a724 217 SetMarkerSize(.4);
a4197d2e 218 SetMarkerStyle(24);
5524a724 219 SetMarkerColor(kGray);
a4197d2e 220 SetOwnIds(kTRUE);
a15e6d7d 221}
edf0c4a0 222
fd31e9de 223//______________________________________________________________________________
d810d0de 224void AliEveTRDClusters::PointSelected(Int_t n)
edf0c4a0 225{
a15e6d7d 226 // Handle an individual point selection from GL.
227
fd31e9de 228 AliTRDcluster *c = dynamic_cast<AliTRDcluster*>(GetPointId(n));
229 printf("\nDetector : %d\n", c->GetDetector());
230 printf("Charge : %f\n", c->GetQ());
231 printf("Sum S : %4.0f\n", c->GetSumS());
232 printf("Time bin : %d\n", c->GetLocalTimeBin());
233 printf("Signals : ");
234 Short_t *cSignals = c->GetSignals();
235 for(Int_t ipad=0; ipad<7; ipad++) printf("%d ", cSignals[ipad]); printf("\n");
236 printf("Central pad : %d\n", c->GetPadCol());
237 printf("MC track labels : ");
238 for(Int_t itrk=0; itrk<3; itrk++) printf("%d ", c->GetLabel(itrk)); printf("\n");
239 // Bool_t AliCluster::GetGlobalCov(Float_t* cov) const
240 // Bool_t AliCluster::GetGlobalXYZ(Float_t* xyz) const
241 // Float_t AliCluster::GetSigmaY2() const
242 // Float_t AliCluster::GetSigmaYZ() const
243 // Float_t AliCluster::GetSigmaZ2() const
edf0c4a0 244}
245
57d55fae 246//______________________________________________________________________________
247void AliEveTRDClusters::Print(Option_t *o) const
248{
249 AliTRDcluster *c = 0x0;
250
251 for(Int_t n = GetN(); n--;){
252 if(!(c = dynamic_cast<AliTRDcluster*>(GetPointId(n)))) continue;
253 c->Print(o);
254 }
255}
256
edf0c4a0 257///////////////////////////////////////////////////////////
6983e87a 258///////////// AliEveTRDTracklet /////////////////////
edf0c4a0 259///////////////////////////////////////////////////////////
edf0c4a0 260
6983e87a 261//______________________________________________________________________________
a4197d2e 262AliEveTRDTracklet::AliEveTRDTracklet(AliTRDseedV1 *trklt):TEveLine()
263 ,fClusters(0x0)
a282bf09 264{
6983e87a 265 // Constructor.
266 SetName("tracklet");
a4197d2e 267
268 SetUserData(trklt);
269 Int_t det = -1, sec;
270 Float_t g[3];
271 AliTRDcluster *c = 0x0;
57d55fae 272 for(Int_t ic=0; ic<AliTRDseed::knTimebins; ic++){
a4197d2e 273 if(!(c = trklt->GetClusters(ic))) continue;
57d55fae 274 if(!fClusters) AddElement(fClusters = new AliEveTRDClusters());
a4197d2e 275 det = c->GetDetector();
276 c->GetGlobalXYZ(g);
277 Int_t id = fClusters->SetNextPoint(g[0], g[1], g[2]);
57d55fae 278 //Int_t id = fClusters->SetNextPoint(c->GetX(), c->GetY(), c->GetZ());
a4197d2e 279 fClusters->SetPointId(id, new AliTRDcluster(*c));
280 }
57d55fae 281 if(fClusters) fClusters->SetTitle(Form("N[%d]", trklt->GetN2()));
282
a4197d2e 283
284 SetTitle(Form("Det[%d] Plane[%d] P[%7.3f]", det, trklt->GetPlane(), trklt->GetMomentum()));
5524a724 285 SetLineColor(kRed);
a4197d2e 286 //SetOwnIds(kTRUE);
287
288 sec = det/30;
289 Double_t alpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5);
290 Double_t x0 = trklt->GetX0(),
291 y0f = trklt->GetYfit(0),
292 ysf = trklt->GetYfit(1),
293 z0r = trklt->GetZref(0),
294 zsr = trklt->GetZref(1);
295 Double_t xg = x0 * TMath::Cos(alpha) - y0f * TMath::Sin(alpha);
296 Double_t yg = x0 * TMath::Sin(alpha) + y0f * TMath::Cos(alpha);
297 SetPoint(0, xg, yg, z0r);
57d55fae 298 //SetPoint(0, x0, y0f, z0r);
299
300
a4197d2e 301 //SetPointId(0, new AliTRDseedV1(*trackletObj));
302 Double_t x1 = x0-3.5,
303 y1f = y0f - ysf*3.5,
304 z1r = z0r - zsr*3.5;
305 xg = x1 * TMath::Cos(alpha) - y1f * TMath::Sin(alpha);
306 yg = x1 * TMath::Sin(alpha) + y1f * TMath::Cos(alpha);
307 SetPoint(1, xg, yg, z1r);
57d55fae 308 //SetPoint(1, x1, y1f, z1r);
a4197d2e 309}
310
311//______________________________________________________________________________
57d55fae 312void AliEveTRDTracklet::Print(Option_t *o) const
a4197d2e 313{
314 AliTRDseedV1 *tracklet = (AliTRDseedV1*)GetUserData();
57d55fae 315 if(!tracklet) return;
316 tracklet->Print(o);
a282bf09 317}
318
edf0c4a0 319///////////////////////////////////////////////////////////
6983e87a 320///////////// AliEveTRDTrack /////////////////////
edf0c4a0 321///////////////////////////////////////////////////////////
6983e87a 322
323//______________________________________________________________________________
baee73d3 324AliEveTRDTrack::AliEveTRDTrack(AliTRDtrackV1 *trk)
325 :TEveLine()
326 ,fTrackState(0)
327 ,fESDStatus(0)
328 ,fAlpha(0.)
329 ,fPoints(0x0)
edf0c4a0 330{
a15e6d7d 331 // Constructor.
a4197d2e 332 SetUserData(trk);
57d55fae 333 SetName("");
334
a4197d2e 335 AliTRDtrackerV1::SetNTimeBins(24);
baee73d3 336
a4197d2e 337 AliTRDseedV1 *tracklet = 0x0;
7bc3159a 338 for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
339 if(!(tracklet = trk->GetTracklet(il))) continue;
a4197d2e 340 if(!tracklet->IsOK()) continue;
baee73d3 341 AddElement(new AliEveTRDTracklet(tracklet));
a4197d2e 342 }
343
baee73d3 344 SetStatus(fTrackState);
345}
a4197d2e 346
baee73d3 347//______________________________________________________________________________
348AliEveTRDTrack::~AliEveTRDTrack()
349{
350 if(fPoints) delete [] fPoints; fPoints = 0x0;
351 //delete dynamic_cast<AliTRDtrackV1*>(GetUserData());
a4197d2e 352}
353
baee73d3 354
a4197d2e 355//______________________________________________________________________________
baee73d3 356void AliEveTRDTrack::SetStatus(UChar_t s)
a4197d2e 357{
baee73d3 358 // nothing to be done
359 if(fPoints && fTrackState == s) return;
360
361 const Int_t nc = AliTRDtrackV1::kMAXCLUSTERSPERTRACK;
362 AliTRDtrackV1 *trk = (AliTRDtrackV1*)GetUserData();
363
364 Bool_t BUILD = kFALSE;
365 if(!fPoints){
366 fPoints = new AliTrackPoint[nc];
367
368 AliTRDcluster *c = trk->GetCluster(0);
369 Double_t x = c->GetX();
370 Int_t sec = c->GetDetector()/30;
371 fAlpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5);
372
373 Double_t dx = (trk->GetCluster(trk->GetNumberOfClusters()-1)->GetX()-x)/nc;
374 for(Int_t ip=0; ip<nc; ip++){
375 fPoints[ip].SetXYZ(x, 0., 0.);
376 x+=dx;
377 }
378 BUILD = kTRUE;
379 }
380
381 // select track model
382 if(BUILD || ((s&12) != (fTrackState&12))){
383 if(TESTBIT(s, kTrackCosmics)){
384 //printf("Straight track\n");
385 AliTRDtrackerV1::FitLine(trk, 0x0, kFALSE, nc, fPoints);
386 } else {
387 if(TESTBIT(s, kTrackModel)){
388 //printf("Kalman track\n");
12896fe5 389 if(trk->GetNumberOfTracklets() >=4) AliTRDtrackerV1::FitKalman(trk, 0x0, kFALSE, nc, fPoints);
baee73d3 390 } else {
391 //printf("Rieman track\n");
392 if(trk->GetNumberOfTracklets() >=4) AliTRDtrackerV1::FitRiemanTilt(trk, 0x0, kTRUE, nc, fPoints);
393 }
394 }
a4197d2e 395
baee73d3 396 Float_t global[3];
397 for(Int_t ip=0; ip<nc; ip++){
398 fPoints[ip].Rotate(-fAlpha).GetXYZ(global);
399 SetPoint(ip, global[0], global[1], global[2]);
400 }
401 SetSmooth(kTRUE);
402 }
403
404 // set color
405 if(BUILD || ((s&3) != (fTrackState&3))){
406 if(TESTBIT(s, kSource)){
407 //printf("Source color\n");
408 if(fESDStatus&AliESDtrack::kTRDin){
409 SetMarkerColor(kGreen);
410 SetLineColor(kGreen);
411 } else {
412 SetMarkerColor(kMagenta);
413 SetLineColor(kMagenta);
414 }
415 } else {
416 if(TESTBIT(s, kPID) == AliTRDReconstructor::kLQPID){
417 //printf("PID color kLQPID\n");
418 //trk->GetReconstructor()->SetOption("!nn");
419 } else {
420 //printf("PID color kNNPID\n");
421 //trk->GetReconstructor()->SetOption("nn");
422 }
423 trk->CookPID();
424
425 Int_t species = 0; Float_t pid = 0.;
426 for(Int_t is=0; is<AliPID::kSPECIES; is++)
427 if(trk->GetPID(is) > pid){
428 pid = trk->GetPID(is);
429 species = is;
430 }
431 switch(species){
432 case AliPID::kElectron:
433 SetMarkerColor(kRed);
434 SetLineColor(kRed);
435 break;
436 default:
437 SetMarkerColor(kBlue);
438 SetLineColor(kBlue);
439 break;
440 }
441 }
442 SetLineWidth(2);
443 }
444
445 Char_t *model = "line";
446 if(!TESTBIT(s, kTrackCosmics)){
447 if(TESTBIT(s, kTrackModel)) model = "kalman";
448 else model = "rieman";
449 }
450 Int_t species = 0; Float_t pid = 0.;
451 for(Int_t is=0; is<AliPID::kSPECIES; is++)
452 if(trk->GetPID(is) > pid){
453 pid = trk->GetPID(is);
454 species = is;
455 }
edf0c4a0 456
57d55fae 457 SetTitle(Form(
458 "Tracklets[%d] Clusters[%d]\n"
459 "Reconstruction Source[%s]\n"
460 "PID[%4.1f %4.1f %4.1f %4.1f %4.1f]\n"
461 "MC[%d]", trk->GetNumberOfTracklets(), trk->GetNumberOfClusters(), fESDStatus&AliESDtrack::kTRDin ? "barrel" : "sa",
462 1.E2*trk->GetPID(0), 1.E2*trk->GetPID(1),
463 1.E2*trk->GetPID(2), 1.E2*trk->GetPID(3), 1.E2*trk->GetPID(4), trk->GetLabel()));
464
465 if(GetName()){
466 char id[6]; strncpy(id, GetName(), 6);
467 SetName(Form("%s %s", id, AliPID::ParticleName(species)));
468 }
baee73d3 469
470 // save track status
471 fTrackState = s;
472}