]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveTRDData.cxx
26b0a226a0018c1f5f5ca72d2fa0eef76b6c9526
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTRDData.cxx
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          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "TVector.h"
11 #include "TLinearFitter.h"
12 #include "TEveTrans.h"
13
14 #include "AliEveTRDData.h"
15 #include "AliEveTRDModuleImp.h"
16
17 #include "AliLog.h"
18 #include "AliPID.h"
19 #include "AliTrackPointArray.h"
20
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"
34
35 ClassImp(AliEveTRDHits)
36 ClassImp(AliEveTRDDigits)
37 ClassImp(AliEveTRDClusters)
38 ClassImp(AliEveTRDTracklet)
39 ClassImp(AliEveTRDTrack)
40
41 ///////////////////////////////////////////////////////////
42 /////////////   AliEveTRDDigits       /////////////////////
43 ///////////////////////////////////////////////////////////
44
45 //______________________________________________________________________________
46 AliEveTRDDigits::AliEveTRDDigits(AliEveTRDChamber *p) :
47   TEveQuadSet("digits", ""), fParent(p), fBoxes(), fData()
48 {
49   // Constructor.
50 }
51
52 //______________________________________________________________________________
53 AliEveTRDDigits::~AliEveTRDDigits()
54 {
55 //  AliInfo(GetTitle());
56 }
57
58 //______________________________________________________________________________
59 void AliEveTRDDigits::ComputeRepresentation()
60 {
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
67   if(!fData.HasData()){
68     return;
69   }
70
71   TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
72
73   Double_t scale, dy, dz;
74   Int_t q, color;
75   Int_t nrows = fData.GetNrow(),
76         ncols = fData.GetNcol(),
77         ntbs  = fData.GetNtime(),
78         det   = fParent->GetID();
79   Float_t threshold = fParent->GetDigitsThreshold();
80
81   AliTRDtransform transform(det);
82   AliTRDgeometry *geo = fParent->fGeo;
83   AliTRDpadPlane *pp = geo->GetPadPlane(geo->GetLayer(det), geo->GetStack(det));
84
85   // express position in tracking coordinates
86   fData.Expand();
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);
105         QuadColor(color);
106         QuadId(new TNamed(Form("Charge%d", q), "dummy title"));
107       }  // end time loop
108     }  // end col loop
109   }  // end row loop
110   fData.Compress(1);
111   
112   // rotate to global coordinates
113   //RefitPlex();
114   TEveTrans& t = RefMainTrans();
115   t.SetRotByAngles((geo->GetSector(det)+.5)*AliTRDgeometry::GetAlpha(), 0.,0.);
116 }
117
118 //______________________________________________________________________________
119 void AliEveTRDDigits::SetData(AliTRDdigitsManager *digits)
120 {
121   // Set data source.
122
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;
142       }
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);
151 }
152
153
154 //______________________________________________________________________________
155 void AliEveTRDDigits::Paint(Option_t *option)
156 {
157   // Paint the object.
158
159   if(fParent->GetDigitsBox()) fBoxes.Paint(option);
160   else TEveQuadSet::Paint(option);
161 }
162
163 //______________________________________________________________________________
164 void AliEveTRDDigits::Reset()
165 {
166   // Reset raw and visual data.
167
168   TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
169   // MT fBoxes.fBoxes.clear();
170   fData.Reset();
171 }
172
173 ///////////////////////////////////////////////////////////
174 /////////////   AliEveTRDHits         /////////////////////
175 ///////////////////////////////////////////////////////////
176
177 //______________________________________________________________________________
178 AliEveTRDHits::AliEveTRDHits() : TEvePointSet("hits", 20)
179 {
180   // Constructor.
181   SetMarkerSize(.1);
182   SetMarkerColor(2);
183   SetOwnIds(kTRUE);
184 }
185
186 //______________________________________________________________________________
187 AliEveTRDHits::~AliEveTRDHits()
188 {
189   //AliInfo(GetTitle());
190 }
191
192 //______________________________________________________________________________
193 void AliEveTRDHits::PointSelected(Int_t n)
194 {
195   // Handle an individual point selection from GL.
196
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());
204 }
205
206
207 ///////////////////////////////////////////////////////////
208 /////////////   AliEveTRDClusters         /////////////////////
209 ///////////////////////////////////////////////////////////
210
211 //______________________________________________________________________________
212 AliEveTRDClusters::AliEveTRDClusters():AliEveTRDHits()
213 {
214   // Constructor.
215   SetName("clusters");
216
217   SetMarkerSize(.4);
218   SetMarkerStyle(24);
219   SetMarkerColor(kGray);
220   SetOwnIds(kTRUE);
221 }
222
223 //______________________________________________________________________________
224 void AliEveTRDClusters::PointSelected(Int_t n)
225 {
226   // Handle an individual point selection from GL.
227
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
244 }
245
246 ///////////////////////////////////////////////////////////
247 /////////////   AliEveTRDTracklet         /////////////////////
248 ///////////////////////////////////////////////////////////
249
250 //______________________________________________________________________________
251 AliEveTRDTracklet::AliEveTRDTracklet(AliTRDseedV1 *trklt):TEveLine()
252   ,fClusters(0x0)
253 {
254   // Constructor.
255   SetName("tracklet");
256   
257   SetUserData(trklt);
258   Int_t det = -1, sec;
259   Float_t g[3];
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();
265     c->GetGlobalXYZ(g); 
266     Int_t id = fClusters->SetNextPoint(g[0], g[1], g[2]);    
267     fClusters->SetPointId(id, new AliTRDcluster(*c));
268   } 
269
270   SetTitle(Form("Det[%d] Plane[%d] P[%7.3f]", det, trklt->GetPlane(), trklt->GetMomentum()));
271   SetLineColor(kRed);
272   //SetOwnIds(kTRUE);
273   
274   sec = det/30;
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, 
286     y1f = y0f - ysf*3.5,
287     z1r = z0r - zsr*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);
291 }
292
293 //______________________________________________________________________________
294 void AliEveTRDTracklet::ProcessData()
295 {
296   AliTRDseedV1 *tracklet = (AliTRDseedV1*)GetUserData();
297   tracklet->Print();
298 }
299
300 ///////////////////////////////////////////////////////////
301 /////////////   AliEveTRDTrack         /////////////////////
302 ///////////////////////////////////////////////////////////
303
304 //______________________________________________________________________________
305 AliEveTRDTrack::AliEveTRDTrack(AliTRDtrackV1 *trk) : TEveLine()
306 {
307   // Constructor.
308   SetName("track");
309
310   SetUserData(trk);
311   
312   AliTRDtrackerV1::SetNTimeBins(24);
313   AliTrackPoint points[AliTRDtrackV1::kMAXCLUSTERSPERTRACK];
314   Int_t nc = 0, sec = -1; Float_t alpha = 0.;
315   AliTRDcluster *c = 0x0;
316   AliTRDseedV1 *tracklet = 0x0;
317   for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
318     if(!(tracklet = trk->GetTracklet(il))) continue;
319     if(!tracklet->IsOK()) continue;
320     AddElement(fTracklet[il] = new AliEveTRDTracklet(tracklet));
321
322     for(Int_t ic=34; ic>=0; ic--){
323       if(!(c = tracklet->GetClusters(ic))) continue;
324       if(sec<0){
325         sec = c->GetDetector()/30;
326         alpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5); 
327       }
328       points[nc].SetXYZ(c->GetX(),0.,0.);
329       nc++;
330     }
331   }
332
333   AliTRDtrackerV1::FitRiemanTilt(trk, 0x0, kTRUE, nc, points);
334   //AliTRDtrackerV1::FitKalman(trk, 0x0, kFALSE, nc, points);
335   //AliTRDtrackerV1::FitLine(trk, 0x0, kFALSE, nc, points);
336
337   Float_t global[3];
338   for(Int_t ip=0; ip<nc; ip++){
339     points[ip].Rotate(-alpha).GetXYZ(global);
340     SetNextPoint(global[0], global[1], global[2]);
341   }
342
343   SetMarkerColor(kGreen);
344   SetLineColor(kGreen);
345   SetSmooth(kTRUE);
346 }
347
348 //______________________________________________________________________________
349 void AliEveTRDTrack::ProcessData()
350 {
351   AliTRDtrackV1 *track = (AliTRDtrackV1*)GetUserData();
352   AliInfo(Form("Clusters[%d]", track->GetNumberOfClusters()));
353   
354   track->CookPID();
355   printf("PIDLQ : "); for(int is=0; is<AliPID::kSPECIES; is++) printf("%s[%5.2f] ", AliPID::ParticleName(is), 1.E2*track->GetPID(is)); printf("\n");
356 }
357