]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSAlignMille2.h
Changes to obey coding conventions (R. Shaoyan)
[u/mrichter/AliRoot.git] / ITS / AliITSAlignMille2.h
CommitLineData
7b85e477 1#ifndef ALIITSALIGNMILLE2_H
2#define ALIITSALIGNMILLE2_H
6526a72c 3
7b85e477 4/* Copyright(c) 2007-2009 , ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
057304f3 7/* $Id$ */
6526a72c 8//-----------------------------------------------------------------------------
7b85e477 9//
6526a72c 10// Interface to AliMillePede2 alignment class for the ALICE ITS detector
11//
12// ITS specific alignment class which interface to AliMillepede.
13// For each track ProcessTrack calculates the local and global derivatives
14// at each hit and fill the corresponding local equations. Provide methods for
15// fixing or constraining detection elements for best results.
16//
17// author M. Lunardon (thanks to J. Castillo), ruben.shahoyan@cern.ch
18//-----------------------------------------------------------------------------
7b85e477 19
20#include <TString.h>
21#include <TObject.h>
6526a72c 22#include <TGeoMatrix.h>
7b85e477 23#include "AliTrackPointArray.h"
24#include "AliITSAlignMille2Module.h"
25
45993b23 26class TArrayI;
27class TSystem;
28class TGeoManager;
29class TVirtualFitter;
7b85e477 30class AliMillePede2;
31class AliAlignObjParams;
7b85e477 32class AliTrackFitterRieman;
45993b23 33class AliITSAlignMille2Constraint;
34class AliITSAlignMille2ConstrArray;
35class AliITSresponseSDD;
7b85e477 36
37class AliITSAlignMille2: public TObject
38{
39 public:
6526a72c 40 enum {kNLocal=5,kMaxPoints=100,
41 kNParChGeom = AliITSAlignMille2Module::kMaxParGeom,
42 kNParCh = AliITSAlignMille2Module::kMaxParTot,
43 kMaxITSSensID=2197,kMaxITSSensVID=14300,kMinITSSupeModuleID=14336,kSDDoffsID=240};
7b85e477 44 //
6526a72c 45 protected:
46 struct Mille2Data { // structure to store data for 2 LocalEquations (X and Z)
47 enum {kMaxLev = 7};
45993b23 48 Double_t fMeasX, fMeasZ, fSigmaX, fSigmaZ; // measured coordinates/errors
49 Double_t fDerLocX[kNLocal], fDerLocZ[kNLocal]; // calculated local derivatives
50 Int_t fNModFilled, fNGlobFilled, fModuleID[kMaxLev]; // used module info
51 Int_t fParMilleID[AliITSAlignMille2Module::kMaxParTot*kMaxLev]; // param id's
52 Double_t fDerGloX[AliITSAlignMille2Module::kMaxParTot*kMaxLev]; // global derivatives in X
53 Double_t fDerGloZ[AliITSAlignMille2Module::kMaxParTot*kMaxLev]; // and Z
6526a72c 54 };
55 //
7b85e477 56 public:
57 //
6526a72c 58 AliITSAlignMille2(const Char_t *configFilename="AliITSAlignMille.conf");
7b85e477 59 virtual ~AliITSAlignMille2();
60 //
6526a72c 61 AliMillePede2* GetMillePede() const {return fMillepede;}
62 //
63 // configuration methods
64 //
65 Int_t IsVIDDefined(UShort_t voluid) const;
66 Int_t IsVIDContained(UShort_t voluid) const;
67 Int_t IsSymDefined(const Char_t* name) const;
68 Int_t IsSymContained(const Char_t* name) const;
69 //
7b85e477 70 Int_t GetModuleIndex(const Char_t *symname);
71 Int_t GetModuleIndex(UShort_t voluid);
72 UShort_t GetModuleVolumeID(const Char_t *symname);
73 UShort_t GetModuleVolumeID(Int_t index);
6526a72c 74 AliITSAlignMille2Module* GetMilleModuleByVID(UShort_t voluid) const; // get pointer to the defined supermodule
75 AliITSAlignMille2Module* GetMilleModuleBySymName(const Char_t* symname) const; // get pointer to the defined supermodule
76 AliITSAlignMille2Module* GetMilleModuleIfContained(const Char_t* symname) const;
77 AliITSAlignMille2Module* GetMilleModule(Int_t id) const {return (AliITSAlignMille2Module*)fMilleModule[id];}
78 AliITSAlignMille2Module* GetCurrentModule() const {return fCurrentModule;}
79 AliITSAlignMille2Module* GetSuperModule(Int_t id) const {return (AliITSAlignMille2Module*)fSuperModule[id];}
80 //
81 AliAlignObjParams* GetPrealignedObject(const Char_t* symname) const;
82 AliAlignObjParams* GetConstrRefObject(const Char_t* symname) const;
83 //
84 void ConvertParamsToGlobal();
85 void ConvertParamsToLocal();
7b85e477 86 //
7b85e477 87 const Char_t* GetGeometryFileName() {return fGeometryFileName.Data();}
88 const Char_t* GetPreAlignmentFileName() {return fPreAlignmentFileName.Data();}
89 TClonesArray* GetPreAlignmentDeltas() const {return fPrealignment;}
6526a72c 90 AliITSresponseSDD* GetSDDPrecalibration() const {return fCorrectSDD;}
91 AliITSresponseSDD* GetSDDInit() const {return fInitialRecSDD;}
7b85e477 92 void PrintCurrentModuleInfo() const {if (fCurrentModule) fCurrentModule->Print();}
93 void Print(Option_t*) const;
94 Bool_t IsConfigured() const {return fIsConfigured;}
7b85e477 95 Bool_t GetUseGlobalDelta() const {return fUseGlobalDelta;}
6526a72c 96 Bool_t IsConstraintWrtRef() const {return fConstrRef!=0;}
97 Bool_t FixedOrphans() const;
98 //
99 // geometry stuffs
100 Int_t GetNModules() const {return fNModules;}
101 Int_t GetCurrentModuleIndex() const {return fCurrentModule ? fCurrentModule->GetIndex():-1;}
102 TGeoHMatrix *GetCurrentModuleHMatrix() const {return fCurrentModule ? fCurrentModule->GetMatrix():0;}
103 Double_t *GetCurrentModuleTranslation() const {return fCurrentModule ? fCurrentModule->GetMatrix()->GetTranslation():0;}
104 Int_t GetCurrentModuleInternalIndex() const {return fCurrentModule ? Int_t(fCurrentModule->GetUniqueID()):-1;}
105 Int_t GetTotBadLocEqPoints() const {return fTotBadLocEqPoints;}
106 Int_t GetNConstraints() const {return fConstraints.GetLast()+1;}
107 Int_t InitModuleParams();
7b85e477 108 //
109 // fitting methods
45993b23 110 AliTrackFitterRieman *GetRiemanFitter() const {return fRieman;}
7b85e477 111 AliTrackPointArray *PrepareTrack(const AliTrackPointArray *track);
45993b23 112 AliTrackPointArray *GetCurrentTrack() const {return (AliTrackPointArray*)fTrack;}
113 AliTrackPoint *GetCurrentCluster() const {return (AliTrackPoint*)&fCluster;}
114 void SetCurrentTrack(const AliTrackPointArray *atp) {fTrack = (AliTrackPointArray*)atp;}
115 void SetCurrentCluster(const AliTrackPoint &atp) {fCluster = atp;}
7b85e477 116 void InitTrackParams(int meth=1);
6526a72c 117 Int_t ProcessTrack(const AliTrackPointArray *track);
7b85e477 118 Int_t CheckCurrentTrack();
6526a72c 119 //
7b85e477 120 Int_t CalcIntersectionPoint(Double_t *lpar, Double_t *gpar);
121 Int_t CalcDerivatives(Int_t paridx, Bool_t islpar);
122 Double_t* GetLocalIntersectionPoint() const {return (Double_t*)fPintLoc;}
123 Double_t* GetGlobalIntersectionPoint() const {return (Double_t*)fPintGlo;}
124 AliTrackPointArray *SortTrack(const AliTrackPointArray *atp);
125 void SetTemporaryExcludedModule(Int_t index) {fTempExcludedModule=index;}
126 Int_t GetTemporaryExcludedModule() const {return fTempExcludedModule;}
6526a72c 127 Double_t GetMeasGlo(Int_t dim) const {return fMeasGlo[dim];}
128 Double_t GetMeasLoc(Int_t dim) const {return fMeasLoc[dim];}
129 Int_t GetCurrentLayer() const;
7b85e477 130 //
131 // Hierarchical contraints
6526a72c 132 Bool_t PseudoParentsAllowed() const {return fAllowPseudoParents;}
133 void ConstrainModuleSubUnitsMean(Int_t idm, Double_t val=0, UInt_t pattern=0xff);
134 void ConstrainModuleSubUnitsMedian(Int_t idm, Double_t val=0, UInt_t pattern=0xff);
135 void ConstrainOrphansMean(Double_t val=0, UInt_t pattern=0xff);
136 void ConstrainOrphansMedian(Double_t val=0, UInt_t pattern=0xff);
137 void ConstrainLocal(const Char_t* name,Double_t *parcf,Int_t npar,Double_t val,Double_t err);
7b85e477 138 //
45993b23 139 void ApplyGaussianConstraint(const AliITSAlignMille2ConstrArray* cstr);
6526a72c 140 void ApplyPreConstraints();
141 void ApplyPostConstraints();
7b85e477 142 //
45993b23 143 Bool_t IsParModConstrained(const AliITSAlignMille2Module* mod,Int_t par, Bool_t &meanmed, Bool_t &gaussian) const;
144 Bool_t IsParModFamilyVaried(const AliITSAlignMille2Module* mod,Int_t par,Int_t depth=999) const;
145 Bool_t IsParFamilyFree(const AliITSAlignMille2Module* mod,Int_t par,Int_t depth=999) const;
7b85e477 146 //
147 // millepede methods
6526a72c 148 Int_t GlobalFit();
7b85e477 149 void FixParameter(Int_t param, Double_t value);
7b85e477 150 void PrintGlobalParameters();
7b85e477 151 Int_t AddLocalEquation(Mille2Data &m);
152 void SetLocalEquations(const Mille2Data *marr, Int_t neq);
153 //
6526a72c 154 // module specific
7b85e477 155 //
6526a72c 156 Double_t GetTDriftSDD() const;
157 Double_t GetVDriftSDD() const;
158 //
159 AliITSAlignMille2Constraint* GetConstraint(Int_t i) const {return (AliITSAlignMille2Constraint*)fConstraints.At(i);}
160 AliITSAlignMille2Constraint* GetConstraint(const char* name) const {return (AliITSAlignMille2Constraint*)fConstraints.FindObject(name);}
7b85e477 161 //
162 // debug stuffs
6526a72c 163 void FetchCluster(const AliTrackPointArray *trc,int ip) {trc->GetPoint(fCluster,ip);}
45993b23 164 void SetLocalInitParams(const Double_t *par) {for (int i=kNLocal;i--;) fLocalInitParam[i]=par[i];}
7b85e477 165 Double_t *GetMeasLoc() const {return (Double_t*)fMeasLoc;}
166 Double_t *GetSigmaLoc() const {return (Double_t*)fSigmaLoc;}
167 Double_t GetBField() const {return fBField;}
168 Double_t *GetLocalInitParam() const {return (Double_t*)fLocalInitParam;}
169 Double_t *GetLocalInitParEr() const {return (Double_t*)fLocalInitParEr;}
6526a72c 170 Double_t GetLocalDif(int par, int coor) const {return fDerivativeLoc[par][coor];}
171 Double_t GetGlobalDif(int par, int coor) const {return fDerivativeGlo[par][coor];}
7b85e477 172 Int_t GetPreAlignmentQualityFactor(Int_t index) const;// if not prealign. return -1
173 void SetBug(Int_t bug) {fBug=bug;} // 1:SSD inversion sens.18-19
6526a72c 174 static AliITSAlignMille2* GetInstance() {return fgInstance;}
175
176 // pepo
177 // flag for AliITSAlignMille compatibility
178 Int_t GetMilleVersion() const {return fMilleVersion;}
179 void SetMilleVersion(Int_t m1) {fMilleVersion=m1;}
180 // modified existing methods
181 void SetCurrentModule(Int_t id);
182 // old methods recovered
183 Int_t IsDefined(UShort_t voluid) const {return IsVIDDefined(voluid);}
184 Int_t IsContained(UShort_t voluid) const {return IsVIDContained(voluid);}
185 // moved from private to public
186 void SetRequiredPoint(Char_t* where, Int_t ndet, Int_t updw, Int_t nreqpts);
187 Bool_t InitRiemanFit();
188 void SetMinNPtsPerTrack(Int_t pts=3) {fMinNPtsPerTrack=pts;}
7b85e477 189 //
190 private:
191 //
192 // configuration methods
6526a72c 193 void Init();
7b85e477 194 Int_t LoadConfig(const Char_t *cfile="AliITSAlignMille.conf");
6526a72c 195 TObjArray* GetConfigRecord(FILE* stream, TString& recTitle, TString& recOpt, Bool_t rew);
196 //
197 void BuildHierarchy();
7b85e477 198 Int_t LoadSuperModuleFile(const Char_t *cfile="ITSMilleSuperModules.root");
199 void ResetLocalEquation();
6526a72c 200 Int_t InitGeometry();
7b85e477 201 Int_t ApplyToGeometry();
202 //
6526a72c 203 void ConstrainModuleSubUnits(Int_t idm, Double_t val=0, UInt_t pattern=0xff);
204 void ConstrainOrphans(Double_t val=0,UInt_t pattern=0xff);
205 void PostConstrainModuleSubUnits(Int_t type,Int_t idm, Double_t val, UInt_t pattern);
206 void PostConstrainOrphans(Int_t type,Double_t val, UInt_t pattern);
207 //
208 void SetGeometryFileName(const Char_t* filename="geometry.root") { fGeometryFileName = filename; }
209
210 void SetInitTrackParamsMeth(Int_t meth=1) {fInitTrackParamsMeth=meth;}
211 //
212 void AddConstraint(Double_t *factor, Double_t value, Double_t sigma=0);
213 void InitGlobalParameters(Double_t *par);
214 void SetLocalDerivative(Int_t index, Double_t value) {fLocalDerivatives[index] = value;}
215 void SetGlobalDerivative(Int_t index, Double_t value) {fGlobalDerivatives[index] = value;}
216 //
7b85e477 217 // millepede methods
6526a72c 218 //
219 void SetUseGlobalDelta(Bool_t v=kTRUE) {fUseGlobalDelta = v;}
220 void SetAllowPseudoParents(Bool_t v=kTRUE) {fAllowPseudoParents = v;}
221 Int_t SetConstraintWrtRef(const char* reffname);
7b85e477 222 //
223 AliITSAlignMille2(const AliITSAlignMille2& rhs);
224 AliITSAlignMille2& operator=(const AliITSAlignMille2& rhs);
225 //
226 protected:
227 //
228 // millepede stuffs
229 AliMillePede2 *fMillepede; // Detector independent alignment class
230 Double_t fStartFac; // Initial value for chi2 cut
231 Double_t fResCutInitial; // Cut on residual for first iteration
232 Double_t fResCut; // Cut on residual for other iterations
233 Int_t fNGlobal; // Number of global parameters
234 Int_t fNLocal; // Number of local parameters
235 Int_t fNStdDev; // Number of standard deviations for chi2 cut
236 Bool_t fIsMilleInit; // Flag for initialization
6526a72c 237 Bool_t fAllowPseudoParents; // For simple constraints don't involve parents into the fit
7b85e477 238 //
239 // fitting stuffs
240 AliITSAlignMille2Module *fCurrentModule; // Current SuperModule index
241 AliTrackPointArray *fTrack; // pointer to current track
6526a72c 242 TObjArray fTrackBuff; // buffer for tracks of min length
7b85e477 243 AliTrackPoint fCluster; // current cluster
244 Double_t *fGlobalDerivatives; // Array of global derivatives
245 Double_t fLocalDerivatives[kNLocal]; // Array of local deriv.
246 Double_t fLocalInitParam[kNLocal]; // Array with inital values for local parameters for current track
247 Double_t fLocalInitParEr[kNLocal][kNLocal];// Array with inital values for local parameters for current track
248 Double_t fModuleInitParam[kNParCh]; // Array with inital values for current module parameters (init geometry)
45993b23 249 Double_t fPintLoc[3]; // track/module intersection point in local coordinates
250 Double_t fPintLoc0[3]; // track/module intersection point in local coordinates (before variation)
251 Double_t fPintGlo[3]; // track/module intersection point in global coordinates
7b85e477 252 Double_t fMeasLoc[3]; // current point local coordinates (the original ones)
253 Double_t fMeasGlo[3]; // current point glob. coord (AliTrackPoint)
254 Double_t fSigmaLoc[3]; // stdev current point
255 Double_t fSigmaFactor[3]; // multiplicative factor for cluster sigmaX,Y,Z
256 //
6526a72c 257 Double_t fDerivativeLoc[kNLocal][3]; // XYZ deriv. over local params
258 Double_t fDerivativeGlo[kNParCh][3]; // XYZ deriv. over global params
7b85e477 259 Int_t fMinNPtsPerTrack; // min number of points per track to accept it
260 Int_t fInitTrackParamsMeth; // method for track fit
261 Int_t fTotBadLocEqPoints; // total number of reject points because of bad EqLoc
262 AliTrackFitterRieman *fRieman; // riemann fitter for helices
263 //
6526a72c 264 TObjArray fConstraints; // list of constraints
7b85e477 265 // >> new members
266 Bool_t fUseGlobalDelta; // intetpret deltas as global
267 Bool_t fRequirePoints; // required points in specific layers
268 Int_t fNReqLayUp[6]; /// number of points required in layer[n] with Y>0
269 Int_t fNReqLayDown[6]; /// number of points required in layer[n] with Y<0
270 Int_t fNReqLay[6]; /// number of points required in layer[n]
271 Int_t fNReqDetUp[3]; /// number of points required in Detector[n] with Y>0
272 Int_t fNReqDetDown[3]; /// number of points required in Detector[n] with Y<0
273 Int_t fNReqDet[3]; /// number of points required in Detector[n]
274 Int_t fTempExcludedModule; /// single module temporary excluded from initial fit
275 // << new members
276 //
277 // geometry stuffs
278 TString fGeometryFileName; // Geometry file name
279 TString fPreAlignmentFileName; // file with prealigned objects
6526a72c 280 TString fConstrRefFileName; // file with prealigned objects wrt which constraints are defined
45993b23 281 TGeoManager *fGeoManager; // pointer to Alice geomanager
282 Bool_t fIsConfigured; // flag for loaded config file
283 TArrayS fPreAlignQF; // prealignment flags (not used?)
7b85e477 284 //
6526a72c 285 AliITSresponseSDD* fCorrectSDD; // array of SDD t0/vdrift calib params
286 AliITSresponseSDD* fInitialRecSDD; // array of SDD t0/vdrift calib params used to create the track points
7b85e477 287 TClonesArray* fPrealignment; // array of prealignment global deltas
6526a72c 288 TClonesArray* fConstrRef; // array of refererence deltas with respect to which the constraint are defined (survey?)
7b85e477 289 TObjArray fMilleModule; /// array of super modules to be aligned
290 TObjArray fSuperModule; /// array of super modules defined in supermodule file
291 Int_t fNModules; // number of defined modules from config file
292 Int_t fNSuperModules; /// number of custom supermodules in SM file
293 Bool_t fUsePreAlignment; // start from prealigned setup
7b85e477 294 Bool_t fBOn; // magentic field ON
295 Double_t fBField; // value of magnetic field
296 Int_t fBug; /// tag for temporary bug correction
6526a72c 297 // pepo
298 Int_t fMilleVersion; /// tag for backward compatibility
299 // endpepo
300 //
301 Double_t fDriftSpeed[50]; //temporary array for drift times of SDD alitrackpoints
302 Double_t fDriftTime0[50]; //temporary array for drift time 0's used for SDD alitrackpoints
7b85e477 303 //
304 static AliITSAlignMille2* fgInstance; // global pointer on itself
305 static Int_t fgInstanceID; // global counter of the instances
6526a72c 306 //
7b85e477 307 ClassDef(AliITSAlignMille2, 0)
7b85e477 308};
309
310#endif