]>
Commit | Line | Data |
---|---|---|
77203477 | 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 * | |
39779ce6 | 8 | * documentation strictly for non-commercialf purposes is hereby granted * |
77203477 | 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 | /* $Id: AliTRDtrackingResolution.cxx 27496 2008-07-22 08:35:45Z cblume $ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Reconstruction QA // | |
21 | // // | |
22 | // Authors: // | |
23 | // Markus Fasel <M.Fasel@gsi.de> // | |
24 | // // | |
25 | //////////////////////////////////////////////////////////////////////////// | |
26 | ||
aaf47b30 | 27 | #include <cstring> |
28 | ||
29 | ||
77203477 | 30 | #include <TObjArray.h> |
31 | #include <TList.h> | |
7102d1b1 | 32 | #include <TH2.h> |
33 | #include <TH1.h> | |
34 | #include <TF1.h> | |
77203477 | 35 | #include <TProfile.h> |
7102d1b1 | 36 | #include <TGraphErrors.h> |
77203477 | 37 | #include <TMath.h> |
aaf47b30 | 38 | #include "TTreeStream.h" |
39 | #include "TGeoManager.h" | |
77203477 | 40 | |
41 | #include "AliAnalysisManager.h" | |
77203477 | 42 | #include "AliTrackReference.h" |
aaf47b30 | 43 | #include "AliTrackPointArray.h" |
44 | #include "AliCDBManager.h" | |
45 | ||
46 | #include "AliTRDcluster.h" | |
47 | #include "AliTRDseedV1.h" | |
48 | #include "AliTRDtrackV1.h" | |
49 | #include "AliTRDtrackerV1.h" | |
50 | #include "AliTRDReconstructor.h" | |
51 | #include "AliTRDrecoParam.h" | |
77203477 | 52 | |
53 | #include "AliTRDtrackInfo/AliTRDtrackInfo.h" | |
54 | #include "AliTRDtrackingResolution.h" | |
55 | ||
77203477 | 56 | ClassImp(AliTRDtrackingResolution) |
57 | ||
58 | //________________________________________________________ | |
59 | AliTRDtrackingResolution::AliTRDtrackingResolution(const char * name): | |
aaf47b30 | 60 | AliAnalysisTask(name, "") |
39779ce6 | 61 | ,fTracks(0x0) |
62 | ,fHistos(0x0) | |
aaf47b30 | 63 | ,fReconstructor(0x0) |
4b8f8a35 | 64 | ,fHasMCdata(kTRUE) |
aaf47b30 | 65 | ,fDebugLevel(0) |
66 | ,fDebugStream(0x0) | |
77203477 | 67 | { |
aaf47b30 | 68 | AliCDBManager *cdb = AliCDBManager::Instance(); |
69 | cdb->SetDefaultStorage("local://$ALICE_ROOT"); | |
70 | cdb->SetRun(0); | |
71 | TGeoManager::Import("geometry.root"); | |
72 | fReconstructor = new AliTRDReconstructor(); | |
73 | fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam()); | |
74 | AliTRDtrackerV1::SetNTimeBins(24); | |
75 | ||
77203477 | 76 | DefineInput(0, TObjArray::Class()); |
77 | DefineOutput(0, TList::Class()); | |
78 | } | |
79 | ||
80 | //________________________________________________________ | |
81 | void AliTRDtrackingResolution::ConnectInputData(Option_t *){ | |
39779ce6 | 82 | fTracks = dynamic_cast<TObjArray *>(GetInputData(0)); |
77203477 | 83 | } |
84 | ||
85 | //________________________________________________________ | |
86 | void AliTRDtrackingResolution::CreateOutputObjects() | |
87 | { | |
88 | // spatial resolution | |
77203477 | 89 | OpenFile(0, "RECREATE"); |
39779ce6 | 90 | |
91 | fHistos = new TList(); | |
92 | ||
93 | // Resolution histos | |
4b8f8a35 | 94 | if(HasMCdata()){ |
95 | // tracklet resolution [0] | |
96 | fHistos->AddAt(new TH2I("fY", "", 21, -21., 21., 100, -.5, .5), 0); | |
97 | // tracklet angular resolution [1] | |
98 | fHistos->AddAt(new TH2I("fPhi", "", 21, -21., 21., 100, -10., 10.), 1); | |
99 | } | |
39779ce6 | 100 | // Residual histos |
101 | // cluster to tracklet residuals [2] | |
4b8f8a35 | 102 | Int_t position = HasMCdata() ? 2 : 0; |
103 | fHistos->AddAt(new TH2I("fYClRes", "", 21, -21., 21., 100, -.5, .5), position); | |
77203477 | 104 | } |
105 | ||
106 | //________________________________________________________ | |
7102d1b1 | 107 | void AliTRDtrackingResolution::Exec(Option_t *) |
108 | { | |
77203477 | 109 | // spatial Resolution: res = pos_{Tracklet}(x = x_{Anode wire}) - pos_{TrackRef}(x = x_{Anode wire}) |
110 | // angular Resolution: res = Tracklet angle - TrackRef Angle | |
7102d1b1 | 111 | |
39779ce6 | 112 | Int_t nTrackInfos = fTracks->GetEntriesFast(); |
113 | if(fDebugLevel>=2) printf("Number of Histograms: %d\n", fHistos->GetEntries()); | |
aaf47b30 | 114 | |
115 | Double_t dy, dz; | |
39779ce6 | 116 | AliTrackPoint tr[kNLayers], tk[kNLayers]; |
aaf47b30 | 117 | AliTRDtrackV1 *fTrack = 0x0; |
77203477 | 118 | AliTRDtrackInfo *fInfo = 0x0; |
119 | if(fDebugLevel>=2) printf("Number of TrackInfos: %d\n", nTrackInfos); | |
120 | for(Int_t iTI = 0; iTI < nTrackInfos; iTI++){ | |
77203477 | 121 | // check if ESD and MC-Information are available |
39779ce6 | 122 | if(!(fInfo = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(iTI)))) continue; |
aaf47b30 | 123 | if(!(fTrack = fInfo->GetTRDtrack())) continue; |
7102d1b1 | 124 | if(fDebugLevel>=3) printf("\tDoing track[%d] NTrackRefs[%d]\n", iTI, fInfo->GetNTrackRefs()); |
125 | ||
39779ce6 | 126 | |
127 | Int_t npts = 0; | |
aaf47b30 | 128 | AliTRDseedV1 *fTracklet = 0x0; |
77203477 | 129 | for(Int_t iplane = 0; iplane < kNLayers; iplane++){ |
aaf47b30 | 130 | if(!(fTracklet = fTrack->GetTracklet(iplane))) continue; |
131 | if(!fTracklet->IsOK()) continue; | |
132 | ||
39779ce6 | 133 | // Book point arrays |
134 | tr[npts].SetXYZ(fTracklet->GetX0(), 0., 0.); | |
135 | tk[npts].SetXYZ(fTracklet->GetX0(), fTracklet->GetYfit(0), fTracklet->GetZfit(0)); | |
136 | npts++; | |
137 | ||
7102d1b1 | 138 | if(fDebugLevel>=4) printf("\t\tLy[%d] X0[%6.3f] Ncl[%d]\n", iplane, fTracklet->GetX0(), fTracklet->GetN()); |
139 | ||
39779ce6 | 140 | Float_t phi = TMath::ATan(fTracklet->GetYref(1)); |
7102d1b1 | 141 | |
39779ce6 | 142 | // RESOLUTION (compare to MC) |
4b8f8a35 | 143 | if(HasMCdata()){ |
144 | if(fInfo->GetNTrackRefs() >= 2){ | |
145 | Float_t phiMC; | |
146 | if(Resolution(fTracklet, fInfo, phiMC)) phi = phiMC; | |
147 | } | |
148 | } | |
aaf47b30 | 149 | |
39779ce6 | 150 | // Do clusters residuals |
151 | fTracklet->SetZref(1, 1.); | |
152 | fTracklet->Fit(); | |
4b8f8a35 | 153 | Int_t histpos = HasMCdata() ? 2 : 0; |
aaf47b30 | 154 | AliTRDcluster *c = 0x0; |
155 | for(Int_t ic=AliTRDseed::knTimebins-1; ic>=0; ic--){ | |
156 | if(!(c = fTracklet->GetClusters(ic))) continue; | |
39779ce6 | 157 | |
158 | dy = fTracklet->GetYat(c->GetX()) - c->GetY(); | |
4b8f8a35 | 159 | ((TH2I*)fHistos->At(histpos))->Fill(phi*TMath::RadToDeg(), dy); |
39779ce6 | 160 | if(fDebugLevel>=1){ |
161 | Float_t q = c->GetQ(); | |
162 | (*fDebugStream) << "ClsTrkltResidual" | |
163 | << "plane=" << iplane | |
164 | << "phi=" << phi | |
165 | << "q=" << q | |
166 | << "dy=" << dy | |
167 | << "\n"; | |
168 | } | |
aaf47b30 | 169 | } |
170 | } | |
39779ce6 | 171 | |
172 | ||
173 | // this protection we might drop TODO | |
174 | if(fTrack->GetNumberOfTracklets() < 6) continue; | |
175 | ||
176 | AliTRDtrackerV1::FitRiemanTilt(fTrack, 0x0, kTRUE, npts, tr); | |
177 | for(Int_t ip=0; ip<npts; ip++){ | |
178 | dy = tk[ip].GetY() - tr[ip].GetY(); | |
179 | dz = tk[ip].GetZ() - tr[ip].GetZ(); | |
aaf47b30 | 180 | if(fDebugLevel>=1){ |
181 | (*fDebugStream) << "ResidualsRT" | |
182 | << "dy=" << dy | |
183 | << "dz=" << dz | |
184 | /* << "phi=" << phi | |
185 | << "theta=" << theta | |
186 | << "dphi=" << dphi*/ | |
187 | << "\n"; | |
188 | } | |
189 | } | |
190 | ||
191 | // AliTRDtrackerV1::FitKalman(fTrack, 0x0, kFALSE, nc, tr); | |
192 | // for(Int_t ip=0; ip<nc; ip++){ | |
193 | // dy = cl[ip].GetY() - tr[ip].GetY(); | |
194 | // dz = cl[ip].GetZ() - tr[ip].GetZ(); | |
195 | // if(fDebugLevel>=1){ | |
196 | // (*fDebugStream) << "ResidualsKF" | |
197 | // << "dy=" << dy | |
198 | // << "dz=" << dz | |
199 | // /* << "phi=" << phi | |
200 | // << "theta=" << theta | |
201 | // << "dphi=" << dphi*/ | |
202 | // << "\n"; | |
203 | // } | |
204 | // } | |
39779ce6 | 205 | |
206 | ||
77203477 | 207 | } |
39779ce6 | 208 | PostData(0, fHistos); |
77203477 | 209 | } |
210 | ||
39779ce6 | 211 | |
212 | //________________________________________________________ | |
213 | Bool_t AliTRDtrackingResolution::Resolution(AliTRDseedV1 *tracklet, AliTRDtrackInfo *fInfo, Float_t &phi) | |
214 | { | |
215 | ||
216 | AliTrackReference *fTrackRefs[2] = {0x0, 0x0}, *tempTrackRef = 0x0; | |
217 | ||
218 | // check for 2 track ref where the radial position has a distance less than 3.7mm | |
219 | Int_t nFound = 0; | |
220 | for(Int_t itr = 0; itr < fInfo->GetNTrackRefs(); itr++){ | |
221 | if(!(tempTrackRef = fInfo->GetTrackRef(itr))) continue; | |
222 | if(fDebugLevel>=5) printf("TrackRef %d: x = %f\n", itr, tempTrackRef->LocalX()); | |
223 | if(TMath::Abs(tracklet->GetX0() - tempTrackRef->LocalX()) > 3.7) continue; | |
224 | fTrackRefs[nFound++] = tempTrackRef; | |
225 | if(nFound == 2) break; | |
226 | } | |
227 | if(nFound < 2){ | |
228 | if(fDebugLevel>=4) printf("\t\tFound track crossing [%d] refX[%6.3f]\n", nFound, nFound>0 ? fTrackRefs[0]->LocalX() : 0.); | |
229 | return kFALSE; | |
230 | } | |
231 | // We found 2 track refs for the tracklet, get y and z at the anode wire by a linear approximation | |
232 | ||
233 | ||
234 | // RESOLUTION | |
235 | Double_t dx = fTrackRefs[1]->LocalX() - fTrackRefs[0]->LocalX(); | |
236 | if(dx <= 0.){ | |
237 | if(fDebugLevel>=4) printf("\t\ttrack ref in the wrong order refX0[%6.3f] refX1[%6.3f]\n", fTrackRefs[0]->LocalX(), fTrackRefs[1]->LocalX()); | |
238 | return kFALSE; | |
239 | } | |
240 | Double_t dydx = (fTrackRefs[1]->LocalY() - fTrackRefs[0]->LocalY()) / dx; | |
241 | Double_t dzdx = (fTrackRefs[1]->Z() - fTrackRefs[0]->Z()) / dx; | |
242 | Double_t dx0 = fTrackRefs[1]->LocalX() - tracklet->GetX0(); | |
243 | Double_t ymc = fTrackRefs[1]->LocalY() - dydx*dx0; | |
244 | Double_t zmc = fTrackRefs[1]->Z() - dzdx*dx0; | |
245 | ||
246 | // recalculate tracklet based on the MC info | |
247 | tracklet->SetYref(0, zmc); | |
248 | tracklet->SetYref(1, dzdx); | |
249 | tracklet->Fit(); | |
250 | Double_t dy = tracklet->GetYfit(0) - ymc; | |
251 | Double_t dz = tracklet->GetZfit(0) - zmc; | |
252 | ||
253 | //res_y *= 100; // in mm | |
254 | Double_t momentum = fTrackRefs[0]->P(); | |
255 | ||
256 | phi = TMath::ATan(dydx); | |
257 | Double_t theta = TMath::ATan(dzdx); | |
258 | Double_t dphi = TMath::ATan(tracklet->GetYfit(1)) - phi; | |
259 | if(fDebugLevel>=4) printf("\t\tdx[%6.4f] dy[%6.4f] dz[%6.4f] dphi[%6.4f] \n", dx, dy, dz, dphi); | |
260 | ||
261 | // Fill Histograms | |
262 | if(TMath::Abs(dx-3.7)<1.E-3){ | |
263 | ((TH2I*)fHistos->At(0))->Fill(phi*TMath::RadToDeg(), dy); | |
264 | ((TH2I*)fHistos->At(1))->Fill(phi*TMath::RadToDeg(), dphi*TMath::RadToDeg()); | |
265 | } | |
266 | // Fill Debug Tree | |
267 | if(fDebugLevel>=1){ | |
268 | Int_t iplane = tracklet->GetPlane(); | |
269 | (*fDebugStream) << "TrkltResolution" | |
270 | << "plane=" << iplane | |
271 | << "p=" << momentum | |
272 | << "dx=" << dx | |
273 | << "dy=" << dy | |
274 | << "dz=" << dz | |
275 | << "phi=" << phi | |
276 | << "theta=" << theta | |
277 | << "dphi=" << dphi | |
278 | << "\n"; | |
279 | } | |
280 | ||
281 | return kTRUE; | |
282 | } | |
283 | ||
284 | ||
77203477 | 285 | //________________________________________________________ |
7102d1b1 | 286 | void AliTRDtrackingResolution::Terminate(Option_t *) |
287 | { | |
77203477 | 288 | if(fDebugStream) delete fDebugStream; |
7102d1b1 | 289 | |
4b8f8a35 | 290 | if(HasMCdata()){ |
291 | //process distributions | |
292 | fHistos = dynamic_cast<TList*>(GetOutputData(0)); | |
293 | if (!fHistos) { | |
294 | Printf("ERROR: list not available"); | |
295 | return; | |
296 | } | |
297 | TH2I *h2 = 0x0; | |
298 | TH1D *h = 0x0; | |
299 | ||
300 | // y resolution | |
301 | TF1 *f = new TF1("f1", "gaus", -.5, .5); | |
302 | h2 = (TH2I*)fHistos->At(0); | |
303 | TGraphErrors *gm = new TGraphErrors(h2->GetNbinsX()); | |
304 | gm->SetNameTitle("meany", "Mean dy"); | |
305 | TGraphErrors *gs = new TGraphErrors(h2->GetNbinsX()); | |
306 | gs->SetNameTitle("sigmy", "Sigma y"); | |
307 | for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){ | |
308 | Double_t phi = h2->GetXaxis()->GetBinCenter(iphi); | |
309 | f->SetParameter(1, 0.);f->SetParameter(2, 2.e-2); | |
310 | h = h2->ProjectionY("py", iphi, iphi); | |
311 | h->Fit(f, "q", "goff", -.5, .5); | |
312 | Int_t jphi = iphi -1; | |
313 | gm->SetPoint(jphi, phi, f->GetParameter(1)); | |
314 | gm->SetPointError(jphi, 0., f->GetParError(1)); | |
315 | gs->SetPoint(jphi, phi, f->GetParameter(2)); | |
316 | gs->SetPointError(jphi, 0., f->GetParError(2)); | |
317 | } | |
318 | fHistos->Add(gm); | |
319 | fHistos->Add(gs); | |
320 | ||
321 | // phi resolution | |
322 | h2 = (TH2I*)fHistos->At(1); | |
323 | gm = new TGraphErrors(h2->GetNbinsX()); | |
324 | gm->SetNameTitle("meanphi", "Mean Phi"); | |
325 | gs = new TGraphErrors(h2->GetNbinsX()); | |
326 | gs->SetNameTitle("sigmphi", "Sigma Phi"); | |
327 | for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){ | |
328 | Double_t phi = h2->GetXaxis()->GetBinCenter(iphi); | |
329 | f->SetParameter(1, 0.);f->SetParameter(2, 2.e-2); | |
330 | h = h2->ProjectionY("py", iphi, iphi); | |
331 | h->Fit(f, "q", "goff", -.5, .5); | |
332 | Int_t jphi = iphi -1; | |
333 | gm->SetPoint(jphi, phi, f->GetParameter(1)); | |
334 | gm->SetPointError(jphi, 0., f->GetParError(1)); | |
335 | gs->SetPoint(jphi, phi, f->GetParameter(2)); | |
336 | gs->SetPointError(jphi, 0., f->GetParError(2)); | |
337 | } | |
338 | fHistos->Add(gm); | |
339 | fHistos->Add(gs); | |
340 | ||
341 | ||
342 | delete f; | |
7102d1b1 | 343 | } |
77203477 | 344 | } |
345 | ||
346 | //________________________________________________________ | |
347 | void AliTRDtrackingResolution::SetDebugLevel(Int_t level){ | |
348 | fDebugLevel = level; | |
349 | if(!fDebugLevel) return; | |
350 | if(fDebugStream) return; | |
351 | fDebugStream = new TTreeSRedirector("TRD.Resolution.root"); | |
352 | } | |
aaf47b30 | 353 | |
354 | //________________________________________________________ | |
355 | void AliTRDtrackingResolution::SetRecoParam(AliTRDrecoParam *r) | |
356 | { | |
357 | fReconstructor->SetRecoParam(r); | |
358 | } |