]>
Commit | Line | Data |
---|---|---|
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 | 26 | class TArrayI; |
27 | class TSystem; | |
28 | class TGeoManager; | |
29 | class TVirtualFitter; | |
7b85e477 | 30 | class AliMillePede2; |
31 | class AliAlignObjParams; | |
7b85e477 | 32 | class AliTrackFitterRieman; |
45993b23 | 33 | class AliITSAlignMille2Constraint; |
34 | class AliITSAlignMille2ConstrArray; | |
35 | class AliITSresponseSDD; | |
7b85e477 | 36 | |
37 | class 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 | // |
45 | public: | |
46 | // | |
6526a72c | 47 | AliITSAlignMille2(const Char_t *configFilename="AliITSAlignMille.conf"); |
7b85e477 | 48 | virtual ~AliITSAlignMille2(); |
49 | // | |
6526a72c | 50 | AliMillePede2* GetMillePede() const {return fMillepede;} |
51 | // | |
52 | // configuration methods | |
53 | // | |
54 | Int_t IsVIDDefined(UShort_t voluid) const; | |
55 | Int_t IsVIDContained(UShort_t voluid) const; | |
56 | Int_t IsSymDefined(const Char_t* name) const; | |
57 | Int_t IsSymContained(const Char_t* name) const; | |
58 | // | |
7b85e477 | 59 | Int_t GetModuleIndex(const Char_t *symname); |
60 | Int_t GetModuleIndex(UShort_t voluid); | |
61 | UShort_t GetModuleVolumeID(const Char_t *symname); | |
62 | UShort_t GetModuleVolumeID(Int_t index); | |
6526a72c | 63 | AliITSAlignMille2Module* GetMilleModuleByVID(UShort_t voluid) const; // get pointer to the defined supermodule |
64 | AliITSAlignMille2Module* GetMilleModuleBySymName(const Char_t* symname) const; // get pointer to the defined supermodule | |
65 | AliITSAlignMille2Module* GetMilleModuleIfContained(const Char_t* symname) const; | |
66 | AliITSAlignMille2Module* GetMilleModule(Int_t id) const {return (AliITSAlignMille2Module*)fMilleModule[id];} | |
67 | AliITSAlignMille2Module* GetCurrentModule() const {return fCurrentModule;} | |
68 | AliITSAlignMille2Module* GetSuperModule(Int_t id) const {return (AliITSAlignMille2Module*)fSuperModule[id];} | |
69 | // | |
70 | AliAlignObjParams* GetPrealignedObject(const Char_t* symname) const; | |
71 | AliAlignObjParams* GetConstrRefObject(const Char_t* symname) const; | |
72 | // | |
73 | void ConvertParamsToGlobal(); | |
74 | void ConvertParamsToLocal(); | |
7b85e477 | 75 | // |
7b85e477 | 76 | const Char_t* GetGeometryFileName() {return fGeometryFileName.Data();} |
77 | const Char_t* GetPreAlignmentFileName() {return fPreAlignmentFileName.Data();} | |
78 | TClonesArray* GetPreAlignmentDeltas() const {return fPrealignment;} | |
6526a72c | 79 | AliITSresponseSDD* GetSDDPrecalibration() const {return fCorrectSDD;} |
80 | AliITSresponseSDD* GetSDDInit() const {return fInitialRecSDD;} | |
7b85e477 | 81 | void PrintCurrentModuleInfo() const {if (fCurrentModule) fCurrentModule->Print();} |
82 | void Print(Option_t*) const; | |
83 | Bool_t IsConfigured() const {return fIsConfigured;} | |
7b85e477 | 84 | Bool_t GetUseGlobalDelta() const {return fUseGlobalDelta;} |
6526a72c | 85 | Bool_t IsConstraintWrtRef() const {return fConstrRef!=0;} |
86 | Bool_t FixedOrphans() const; | |
87 | // | |
88 | // geometry stuffs | |
89 | Int_t GetNModules() const {return fNModules;} | |
90 | Int_t GetCurrentModuleIndex() const {return fCurrentModule ? fCurrentModule->GetIndex():-1;} | |
91 | TGeoHMatrix *GetCurrentModuleHMatrix() const {return fCurrentModule ? fCurrentModule->GetMatrix():0;} | |
92 | Double_t *GetCurrentModuleTranslation() const {return fCurrentModule ? fCurrentModule->GetMatrix()->GetTranslation():0;} | |
93 | Int_t GetCurrentModuleInternalIndex() const {return fCurrentModule ? Int_t(fCurrentModule->GetUniqueID()):-1;} | |
94 | Int_t GetTotBadLocEqPoints() const {return fTotBadLocEqPoints;} | |
95 | Int_t GetNConstraints() const {return fConstraints.GetLast()+1;} | |
96 | Int_t InitModuleParams(); | |
7b85e477 | 97 | // |
98 | // fitting methods | |
45993b23 | 99 | AliTrackFitterRieman *GetRiemanFitter() const {return fRieman;} |
7b85e477 | 100 | AliTrackPointArray *PrepareTrack(const AliTrackPointArray *track); |
45993b23 | 101 | AliTrackPointArray *GetCurrentTrack() const {return (AliTrackPointArray*)fTrack;} |
102 | AliTrackPoint *GetCurrentCluster() const {return (AliTrackPoint*)&fCluster;} | |
103 | void SetCurrentTrack(const AliTrackPointArray *atp) {fTrack = (AliTrackPointArray*)atp;} | |
104 | void SetCurrentCluster(const AliTrackPoint &atp) {fCluster = atp;} | |
7b85e477 | 105 | void InitTrackParams(int meth=1); |
6526a72c | 106 | Int_t ProcessTrack(const AliTrackPointArray *track); |
7b85e477 | 107 | Int_t CheckCurrentTrack(); |
6526a72c | 108 | // |
7b85e477 | 109 | Int_t CalcIntersectionPoint(Double_t *lpar, Double_t *gpar); |
110 | Int_t CalcDerivatives(Int_t paridx, Bool_t islpar); | |
111 | Double_t* GetLocalIntersectionPoint() const {return (Double_t*)fPintLoc;} | |
112 | Double_t* GetGlobalIntersectionPoint() const {return (Double_t*)fPintGlo;} | |
113 | AliTrackPointArray *SortTrack(const AliTrackPointArray *atp); | |
114 | void SetTemporaryExcludedModule(Int_t index) {fTempExcludedModule=index;} | |
115 | Int_t GetTemporaryExcludedModule() const {return fTempExcludedModule;} | |
6526a72c | 116 | Double_t GetMeasGlo(Int_t dim) const {return fMeasGlo[dim];} |
117 | Double_t GetMeasLoc(Int_t dim) const {return fMeasLoc[dim];} | |
118 | Int_t GetCurrentLayer() const; | |
7b85e477 | 119 | // |
120 | // Hierarchical contraints | |
6526a72c | 121 | Bool_t PseudoParentsAllowed() const {return fAllowPseudoParents;} |
122 | void ConstrainModuleSubUnitsMean(Int_t idm, Double_t val=0, UInt_t pattern=0xff); | |
123 | void ConstrainModuleSubUnitsMedian(Int_t idm, Double_t val=0, UInt_t pattern=0xff); | |
124 | void ConstrainOrphansMean(Double_t val=0, UInt_t pattern=0xff); | |
125 | void ConstrainOrphansMedian(Double_t val=0, UInt_t pattern=0xff); | |
126 | void ConstrainLocal(const Char_t* name,Double_t *parcf,Int_t npar,Double_t val,Double_t err); | |
7b85e477 | 127 | // |
45993b23 | 128 | void ApplyGaussianConstraint(const AliITSAlignMille2ConstrArray* cstr); |
6526a72c | 129 | void ApplyPreConstraints(); |
130 | void ApplyPostConstraints(); | |
7b85e477 | 131 | // |
45993b23 | 132 | Bool_t IsParModConstrained(const AliITSAlignMille2Module* mod,Int_t par, Bool_t &meanmed, Bool_t &gaussian) const; |
133 | Bool_t IsParModFamilyVaried(const AliITSAlignMille2Module* mod,Int_t par,Int_t depth=999) const; | |
134 | Bool_t IsParFamilyFree(const AliITSAlignMille2Module* mod,Int_t par,Int_t depth=999) const; | |
7b85e477 | 135 | // |
136 | // millepede methods | |
6526a72c | 137 | Int_t GlobalFit(); |
7b85e477 | 138 | void FixParameter(Int_t param, Double_t value); |
7b85e477 | 139 | void PrintGlobalParameters(); |
7b85e477 | 140 | // |
6526a72c | 141 | // module specific |
7b85e477 | 142 | // |
6526a72c | 143 | Double_t GetTDriftSDD() const; |
144 | Double_t GetVDriftSDD() const; | |
145 | // | |
146 | AliITSAlignMille2Constraint* GetConstraint(Int_t i) const {return (AliITSAlignMille2Constraint*)fConstraints.At(i);} | |
147 | AliITSAlignMille2Constraint* GetConstraint(const char* name) const {return (AliITSAlignMille2Constraint*)fConstraints.FindObject(name);} | |
7b85e477 | 148 | // |
149 | // debug stuffs | |
6526a72c | 150 | void FetchCluster(const AliTrackPointArray *trc,int ip) {trc->GetPoint(fCluster,ip);} |
45993b23 | 151 | void SetLocalInitParams(const Double_t *par) {for (int i=kNLocal;i--;) fLocalInitParam[i]=par[i];} |
7b85e477 | 152 | Double_t *GetMeasLoc() const {return (Double_t*)fMeasLoc;} |
153 | Double_t *GetSigmaLoc() const {return (Double_t*)fSigmaLoc;} | |
154 | Double_t GetBField() const {return fBField;} | |
155 | Double_t *GetLocalInitParam() const {return (Double_t*)fLocalInitParam;} | |
156 | Double_t *GetLocalInitParEr() const {return (Double_t*)fLocalInitParEr;} | |
6526a72c | 157 | Double_t GetLocalDif(int par, int coor) const {return fDerivativeLoc[par][coor];} |
158 | Double_t GetGlobalDif(int par, int coor) const {return fDerivativeGlo[par][coor];} | |
7b85e477 | 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 | |
6526a72c | 161 | static AliITSAlignMille2* GetInstance() {return fgInstance;} |
162 | ||
163 | // pepo | |
164 | // flag for AliITSAlignMille compatibility | |
165 | Int_t GetMilleVersion() const {return fMilleVersion;} | |
166 | void SetMilleVersion(Int_t m1) {fMilleVersion=m1;} | |
167 | // modified existing methods | |
168 | void SetCurrentModule(Int_t id); | |
169 | // old methods recovered | |
170 | Int_t IsDefined(UShort_t voluid) const {return IsVIDDefined(voluid);} | |
171 | Int_t IsContained(UShort_t voluid) const {return IsVIDContained(voluid);} | |
172 | // moved from private to public | |
173 | void SetRequiredPoint(Char_t* where, Int_t ndet, Int_t updw, Int_t nreqpts); | |
174 | Bool_t InitRiemanFit(); | |
175 | void SetMinNPtsPerTrack(Int_t pts=3) {fMinNPtsPerTrack=pts;} | |
7b85e477 | 176 | // |
4bd2db93 | 177 | protected: |
7b85e477 | 178 | // |
4bd2db93 | 179 | struct Mille2Data { // structure to store data for 2 LocalEquations (X and Z) |
180 | enum {kMaxLev = 7}; | |
181 | Double_t fMeasX, fMeasZ, fSigmaX, fSigmaZ; // measured coordinates/errors | |
182 | Double_t fDerLocX[kNLocal], fDerLocZ[kNLocal]; // calculated local derivatives | |
183 | Int_t fNModFilled, fNGlobFilled, fModuleID[kMaxLev]; // used module info | |
184 | Int_t fParMilleID[AliITSAlignMille2Module::kMaxParTot*kMaxLev]; // param id's | |
185 | Double_t fDerGloX[AliITSAlignMille2Module::kMaxParTot*kMaxLev]; // global derivatives in X | |
186 | Double_t fDerGloZ[AliITSAlignMille2Module::kMaxParTot*kMaxLev]; // and Z | |
187 | }; | |
188 | ||
7b85e477 | 189 | // configuration methods |
6526a72c | 190 | void Init(); |
7b85e477 | 191 | Int_t LoadConfig(const Char_t *cfile="AliITSAlignMille.conf"); |
6526a72c | 192 | TObjArray* GetConfigRecord(FILE* stream, TString& recTitle, TString& recOpt, Bool_t rew); |
18986853 | 193 | Int_t CheckConfigRecords(FILE* stream); |
6526a72c | 194 | // |
195 | void BuildHierarchy(); | |
7b85e477 | 196 | Int_t LoadSuperModuleFile(const Char_t *cfile="ITSMilleSuperModules.root"); |
197 | void ResetLocalEquation(); | |
6526a72c | 198 | Int_t InitGeometry(); |
7b85e477 | 199 | Int_t ApplyToGeometry(); |
200 | // | |
6526a72c | 201 | void ConstrainModuleSubUnits(Int_t idm, Double_t val=0, UInt_t pattern=0xff); |
202 | void ConstrainOrphans(Double_t val=0,UInt_t pattern=0xff); | |
203 | void PostConstrainModuleSubUnits(Int_t type,Int_t idm, Double_t val, UInt_t pattern); | |
204 | void PostConstrainOrphans(Int_t type,Double_t val, UInt_t pattern); | |
205 | // | |
206 | void SetGeometryFileName(const Char_t* filename="geometry.root") { fGeometryFileName = filename; } | |
207 | ||
208 | void SetInitTrackParamsMeth(Int_t meth=1) {fInitTrackParamsMeth=meth;} | |
209 | // | |
210 | void AddConstraint(Double_t *factor, Double_t value, Double_t sigma=0); | |
211 | void InitGlobalParameters(Double_t *par); | |
212 | void SetLocalDerivative(Int_t index, Double_t value) {fLocalDerivatives[index] = value;} | |
213 | void SetGlobalDerivative(Int_t index, Double_t value) {fGlobalDerivatives[index] = value;} | |
214 | // | |
7b85e477 | 215 | // millepede methods |
6526a72c | 216 | // |
4bd2db93 | 217 | Int_t AddLocalEquation(Mille2Data &m); |
218 | void SetLocalEquations(const Mille2Data *marr, Int_t neq); | |
6526a72c | 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 | // | |
18986853 | 228 | enum { |
229 | kGeomFile, | |
230 | kSuperModileFile, | |
231 | kConstrRefFile, | |
232 | kPrealignFile, | |
233 | kPreCalSDDFile, | |
234 | kInitCalSDDFile, | |
235 | kGlobalDeltas, | |
236 | kConstrLocal, | |
237 | kModVolID, | |
238 | kModIndex, | |
239 | kPseudoParents, | |
240 | kTrackFitMethod, | |
241 | kMinPntTrack, | |
242 | kNStDev, | |
243 | kResCutInit, | |
244 | kResCutOther, | |
245 | kLocalSigFactor, | |
246 | kStartFactor, | |
247 | kBField, | |
248 | kSparseMatrix, | |
249 | kRequirePoint, | |
250 | kConstrOrphans, | |
251 | kConstrSubunits, | |
252 | kApplyConstr, | |
253 | // | |
254 | kNKeyWords | |
255 | }; // id's of the keywirds for config file records | |
256 | ||
7b85e477 | 257 | // millepede stuffs |
258 | AliMillePede2 *fMillepede; // Detector independent alignment class | |
259 | Double_t fStartFac; // Initial value for chi2 cut | |
260 | Double_t fResCutInitial; // Cut on residual for first iteration | |
261 | Double_t fResCut; // Cut on residual for other iterations | |
262 | Int_t fNGlobal; // Number of global parameters | |
263 | Int_t fNLocal; // Number of local parameters | |
264 | Int_t fNStdDev; // Number of standard deviations for chi2 cut | |
265 | Bool_t fIsMilleInit; // Flag for initialization | |
6526a72c | 266 | Bool_t fAllowPseudoParents; // For simple constraints don't involve parents into the fit |
7b85e477 | 267 | // |
268 | // fitting stuffs | |
269 | AliITSAlignMille2Module *fCurrentModule; // Current SuperModule index | |
270 | AliTrackPointArray *fTrack; // pointer to current track | |
6526a72c | 271 | TObjArray fTrackBuff; // buffer for tracks of min length |
7b85e477 | 272 | AliTrackPoint fCluster; // current cluster |
273 | Double_t *fGlobalDerivatives; // Array of global derivatives | |
274 | Double_t fLocalDerivatives[kNLocal]; // Array of local deriv. | |
275 | Double_t fLocalInitParam[kNLocal]; // Array with inital values for local parameters for current track | |
276 | Double_t fLocalInitParEr[kNLocal][kNLocal];// Array with inital values for local parameters for current track | |
277 | Double_t fModuleInitParam[kNParCh]; // Array with inital values for current module parameters (init geometry) | |
45993b23 | 278 | Double_t fPintLoc[3]; // track/module intersection point in local coordinates |
279 | Double_t fPintLoc0[3]; // track/module intersection point in local coordinates (before variation) | |
280 | Double_t fPintGlo[3]; // track/module intersection point in global coordinates | |
7b85e477 | 281 | Double_t fMeasLoc[3]; // current point local coordinates (the original ones) |
282 | Double_t fMeasGlo[3]; // current point glob. coord (AliTrackPoint) | |
283 | Double_t fSigmaLoc[3]; // stdev current point | |
284 | Double_t fSigmaFactor[3]; // multiplicative factor for cluster sigmaX,Y,Z | |
285 | // | |
6526a72c | 286 | Double_t fDerivativeLoc[kNLocal][3]; // XYZ deriv. over local params |
287 | Double_t fDerivativeGlo[kNParCh][3]; // XYZ deriv. over global params | |
7b85e477 | 288 | Int_t fMinNPtsPerTrack; // min number of points per track to accept it |
289 | Int_t fInitTrackParamsMeth; // method for track fit | |
290 | Int_t fTotBadLocEqPoints; // total number of reject points because of bad EqLoc | |
291 | AliTrackFitterRieman *fRieman; // riemann fitter for helices | |
292 | // | |
6526a72c | 293 | TObjArray fConstraints; // list of constraints |
7b85e477 | 294 | // >> new members |
295 | Bool_t fUseGlobalDelta; // intetpret deltas as global | |
296 | Bool_t fRequirePoints; // required points in specific layers | |
297 | Int_t fNReqLayUp[6]; /// number of points required in layer[n] with Y>0 | |
298 | Int_t fNReqLayDown[6]; /// number of points required in layer[n] with Y<0 | |
299 | Int_t fNReqLay[6]; /// number of points required in layer[n] | |
300 | Int_t fNReqDetUp[3]; /// number of points required in Detector[n] with Y>0 | |
301 | Int_t fNReqDetDown[3]; /// number of points required in Detector[n] with Y<0 | |
302 | Int_t fNReqDet[3]; /// number of points required in Detector[n] | |
303 | Int_t fTempExcludedModule; /// single module temporary excluded from initial fit | |
304 | // << new members | |
305 | // | |
306 | // geometry stuffs | |
307 | TString fGeometryFileName; // Geometry file name | |
308 | TString fPreAlignmentFileName; // file with prealigned objects | |
6526a72c | 309 | TString fConstrRefFileName; // file with prealigned objects wrt which constraints are defined |
45993b23 | 310 | TGeoManager *fGeoManager; // pointer to Alice geomanager |
311 | Bool_t fIsConfigured; // flag for loaded config file | |
312 | TArrayS fPreAlignQF; // prealignment flags (not used?) | |
7b85e477 | 313 | // |
6526a72c | 314 | AliITSresponseSDD* fCorrectSDD; // array of SDD t0/vdrift calib params |
315 | AliITSresponseSDD* fInitialRecSDD; // array of SDD t0/vdrift calib params used to create the track points | |
7b85e477 | 316 | TClonesArray* fPrealignment; // array of prealignment global deltas |
6526a72c | 317 | TClonesArray* fConstrRef; // array of refererence deltas with respect to which the constraint are defined (survey?) |
7b85e477 | 318 | TObjArray fMilleModule; /// array of super modules to be aligned |
319 | TObjArray fSuperModule; /// array of super modules defined in supermodule file | |
320 | Int_t fNModules; // number of defined modules from config file | |
321 | Int_t fNSuperModules; /// number of custom supermodules in SM file | |
322 | Bool_t fUsePreAlignment; // start from prealigned setup | |
7b85e477 | 323 | Bool_t fBOn; // magentic field ON |
324 | Double_t fBField; // value of magnetic field | |
325 | Int_t fBug; /// tag for temporary bug correction | |
6526a72c | 326 | // pepo |
327 | Int_t fMilleVersion; /// tag for backward compatibility | |
328 | // endpepo | |
329 | // | |
330 | Double_t fDriftSpeed[50]; //temporary array for drift times of SDD alitrackpoints | |
331 | Double_t fDriftTime0[50]; //temporary array for drift time 0's used for SDD alitrackpoints | |
7b85e477 | 332 | // |
333 | static AliITSAlignMille2* fgInstance; // global pointer on itself | |
334 | static Int_t fgInstanceID; // global counter of the instances | |
18986853 | 335 | static const Char_t * kRecKeys[]; // keywords for config file records |
6526a72c | 336 | // |
7b85e477 | 337 | ClassDef(AliITSAlignMille2, 0) |
7b85e477 | 338 | }; |
339 | ||
340 | #endif | |
18986853 | 341 |