ROOT logo
#ifndef ALI_MILLEPEDE_H 
#define ALI_MILLEPEDE_H

/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id$ */

/// \class AliMillepede
/// \brief Class for detector alignment - modified C++ implementation of original
/// millepede package
//
//  Author: Javier Castillo

#include <TObject.h>
#include <TArrayI.h>
#include <TArrayD.h>

class AliMillepede : public TObject {

public: 
  /// Standard constructor
  AliMillepede();

  virtual ~AliMillepede( ); /// Destructor

  /// Initialization
  virtual Int_t InitMille(int nglo, int nloc, int nstd,			  
			  double lResCut, double lResCutInit);
  virtual Int_t GlobalFit(double par[], double error[], double pull[]);
  virtual Int_t SetGlobalParameters(double *param);
  virtual Int_t SetGlobalParameter(int iPar, double vPar);
  virtual Int_t SetParSigma(int iPar, double sigma);
  virtual Int_t SetNonLinear(int index);
  virtual Int_t SetGlobalConstraint(double dercs[], double rhs);
  virtual Int_t SetLocalEquation(double dergb[], double derlc[], double rmeas, double sigma);
  virtual Int_t LocalFit(int n, double localParams[], Bool_t bSingleFit);
                /// Get number of local equations
  virtual Int_t GetNLocalEquations() const {return fNLocalEquations;};
                /// Set number of local equations
  virtual void  SetNLocalEquations(int value) {fNLocalEquations = value;};
  virtual Int_t PrintGlobalParameters() const;
  virtual Int_t SetIterations (double cutfac);
  virtual Double_t GetParError(int iPar) const;

private:

// Max. dimensions

  static const int fgkMaxGlobalPar  = 1000; ///< Max. number of global parameters
  static const int fgkMaxLocalPar   = 20;   ///< Max. number of local parameters
  static const int fgkMaxGloCsts    = 20;   ///< Max. number of constraint equations
  static const int fgkMaxGloPC	    = 1020; ///< fgkMaxGlobalPar+fgkMaxGloCsts


// Private methods 

  // Double_t GetParCorrelation(int i, int j);

  int   SpmInv(double v[][fgkMaxGloPC], double b[], int n);
  int   SpmInv(double v[][fgkMaxLocalPar], double b[], int n);
  int SpAVAt(double v[][fgkMaxLocalPar], double a[][fgkMaxLocalPar], double w[][fgkMaxGlobalPar], int n, int m);
  int SpAX(double a[][fgkMaxLocalPar], double x[], double y[], int n, int m);
  double Chi2DoFLim(int n, int nd);

// Matrices

  double fMatCGlo[fgkMaxGloPC][fgkMaxGloPC];            ///< Matrix C global
  double fMatCLoc[fgkMaxLocalPar][fgkMaxLocalPar];      ///< Matrix C local
  double fMatCGloLoc[fgkMaxGlobalPar][fgkMaxLocalPar];  ///< Rectangular matrix C g*l
  double fMatCGloCorr[fgkMaxGlobalPar][fgkMaxGlobalPar];///< Correction of matrix C global
  double fMatDerConstr[fgkMaxGloCsts][fgkMaxGlobalPar]; ///< Constrained derivatives

// Vectors and useful variables

  double fDiagCGlo[fgkMaxGloPC];        ///< Initial diagonal elements of C global matrix
  double fVecBGlo[fgkMaxGloPC];         ///< Vector B global (parameters) 
  double fVecBGloCorr[fgkMaxGlobalPar]; ///< Correction of vector B global
  double fVecBLoc[fgkMaxLocalPar];      ///< Vector B local (parameters) 

  double fInitPar[fgkMaxGlobalPar];    ///< Initial global parameters
  double fDeltaPar[fgkMaxGlobalPar];   ///< Variation of global parameters 
  double fSigmaPar[fgkMaxGlobalPar];   ///< Sigma of allowed variation of global parameter 

  double fLagMult[fgkMaxGloCsts];   ///< Lagrange multipliers of constrained equations

  Bool_t fIsNonLinear[fgkMaxGlobalPar]; ///< Flag for non linear parameters
  int   fGlo2CGLRow[fgkMaxGlobalPar];   ///< Global parameter to row in "used" g*l matrix
  int   fCGLRow2Glo[fgkMaxGlobalPar];   ///< Row in "used" g*l matrix to global parameter 

  TArrayI fIndexLocEq;  ///< Table of parameter indexes in local equation 
  TArrayD fDerivLocEq;  ///< Table of local equation derivatives wrt. parameter 
  TArrayI fIndexAllEqs; ///< Index in all loc. eq. storage for iterations
  TArrayD fDerivAllEqs; ///< derivative in all loc. eq. storage for iterations
  TArrayI fLocEqPlace;  ///< Loc. Eq. position in AllEqs storage

  Int_t fNIndexLocEq;   ///< Number of entries in fIndexLocEq
  Int_t fNDerivLocEq;   ///< Number of entries in fDerivLocEq
  Int_t fNIndexAllEqs;  ///< Number of entries in fIndexAllEqs
  Int_t fNDerivAllEqs;  ///< Number of entries in fDerivAllEqs
  Int_t fNLocEqPlace;   ///< Number of entries in fLocEqPlace
  

  int    fNLocalEquations;       ///< Number of local equations 
  double fResCutInit;            ///< Cut in residual for first iterartion
  double fResCut;                ///< Cut in residual for other iterartiona

  double fChi2CutFactor;         ///< Cut factor for chi2 cut to accept local fit 
  double fChi2CutRef;            ///< Reference cut for chi2 cut to accept local fit 

  int fIter;                   ///< Current iteration
  int fMaxIter;                ///< Maximum number of iterations
  int fNStdDev;                ///< Number of standard deviations for chi2 cut 
  int fNGlobalConstraints;     ///< Number of constraint equations
  int fNLocalFits;             ///< Number of local fits
  int fNLocalFitsRejected;     ///< Number of local fits rejected
  int fNGlobalPar;             ///< Number of global parameters
  int fNLocalPar;              ///< Number of local parameters

  ClassDef(AliMillepede, 1)  // Millepede Class
};

#endif



 AliMillepede.h:1
 AliMillepede.h:2
 AliMillepede.h:3
 AliMillepede.h:4
 AliMillepede.h:5
 AliMillepede.h:6
 AliMillepede.h:7
 AliMillepede.h:8
 AliMillepede.h:9
 AliMillepede.h:10
 AliMillepede.h:11
 AliMillepede.h:12
 AliMillepede.h:13
 AliMillepede.h:14
 AliMillepede.h:15
 AliMillepede.h:16
 AliMillepede.h:17
 AliMillepede.h:18
 AliMillepede.h:19
 AliMillepede.h:20
 AliMillepede.h:21
 AliMillepede.h:22
 AliMillepede.h:23
 AliMillepede.h:24
 AliMillepede.h:25
 AliMillepede.h:26
 AliMillepede.h:27
 AliMillepede.h:28
 AliMillepede.h:29
 AliMillepede.h:30
 AliMillepede.h:31
 AliMillepede.h:32
 AliMillepede.h:33
 AliMillepede.h:34
 AliMillepede.h:35
 AliMillepede.h:36
 AliMillepede.h:37
 AliMillepede.h:38
 AliMillepede.h:39
 AliMillepede.h:40
 AliMillepede.h:41
 AliMillepede.h:42
 AliMillepede.h:43
 AliMillepede.h:44
 AliMillepede.h:45
 AliMillepede.h:46
 AliMillepede.h:47
 AliMillepede.h:48
 AliMillepede.h:49
 AliMillepede.h:50
 AliMillepede.h:51
 AliMillepede.h:52
 AliMillepede.h:53
 AliMillepede.h:54
 AliMillepede.h:55
 AliMillepede.h:56
 AliMillepede.h:57
 AliMillepede.h:58
 AliMillepede.h:59
 AliMillepede.h:60
 AliMillepede.h:61
 AliMillepede.h:62
 AliMillepede.h:63
 AliMillepede.h:64
 AliMillepede.h:65
 AliMillepede.h:66
 AliMillepede.h:67
 AliMillepede.h:68
 AliMillepede.h:69
 AliMillepede.h:70
 AliMillepede.h:71
 AliMillepede.h:72
 AliMillepede.h:73
 AliMillepede.h:74
 AliMillepede.h:75
 AliMillepede.h:76
 AliMillepede.h:77
 AliMillepede.h:78
 AliMillepede.h:79
 AliMillepede.h:80
 AliMillepede.h:81
 AliMillepede.h:82
 AliMillepede.h:83
 AliMillepede.h:84
 AliMillepede.h:85
 AliMillepede.h:86
 AliMillepede.h:87
 AliMillepede.h:88
 AliMillepede.h:89
 AliMillepede.h:90
 AliMillepede.h:91
 AliMillepede.h:92
 AliMillepede.h:93
 AliMillepede.h:94
 AliMillepede.h:95
 AliMillepede.h:96
 AliMillepede.h:97
 AliMillepede.h:98
 AliMillepede.h:99
 AliMillepede.h:100
 AliMillepede.h:101
 AliMillepede.h:102
 AliMillepede.h:103
 AliMillepede.h:104
 AliMillepede.h:105
 AliMillepede.h:106
 AliMillepede.h:107
 AliMillepede.h:108
 AliMillepede.h:109
 AliMillepede.h:110
 AliMillepede.h:111
 AliMillepede.h:112
 AliMillepede.h:113
 AliMillepede.h:114
 AliMillepede.h:115
 AliMillepede.h:116
 AliMillepede.h:117
 AliMillepede.h:118
 AliMillepede.h:119
 AliMillepede.h:120
 AliMillepede.h:121
 AliMillepede.h:122
 AliMillepede.h:123
 AliMillepede.h:124
 AliMillepede.h:125
 AliMillepede.h:126