]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCcalibLaser.cxx
Preprocessing of the Laser information (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibLaser.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17   laser track clasification;
18   TCut cutT("cutT","abs(Tr.fP[3])<0.06");
19   TCut cutPt("cutPt","abs(Tr.fP[4])<0.1");
20   TCut cutN("cutN","fTPCncls>100");
21   
22   TCut cutA = cutT+cutPt+cutN;
23
24   TCut cutFi("cutZB","");
25   TCut cutFi("cutFi","abs((180*atan2(x1,x0)/pi-20)%40)<5");
26   TChain * chain = tool.MakeChain("chain.txt","Track",0,1000000)
27 */
28
29
30
31 #include "TLinearFitter.h"
32 #include "AliTPCcalibLaser.h"
33 #include "AliExternalTrackParam.h"
34 #include "AliESDEvent.h"
35 #include "AliESDfriend.h"
36 #include "AliESDtrack.h"
37 #include "AliTPCTracklet.h"
38 #include "TH1D.h"
39 #include "TVectorD.h"
40 #include "TTreeStream.h"
41 #include "TFile.h"
42 #include "TF1.h"
43 #include "TGraphErrors.h"
44 #include "AliTPCclusterMI.h"
45 #include "AliTPCseed.h"
46 #include "AliTracker.h"
47 #include "TClonesArray.h"
48
49
50 #include "TTreeStream.h"
51 #include <iostream>
52 #include <sstream>
53 #include "AliTPCLaserTrack.h"
54
55 using namespace std;
56
57 ClassImp(AliTPCcalibLaser)
58
59 AliTPCcalibLaser::AliTPCcalibLaser():
60   AliTPCcalibBase(),
61   fESD(0),
62   fESDfriend(),
63   fTracksMirror(1000),
64   fTracksEsd(1000),
65   fTracksEsdParam(1000),
66   fTracksTPC(1000),
67   fRun(0)
68 {
69   //
70   // Constructor
71   //
72   fTracksEsdParam.SetOwner(kTRUE);
73 }
74
75 AliTPCcalibLaser::AliTPCcalibLaser(const Text_t *name, const Text_t *title):
76   AliTPCcalibBase(),
77   fESD(0),
78   fESDfriend(0),
79   fTracksMirror(1000),
80   fTracksEsd(1000),
81   fTracksEsdParam(1000),
82   fTracksTPC(1000),
83   fRun(0)
84 {
85   SetName(name);
86   SetTitle(title);
87   //
88   // Constructor
89   //
90   fTracksEsdParam.SetOwner(kTRUE);  
91 }
92
93 AliTPCcalibLaser::~AliTPCcalibLaser() {
94   //
95   // destructor
96   //
97 }
98
99
100
101 void AliTPCcalibLaser::Process(AliESDEvent * event) {
102   //
103   // 
104   // Loop over tracks and call  Process function
105   //
106   fESD = event;
107   if (!fESD) {
108     return;
109   }
110   fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
111   if (!fESDfriend) {
112     return;
113   }
114   fTracksTPC.Clear();
115   fTracksEsd.Clear();
116   fTracksEsdParam.Delete();
117   //
118   Int_t n=fESD->GetNumberOfTracks();
119   Int_t run = fESD->GetRunNumber();
120   fRun = run;
121   for (Int_t i=0;i<n;++i) {
122     AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
123     AliESDtrack *track=fESD->GetTrack(i);
124     TObject *calibObject=0;
125     AliTPCseed *seed=0;
126     for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
127       if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
128         break;
129     if (track&&seed) FindMirror(track,seed);
130     //
131   }
132   
133   FitDriftV();
134   
135   //
136   for (Int_t id=0; id<1000; id++){
137     //
138     //
139     if (!fTracksEsdParam.At(id)) continue;
140     DumpLaser(id);
141     RefitLaser(id);    
142   }
143 }
144
145 Int_t  AliTPCcalibLaser::FindMirror(AliESDtrack *track, AliTPCseed *seed){
146   //
147   // Find corresponding mirror
148   // add the corresponding tracks
149   //
150   Float_t kRadius0 = 252;
151   Float_t kRadius  = 254.25;
152   if (!track->GetOuterParam()) return -1;
153   AliExternalTrackParam param(*(track->GetOuterParam()));
154   AliTracker::PropagateTrackTo(&param,kRadius0,0.10566,3,kTRUE);
155   AliTracker::PropagateTrackTo(&param,kRadius,0.10566,0.1,kTRUE);
156   AliTPCLaserTrack ltr;
157   AliTPCLaserTrack *ltrp=0x0;
158   //
159   Int_t id = AliTPCLaserTrack::IdentifyTrack(&param);
160   if (id!=-1 && (AliTPCLaserTrack::GetTracks()->UncheckedAt(id))) 
161     ltrp=(AliTPCLaserTrack*)AliTPCLaserTrack::GetTracks()->UncheckedAt(id);
162   else 
163     ltrp=&ltr;
164   
165   if (id>=0){
166     if (!fTracksMirror.At(id)) fTracksMirror.AddAt(ltrp,id);
167     fTracksEsdParam.AddAt(param.Clone(),id);
168     fTracksEsd.AddAt(track,id);
169     fTracksTPC.AddAt(seed,id);
170   }
171   return id;
172 }
173
174
175
176 void AliTPCcalibLaser::DumpLaser(Int_t id) {
177   //
178   //  Dump Laser info to the tree
179   //
180   AliESDtrack   *track    = (AliESDtrack*)fTracksEsd.At(id);
181   AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
182   AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
183   //
184   // Fast laser ID
185   //
186   Double_t xyz[3];
187   Double_t pxyz[3];
188   param->GetXYZ(xyz);
189   param->GetPxPyPz(pxyz);
190   if (fStreamLevel>0){
191     TTreeSRedirector *cstream = GetDebugStreamer();
192     if (cstream){
193       (*cstream)<<"Track"<<
194         "run="<<fRun<<
195         "id="<<id<<
196         //
197         "LTr.="<<ltrp<<
198         "Esd.="<<track<<
199         "Tr.="<<param<<
200         "x0="<<xyz[0]<<
201         "x1="<<xyz[1]<<
202         "x2="<<xyz[2]<<
203         "px0="<<pxyz[0]<<
204         "px1="<<pxyz[1]<<
205         "px2="<<pxyz[2]<<
206         "\n";
207     }
208   }
209 }
210
211
212 void AliTPCcalibLaser::RefitLaser(Int_t id){
213   //
214   // Refit the track store residuals
215   //
216
217   AliTPCseed *track    = (AliTPCseed*)fTracksTPC.At(id);
218   AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
219   AliTPCLaserTrack *ltrp = (AliTPCLaserTrack*)fTracksMirror.At(id);
220                              
221   //
222   static TLinearFitter fy2(3,"hyp2");
223   static TLinearFitter fz2(3,"hyp2");
224   static TLinearFitter fy1(2,"hyp1");
225   static TLinearFitter fz1(2,"hyp1");
226   static TVectorD vecy2,vecz2,vecy1,vecz1;
227
228   const Int_t kMinClusters=20;
229   Int_t nclusters[72]; 
230   //
231   for (Int_t i=0;i<72;++i) nclusters[i]=0;
232
233   for (Int_t i=0;i<160;++i) {    
234     AliTPCclusterMI *c=track->GetClusterPointer(i);
235     if (c) nclusters[c->GetDetector()]++;
236   }
237    
238   for (Int_t isec=0; isec<72;isec++){
239     if (nclusters[isec]<kMinClusters) continue;
240     fy2.ClearPoints();
241     fz2.ClearPoints();
242     fy1.ClearPoints();
243     fz1.ClearPoints();
244     //
245     for (Int_t irow=0;irow<160;++irow) {      
246       AliTPCclusterMI *c=track->GetClusterPointer(irow);
247       //if (c && RejectCluster(c)) continue;
248       if (c&&c->GetDetector()==isec) {
249         Double_t xd = c->GetX()-120;;
250         Double_t x[2]={xd,xd*xd};
251         fy2.AddPoint(x,c->GetY());
252         fz2.AddPoint(x,c->GetZ());
253         //
254         fy1.AddPoint(x,c->GetY());
255         fz1.AddPoint(x,c->GetZ());
256       }
257     }
258     fy2.Eval();
259     fz2.Eval();
260     fy1.Eval();
261     fz1.Eval();
262     fy1.GetParameters(vecy1);
263     fy2.GetParameters(vecy2);
264     fz1.GetParameters(vecz1);
265     fz2.GetParameters(vecz2);
266     
267     if (fStreamLevel>0){
268       TTreeSRedirector *cstream = GetDebugStreamer();
269       if (cstream){
270         Float_t dedx = track->GetdEdx();
271         (*cstream)<<"Tracklet"<<
272           "LTr.="<<ltrp<<
273           "Tr.="<<param<<
274           "sec="<<isec<<
275           "ncl="<<nclusters[isec]<<
276           "dedx="<<dedx<<
277           "dedx="<<dedx<<
278           "vy1.="<<&vecy1<<
279           "vy2.="<<&vecy2<<
280           "vz1.="<<&vecz1<<
281           "vz2.="<<&vecz2<<
282           "\n";
283       }
284     }
285   }
286   //
287   //
288   //
289   //   for (Int_t irow=0;irow<160;++irow) {      
290   //       AliTPCclusterMI *c=track->GetClusterPointer(irow);
291   //       if (c && RejectCluster(c)) continue;
292   //       if (c&&c->GetDetector()==isec) {
293   //    Double_t x[2]={c->GetX(),c->GetX()*c->GetX()};
294   //    fy2.AddPoint(&x,c->GetY());
295   //    fz2.AddPoint(&x,c->GetZ());
296   //    //
297   //    fy1.AddPoint(&x,c->GetY());
298   //    fz1.AddPoint(&x,c->GetZ());
299   //       }
300   //     }    
301   
302 }
303
304
305 void AliTPCcalibLaser::Analyze(){
306   //
307   //
308   //
309 }
310
311
312
313