1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
23 // Alex Bercuci <A.Bercuci@gsi.de> //
24 // Markus Fasel <M.Fasel@gsi.de> //
26 ///////////////////////////////////////////////////////////////////////////////
29 #include <TLinearFitter.h>
31 #include <TTreeStream.h>
35 #include "AliTRDseed.h"
36 #include "AliTRDcalibDB.h"
37 #include "AliTRDcluster.h"
38 #include "AliTRDReconstructor.h"
39 #include "AliTRDseedV1.h"
40 #include "AliTRDtrackerFitter.h"
44 ClassImp(AliTRDtrackerFitter)
46 //_________________________________________________________________________
47 AliTRDtrackerFitter::AliTRDtrackerFitter()
67 fRieman1 = new AliRieman(1000);
68 fRieman2 = new AliRieman(1000);
69 fFitterTC = new TLinearFitter(2,"hyp2");
70 fFitterT2 = new TLinearFitter(4,"hyp4");
71 fFitterTC->StoreData(kTRUE);
72 fFitterT2->StoreData(kTRUE);
75 //_________________________________________________________________________
76 AliTRDtrackerFitter::AliTRDtrackerFitter(const AliTRDtrackerFitter &f)
93 // Copy Constructor (performs a deep copy)
96 fRieman1 = new AliRieman(*f.fRieman1);
97 fRieman2 = new AliRieman(*f.fRieman2);
98 fFitterTC = new TLinearFitter(*f.fFitterTC);
99 fFitterT2 = new TLinearFitter(*f.fFitterT2);
100 fFitterTC->StoreData(kTRUE);
101 fFitterT2->StoreData(kTRUE);
104 //_________________________________________________________________________
105 AliTRDtrackerFitter::~AliTRDtrackerFitter()
117 //_________________________________________________________________________
118 AliTRDtrackerFitter &AliTRDtrackerFitter::operator=(const AliTRDtrackerFitter& fitter)
121 // Assignment operator using the copy Method of this class
129 //_________________________________________________________________________
130 void AliTRDtrackerFitter::Copy(TObject &f) const
134 // Performs a deep copy. Mainly used in the Assignment operator
137 AliTRDtrackerFitter &tf = (AliTRDtrackerFitter &) f;
141 tf.fFitterTC = new TLinearFitter(*fFitterTC);
144 tf.fFitterT2 = new TLinearFitter(*fFitterT2);
147 tf.fRieman1 = new AliRieman(*fRieman1);
150 tf.fRieman2 = new AliRieman(*fRieman2);
151 tf.fChi2TR = fChi2TR;
152 tf.fChi2TC = fChi2TC;
158 tf.fNlayers = fNlayers;
159 tf.fDebugStream = 0x0;
160 fFitterTC->StoreData(kTRUE);
161 fFitterT2->StoreData(kTRUE);
164 //_________________________________________________________________________
165 void AliTRDtrackerFitter::FitRieman(AliTRDcluster **cl, Int_t nLayers)
168 // Performs a Rieman Fit including 4 clusters (one in each layer)
171 for(Int_t i = 0; i < nLayers; i++)
172 fRieman1->AddPoint(cl[i]->GetX(), cl[i]->GetY(), cl[i]->GetZ(), 1, 10);
176 //_________________________________________________________________________
177 void AliTRDtrackerFitter::FitRieman(AliTRDseedV1 *cseed, Int_t *planes)
180 // Performs a Rieman fit using four respectively six seeds
181 // 2 times used: 1st with 4 parameters and Later in the full track
182 // fitting Part with 6 parameters
185 Int_t lplanes[] = {0, 1, 2, 3, 4, 5}, *tplanes;
192 tplanes = &lplanes[0];
195 for(Int_t iLayer = 0; iLayer < nplanes; iLayer++){
196 if(!cseed[tplanes[iLayer]].IsOK()) continue;
197 fRieman1->AddPoint(cseed[tplanes[iLayer]].GetX0(), cseed[tplanes[iLayer]].GetYfitR(0), cseed[tplanes[iLayer]].GetZProb(), 1, 10);
202 //_________________________________________________________________________
203 Double_t AliTRDtrackerFitter::FitHyperplane(AliTRDseedV1 *cseed
208 // performs a hyperplane fit
210 // Two linear fitters: one in which kz is fixed and one in which kz is a free parameter
211 // checking if values are acceptable and improves the fitresults
212 // Calculates curvature parameters and chisquares
213 // Return: likelihood value as a measurement for the seedquality
216 //const Int_t kMaxTimebins = 100; // Buffer
217 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
218 Int_t nTimeBins = cal->GetNumberOfTimeBins();
220 fFitterTC->ClearPoints();
221 fFitterT2->ClearPoints();
224 Double_t xref2 = (cseed[2].GetX0() + cseed[3].GetX0())/2;
226 for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
227 if (!cseed[iLayer].IsOK()) continue;
228 fHl[iLayer] = cseed[iLayer].GetTilt();
230 for (Int_t itime = 0; itime < nTimeBins; itime++) {
231 if (!cseed[iLayer].IsUsable(itime)) continue;
233 // X relative to the middle chamber
234 Double_t x = cseed[iLayer].GetX(itime) + cseed[iLayer].GetX0() - xref2;
235 Double_t y = cseed[iLayer].GetY(itime);
236 Double_t z = cseed[iLayer].GetZ(itime);
237 // ExB correction to the correction
241 Double_t x2 = cseed[iLayer].GetX(itime) + cseed[iLayer].GetX0();
242 Double_t t = 1.0 / (x2*x2 + y*y);
244 uvt[0] = 2.0 * x2 * uvt[1]; // u
245 uvt[2] = 2.0 * fHl[iLayer] * uvt[1];
246 uvt[3] = 2.0 * fHl[iLayer] * x * uvt[1];
247 uvt[4] = 2.0 * (y + fHl[iLayer]*z) * uvt[1];
248 Double_t error = 2.0 * 0.2 * uvt[1];
249 fFitterT2->AddPoint(uvt,uvt[4],error);
251 //Constrained fRieman1
252 z = cseed[iLayer].GetZ(itime);
253 uvt[0] = 2.0 * x2 * t; // u
254 uvt[1] = 2.0 * fHl[iLayer] * x2 * uvt[1];
255 uvt[2] = 2.0 * (y + fHl[iLayer] * (z - zFitter)) * t; // parameter that is most propably wrong
256 fFitterTC->AddPoint(uvt,uvt[2],error);
257 fRieman2->AddPoint(x2,y,z,1,10);
265 Double_t rpolz0 = fFitterT2->GetParameter(3);
266 Double_t rpolz1 = fFitterT2->GetParameter(4);
268 // Linear fitter - not possible to make boundaries
269 // Do not accept non possible z and dzdx combinations
270 Bool_t acceptablez = kTRUE;
271 for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
272 if(!cseed[iLayer].IsOK()) continue;
273 Double_t zT2 = rpolz0 + rpolz1 * (cseed[iLayer].GetX0() - xref2);
274 if (TMath::Abs(cseed[iLayer].GetZProb() - zT2) > cseed[iLayer].GetPadLength() * 0.5 + 1.0) acceptablez = kFALSE;
277 fFitterT2->FixParameter(3,fRieman1->GetZat(xref2));
278 fFitterT2->FixParameter(4,fRieman1->GetDZat(xref2));
280 fFitterT2->ReleaseParameter(3);
281 fFitterT2->ReleaseParameter(4);
282 rpolz0 = fFitterT2->GetParameter(3);
283 rpolz1 = fFitterT2->GetParameter(4);
286 fChi2TR = fFitterT2->GetChisquare() / Float_t(npointsT);
287 fChi2TC = fFitterTC->GetChisquare() / Float_t(npointsT);
288 Double_t polz1c = fFitterTC->GetParameter(2);
289 Double_t polz0c = polz1c * xref2;
290 Double_t aC = fFitterTC->GetParameter(0);
291 Double_t bC = fFitterTC->GetParameter(1);
292 fCC = aC / TMath::Sqrt(bC * bC + 1.0); // Curvature
293 Double_t aR = fFitterT2->GetParameter(0);
294 Double_t bR = fFitterT2->GetParameter(1);
295 Double_t dR = fFitterT2->GetParameter(2);
296 fCR = 1.0 + bR*bR - dR*aR;
299 fDca = -dR / (TMath::Sqrt(1.0 + bR*bR - dR*aR) + TMath::Sqrt(1.0 + bR*bR));
300 fCR = aR / TMath::Sqrt(fCR);
304 Double_t chi2ZT2 = 0.0;
305 Double_t chi2ZTC = 0.0;
306 for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
307 if(!cseed[iLayer].IsOK()) continue;
308 Double_t zT2 = rpolz0 + rpolz1 * (cseed[iLayer].GetX0() - xref2);
309 Double_t zTC = polz0c + polz1c * (cseed[iLayer].GetX0() - xref2);
310 chi2ZT2 += TMath::Abs(cseed[iLayer].GetMeanz() - zT2);
311 chi2ZTC += TMath::Abs(cseed[iLayer].GetMeanz() - zTC);
313 chi2ZT2 /= TMath::Max((fNlayers - 3.0),1.0);
314 chi2ZTC /= TMath::Max((fNlayers - 3.0),1.0);
317 AliTRDseedV1::FitRiemanTilt(cseed, kTRUE);
318 Float_t sumdaf = 0.0;
319 for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
320 if(!cseed[iLayer].IsOK()) continue;
321 sumdaf += TMath::Abs((cseed[iLayer].GetYfit(1) - cseed[iLayer].GetYref(1))/ cseed[iLayer].GetSigmaY2());
323 sumdaf /= Float_t (fNlayers - 2.0);
326 Double_t likezf = TMath::Exp(-chi2ZF * 0.14);
327 Double_t likechi2C = TMath::Exp(-fChi2TC * 0.677);
328 Double_t likechi2TR = TMath::Exp(-fChi2TR * 0.78);
329 Double_t likeaf = TMath::Exp(-sumdaf * 3.23);
330 Double_t likef = likezf * likechi2TR * likeaf;
333 if(fDebugStream && AliTRDReconstructor::StreamLevel() >= 2){
334 TTreeSRedirector &treeStreamer = *fDebugStream;
335 treeStreamer << "FitHyperplane"
336 << "seed0.=" << &cseed[0]
337 << "seed1.=" << &cseed[1]
338 << "seed2.=" << &cseed[2]
339 << "seed3.=" << &cseed[3]
340 << "seed4.=" << &cseed[4]
341 << "seed5.=" << &cseed[5]
342 << "chi2TR=" << fChi2TR
343 << "chi2TC=" << fChi2TC
344 << "chi2ZT2=" << chi2ZT2
345 << "chi2ZTC=" << chi2ZTC
350 << "Polz0=" << polz0c
351 << "Polz1=" << polz1c
352 << "RPolz0=" << rpolz0
353 << "RPolz1=" << rpolz1
354 << "Likechi2C=" << likechi2C
355 << "Likechi2TR=" << likechi2TR
356 << "Likezf=" << likezf
357 << "Likeaf=" << likeaf
359 << "Rieman1.=" << fRieman1
360 << "Rieman2.=" << fRieman2
368 //_________________________________________________________________________
369 void AliTRDtrackerFitter::GetHyperplaneFitChi2(Double_t *chisquares) const
372 // Getter method returns the chisquares of the hyperplane fit
375 chisquares[0] = fChi2TR;
376 chisquares[1] = fChi2TC;
379 //_________________________________________________________________________
380 void AliTRDtrackerFitter::GetHyperplaneFitResults(Double_t *params) const
383 // Getter Method returning the Curvature parameters of the hyperplane fit
391 //_________________________________________________________________________
392 void AliTRDtrackerFitter::Reset()
400 //fFitterTC->Clear();
401 //fFitterT2->Clear();