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