]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveTRDData.cxx
added conf for making flow par file for grid and CAF
[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 "AliTRDgeometry.h"
29 #include "AliTRDtransform.h"
30 #include "AliTRDReconstructor.h"
31 #include "AliTRDrecoParam.h"
32
33 ClassImp(AliEveTRDHits)
34 ClassImp(AliEveTRDDigits)
35 ClassImp(AliEveTRDClusters)
36 ClassImp(AliEveTRDTracklet)
37 ClassImp(AliEveTRDTrack)
38
39 ///////////////////////////////////////////////////////////
40 /////////////   AliEveTRDDigits       /////////////////////
41 ///////////////////////////////////////////////////////////
42
43 //______________________________________________________________________________
44 AliEveTRDDigits::AliEveTRDDigits(AliEveTRDChamber *p) :
45   TEveQuadSet("digits", ""), fParent(p), fBoxes(), fData()
46 {
47   // Constructor.
48 }
49
50 //______________________________________________________________________________
51 AliEveTRDDigits::~AliEveTRDDigits()
52 {
53 //  AliInfo(GetTitle());
54 }
55
56 //______________________________________________________________________________
57 void AliEveTRDDigits::ComputeRepresentation()
58 {
59   // Calculate digits representation according to user settings. The
60   // user can set the following parameters:
61   // - digits scale (log/lin)
62   // - digits threshold
63   // - digits apparence (quads/boxes)
64
65   TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
66
67   Double_t scale, dy, dz;
68   Int_t q, color;
69   Int_t nrows = fParent->fNrows,
70         ncols = fParent->fNcols,
71         ntbs  = fParent->fNtime,
72         det   = fParent->GetID();
73   Float_t threshold = fParent->GetDigitsThreshold();
74
75   AliTRDtransform transform(det);
76   AliTRDgeometry *geo = fParent->fGeo;
77   AliTRDpadPlane *pp = geo->GetPadPlane(geo->GetPlane(det), geo->GetChamber(det));
78
79   // express position in tracking coordinates
80   fData.Expand();
81   for (Int_t ir = 0; ir < nrows; ir++) {
82     dz = pp->GetRowSize(ir);
83     for (Int_t ic = 0; ic < ncols; ic++) {
84       dy = pp->GetColSize(ic);
85       for (Int_t it = 0; it < ntbs; it++) {
86         q = fData.GetDataUnchecked(ir, ic, it);
87         if (q < threshold) continue;
88
89         Double_t x[6] = {0., 0., Double_t(q), 0., 0., 0.}; 
90         Int_t  roc[3] = {ir, ic, 0}; 
91         Bool_t    out = kTRUE;
92         transform.Transform(&x[0], &roc[0], UInt_t(it), out, 0);
93
94         scale = q < 512 ? q/512. : 1.;
95         color  = 50+int(scale*50.);
96     
97         AddQuad(x[1]-.45*dy, x[2]-.5*dz*scale, x[0], .9*dy, dz*scale);
98         QuadValue(q);
99         QuadColor(Color_t(color));
100         QuadId(new TNamed(Form("Charge%d", q), "dummy title"));
101       }  // end time loop
102     }  // end col loop
103   }  // end row loop
104   fData.Compress(1);
105   
106   // rotate to global coordinates
107   //RefitPlex();
108   TEveTrans& t = RefMainTrans();
109   t.SetRotByAngles((geo->GetSector(det)+.5)*AliTRDgeometry::GetAlpha(), 0.,0.);
110 }
111
112 //______________________________________________________________________________
113 void AliEveTRDDigits::SetData(AliTRDdigitsManager *digits)
114 {
115   // Set data source.
116
117   fData.Allocate(fParent->fNrows, fParent->fNcols, fParent->fNtime);
118   //    digits->Expand();
119   for (Int_t  row = 0;  row <  fParent->fNrows;  row++)
120     for (Int_t  col = 0;  col <  fParent->fNcols;  col++)
121       for (Int_t time = 0; time < fParent->fNtime; time++) {
122         if(digits->GetDigitAmp(row, col, time, fParent->GetID()) < 0) continue;
123         fData.SetDataUnchecked(row, col, time, digits->GetDigitAmp(row, col, time, fParent->GetID()));
124       }
125 }
126
127
128 //______________________________________________________________________________
129 void AliEveTRDDigits::Paint(Option_t *option)
130 {
131   // Paint the object.
132
133   if(fParent->GetDigitsBox()) fBoxes.Paint(option);
134   else TEveQuadSet::Paint(option);
135 }
136
137 //______________________________________________________________________________
138 void AliEveTRDDigits::Reset()
139 {
140   // Reset raw and visual data.
141
142   TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
143   // MT fBoxes.fBoxes.clear();
144   fData.Reset();
145 }
146
147 ///////////////////////////////////////////////////////////
148 /////////////   AliEveTRDHits         /////////////////////
149 ///////////////////////////////////////////////////////////
150
151 //______________________________________________________________________________
152 AliEveTRDHits::AliEveTRDHits() : TEvePointSet("hits", 20)
153 {
154   // Constructor.
155   SetMarkerSize(.1);
156   SetMarkerColor(2);
157   SetOwnIds(kTRUE);
158 }
159
160 //______________________________________________________________________________
161 AliEveTRDHits::~AliEveTRDHits()
162 {
163   //AliInfo(GetTitle());
164 }
165
166 //______________________________________________________________________________
167 void AliEveTRDHits::PointSelected(Int_t n)
168 {
169   // Handle an individual point selection from GL.
170
171   AliTRDhit *h = dynamic_cast<AliTRDhit*>(GetPointId(n));
172   printf("\nDetector             : %d\n", h->GetDetector());
173   printf("Region of production : %c\n", h->FromAmplification() ? 'A' : 'D');
174   printf("TR photon            : %s\n", h->FromTRphoton() ? "Yes" : "No");
175   printf("Charge               : %d\n", h->GetCharge());
176   printf("MC track label       : %d\n", h->GetTrack());
177   printf("Time from collision  : %f\n", h->GetTime());
178 }
179
180
181 ///////////////////////////////////////////////////////////
182 /////////////   AliEveTRDClusters         /////////////////////
183 ///////////////////////////////////////////////////////////
184
185 //______________________________________________________________________________
186 AliEveTRDClusters::AliEveTRDClusters():AliEveTRDHits()
187 {
188   // Constructor.
189   SetName("clusters");
190
191   SetMarkerSize(.2);
192   SetMarkerStyle(24);
193   SetMarkerColor(kGreen);
194   SetOwnIds(kTRUE);
195 }
196
197 //______________________________________________________________________________
198 void AliEveTRDClusters::PointSelected(Int_t n)
199 {
200   // Handle an individual point selection from GL.
201
202   AliTRDcluster *c = dynamic_cast<AliTRDcluster*>(GetPointId(n));
203   printf("\nDetector             : %d\n", c->GetDetector());
204   printf("Charge               : %f\n", c->GetQ());
205   printf("Sum S                : %4.0f\n", c->GetSumS());
206   printf("Time bin             : %d\n", c->GetLocalTimeBin());
207   printf("Signals              : ");
208   Short_t *cSignals = c->GetSignals();
209   for(Int_t ipad=0; ipad<7; ipad++) printf("%d ", cSignals[ipad]); printf("\n");
210   printf("Central pad          : %d\n", c->GetPadCol());
211   printf("MC track labels      : ");
212   for(Int_t itrk=0; itrk<3; itrk++) printf("%d ", c->GetLabel(itrk)); printf("\n");
213   // Bool_t     AliCluster::GetGlobalCov(Float_t* cov) const
214   // Bool_t     AliCluster::GetGlobalXYZ(Float_t* xyz) const
215   // Float_t    AliCluster::GetSigmaY2() const
216   // Float_t    AliCluster::GetSigmaYZ() const
217   // Float_t    AliCluster::GetSigmaZ2() const
218 }
219
220 ///////////////////////////////////////////////////////////
221 /////////////   AliEveTRDTracklet         /////////////////////
222 ///////////////////////////////////////////////////////////
223
224 //______________________________________________________________________________
225 AliEveTRDTracklet::AliEveTRDTracklet(AliTRDseedV1 *trklt):TEveLine()
226   ,fClusters(0x0)
227 {
228   // Constructor.
229   SetName("tracklet");
230   
231   SetUserData(trklt);
232   Int_t det = -1, sec;
233   Float_t g[3];
234   AliTRDcluster *c = 0x0;
235   AddElement(fClusters = new AliEveTRDClusters());
236   for(Int_t ic=0; ic<35; ic++){
237     if(!(c = trklt->GetClusters(ic))) continue;
238     det = c->GetDetector();
239     c->GetGlobalXYZ(g); 
240     Int_t id = fClusters->SetNextPoint(g[0], g[1], g[2]);    
241     fClusters->SetPointId(id, new AliTRDcluster(*c));
242   } 
243
244   SetTitle(Form("Det[%d] Plane[%d] P[%7.3f]", det, trklt->GetPlane(), trklt->GetMomentum()));
245   SetLineColor(kYellow);
246   //SetOwnIds(kTRUE);
247   
248   sec = det/30;
249   Double_t alpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5); 
250   Double_t x0 = trklt->GetX0(), 
251     y0f = trklt->GetYfit(0), 
252     ysf = trklt->GetYfit(1),
253     z0r = trklt->GetZref(0), 
254     zsr = trklt->GetZref(1);
255   Double_t xg =  x0 * TMath::Cos(alpha) - y0f * TMath::Sin(alpha); 
256   Double_t yg = x0 * TMath::Sin(alpha) + y0f * TMath::Cos(alpha);
257   SetPoint(0, xg, yg, z0r);
258   //SetPointId(0, new AliTRDseedV1(*trackletObj));
259   Double_t x1 = x0-3.5, 
260     y1f = y0f - ysf*3.5,
261     z1r = z0r - zsr*3.5; 
262   xg =  x1 * TMath::Cos(alpha) - y1f * TMath::Sin(alpha); 
263   yg = x1 * TMath::Sin(alpha) + y1f * TMath::Cos(alpha);
264   SetPoint(1, xg, yg, z1r);
265 }
266
267 //______________________________________________________________________________
268 void AliEveTRDTracklet::ProcessData()
269 {
270   AliTRDseedV1 *tracklet = (AliTRDseedV1*)GetUserData();
271   tracklet->Print();
272 }
273
274 ///////////////////////////////////////////////////////////
275 /////////////   AliEveTRDTrack         /////////////////////
276 ///////////////////////////////////////////////////////////
277
278 //______________________________________________________________________________
279 AliEveTRDTrack::AliEveTRDTrack(AliTRDtrackV1 *trk) : TEveLine()
280 {
281   // Constructor.
282   SetName("track");
283
284   SetUserData(trk);
285   
286   AliTRDtrackerV1::SetNTimeBins(24);
287   AliTrackPoint points[AliTRDtrackV1::kMAXCLUSTERSPERTRACK];
288   Int_t nc = 0, sec = -1; Float_t alpha = 0.;
289   AliTRDcluster *c = 0x0;
290   AliTRDseedV1 *tracklet = 0x0;
291   for(Int_t ip=0; ip<AliTRDgeometry::kNplan; ip++){
292     if(!(tracklet = trk->GetTracklet(ip))) continue;
293     if(!tracklet->IsOK()) continue;
294     AddElement(fTracklet[ip] = new AliEveTRDTracklet(tracklet));
295
296     for(Int_t ic=34; ic>=0; ic--){
297       if(!(c = tracklet->GetClusters(ic))) continue;
298       if(sec<0){
299         sec = c->GetDetector()/30;
300         alpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5); 
301       }
302       points[nc].SetXYZ(c->GetX(),0.,0.);
303       nc++;
304     }
305   }
306
307   AliTRDtrackerV1::FitRiemanTilt(trk, 0x0, kTRUE, nc, points);
308   //AliTRDtrackerV1::FitKalman(trk, 0x0, kFALSE, nc, points);
309
310   Float_t global[3];
311   for(Int_t ip=0; ip<nc; ip++){
312     points[ip].Rotate(-alpha).GetXYZ(global);
313     SetNextPoint(global[0], global[1], global[2]);
314   }
315
316   SetMarkerColor(kCyan);
317   SetLineColor(kCyan);
318   SetSmooth(kTRUE);
319 }
320
321 //______________________________________________________________________________
322 void AliEveTRDTrack::ProcessData()
323 {
324   AliTRDtrackV1 *track = (AliTRDtrackV1*)GetUserData();
325   AliInfo(Form("Clusters[%d]", track->GetNumberOfClusters()));
326   
327   AliTRDReconstructor::RecoParam()->SetPIDMethod(0);
328   track->CookPID();
329   printf("PIDLQ : "); for(int is=0; is<AliPID::kSPECIES; is++) printf("%s[%5.2f] ", AliPID::ParticleName(is), 1.E2*track->GetPID(is)); printf("\n");
330
331   AliTRDReconstructor::RecoParam()->SetPIDMethod(1);
332   track->CookPID();
333   printf("PIDNN : "); for(int is=0; is<AliPID::kSPECIES; is++) printf("%s[%5.2f] ", AliPID::ParticleName(is), 1.E2*track->GetPID(is)); printf("\n");
334 }
335