]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCcalibCalib.cxx
Removed obsolete classes
[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<<
15e48021 227 "cR="<<corrR<<
228 "dxq="<<dxq<<
229 "dyq="<<dyq<<
230 "dzq="<<dzq<<
9dcfce73 231 "\n";
232 }
233 }
234 }
15e48021 235 //
236 //
237 //
11c7a854 238 Int_t ncl = seed->GetNumberOfClusters();
239 Double_t covar[15];
240 for (Int_t i=0;i<15;i++) covar[i]=0;
241 covar[0]=10.*10.;
242 covar[2]=10.*10.;
243 covar[5]=10.*10./(64.*64.);
244 covar[9]=10.*10./(64.*64.);
245 covar[14]=1*1;
246
9dcfce73 247 //
248 // And now do refit
249 //
11c7a854 250 AliExternalTrackParam * trackInOld = (AliExternalTrackParam*)track->GetInnerParam();
9dcfce73 251 AliExternalTrackParam * trackOutOld = (AliExternalTrackParam*)track->GetOuterParam();
252
253 AliExternalTrackParam trackIn = *trackOutOld;
11c7a854 254 trackIn.ResetCovariance(200.);
11c7a854 255 trackIn.AddCovariance(covar);
9dcfce73 256 Double_t xyz[3];
257 Int_t nclIn=0,nclOut=0;
258 //
15e48021 259 // Refit in
260 //
261
262 for (Int_t irow=159; irow>0; irow--){
263 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
264 if (!cl) continue;
265 if (cl->GetX()<80) continue;
266 Int_t sector = cl->GetDetector();
267 Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackIn.GetAlpha();
268 if (TMath::Abs(dalpha)>0.01)
269 trackIn.Rotate(TMath::DegToRad()*(sector%18*20.+10.));
270 Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
271 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
272 AliTPCseed::GetError(cl, &trackIn,cov[0],cov[2]);
273 cov[0]*=cov[0];
274 cov[2]*=cov[2];
275 trackIn.GetXYZ(xyz);
276 Double_t bz = AliTracker::GetBz(xyz);
277
278 if (!trackIn.PropagateTo(r[0],bz)) continue;
279 if (RejectCluster(cl,&trackIn)) continue;
280 nclIn++;
281 trackIn.Update(&r[1],cov);
282 }
283 //
284 AliExternalTrackParam trackOut = trackIn;
285 trackOut.ResetCovariance(200.);
286 trackOut.AddCovariance(covar);
287 //
9dcfce73 288 // Refit out
289 //
15e48021 290 //Bool_t lastEdge=kFALSE;
9dcfce73 291 for (Int_t irow=0; irow<160; irow++){
292 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
293 if (!cl) continue;
294 if (cl->GetX()<80) continue;
295 Int_t sector = cl->GetDetector();
296 Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackOut.GetAlpha();
297
298 if (TMath::Abs(dalpha)>0.01)
299 trackOut.Rotate(TMath::DegToRad()*(sector%18*20.+10.));
9dcfce73 300 Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
91350f5b 301
302 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
303 AliTPCseed::GetError(cl, &trackOut,cov[0],cov[2]);
304 cov[0]*=cov[0];
305 cov[2]*=cov[2];
9dcfce73 306 trackOut.GetXYZ(xyz);
307 Double_t bz = AliTracker::GetBz(xyz);
15e48021 308 if (!trackOut.PropagateTo(r[0],bz)) continue;
42b40d07 309 if (RejectCluster(cl,&trackOut)) continue;
15e48021 310 nclOut++;
311 trackOut.Update(&r[1],cov);
312 //if (cl->GetType()<0) lastEdge=kTRUE;
313 //if (cl->GetType()>=0) lastEdge=kFALSE;
9dcfce73 314 }
315 //
9dcfce73 316 //
15e48021 317 //
318 nclIn=0;
319 trackIn = trackOut;
320 trackIn.ResetCovariance(10.);
321 //
322 // Refit in one more time
323 //
9dcfce73 324 for (Int_t irow=159; irow>0; irow--){
325 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
326 if (!cl) continue;
327 if (cl->GetX()<80) continue;
328 Int_t sector = cl->GetDetector();
329 Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackIn.GetAlpha();
330 if (TMath::Abs(dalpha)>0.01)
331 trackIn.Rotate(TMath::DegToRad()*(sector%18*20.+10.));
9dcfce73 332 Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
333 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
91350f5b 334 AliTPCseed::GetError(cl, &trackIn,cov[0],cov[2]);
335 cov[0]*=cov[0];
336 cov[2]*=cov[2];
337 trackIn.GetXYZ(xyz);
9dcfce73 338 Double_t bz = AliTracker::GetBz(xyz);
339
15e48021 340 if (!trackIn.PropagateTo(r[0],bz)) continue;
42b40d07 341 if (RejectCluster(cl,&trackIn)) continue;
15e48021 342 nclIn++;
9dcfce73 343 trackIn.Update(&r[1],cov);
344 }
15e48021 345
346
3bf5c7a6 347 trackIn.Rotate(trackInOld->GetAlpha());
348 trackOut.Rotate(trackOutOld->GetAlpha());
349 //
350 trackInOld->GetXYZ(xyz);
351 Double_t bz = AliTracker::GetBz(xyz);
352 trackIn.PropagateTo(trackInOld->GetX(),bz);
353 //
354 trackOutOld->GetXYZ(xyz);
355 bz = AliTracker::GetBz(xyz);
356 trackOut.PropagateTo(trackOutOld->GetX(),bz);
357
9dcfce73 358
359 if (fStreamLevel>0){
360 TTreeSRedirector *cstream = GetDebugStreamer();
361 if (cstream){
362 (*cstream)<<"Tracks"<<
108953e9 363 "run="<<fRun<< // run number
364 "event="<<fEvent<< // event number
365 "time="<<fTime<< // time stamp of event
366 "trigger="<<fTrigger<< // trigger
15e48021 367 "triggerClass="<<&fTriggerClass<< // trigger
108953e9 368 "mag="<<fMagF<< // magnetic field
9dcfce73 369 "nclIn="<<nclIn<<
370 "nclOut="<<nclOut<<
371 "ncl="<<ncl<<
372 "TrIn0.="<<trackInOld<<
373 "TrOut0.="<<trackOutOld<<
374 "TrIn1.="<<&trackIn<<
375 "TrOut1.="<<&trackOut<<
376 "\n";
377 }
378 }
3bf5c7a6 379 //
981e9de5 380 // And now rewrite ESDtrack and TPC seed
3bf5c7a6 381 //
382
383 (*trackInOld) = trackIn;
384 (*trackOutOld) = trackOut;
385 AliExternalTrackParam *t = &trackIn;
386 track->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
981e9de5 387 seed->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
15e48021 388 seed->SetNumberOfClusters((nclIn+nclOut)*0.5);
2cfb8d90 389 return kTRUE;
9dcfce73 390}
391
392
393
394Bool_t AliTPCcalibCalib::RejectCluster(AliTPCclusterMI* cl, AliExternalTrackParam * param){
395 //
396 // check the acceptance of cluster
397 // Cut on edge effects
398 //
15e48021 399 Float_t kEdgeCut=2.5;
400 Float_t kSigmaCut=6;
401
9dcfce73 402 Bool_t isReject = kFALSE;
403 Float_t edgeY = cl->GetX()*TMath::Tan(TMath::Pi()/18);
404 Float_t dist = edgeY - TMath::Abs(cl->GetY());
405 if (param) dist = TMath::Abs(edgeY - TMath::Abs(param->GetY()));
15e48021 406 if (dist<kEdgeCut) isReject=kTRUE;
407
408 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
409 AliTPCseed::GetError(cl, param,cov[0],cov[2]);
410 Double_t py = (cl->GetY()-param->GetY())/TMath::Sqrt(cov[0]*cov[0]+param->GetSigmaY2());
411 Double_t pz = (cl->GetZ()-param->GetZ())/TMath::Sqrt(cov[2]*cov[2]+param->GetSigmaZ2());
412 //
413 if ((py*py+pz*pz)>kSigmaCut*kSigmaCut) isReject=kTRUE;
414
9dcfce73 415 return isReject;
416}
417
418
91350f5b 419