]>
Commit | Line | Data |
---|---|---|
98937d93 | 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 | // Implementation of the derived class for track residuals | |
18 | // based on Chi2 minimization | |
19 | // | |
20 | //----------------------------------------------------------------- | |
21 | ||
93e1dfe1 | 22 | #include <TVirtualFitter.h> |
98937d93 | 23 | #include <TGeoMatrix.h> |
24 | ||
25 | #include "AliAlignObj.h" | |
26 | #include "AliTrackPointArray.h" | |
27 | #include "AliTrackResidualsChi2.h" | |
28 | ||
a4ef2f82 | 29 | void TrackResidualsChi2Fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *x, Int_t iflag); |
46ae650f | 30 | |
93e1dfe1 | 31 | |
98937d93 | 32 | ClassImp(AliTrackResidualsChi2) |
33 | ||
93e1dfe1 | 34 | |
98937d93 | 35 | //______________________________________________________________________________ |
a4ef2f82 | 36 | void TrackResidualsChi2Fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag) |
98937d93 | 37 | { |
38 | // This function is called by minuit | |
39 | // The corresponding member method is called | |
40 | // using SetObjectFit/GetObjectFit methods of TMinuit | |
93e1dfe1 | 41 | AliTrackResidualsChi2* dummy = (AliTrackResidualsChi2 *)TVirtualFitter::GetFitter()->GetObjectFit(); |
98937d93 | 42 | dummy->Chi2(npar, gin, f, par, iflag); |
43 | } | |
44 | ||
45 | //______________________________________________________________________________ | |
46 | Bool_t AliTrackResidualsChi2::Minimize() | |
47 | { | |
48 | // Implementation of Chi2 based minimization | |
49 | // of track residuala sum | |
93e1dfe1 | 50 | // |
51 | // CHOLM: Modified to use the TVirtualFitter interface only. This | |
52 | // makes it possible other fitters than TMinuit (say TMinuit2, | |
53 | // TFumili) by simply changing ones configuration file, or setting | |
54 | // it up in a script. Much more robust and flexible. | |
46ae650f | 55 | Double_t arglist[10]; |
56 | Int_t ierflg = 0; | |
93e1dfe1 | 57 | TVirtualFitter *fitter = TVirtualFitter::Fitter(this,6); //initialize TMinuit |
46ae650f | 58 | arglist[0] = -1; |
93e1dfe1 | 59 | ierflg = fitter->ExecuteCommand("SET PRINT", arglist, 1); |
46ae650f | 60 | |
a4ef2f82 | 61 | fitter->SetFCN(TrackResidualsChi2Fcn); |
98937d93 | 62 | |
98937d93 | 63 | arglist[0] = 1; |
93e1dfe1 | 64 | ierflg = fitter->ExecuteCommand("SET ERR", arglist ,1); |
98937d93 | 65 | |
66 | // Set starting values and step sizes for parameters | |
46ae650f | 67 | Double_t pars[6] = {0,0,0,0,0,0}; |
68 | Double_t step[6] = {0.0001,0.0001,0.0001,0.0001,0.0001,0.0001}; | |
93e1dfe1 | 69 | ierflg = fitter->SetParameter(0, "dx", pars[0], step[0], 0,0); |
70 | ierflg = fitter->SetParameter(1, "dy", pars[1], step[1], 0,0); | |
71 | ierflg = fitter->SetParameter(2, "dz", pars[2], step[2], 0,0); | |
72 | ierflg = fitter->SetParameter(3, "psi", pars[3], step[3], 0,0); | |
73 | ierflg = fitter->SetParameter(4, "theta", pars[4], step[4], 0,0); | |
74 | ierflg = fitter->SetParameter(5, "phi", pars[5], step[5], 0,0); | |
98937d93 | 75 | |
76 | // Now ready for minimization step | |
77 | arglist[0] = 500; | |
78 | arglist[1] = 1.; | |
93e1dfe1 | 79 | fitter->ExecuteCommand("MIGRAD", arglist ,2); |
98937d93 | 80 | |
81 | // Print results | |
82 | Double_t amin,edm,errdef; | |
83 | Int_t nvpar,nparx,icstat; | |
93e1dfe1 | 84 | icstat = fitter->GetStats(amin,edm,errdef,nvpar,nparx); |
46ae650f | 85 | fChi2 = amin; fNdf -= nvpar; |
98937d93 | 86 | |
87 | return kTRUE; | |
88 | } | |
89 | ||
90 | //______________________________________________________________________________ | |
91 | void AliTrackResidualsChi2::Chi2(Int_t & /* npar */, Double_t * /* gin */, Double_t &f, Double_t *par, Int_t /* iflag */) | |
92 | { | |
93 | // Chi2 function to be minimized | |
94 | // Sums all the track residuals | |
95 | Double_t chi2 = 0; | |
96 | ||
97 | fAlignObj->SetPars(par[0],par[1],par[2],par[3],par[4],par[5]); | |
98937d93 | 98 | |
99 | AliTrackPoint p1,p2; | |
46ae650f | 100 | |
101 | Bool_t count = kFALSE; | |
102 | if (fNdf == 0) count = kTRUE; | |
98937d93 | 103 | |
104 | for (Int_t itrack = 0; itrack < fLast; itrack++) { | |
105 | if (!fVolArray[itrack] || !fTrackArray[itrack]) continue; | |
106 | for (Int_t ipoint = 0; ipoint < fVolArray[itrack]->GetNPoints(); ipoint++) { | |
107 | fVolArray[itrack]->GetPoint(p1,ipoint); | |
46ae650f | 108 | fAlignObj->Transform(p1); |
98937d93 | 109 | fTrackArray[itrack]->GetPoint(p2,ipoint); |
cc345ce3 | 110 | Float_t residual = p2.GetResidual(p1,kTRUE); |
46ae650f | 111 | chi2 += residual; |
112 | if (count) fNdf += 3; | |
98937d93 | 113 | } |
114 | } | |
115 | f = chi2; | |
116 | } |