]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCcalibCalib.cxx
Using switch - use ExB correction
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibCalib.cxx
CommitLineData
9dcfce73 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///////////////////////////////////////////////////////////////////////////////
18// //
19// Component for redoing the reconstruction from the clusters and tracks
20//
21// The new calibration data used
22//
23// In reality it overwrites the content of the ESD
24//
25
3bf5c7a6 26/*
27
28 gSystem->Load("libANALYSIS");
29 gSystem->Load("libTPCcalib");
30 //
31 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
32 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
33 AliXRDPROOFtoolkit tool;
11c7a854 34 TChain * chainCl = tool.MakeChain("calib.txt","Clusters",0,1);
35 chainCl->Lookup();
36 TChain * chainTr = tool.MakeChain("calib.txt","Tracks",0,1);
37 chainTr->Lookup();
3bf5c7a6 38
39
40
41*/
42
43
44
9dcfce73 45// marian.ivanov@cern.ch
46//
47#include "AliTPCcalibCalib.h"
48#include "TSystem.h"
49#include "TFile.h"
50#include "TTreeStream.h"
51#include "AliLog.h"
52#include "TTimeStamp.h"
53#include "AliESDEvent.h"
54#include "AliESDfriend.h"
55#include "AliESDtrack.h"
56#include "AliTracker.h"
11c7a854 57#include "AliTPCClusterParam.h"
9dcfce73 58
59#include "AliTPCcalibDB.h"
60#include "AliTPCTransform.h"
61#include "AliTPCclusterMI.h"
62#include "AliTPCseed.h"
15e48021 63#include "AliTPCPointCorrection.h"
9dcfce73 64
65ClassImp(AliTPCcalibCalib)
66
67AliTPCcalibCalib::AliTPCcalibCalib():
68 AliTPCcalibBase()
69{
70 //
71 // Constructor
72 //
73}
74
75
76AliTPCcalibCalib::AliTPCcalibCalib(const Text_t *name, const Text_t *title)
77 :AliTPCcalibBase()
78{
79 SetName(name);
80 SetTitle(title);
81}
82
83
84AliTPCcalibCalib::AliTPCcalibCalib(const AliTPCcalibCalib&calib):
85 AliTPCcalibBase(calib)
86{
87 //
88 // copy constructor
89 //
90}
91
92AliTPCcalibCalib &AliTPCcalibCalib::operator=(const AliTPCcalibCalib&calib){
93 //
94 //
95 //
96 ((AliTPCcalibBase *)this)->operator=(calib);
97 return *this;
98}
99
100
101AliTPCcalibCalib::~AliTPCcalibCalib() {
102 //
103 // destructor
104 //
105}
106
107
108void AliTPCcalibCalib::Process(AliESDEvent *event){
109 //
110 //
111 //
112 if (!event) {
113 return;
114 }
115 AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
116 if (!ESDfriend) {
117 return;
118 }
119
120 if (GetDebugLevel()>20) printf("Hallo world: Im here\n");
121 Int_t ntracks=event->GetNumberOfTracks();
91350f5b 122 //AliTPCcalibDB::Instance()->SetExBField(fMagF);
5c3e0d17 123
9dcfce73 124 //
125 //
126 //
127
128 for (Int_t i=0;i<ntracks;++i) {
129 AliESDtrack *track = event->GetTrack(i);
130 const AliExternalTrackParam * trackIn = track->GetInnerParam();
131 const AliExternalTrackParam * trackOut = track->GetOuterParam();
132 if (!trackIn) continue;
133 if (!trackOut) continue;
134
135 AliESDfriendTrack *friendTrack = ESDfriend->GetTrack(i);
136 TObject *calibObject;
137 AliTPCseed *seed = 0;
138 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
139 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
140 }
141 if (!seed) continue;
142 RefitTrack(track, seed);
143 }
144 return;
145}
146
147Bool_t AliTPCcalibCalib::RefitTrack(AliESDtrack * track, AliTPCseed *seed){
148 //
149 // Refit track
150 //
151
15e48021 152 //
153 // 0 - Setup transform object
154 //
155 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
156 transform->SetCurrentRun(fRun);
157 transform->SetCurrentTimeStamp((UInt_t)fTime);
9dcfce73 158 //
159 // First apply calibration
160 //
15e48021 161 AliTPCPointCorrection * corr = AliTPCPointCorrection::Instance();
9dcfce73 162 for (Int_t irow=0;irow<159;irow++) {
163 AliTPCclusterMI *cluster=seed->GetClusterPointer(irow);
164 if (!cluster) continue;
165 AliTPCclusterMI cl0(*cluster);
166 Double_t x[3]={cluster->GetRow(),cluster->GetPad(),cluster->GetTimeBin()};
167 Int_t i[1]={cluster->GetDetector()};
168 transform->Transform(x,i,0,1);
11c7a854 169 //
170 // get position correction
171 //
172 Int_t ipad=0;
173 if (cluster->GetDetector()>35) ipad=1;
174 Float_t dy =AliTPCClusterParam::SPosCorrection(0,ipad,cluster->GetPad(),cluster->GetTimeBin(),cluster->GetZ(),cluster->GetSigmaY2(),cluster->GetSigmaZ2(),cluster->GetMax());
175 Float_t dz =AliTPCClusterParam::SPosCorrection(1,ipad,cluster->GetPad(),cluster->GetTimeBin(),cluster->GetZ(),cluster->GetSigmaY2(),cluster->GetSigmaZ2(),cluster->GetMax());
176 //x[1]-=dy;
177 //x[2]-=dz;
15e48021 178 //
179 // Apply sector alignment
180 //
181 Double_t dxq = AliTPCPointCorrection::SGetCorrectionSector(0,cluster->GetDetector()%36,cluster->GetX(),
182 cluster->GetY(),cluster->GetZ());
183 Double_t dyq = AliTPCPointCorrection::SGetCorrectionSector(1,cluster->GetDetector()%36,cluster->GetX(),
184 cluster->GetY(),cluster->GetZ());
185 Double_t dzq = AliTPCPointCorrection::SGetCorrectionSector(2,cluster->GetDetector()%36,cluster->GetX(),
186 cluster->GetY(),cluster->GetZ());
187 if (kTRUE){
188 x[0]-=dxq;
189 x[1]-=dyq;
190 x[2]-=dzq;
191 }
192 //
193 // Apply r-phi correction - To be done on track level- knowing the track angle !!!
194 //
195 Double_t corrclY =
196 corr->RPhiCOGCorrection(cluster->GetDetector(),cluster->GetRow(), cluster->GetPad(),
197 cluster->GetY(),cluster->GetY(), cluster->GetZ(), 0., cluster->GetMax(),2.5);
198 // R correction
199 Double_t corrR = corr->CorrectionOutR0(kFALSE,kFALSE,cluster->GetX(),cluster->GetY(),cluster->GetZ(),cluster->GetDetector());
200
201 if (kTRUE){
202 if (cluster->GetY()>0) x[1]+=corrclY; // rphi correction
203 if (cluster->GetY()<0) x[1]-=corrclY; // rphi correction
204 x[0]+=corrR; // radial correction
205 }
11c7a854 206
15e48021 207 //
208 //
9dcfce73 209 //
210 cluster->SetX(x[0]);
211 cluster->SetY(x[1]);
212 cluster->SetZ(x[2]);
213 if (fStreamLevel>2){
214 TTreeSRedirector *cstream = GetDebugStreamer();
215 if (cstream){
216 (*cstream)<<"Clusters"<<
108953e9 217 "run="<<fRun<< // run number
218 "event="<<fEvent<< // event number
219 "time="<<fTime<< // time stamp of event
220 "trigger="<<fTrigger<< // trigger
15e48021 221 "triggerClass="<<&fTriggerClass<< // trigger
108953e9 222 "mag="<<fMagF<< // magnetic field
9dcfce73 223 "cl0.="<<&cl0<<
224 "cl.="<<cluster<<
11c7a854 225 "cy="<<dy<<
226 "cz="<<dz<<
fe8454d9 227 "cY="<<corrclY<<
15e48021 228 "cR="<<corrR<<
229 "dxq="<<dxq<<
230 "dyq="<<dyq<<
231 "dzq="<<dzq<<
9dcfce73 232 "\n";
233 }
234 }
235 }
15e48021 236 //
237 //
238 //
11c7a854 239 Int_t ncl = seed->GetNumberOfClusters();
240 Double_t covar[15];
241 for (Int_t i=0;i<15;i++) covar[i]=0;
242 covar[0]=10.*10.;
243 covar[2]=10.*10.;
244 covar[5]=10.*10./(64.*64.);
245 covar[9]=10.*10./(64.*64.);
246 covar[14]=1*1;
247
9dcfce73 248 //
249 // And now do refit
250 //
11c7a854 251 AliExternalTrackParam * trackInOld = (AliExternalTrackParam*)track->GetInnerParam();
9dcfce73 252 AliExternalTrackParam * trackOutOld = (AliExternalTrackParam*)track->GetOuterParam();
253
254 AliExternalTrackParam trackIn = *trackOutOld;
11c7a854 255 trackIn.ResetCovariance(200.);
11c7a854 256 trackIn.AddCovariance(covar);
9dcfce73 257 Double_t xyz[3];
258 Int_t nclIn=0,nclOut=0;
259 //
15e48021 260 // Refit in
261 //
262
263 for (Int_t irow=159; irow>0; irow--){
264 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
265 if (!cl) continue;
266 if (cl->GetX()<80) continue;
267 Int_t sector = cl->GetDetector();
268 Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackIn.GetAlpha();
269 if (TMath::Abs(dalpha)>0.01)
270 trackIn.Rotate(TMath::DegToRad()*(sector%18*20.+10.));
271 Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
272 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
273 AliTPCseed::GetError(cl, &trackIn,cov[0],cov[2]);
274 cov[0]*=cov[0];
275 cov[2]*=cov[2];
276 trackIn.GetXYZ(xyz);
277 Double_t bz = AliTracker::GetBz(xyz);
278
279 if (!trackIn.PropagateTo(r[0],bz)) continue;
280 if (RejectCluster(cl,&trackIn)) continue;
281 nclIn++;
282 trackIn.Update(&r[1],cov);
283 }
284 //
285 AliExternalTrackParam trackOut = trackIn;
286 trackOut.ResetCovariance(200.);
287 trackOut.AddCovariance(covar);
288 //
9dcfce73 289 // Refit out
290 //
15e48021 291 //Bool_t lastEdge=kFALSE;
9dcfce73 292 for (Int_t irow=0; irow<160; irow++){
293 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
294 if (!cl) continue;
295 if (cl->GetX()<80) continue;
296 Int_t sector = cl->GetDetector();
297 Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackOut.GetAlpha();
298
299 if (TMath::Abs(dalpha)>0.01)
300 trackOut.Rotate(TMath::DegToRad()*(sector%18*20.+10.));
9dcfce73 301 Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
91350f5b 302
303 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
304 AliTPCseed::GetError(cl, &trackOut,cov[0],cov[2]);
305 cov[0]*=cov[0];
306 cov[2]*=cov[2];
9dcfce73 307 trackOut.GetXYZ(xyz);
308 Double_t bz = AliTracker::GetBz(xyz);
15e48021 309 if (!trackOut.PropagateTo(r[0],bz)) continue;
42b40d07 310 if (RejectCluster(cl,&trackOut)) continue;
15e48021 311 nclOut++;
312 trackOut.Update(&r[1],cov);
313 //if (cl->GetType()<0) lastEdge=kTRUE;
314 //if (cl->GetType()>=0) lastEdge=kFALSE;
9dcfce73 315 }
316 //
9dcfce73 317 //
15e48021 318 //
319 nclIn=0;
320 trackIn = trackOut;
321 trackIn.ResetCovariance(10.);
322 //
323 // Refit in one more time
324 //
9dcfce73 325 for (Int_t irow=159; irow>0; irow--){
326 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
327 if (!cl) continue;
328 if (cl->GetX()<80) continue;
329 Int_t sector = cl->GetDetector();
330 Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackIn.GetAlpha();
331 if (TMath::Abs(dalpha)>0.01)
332 trackIn.Rotate(TMath::DegToRad()*(sector%18*20.+10.));
9dcfce73 333 Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
334 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
91350f5b 335 AliTPCseed::GetError(cl, &trackIn,cov[0],cov[2]);
336 cov[0]*=cov[0];
337 cov[2]*=cov[2];
338 trackIn.GetXYZ(xyz);
9dcfce73 339 Double_t bz = AliTracker::GetBz(xyz);
340
15e48021 341 if (!trackIn.PropagateTo(r[0],bz)) continue;
42b40d07 342 if (RejectCluster(cl,&trackIn)) continue;
15e48021 343 nclIn++;
9dcfce73 344 trackIn.Update(&r[1],cov);
345 }
15e48021 346
347
3bf5c7a6 348 trackIn.Rotate(trackInOld->GetAlpha());
349 trackOut.Rotate(trackOutOld->GetAlpha());
350 //
351 trackInOld->GetXYZ(xyz);
352 Double_t bz = AliTracker::GetBz(xyz);
353 trackIn.PropagateTo(trackInOld->GetX(),bz);
354 //
355 trackOutOld->GetXYZ(xyz);
356 bz = AliTracker::GetBz(xyz);
357 trackOut.PropagateTo(trackOutOld->GetX(),bz);
358
9dcfce73 359
360 if (fStreamLevel>0){
361 TTreeSRedirector *cstream = GetDebugStreamer();
362 if (cstream){
363 (*cstream)<<"Tracks"<<
108953e9 364 "run="<<fRun<< // run number
365 "event="<<fEvent<< // event number
366 "time="<<fTime<< // time stamp of event
367 "trigger="<<fTrigger<< // trigger
15e48021 368 "triggerClass="<<&fTriggerClass<< // trigger
108953e9 369 "mag="<<fMagF<< // magnetic field
9dcfce73 370 "nclIn="<<nclIn<<
371 "nclOut="<<nclOut<<
372 "ncl="<<ncl<<
373 "TrIn0.="<<trackInOld<<
374 "TrOut0.="<<trackOutOld<<
375 "TrIn1.="<<&trackIn<<
376 "TrOut1.="<<&trackOut<<
377 "\n";
378 }
379 }
3bf5c7a6 380 //
981e9de5 381 // And now rewrite ESDtrack and TPC seed
3bf5c7a6 382 //
383
384 (*trackInOld) = trackIn;
385 (*trackOutOld) = trackOut;
386 AliExternalTrackParam *t = &trackIn;
387 track->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
981e9de5 388 seed->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
fe8454d9 389 seed->SetNumberOfClusters((nclIn+nclOut)/2);
2cfb8d90 390 return kTRUE;
9dcfce73 391}
392
393
394
395Bool_t AliTPCcalibCalib::RejectCluster(AliTPCclusterMI* cl, AliExternalTrackParam * param){
396 //
397 // check the acceptance of cluster
398 // Cut on edge effects
399 //
15e48021 400 Float_t kEdgeCut=2.5;
401 Float_t kSigmaCut=6;
402
9dcfce73 403 Bool_t isReject = kFALSE;
404 Float_t edgeY = cl->GetX()*TMath::Tan(TMath::Pi()/18);
405 Float_t dist = edgeY - TMath::Abs(cl->GetY());
406 if (param) dist = TMath::Abs(edgeY - TMath::Abs(param->GetY()));
15e48021 407 if (dist<kEdgeCut) isReject=kTRUE;
408
409 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
410 AliTPCseed::GetError(cl, param,cov[0],cov[2]);
411 Double_t py = (cl->GetY()-param->GetY())/TMath::Sqrt(cov[0]*cov[0]+param->GetSigmaY2());
412 Double_t pz = (cl->GetZ()-param->GetZ())/TMath::Sqrt(cov[2]*cov[2]+param->GetSigmaZ2());
413 //
414 if ((py*py+pz*pz)>kSigmaCut*kSigmaCut) isReject=kTRUE;
415
9dcfce73 416 return isReject;
417}
418
419
91350f5b 420