2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
4 /**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
11 #include "TLinearFitter.h"
12 #include "TEveTrans.h"
14 #include "AliEveTRDData.h"
15 #include "AliEveTRDModuleImp.h"
19 #include "AliTrackPointArray.h"
21 #include "AliTRDhit.h"
22 #include "AliTRDcluster.h"
23 #include "AliTRDseedV1.h"
24 #include "AliTRDtrackV1.h"
25 #include "AliTRDtrackerV1.h"
26 #include "AliTRDpadPlane.h"
27 #include "AliTRDdigitsManager.h"
28 #include "AliTRDdataArrayDigits.h"
29 #include "AliTRDSignalIndex.h"
30 #include "AliTRDgeometry.h"
31 #include "AliTRDtransform.h"
32 #include "AliTRDReconstructor.h"
33 #include "AliTRDrecoParam.h"
35 ClassImp(AliEveTRDHits)
36 ClassImp(AliEveTRDDigits)
37 ClassImp(AliEveTRDClusters)
38 ClassImp(AliEveTRDTracklet)
39 ClassImp(AliEveTRDTrack)
41 ///////////////////////////////////////////////////////////
42 ///////////// AliEveTRDDigits /////////////////////
43 ///////////////////////////////////////////////////////////
45 //______________________________________________________________________________
46 AliEveTRDDigits::AliEveTRDDigits(AliEveTRDChamber *p) :
47 TEveQuadSet("digits", ""), fParent(p), fBoxes(), fData()
52 //______________________________________________________________________________
53 AliEveTRDDigits::~AliEveTRDDigits()
55 // AliInfo(GetTitle());
58 //______________________________________________________________________________
59 void AliEveTRDDigits::ComputeRepresentation()
61 // Calculate digits representation according to user settings. The
62 // user can set the following parameters:
63 // - digits scale (log/lin)
65 // - digits apparence (quads/boxes)
71 TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
73 Double_t scale, dy, dz;
75 Int_t nrows = fData.GetNrow(),
76 ncols = fData.GetNcol(),
77 ntbs = fData.GetNtime(),
78 det = fParent->GetID();
79 Float_t threshold = fParent->GetDigitsThreshold();
81 AliTRDtransform transform(det);
82 AliTRDgeometry *geo = fParent->fGeo;
83 AliTRDpadPlane *pp = geo->GetPadPlane(geo->GetLayer(det), geo->GetStack(det));
85 // express position in tracking coordinates
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;
95 Double_t x[6] = {0., 0., Double_t(q), 0., 0., 0.};
96 Int_t roc[3] = {ir, ic, 0};
98 transform.Transform(&x[0], &roc[0], UInt_t(it), out, 0);
100 scale = q < 512 ? q/512. : 1.;
101 color = 50+int(scale*50.);
103 AddQuad(x[1]-.45*dy, x[2]-.5*dz*scale, x[0], .9*dy, dz*scale);
106 QuadId(new TNamed(Form("Charge%d", q), "dummy title"));
112 // rotate to global coordinates
114 TEveTrans& t = RefMainTrans();
115 t.SetRotByAngles((geo->GetSector(det)+.5)*AliTRDgeometry::GetAlpha(), 0.,0.);
118 //______________________________________________________________________________
119 void AliEveTRDDigits::SetData(AliTRDdigitsManager *digits)
123 Int_t det = fParent->GetID();
124 AliTRDdataArrayDigits *data = digits->GetDigits(det);
125 if(!data->HasData()) return;
128 AliTRDSignalIndex *indexes = digits->GetIndexes(det);
129 if(!indexes->IsAllocated()) digits->BuildIndexes(det);
131 if(!fData.HasData()) fData.Allocate(data->GetNrow(), data->GetNcol(), data->GetNtime());
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
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);
154 //______________________________________________________________________________
155 void AliEveTRDDigits::Paint(Option_t *option)
159 if(fParent->GetDigitsBox()) fBoxes.Paint(option);
160 else TEveQuadSet::Paint(option);
163 //______________________________________________________________________________
164 void AliEveTRDDigits::Reset()
166 // Reset raw and visual data.
168 TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
169 // MT fBoxes.fBoxes.clear();
173 ///////////////////////////////////////////////////////////
174 ///////////// AliEveTRDHits /////////////////////
175 ///////////////////////////////////////////////////////////
177 //______________________________________________________________________________
178 AliEveTRDHits::AliEveTRDHits() : TEvePointSet("hits", 20)
186 //______________________________________________________________________________
187 AliEveTRDHits::~AliEveTRDHits()
189 //AliInfo(GetTitle());
192 //______________________________________________________________________________
193 void AliEveTRDHits::PointSelected(Int_t n)
195 // Handle an individual point selection from GL.
197 AliTRDhit *h = dynamic_cast<AliTRDhit*>(GetPointId(n));
198 printf("\nDetector : %d\n", h->GetDetector());
199 printf("Region of production : %c\n", h->FromAmplification() ? 'A' : 'D');
200 printf("TR photon : %s\n", h->FromTRphoton() ? "Yes" : "No");
201 printf("Charge : %d\n", h->GetCharge());
202 printf("MC track label : %d\n", h->GetTrack());
203 printf("Time from collision : %f\n", h->GetTime());
207 ///////////////////////////////////////////////////////////
208 ///////////// AliEveTRDClusters /////////////////////
209 ///////////////////////////////////////////////////////////
211 //______________________________________________________________________________
212 AliEveTRDClusters::AliEveTRDClusters():AliEveTRDHits()
219 SetMarkerColor(kGray);
223 //______________________________________________________________________________
224 void AliEveTRDClusters::PointSelected(Int_t n)
226 // Handle an individual point selection from GL.
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
246 ///////////////////////////////////////////////////////////
247 ///////////// AliEveTRDTracklet /////////////////////
248 ///////////////////////////////////////////////////////////
250 //______________________________________________________________________________
251 AliEveTRDTracklet::AliEveTRDTracklet(AliTRDseedV1 *trklt):TEveLine()
260 AliTRDcluster *c = 0x0;
261 AddElement(fClusters = new AliEveTRDClusters());
262 for(Int_t ic=0; ic<35; ic++){
263 if(!(c = trklt->GetClusters(ic))) continue;
264 det = c->GetDetector();
266 Int_t id = fClusters->SetNextPoint(g[0], g[1], g[2]);
267 fClusters->SetPointId(id, new AliTRDcluster(*c));
270 SetTitle(Form("Det[%d] Plane[%d] P[%7.3f]", det, trklt->GetPlane(), trklt->GetMomentum()));
275 Double_t alpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5);
276 Double_t x0 = trklt->GetX0(),
277 y0f = trklt->GetYfit(0),
278 ysf = trklt->GetYfit(1),
279 z0r = trklt->GetZref(0),
280 zsr = trklt->GetZref(1);
281 Double_t xg = x0 * TMath::Cos(alpha) - y0f * TMath::Sin(alpha);
282 Double_t yg = x0 * TMath::Sin(alpha) + y0f * TMath::Cos(alpha);
283 SetPoint(0, xg, yg, z0r);
284 //SetPointId(0, new AliTRDseedV1(*trackletObj));
285 Double_t x1 = x0-3.5,
288 xg = x1 * TMath::Cos(alpha) - y1f * TMath::Sin(alpha);
289 yg = x1 * TMath::Sin(alpha) + y1f * TMath::Cos(alpha);
290 SetPoint(1, xg, yg, z1r);
293 //______________________________________________________________________________
294 void AliEveTRDTracklet::ProcessData()
296 AliTRDseedV1 *tracklet = (AliTRDseedV1*)GetUserData();
300 ///////////////////////////////////////////////////////////
301 ///////////// AliEveTRDTrack /////////////////////
302 ///////////////////////////////////////////////////////////
304 //______________________________________________________________________________
305 AliEveTRDTrack::AliEveTRDTrack(AliTRDtrackV1 *trk)
317 AliTRDtrackerV1::SetNTimeBins(24);
319 AliTRDseedV1 *tracklet = 0x0;
320 for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
321 if(!(tracklet = trk->GetTracklet(il))) continue;
322 if(!tracklet->IsOK()) continue;
323 AddElement(new AliEveTRDTracklet(tracklet));
326 SetStatus(fTrackState);
329 //______________________________________________________________________________
330 AliEveTRDTrack::~AliEveTRDTrack()
332 if(fPoints) delete [] fPoints; fPoints = 0x0;
333 //delete dynamic_cast<AliTRDtrackV1*>(GetUserData());
337 //______________________________________________________________________________
338 void AliEveTRDTrack::SetStatus(UChar_t s)
340 // nothing to be done
341 if(fPoints && fTrackState == s) return;
343 const Int_t nc = AliTRDtrackV1::kMAXCLUSTERSPERTRACK;
344 AliTRDtrackV1 *trk = (AliTRDtrackV1*)GetUserData();
346 Bool_t BUILD = kFALSE;
348 fPoints = new AliTrackPoint[nc];
350 AliTRDcluster *c = trk->GetCluster(0);
351 Double_t x = c->GetX();
352 Int_t sec = c->GetDetector()/30;
353 fAlpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5);
355 Double_t dx = (trk->GetCluster(trk->GetNumberOfClusters()-1)->GetX()-x)/nc;
356 for(Int_t ip=0; ip<nc; ip++){
357 fPoints[ip].SetXYZ(x, 0., 0.);
363 // select track model
364 if(BUILD || ((s&12) != (fTrackState&12))){
365 if(TESTBIT(s, kTrackCosmics)){
366 //printf("Straight track\n");
367 AliTRDtrackerV1::FitLine(trk, 0x0, kFALSE, nc, fPoints);
369 if(TESTBIT(s, kTrackModel)){
370 //printf("Kalman track\n");
371 //AliTRDtrackerV1::FitKalman(trk, 0x0, kFALSE, nc, fPoints);
373 //printf("Rieman track\n");
374 if(trk->GetNumberOfTracklets() >=4) AliTRDtrackerV1::FitRiemanTilt(trk, 0x0, kTRUE, nc, fPoints);
379 for(Int_t ip=0; ip<nc; ip++){
380 fPoints[ip].Rotate(-fAlpha).GetXYZ(global);
381 SetPoint(ip, global[0], global[1], global[2]);
387 if(BUILD || ((s&3) != (fTrackState&3))){
388 if(TESTBIT(s, kSource)){
389 //printf("Source color\n");
390 if(fESDStatus&AliESDtrack::kTRDin){
391 SetMarkerColor(kGreen);
392 SetLineColor(kGreen);
394 SetMarkerColor(kMagenta);
395 SetLineColor(kMagenta);
398 if(TESTBIT(s, kPID) == AliTRDReconstructor::kLQPID){
399 //printf("PID color kLQPID\n");
400 //trk->GetReconstructor()->SetOption("!nn");
402 //printf("PID color kNNPID\n");
403 //trk->GetReconstructor()->SetOption("nn");
407 Int_t species = 0; Float_t pid = 0.;
408 for(Int_t is=0; is<AliPID::kSPECIES; is++)
409 if(trk->GetPID(is) > pid){
410 pid = trk->GetPID(is);
414 case AliPID::kElectron:
415 SetMarkerColor(kRed);
419 SetMarkerColor(kBlue);
427 Char_t *model = "line";
428 if(!TESTBIT(s, kTrackCosmics)){
429 if(TESTBIT(s, kTrackModel)) model = "kalman";
430 else model = "rieman";
432 Int_t species = 0; Float_t pid = 0.;
433 for(Int_t is=0; is<AliPID::kSPECIES; is++)
434 if(trk->GetPID(is) > pid){
435 pid = trk->GetPID(is);
439 SetTitle(Form("Nc[%d] Nt[%d] Model[%s] Source[%s]", trk->GetNumberOfClusters(), trk->GetNumberOfTracklets(), model, fESDStatus&AliESDtrack::kTRDin ? "barrel" : "sa"));
440 SetName(AliPID::ParticleName(species));