Added ITS Alignment interface to MillePede2 and related supermodule class
[u/mrichter/AliRoot.git] / ITS / AliITSAlignMille2.h
CommitLineData
7b85e477 1#ifndef ALIITSALIGNMILLE2_H
2#define ALIITSALIGNMILLE2_H
3/* Copyright(c) 2007-2009 , ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6
7/// \ingroup rec
8/// \class AliITSAlignMille2
9/// \brief Class for alignment of ITS
10//
11// Authors: Marcello Lunardon
12
13#include <TString.h>
14#include <TObject.h>
15#include "AliTrackPointArray.h"
16#include "AliITSAlignMille2Module.h"
17
18class AliMillePede2;
19class AliAlignObjParams;
20class TGeoManager;
21class TGeoHMatrix;
22//class AliITSAlignMille2Module;
23class AliTrackFitterRieman;
24class TVirtualFitter;
25// number of used objects
26
27#define ITSMILLE2_NPARCH 6
28#define ITSMILLE2_NLOCAL 5
29
30struct Mille2Data {
31 /// structure to store data for 2 LocalEquations (X and Z)
32 //
33 Int_t moduleIDX[10]; // max 10 hierarchy levels!!!
34 Int_t levFilled;
35 //
36 Double_t measX;
37 Double_t measZ;
38 Double_t sigmaX;
39 Double_t sigmaZ;
40 //
41 Double_t derlocX[ITSMILLE2_NLOCAL];
42 Double_t derlocZ[ITSMILLE2_NLOCAL];
43 //
44 Double_t dergloX[ITSMILLE2_NPARCH*10];
45 Double_t dergloZ[ITSMILLE2_NPARCH*10];
46};
47
48class AliITSAlignMille2: public TObject
49{
50 public:
51 enum {kNLocal=ITSMILLE2_NLOCAL,kNParCh=ITSMILLE2_NPARCH,
52 kMaxITSSensID=2197,kMaxITSSensVID=14300,kMinITSSupeModuleID=14336};
53 enum {kDOFTX,kDOFTY,kDOFTZ,kDOFPH,kDOFTH,kDOFPS};
54 //
55 public:
56 //
57 AliITSAlignMille2(const Char_t *configFilename="AliITSAlignMille.conf", Bool_t initmille=kTRUE);
58 virtual ~AliITSAlignMille2();
59 //
60 AliMillePede2* GetMillePede() const {return fMillepede;}
61
62 // geometry methods
63 Int_t GetModuleIndex(const Char_t *symname);
64 Int_t GetModuleIndex(UShort_t voluid);
65 UShort_t GetModuleVolumeID(const Char_t *symname);
66 UShort_t GetModuleVolumeID(Int_t index);
67 void SetParSigTranslations(double v) {fParSigTranslations = v;}
68 void SetParSigRotations(double v) {fParSigRotations = v;}
69 //
70 // configuration methods
71 void SetGeometryFileName(const Char_t* filename="geometry.root") { fGeometryFileName = filename; }
72 const Char_t* GetGeometryFileName() {return fGeometryFileName.Data();}
73 const Char_t* GetPreAlignmentFileName() {return fPreAlignmentFileName.Data();}
74 TClonesArray* GetPreAlignmentDeltas() const {return fPrealignment;}
75 void SetCurrentModule(Int_t id) {fCurrentModule = GetMilleModule(id);}
76 void PrintCurrentModuleInfo() const {if (fCurrentModule) fCurrentModule->Print();}
77 void Print(Option_t*) const;
78 Bool_t IsConfigured() const {return fIsConfigured;}
79 void SetRequiredPoint(Char_t* where, Int_t ndet, Int_t updw, Int_t nreqpts);
80 void SetUseGlobalDelta(Bool_t v=kTRUE) {fUseGlobalDelta = v;}
81 Bool_t GetUseGlobalDelta() const {return fUseGlobalDelta;}
82 //
83 // fitting methods
84 AliTrackFitterRieman *GetRiemanFitter() const {return fRieman;}
85 AliTrackPointArray *PrepareTrack(const AliTrackPointArray *track);
86 Int_t ProcessTrack(const AliTrackPointArray *track);
87 void InitTrackParams(int meth=1);
88 void SetMinNPtsPerTrack(Int_t pts=3) {fMinNPtsPerTrack=pts;}
89 void SetInitTrackParamsMeth(Int_t meth=1) {fInitTrackParamsMeth=meth;}
90 Bool_t InitRiemanFit();
91 Int_t InitModuleParams();
92 Int_t CheckCurrentTrack();
93 Bool_t CheckVolumeID(UShort_t voluid) const;
94 Int_t IsDefined(UShort_t voluid) const;
95 Int_t IsContained(UShort_t voluid) const;
96 Int_t CalcIntersectionPoint(Double_t *lpar, Double_t *gpar);
97 Int_t CalcDerivatives(Int_t paridx, Bool_t islpar);
98 Double_t* GetLocalIntersectionPoint() const {return (Double_t*)fPintLoc;}
99 Double_t* GetGlobalIntersectionPoint() const {return (Double_t*)fPintGlo;}
100 AliTrackPointArray *SortTrack(const AliTrackPointArray *atp);
101 void SetTemporaryExcludedModule(Int_t index) {fTempExcludedModule=index;}
102 Int_t GetTemporaryExcludedModule() const {return fTempExcludedModule;}
103 //
104 // Hierarchical contraints
105 void ConstrainModuleSubUnits(Int_t idm, Double_t val=0, UInt_t pattern=0xfffffff);
106 void ConstrainOrphans(Double_t val=0,UInt_t pattern=0xfffffff);
107 void ConstrainLinComb(const Int_t *modLst,const Float_t *wghLst, Int_t nmd, Double_t val=0, UInt_t pattern=0xfffffff);
108 //
109 void PostConstrainModuleSubUnitsMedian(Int_t idm, Double_t val=0, UInt_t pattern=0xfffffff);
110 void PostConstrainOrphansMedian(Double_t val=0, UInt_t pattern=0xfffffff);
111 //
112 // Double_t* GetModuleConstrDerivs(Int_t matRow,Int_t matCol, TGeoHMatrix &matLoc);
113 //
114 // millepede methods
115 void FixParameter(Int_t param, Double_t value);
116 void AddConstraint(Double_t *factor, Double_t value );
117 void InitGlobalParameters(Double_t *par);
118 void SetLocalDerivative(Int_t index, Double_t value) {fLocalDerivatives[index] = value;}
119 void SetGlobalDerivative(Int_t index, Double_t value) {fGlobalDerivatives[index] = value;}
120 //
121 Int_t GlobalFit(Double_t *parameters=0,Double_t *errors=0,Double_t *pulls=0);
122 void PrintGlobalParameters();
123 Double_t GetParError(Int_t iPar);
124 Int_t AddLocalEquation(Mille2Data &m);
125 void SetLocalEquations(const Mille2Data *marr, Int_t neq);
126 //
127 // fitting stuffs
128 AliTrackPointArray *GetCurrentTrack() {return fTrack;}
129 AliTrackPoint *GetCurrentCluster() {return &fCluster;}
130 void SetCurrentTrack(AliTrackPointArray *atp) {fTrack=atp;}
131 void SetCurrentCluster(AliTrackPoint &atp) {fCluster=atp;}
132
133 // geometry stuffs
134 Int_t GetNModules() const {return fNModules;}
135 Int_t GetCurrentModuleIndex() const {return fCurrentModule ? fCurrentModule->GetIndex():-1;}
136 TGeoHMatrix *GetCurrentModuleHMatrix() const {return fCurrentModule ? fCurrentModule->GetMatrix():0;}
137 Double_t *GetCurrentModuleTranslation() const {return fCurrentModule ? fCurrentModule->GetMatrix()->GetTranslation():0;}
138 Int_t GetCurrentModuleInternalIndex() const {return fCurrentModule ? fCurrentModule->GetUniqueID():-1;}
139 Int_t GetTotBadLocEqPoints() const {return fTotBadLocEqPoints;}
140 //
141 AliITSAlignMille2Module* GetMilleModuleByVID(UShort_t voluid) const; // get pointer to the defined supermodule
142 AliITSAlignMille2Module* GetMilleModule(Int_t id) const {return (AliITSAlignMille2Module*)fMilleModule[id];}
143 AliITSAlignMille2Module* GetCurrentModule() const {return fCurrentModule;}
144 AliITSAlignMille2Module* GetSuperModule(Int_t id) const {return (AliITSAlignMille2Module*)fSuperModule[id];}
145 //
146 // debug stuffs
147 Double_t *GetMeasLoc() const {return (Double_t*)fMeasLoc;}
148 Double_t *GetSigmaLoc() const {return (Double_t*)fSigmaLoc;}
149 Double_t GetBField() const {return fBField;}
150 Double_t *GetLocalInitParam() const {return (Double_t*)fLocalInitParam;}
151 Double_t *GetLocalInitParEr() const {return (Double_t*)fLocalInitParEr;}
152 Double_t GetLocalDX() const {return fDerivativeLoc[0];}
153 Double_t GetLocalDY() const {return fDerivativeLoc[1];}
154 Double_t GetLocalDZ() const {return fDerivativeLoc[2];}
155 Double_t GetLocalDif(int i) const {return fDerivativeLoc[i];}
156 Double_t GetParSigTranslations() const {return fParSigTranslations;}
157 Double_t GetParSigRotations() const {return fParSigRotations;}
158 Int_t GetPreAlignmentQualityFactor(Int_t index) const;// if not prealign. return -1
159 void SetBug(Int_t bug) {fBug=bug;} // 1:SSD inversion sens.18-19
160 static AliITSAlignMille2* GetInstance() {return fgInstance;}
161 //
162 private:
163 //
164 // configuration methods
165 Int_t LoadConfig(const Char_t *cfile="AliITSAlignMille.conf");
166 Int_t LoadSuperModuleFile(const Char_t *cfile="ITSMilleSuperModules.root");
167 void ResetLocalEquation();
168 void InitGeometry();
169 Int_t ApplyToGeometry();
170 //
171 // millepede methods
172 void Init(Int_t nGlobal, Int_t nLocal, Int_t nStdDev);
173 //
174 AliITSAlignMille2(const AliITSAlignMille2& rhs);
175 AliITSAlignMille2& operator=(const AliITSAlignMille2& rhs);
176 //
177 protected:
178 //
179 // millepede stuffs
180 AliMillePede2 *fMillepede; // Detector independent alignment class
181 Double_t fStartFac; // Initial value for chi2 cut
182 Double_t fResCutInitial; // Cut on residual for first iteration
183 Double_t fResCut; // Cut on residual for other iterations
184 Int_t fNGlobal; // Number of global parameters
185 Int_t fNLocal; // Number of local parameters
186 Int_t fNStdDev; // Number of standard deviations for chi2 cut
187 Bool_t fIsMilleInit; // Flag for initialization
188 Bool_t fSensorsIn; // Are sensors explicitly provieded by the conf file?
189 Double_t fParSigTranslations; // init sigma for transl. params [cm]
190 Double_t fParSigRotations; // init sigma for rot. params [deg]
191 //
192 // fitting stuffs
193 AliITSAlignMille2Module *fCurrentModule; // Current SuperModule index
194 AliTrackPointArray *fTrack; // pointer to current track
195 AliTrackPoint fCluster; // current cluster
196 Double_t *fGlobalDerivatives; // Array of global derivatives
197 Double_t fLocalDerivatives[kNLocal]; // Array of local deriv.
198 Double_t fLocalInitParam[kNLocal]; // Array with inital values for local parameters for current track
199 Double_t fLocalInitParEr[kNLocal][kNLocal];// Array with inital values for local parameters for current track
200 Double_t fModuleInitParam[kNParCh]; // Array with inital values for current module parameters (init geometry)
201 Double_t fPintLoc[3];
202 Double_t fPintLoc0[3];
203 Double_t fPintGlo[3];
204 Double_t fMeasLoc[3]; // current point local coordinates (the original ones)
205 Double_t fMeasGlo[3]; // current point glob. coord (AliTrackPoint)
206 Double_t fSigmaLoc[3]; // stdev current point
207 Double_t fSigmaFactor[3]; // multiplicative factor for cluster sigmaX,Y,Z
208 //
209 Double_t fDerivativeLoc[3]; // localXYZ deriv.
210 Int_t fMinNPtsPerTrack; // min number of points per track to accept it
211 Int_t fInitTrackParamsMeth; // method for track fit
212 Int_t fTotBadLocEqPoints; // total number of reject points because of bad EqLoc
213 AliTrackFitterRieman *fRieman; // riemann fitter for helices
214 //
215 // >> new members
216 Bool_t fUseGlobalDelta; // intetpret deltas as global
217 Bool_t fRequirePoints; // required points in specific layers
218 Int_t fNReqLayUp[6]; /// number of points required in layer[n] with Y>0
219 Int_t fNReqLayDown[6]; /// number of points required in layer[n] with Y<0
220 Int_t fNReqLay[6]; /// number of points required in layer[n]
221 Int_t fNReqDetUp[3]; /// number of points required in Detector[n] with Y>0
222 Int_t fNReqDetDown[3]; /// number of points required in Detector[n] with Y<0
223 Int_t fNReqDet[3]; /// number of points required in Detector[n]
224 Int_t fTempExcludedModule; /// single module temporary excluded from initial fit
225 // << new members
226 //
227 // geometry stuffs
228 TString fGeometryFileName; // Geometry file name
229 TString fPreAlignmentFileName; // file with prealigned objects
230 TGeoManager *fGeoManager;
231 Bool_t fIsConfigured;
232 TArrayS fPreAlignQF;
233 //
234 TClonesArray* fPrealignment; // array of prealignment global deltas
235 TObjArray fMilleModule; /// array of super modules to be aligned
236 TObjArray fSuperModule; /// array of super modules defined in supermodule file
237 Int_t fNModules; // number of defined modules from config file
238 Int_t fNSuperModules; /// number of custom supermodules in SM file
239 Bool_t fUsePreAlignment; // start from prealigned setup
240 Bool_t fUseSortedTracks; // default is kTRUE
241 Bool_t fBOn; // magentic field ON
242 Double_t fBField; // value of magnetic field
243 Int_t fBug; /// tag for temporary bug correction
244 //
245 static AliITSAlignMille2* fgInstance; // global pointer on itself
246 static Int_t fgInstanceID; // global counter of the instances
247 ClassDef(AliITSAlignMille2, 0)
248
249};
250
251#endif