]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSAlignMille.h
Correction of the Z position of Q2 quadrupole from Chiara Oppedisano
[u/mrichter/AliRoot.git] / ITS / AliITSAlignMille.h
1 #ifndef ALIITSALIGNMILLE_H
2 #define ALIITSALIGNMILLE_H
3 /* Copyright(c) 2007-2009 , ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8
9 /// \ingroup rec
10 /// \class AliITSAlignMille
11 /// \brief Class for alignment of ITS
12 //
13 // Authors: Marcello Lunardon
14
15 #include <TString.h>
16 #include <TObject.h>
17 #include <TArray.h>
18 #include "AliTrackPointArray.h"
19
20 class AliMillepede;
21 class AliAlignObjParams;
22 class TGeoManager;
23 class TGeoHMatrix;
24 class AliITSAlignMilleModule;
25 class AliTrackFitterRieman;
26
27 // number of used objects
28 #define ITSMILLE_NDETELEM    2198
29 #define ITSMILLE_NPARCH         6
30 #define ITSMILLE_NLOCAL         5
31 #define ITSMILLE_NSTDEV         3       
32
33
34 struct MilleData {
35   /// structure to store data for 2 LocalEquations (X and Z)
36   Double_t measX;
37   Double_t sigmaX;
38   Int_t    idxlocX[ITSMILLE_NLOCAL];
39   Double_t derlocX[ITSMILLE_NLOCAL];
40   Int_t    idxgloX[ITSMILLE_NPARCH];  
41   Double_t dergloX[ITSMILLE_NPARCH];
42
43   Double_t measZ;
44   Double_t sigmaZ;
45   Int_t    idxlocZ[ITSMILLE_NLOCAL];
46   Double_t derlocZ[ITSMILLE_NLOCAL];
47   Int_t    idxgloZ[ITSMILLE_NPARCH];  
48   Double_t dergloZ[ITSMILLE_NPARCH];
49 };
50
51 class AliITSAlignMille:public TObject
52 {
53 public:
54   AliITSAlignMille(const Char_t *configFilename="AliITSAlignMille.conf", Bool_t initmille=kTRUE);
55   virtual ~AliITSAlignMille();
56   
57   // geometry methods 
58   Int_t     GetModuleIndex(const Char_t *symname);
59   Int_t     GetModuleIndex(UShort_t voluid);
60   UShort_t  GetModuleVolumeID(const Char_t *symname);
61   UShort_t  GetModuleVolumeID(Int_t index);
62   void      SetCurrentModule(Int_t index); 
63   void      SetCurrentSensitiveModule(Int_t index); // set as current the SENSITIVE module with index 'index'
64
65   // configuration methods
66   void      SetGeometryFileName(const Char_t* filename="geometry.root") 
67     { fGeometryFileName = filename; }
68   const Char_t* GetGeometryFileName() {return fGeometryFileName.Data();}
69   const Char_t* GetPreAlignmentFileName() {return fPreAlignmentFileName.Data();}
70   void      PrintCurrentModuleInfo();
71   void      Print(Option_t*) const;
72   Bool_t    IsConfigured() const {return fIsConfigured;}
73   void      SetRequiredPoint(Char_t* where, Int_t ndet, Int_t updw, Int_t nreqpts);
74   
75   // fitting methods
76   void      SetMinNPtsPerTrack(Int_t pts=3) {fMinNPtsPerTrack=pts;}
77   Int_t     ProcessTrack(AliTrackPointArray *track);
78   AliTrackPointArray *PrepareTrack(AliTrackPointArray *track); // build a new AliTrackPointArray with selected conditions
79   void      InitTrackParams(int meth=1);
80   Bool_t    InitRiemanFit();
81   AliTrackFitterRieman  *GetRiemanFitter() const {return fRieman;}
82   Int_t     InitModuleParams();
83   Int_t     CheckCurrentTrack();
84   Bool_t    CheckVolumeID(UShort_t voluid) const; // checks voluid for sensitive volumes
85   Int_t     IsDefined(UShort_t voluid) const;
86   Int_t     IsContained(UShort_t voluid) const;
87   Int_t     CalcIntersectionPoint(Double_t *lpar, Double_t *gpar);
88   Int_t     CalcDerivatives(Int_t paridx, Bool_t islpar);
89   Double_t* GetLocalIntersectionPoint() {return fPintLoc;}
90   Double_t* GetGlobalIntersectionPoint() {return fPintGlo;}
91   void      SetInitTrackParamsMeth(Int_t meth=1) {fInitTrackParamsMeth=meth;}
92   AliTrackPointArray *SortTrack(AliTrackPointArray *atp);
93   void      SetTemporaryExcludedModule(Int_t index) {fTempExcludedModule=index;}
94
95   // millepede methods
96   void      FixParameter(Int_t param, Double_t value);
97   void      AddConstraint(Double_t *factor, Double_t value );
98   void      InitGlobalParameters(Double_t *par);   
99   void      SetLocalDerivative(Int_t index, Double_t value) 
100     {fLocalDerivatives[index] = value;}
101   void      SetGlobalDerivative(Int_t index, Double_t value) 
102     {fGlobalDerivatives[index] = value;}  
103   void      LocalFit(Int_t iTrack, Double_t *lTrackParam, Int_t lSingleFit);
104   void      GlobalFit(Double_t *parameters,Double_t *errors,Double_t *pulls);
105   void      PrintGlobalParameters();
106   Double_t  GetParError(Int_t iPar);
107   Int_t     AddLocalEquation(MilleData &m);
108   void      SetLocalEquations(MilleData *m, Int_t neq);
109   
110   // fitting stuffs
111   AliTrackPointArray *GetCurrentTrack() {return fTrack;}
112   AliTrackPoint      *GetCurrentCluster() {return &fCluster;}
113   void      SetCurrentTrack(AliTrackPointArray *atp) {fTrack=atp;}
114   void      SetCurrentCluster(AliTrackPoint &atp) {fCluster=atp;}
115
116   // geometry stuffs
117   Int_t     GetNModules() const {return fNModules;}
118   Int_t     GetCurrentModuleIndex() const {return fCurrentModuleIndex;}
119   TGeoHMatrix *GetCurrentModuleHMatrix() {return fCurrentModuleHMatrix;}
120   Double_t *GetCurrentModuleTranslation() {return fCurrentModuleTranslation;}
121   Int_t     GetCurrentModuleInternalIndex() const {return fCurrentModuleInternalIndex;}
122   Int_t    *GetModuleIndexArray() {return fModuleIndex;}
123   Int_t    *GetProcessedPoints() {return fProcessedPoints;}
124   Int_t     GetTotBadLocEqPoints() const {return fTotBadLocEqPoints;}
125   AliITSAlignMilleModule  *GetMilleModule(UShort_t voluid); // get pointer to the defined supermodule
126   AliITSAlignMilleModule  *GetCurrentModule();
127   UShort_t *GetModuleVolumeIDArray() {return fModuleVolumeID;}
128
129   // debug stuffs
130   Double_t  *GetMeasLoc() { return fMeasLoc;}
131   Double_t  *GetSigmaLoc() { return fSigmaLoc;}
132   Double_t   GetBField() const {return fBField;}
133   Double_t  *GetLocalInitParam() {return fLocalInitParam;}
134   Double_t   GetLocalDX() const {return fDerivativeXLoc;}
135   Double_t   GetLocalDZ() const {return fDerivativeZLoc;}
136   Double_t   GetParSigTranslations() const {return fParSigTranslations;}
137   Double_t   GetParSigRotations() const {return fParSigRotations;}
138   Int_t      GetPreAlignmentQualityFactor(Int_t index); // if not prealign. return -1
139   void       SetBug(Int_t bug) {fBug=bug;} // 1:SSD inversion sens.18-19
140
141  private:
142
143   // configuration methods
144   Int_t     LoadConfig(const Char_t *cfile="AliITSAlignMille.conf");
145   Int_t     LoadSuperModuleFile(const Char_t *cfile="ITSMilleSuperModules.root");
146   void      ResetLocalEquation();
147   void      InitGeometry();
148   Int_t     ApplyToGeometry();
149
150   // millepede methods
151   void      Init(Int_t nGlobal, Int_t nLocal, Int_t nStdDev);
152
153   // millepede stuffs
154   AliMillepede *fMillepede;   ///< Detector independent alignment class
155   static Int_t  fgNParCh;      ///< Number of degrees of freedom per chamber
156   static Int_t  fgNDetElem;    ///< Total number of detection elements
157   Double_t      fStartFac;      ///< Initial value for chi2 cut 
158                               ///< if > 1 Iterations in AliMil. are turned on
159   Double_t      fResCutInitial; ///< Cut on residual for first iteration
160   Double_t      fResCut;        ///< Cut on residual for other iterations 
161   Int_t         fNGlobal;       ///< Number of global parameters
162   Int_t         fNLocal;        ///< Number of local parameters
163   Int_t         fNStdDev;       ///< Number of standard deviations for chi2 cut
164   Bool_t        fIsMilleInit;  ///
165   Double_t      fParSigTranslations; ///< init sigma for transl. params [cm]
166   Double_t      fParSigRotations; ///< init sigma for rot. params [deg]
167
168   // fitting stuffs
169   AliTrackPointArray *fTrack;       ///< pointer to current track 
170   AliTrackPoint fCluster;           ///< current cluster
171   Double_t     *fGlobalDerivatives;   ///< Array of global derivatives
172   Double_t      fLocalDerivatives[ITSMILLE_NLOCAL]; ///< Array of local deriv.
173   Double_t      fLocalInitParam[ITSMILLE_NLOCAL];   ///< Array with inital values for local parameters for current track
174   Double_t      fModuleInitParam[ITSMILLE_NPARCH];  ///< Array with inital values for current module parameters (init geometry)
175   Double_t      fPintLoc[3]; ///
176   Double_t      fPintLoc0[3]; ///
177   Double_t      fPintGlo[3]; ///
178   Double_t      fMeasLoc[3]; // current point local coordinates (the original ones)
179   Double_t      fMeasGlo[3]; // current point glob. coord (AliTrackPoint)
180   Double_t      fSigmaLoc[3]; // stdev current point
181   Double_t      fSigmaXfactor; ///
182   Double_t      fSigmaZfactor; ///
183   AliAlignObjParams *fTempAlignObj; ///
184   Double_t      fDerivativeXLoc; // localX deriv.
185   Double_t      fDerivativeZLoc; // localZ deriv.
186   Int_t         fMinNPtsPerTrack; ///
187   Int_t         fInitTrackParamsMeth; ///
188   Int_t        *fProcessedPoints; /// array of statistics of used points per module
189   Int_t         fTotBadLocEqPoints; /// total number of reject points because of bad EqLoc
190   AliTrackFitterRieman *fRieman; /// riemann fitter for helices
191   Bool_t        fRequirePoints;  // required points in specific layers
192   Int_t         fNReqLayUp[6];    /// number of points required in layer[n] with Y>0
193   Int_t         fNReqLayDown[6];  /// number of points required in layer[n] with Y<0
194   Int_t         fNReqLay[6];      /// number of points required in layer[n] 
195   Int_t         fNReqDetUp[3];    /// number of points required in Detector[n] with Y>0
196   Int_t         fNReqDetDown[3];  /// number of points required in Detector[n] with Y<0
197   Int_t         fNReqDet[3];      /// number of points required in Detector[n]
198   Int_t         fTempExcludedModule; /// single module temporary excluded from initial fit
199
200   // geometry stuffs
201   TString       fGeometryFileName;  ///
202   TString       fPreAlignmentFileName;  ///
203   TGeoManager  *fGeoManager;        ///
204   Int_t         fCurrentModuleIndex;   /// SuperModule index
205   Int_t         fCurrentModuleInternalIndex;  /// SuperModule internal index
206   Int_t         fCurrentSensVolIndex;   /// Current point (sens. vol.) index
207   Double_t      fCurrentModuleTranslation[3]; ///
208   Int_t         fNModules;  /// number of defined modules from config file
209   Int_t         fModuleIndex[ITSMILLE_NDETELEM*2]; ///
210   UShort_t      fModuleVolumeID[ITSMILLE_NDETELEM*2];  ///
211   Bool_t        fFreeParam[ITSMILLE_NDETELEM*2][ITSMILLE_NPARCH];  ///
212   Bool_t        fUseLocalShifts; /// 
213   Bool_t        fUseSuperModules; /// 
214   Bool_t        fUsePreAlignment; /// 
215   Bool_t        fUseSortedTracks; /// default is kTRUE 
216   Bool_t        fBOn; /// magentic field ON
217   Double_t      fBField; /// value of magnetic field
218   Int_t         fNSuperModules; /// number of custom supermodules in SM file
219   TGeoHMatrix  *fCurrentModuleHMatrix; /// SuperModule matrix
220   Bool_t        fIsConfigured; ///
221   Int_t         fPreAlignQF[ITSMILLE_NDETELEM*2]; ///
222   Double_t      fSensVolSigmaXfactor[ITSMILLE_NDETELEM*2]; ///
223   Double_t      fSensVolSigmaZfactor[ITSMILLE_NDETELEM*2]; ///
224   Int_t         fBug; /// tag for temporary bug correction
225
226   AliITSAlignMilleModule *fMilleModule[ITSMILLE_NDETELEM*2]; /// array of super modules to be aligned
227
228   AliITSAlignMilleModule *fSuperModule[ITSMILLE_NDETELEM*2]; /// array of super modules defined in supermodule file
229
230   AliITSAlignMille(const AliITSAlignMille& rhs);
231   AliITSAlignMille& operator=(const AliITSAlignMille& rhs);
232
233
234   ClassDef(AliITSAlignMille, 0)
235
236 };
237
238 #endif