]>
Commit | Line | Data |
---|---|---|
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" | |
63 | ||
64 | ClassImp(AliTPCcalibCalib) | |
65 | ||
66 | AliTPCcalibCalib::AliTPCcalibCalib(): | |
67 | AliTPCcalibBase() | |
68 | { | |
69 | // | |
70 | // Constructor | |
71 | // | |
72 | } | |
73 | ||
74 | ||
75 | AliTPCcalibCalib::AliTPCcalibCalib(const Text_t *name, const Text_t *title) | |
76 | :AliTPCcalibBase() | |
77 | { | |
78 | SetName(name); | |
79 | SetTitle(title); | |
80 | } | |
81 | ||
82 | ||
83 | AliTPCcalibCalib::AliTPCcalibCalib(const AliTPCcalibCalib&calib): | |
84 | AliTPCcalibBase(calib) | |
85 | { | |
86 | // | |
87 | // copy constructor | |
88 | // | |
89 | } | |
90 | ||
91 | AliTPCcalibCalib &AliTPCcalibCalib::operator=(const AliTPCcalibCalib&calib){ | |
92 | // | |
93 | // | |
94 | // | |
95 | ((AliTPCcalibBase *)this)->operator=(calib); | |
96 | return *this; | |
97 | } | |
98 | ||
99 | ||
100 | AliTPCcalibCalib::~AliTPCcalibCalib() { | |
101 | // | |
102 | // destructor | |
103 | // | |
104 | } | |
105 | ||
106 | ||
107 | void AliTPCcalibCalib::Process(AliESDEvent *event){ | |
108 | // | |
109 | // | |
110 | // | |
111 | if (!event) { | |
112 | return; | |
113 | } | |
114 | AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend")); | |
115 | if (!ESDfriend) { | |
116 | return; | |
117 | } | |
118 | ||
119 | if (GetDebugLevel()>20) printf("Hallo world: Im here\n"); | |
120 | Int_t ntracks=event->GetNumberOfTracks(); | |
121 | // | |
122 | // | |
123 | // | |
124 | ||
125 | for (Int_t i=0;i<ntracks;++i) { | |
126 | AliESDtrack *track = event->GetTrack(i); | |
127 | const AliExternalTrackParam * trackIn = track->GetInnerParam(); | |
128 | const AliExternalTrackParam * trackOut = track->GetOuterParam(); | |
129 | if (!trackIn) continue; | |
130 | if (!trackOut) continue; | |
131 | ||
132 | AliESDfriendTrack *friendTrack = ESDfriend->GetTrack(i); | |
133 | TObject *calibObject; | |
134 | AliTPCseed *seed = 0; | |
135 | for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) { | |
136 | if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break; | |
137 | } | |
138 | if (!seed) continue; | |
139 | RefitTrack(track, seed); | |
140 | } | |
141 | return; | |
142 | } | |
143 | ||
144 | Bool_t AliTPCcalibCalib::RefitTrack(AliESDtrack * track, AliTPCseed *seed){ | |
145 | // | |
146 | // Refit track | |
147 | // | |
148 | ||
149 | // | |
150 | // First apply calibration | |
151 | // | |
152 | ||
153 | AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform(); | |
154 | for (Int_t irow=0;irow<159;irow++) { | |
155 | AliTPCclusterMI *cluster=seed->GetClusterPointer(irow); | |
156 | if (!cluster) continue; | |
157 | AliTPCclusterMI cl0(*cluster); | |
158 | Double_t x[3]={cluster->GetRow(),cluster->GetPad(),cluster->GetTimeBin()}; | |
159 | Int_t i[1]={cluster->GetDetector()}; | |
160 | transform->Transform(x,i,0,1); | |
11c7a854 | 161 | // |
162 | // get position correction | |
163 | // | |
164 | Int_t ipad=0; | |
165 | if (cluster->GetDetector()>35) ipad=1; | |
166 | Float_t dy =AliTPCClusterParam::SPosCorrection(0,ipad,cluster->GetPad(),cluster->GetTimeBin(),cluster->GetZ(),cluster->GetSigmaY2(),cluster->GetSigmaZ2(),cluster->GetMax()); | |
167 | Float_t dz =AliTPCClusterParam::SPosCorrection(1,ipad,cluster->GetPad(),cluster->GetTimeBin(),cluster->GetZ(),cluster->GetSigmaY2(),cluster->GetSigmaZ2(),cluster->GetMax()); | |
168 | //x[1]-=dy; | |
169 | //x[2]-=dz; | |
170 | ||
9dcfce73 | 171 | // |
172 | cluster->SetX(x[0]); | |
173 | cluster->SetY(x[1]); | |
174 | cluster->SetZ(x[2]); | |
175 | if (fStreamLevel>2){ | |
176 | TTreeSRedirector *cstream = GetDebugStreamer(); | |
177 | if (cstream){ | |
178 | (*cstream)<<"Clusters"<< | |
108953e9 | 179 | "run="<<fRun<< // run number |
180 | "event="<<fEvent<< // event number | |
181 | "time="<<fTime<< // time stamp of event | |
182 | "trigger="<<fTrigger<< // trigger | |
183 | "mag="<<fMagF<< // magnetic field | |
9dcfce73 | 184 | "cl0.="<<&cl0<< |
185 | "cl.="<<cluster<< | |
11c7a854 | 186 | "cy="<<dy<< |
187 | "cz="<<dz<< | |
9dcfce73 | 188 | "\n"; |
189 | } | |
190 | } | |
191 | } | |
11c7a854 | 192 | Int_t ncl = seed->GetNumberOfClusters(); |
193 | Double_t covar[15]; | |
194 | for (Int_t i=0;i<15;i++) covar[i]=0; | |
195 | covar[0]=10.*10.; | |
196 | covar[2]=10.*10.; | |
197 | covar[5]=10.*10./(64.*64.); | |
198 | covar[9]=10.*10./(64.*64.); | |
199 | covar[14]=1*1; | |
200 | ||
9dcfce73 | 201 | // |
202 | // And now do refit | |
203 | // | |
11c7a854 | 204 | AliExternalTrackParam * trackInOld = (AliExternalTrackParam*)track->GetInnerParam(); |
9dcfce73 | 205 | AliExternalTrackParam * trackOutOld = (AliExternalTrackParam*)track->GetOuterParam(); |
206 | ||
207 | AliExternalTrackParam trackIn = *trackOutOld; | |
208 | AliExternalTrackParam trackOut = *trackInOld; | |
11c7a854 | 209 | trackIn.ResetCovariance(200.); |
210 | trackOut.ResetCovariance(200.); | |
211 | trackIn.AddCovariance(covar); | |
212 | trackOut.AddCovariance(covar); | |
9dcfce73 | 213 | Double_t xyz[3]; |
214 | Int_t nclIn=0,nclOut=0; | |
215 | // | |
216 | // Refit out | |
217 | // | |
218 | for (Int_t irow=0; irow<160; irow++){ | |
219 | AliTPCclusterMI *cl=seed->GetClusterPointer(irow); | |
220 | if (!cl) continue; | |
221 | if (cl->GetX()<80) continue; | |
222 | Int_t sector = cl->GetDetector(); | |
223 | Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackOut.GetAlpha(); | |
224 | ||
225 | if (TMath::Abs(dalpha)>0.01) | |
226 | trackOut.Rotate(TMath::DegToRad()*(sector%18*20.+10.)); | |
3bf5c7a6 | 227 | if (RejectCluster(cl,&trackOut)) continue; |
9dcfce73 | 228 | Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()}; |
229 | Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation | |
230 | trackOut.GetXYZ(xyz); | |
231 | Double_t bz = AliTracker::GetBz(xyz); | |
232 | if (trackOut.PropagateTo(r[0],bz)) nclOut++; | |
233 | trackOut.Update(&r[1],cov); | |
234 | ||
235 | } | |
236 | // | |
237 | // Refit in | |
238 | // | |
239 | ||
240 | for (Int_t irow=159; irow>0; irow--){ | |
241 | AliTPCclusterMI *cl=seed->GetClusterPointer(irow); | |
242 | if (!cl) continue; | |
243 | if (cl->GetX()<80) continue; | |
244 | Int_t sector = cl->GetDetector(); | |
245 | Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackIn.GetAlpha(); | |
246 | if (TMath::Abs(dalpha)>0.01) | |
247 | trackIn.Rotate(TMath::DegToRad()*(sector%18*20.+10.)); | |
3bf5c7a6 | 248 | if (RejectCluster(cl,&trackIn)) continue; |
9dcfce73 | 249 | Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()}; |
250 | Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation | |
251 | trackOut.GetXYZ(xyz); | |
252 | Double_t bz = AliTracker::GetBz(xyz); | |
253 | ||
254 | if (trackIn.PropagateTo(r[0],bz)) nclIn++; | |
255 | trackIn.Update(&r[1],cov); | |
256 | } | |
3bf5c7a6 | 257 | trackIn.Rotate(trackInOld->GetAlpha()); |
258 | trackOut.Rotate(trackOutOld->GetAlpha()); | |
259 | // | |
260 | trackInOld->GetXYZ(xyz); | |
261 | Double_t bz = AliTracker::GetBz(xyz); | |
262 | trackIn.PropagateTo(trackInOld->GetX(),bz); | |
263 | // | |
264 | trackOutOld->GetXYZ(xyz); | |
265 | bz = AliTracker::GetBz(xyz); | |
266 | trackOut.PropagateTo(trackOutOld->GetX(),bz); | |
267 | ||
9dcfce73 | 268 | |
269 | if (fStreamLevel>0){ | |
270 | TTreeSRedirector *cstream = GetDebugStreamer(); | |
271 | if (cstream){ | |
272 | (*cstream)<<"Tracks"<< | |
108953e9 | 273 | "run="<<fRun<< // run number |
274 | "event="<<fEvent<< // event number | |
275 | "time="<<fTime<< // time stamp of event | |
276 | "trigger="<<fTrigger<< // trigger | |
277 | "mag="<<fMagF<< // magnetic field | |
9dcfce73 | 278 | "nclIn="<<nclIn<< |
279 | "nclOut="<<nclOut<< | |
280 | "ncl="<<ncl<< | |
281 | "TrIn0.="<<trackInOld<< | |
282 | "TrOut0.="<<trackOutOld<< | |
283 | "TrIn1.="<<&trackIn<< | |
284 | "TrOut1.="<<&trackOut<< | |
285 | "\n"; | |
286 | } | |
287 | } | |
3bf5c7a6 | 288 | // |
289 | // And now rewrite ESDtrack | |
290 | // | |
291 | ||
292 | (*trackInOld) = trackIn; | |
293 | (*trackOutOld) = trackOut; | |
294 | AliExternalTrackParam *t = &trackIn; | |
295 | track->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance()); | |
2cfb8d90 | 296 | return kTRUE; |
9dcfce73 | 297 | } |
298 | ||
299 | ||
300 | ||
301 | Bool_t AliTPCcalibCalib::RejectCluster(AliTPCclusterMI* cl, AliExternalTrackParam * param){ | |
302 | // | |
303 | // check the acceptance of cluster | |
304 | // Cut on edge effects | |
305 | // | |
306 | Bool_t isReject = kFALSE; | |
307 | Float_t edgeY = cl->GetX()*TMath::Tan(TMath::Pi()/18); | |
308 | Float_t dist = edgeY - TMath::Abs(cl->GetY()); | |
309 | if (param) dist = TMath::Abs(edgeY - TMath::Abs(param->GetY())); | |
310 | if (dist<3) isReject=kTRUE; | |
311 | if (cl->GetType()<0) isReject=kTRUE; | |
312 | return isReject; | |
313 | } | |
314 | ||
315 |