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 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////
18 // === Class for fitting properties specific to pad regions ===
20 // For each pad size region a separate TLinearFitter object is assigned.
21 // Commonly used functions such as getting the center of a pad size
22 // region or visualization functions are provided. Also, choosing the
23 // segment and pad type is made easy due to different methods that
24 // can calculate these informations from other coordinates.
26 ////////////////////////////////////////////////////////////////////////////
28 #include "AliTPCFitPad.h"
30 ClassImp(AliTPCFitPad)
32 AliTPCFitPad::~AliTPCFitPad() {
40 AliTPCFitPad::AliTPCFitPad(Int_t ndim, const char* formula, Option_t* opt) :
41 AliTPCCalPadRegion("", ""),
47 // Constructor. The parameters are used for generating new TLinearFitter
48 // objects and are described in its documentation.
52 AliTPCFitPad& AliTPCFitPad::operator=(const AliTPCFitPad& rhs) {
54 // Assignment operator.
58 AliTPCCalPadRegion::operator=(rhs);
60 fFormula = rhs.fFormula;
66 void AliTPCFitPad::Add(AliTPCFitPad* fit) {
68 // Adds another AliTPCFitPad object to this object. The formula should be the
69 // same, though it won't be checked!
72 for (UInt_t iSegment = 0; iSegment < GetNSegments(); iSegment++) {
73 for (UInt_t iPadType = 0; iPadType < GetNPadTypes(); iPadType++) {
74 TLinearFitter* fitter = fit->GetFitterSimple(iSegment, iPadType);
75 // parameter workaround == kTRUE because it is not possible to add another
76 // TLinearFitter object to a "virgin" one. Thus a dummy data point is added
77 // and cleared again immediately afterwards. Due to a broken TLinearFitter
78 // copy constructor this is a necessary workaround.
80 cout << "TLinearFitter::Add called for " << iSegment << ", " << iPadType << endl;
81 GetFitter(iSegment, iPadType, kTRUE)->Add(fitter);
87 TLinearFitter* AliTPCFitPad::GetFitterSimple(UInt_t segment, UInt_t padType) {
89 // This method returns the fitter corresponding to segment and pad type.
90 // In contrast to GetFitter() no fitter will be created, if it does
91 // not exist, but a null pointer is returned.
94 return (TLinearFitter*)(GetObject(segment, padType));
97 TLinearFitter* AliTPCFitPad::GetFitter(UInt_t segment, UInt_t padType, Bool_t workaround) {
99 // This method returns the fitter corresponding
100 // to segment and pad type.
101 // If the fitter doesn't exist yet, it will be created on the fly
102 // according to the parameters passed to the constructor.
104 // The workaround parameter should always be kFALSE. (It is only used by the Add method.)
107 TLinearFitter* fitter = GetFitterSimple(segment, padType);
109 SetObject(new TLinearFitter(fNdim, fFormula, fOpt), segment, padType);
110 fitter = (TLinearFitter*)(GetObject(segment, padType));
113 for (Int_t i = 0; i < fNdim; i++) x[i] = 3.141592;
114 fitter->AddPoint(x, 31.41592);
115 fitter->ClearPoints();
116 //cout << "workaround called for " << segment << ", " << padType << endl;
122 Int_t AliTPCFitPad::Evaluate(Bool_t robust, Double_t frac) {
124 // Evaluates all fitters. Returns 0 if successful, 1 in case of an error.
125 // If the robust option is set to kTRUE a robust fit is performed with frac as
126 // the minimal fraction of good points (see TLinearFitter::EvalRobust for details).
127 // Beware: Robust fitting is much slower!
130 Int_t returnCode = 0;
131 for (UInt_t iSegment = 0; iSegment < GetNSegments(); iSegment++) {
132 for (UInt_t iPadType = 0; iPadType < GetNPadTypes(); iPadType++) {
133 if (TLinearFitter* fitter = GetFitterSimple(iSegment, iPadType)) {
134 Int_t status = robust ? fitter->EvalRobust(frac) : fitter->Eval();
137 Error("Evaluate", "Error in evaluation of fitter in segment %d, pad region %d", iSegment, iPadType);