]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSAlignMille2.h
Fixes for Coverity warnings (A. Mastroserio)
[u/mrichter/AliRoot.git] / ITS / AliITSAlignMille2.h
1 #ifndef ALIITSALIGNMILLE2_H
2 #define ALIITSALIGNMILLE2_H
3
4 /* Copyright(c) 2007-2009 , ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                                */
6
7 /* $Id$ */
8 //-----------------------------------------------------------------------------
9 //
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 //-----------------------------------------------------------------------------
19
20 #include <TString.h>
21 #include <TObject.h>
22 #include <TGeoMatrix.h>
23 #include <TArrayS.h>
24 #include <TArrayD.h>
25 #include "AliTrackPointArray.h"
26 #include "AliITSAlignMille2Module.h"
27
28 class TSystem;
29 class TGeoManager;
30 class TVirtualFitter;
31 class AliMillePede2;
32 class AliAlignObjParams;
33 class AliTrackFitterRieman;
34 class AliITSAlignMille2Constraint;
35 class AliITSAlignMille2ConstrArray;
36 class AliITSresponseSDD;
37 class AliITSTPArrayFit;
38 class AliITSsegmentationSDD;
39 class AliITSDriftSpeedArraySDD;
40 class AliITSCorrectSDDPoints;
41 class AliCDBEntry;
42 class AliESDVertex;
43
44 class AliITSAlignMille2: public TObject
45 {
46  public:
47   enum {kX,kY,kZ};
48   enum {kCosmics, kCollision, kNDataType};
49   enum {kNLocal=5,kMaxPoints=20,
50         kNParChGeom = AliITSAlignMille2Module::kMaxParGeom,
51         kNParCh     = AliITSAlignMille2Module::kMaxParTot,
52         kMaxITSSensID=2197,kVtxSensID=kMaxITSSensID+1,kMaxITSSensVID=14300,kVtxSensVID=14371,
53         kMinITSSupeModuleID=14336,
54         kSDDoffsID=240,kNSDDmod=260};
55   //
56   enum {kCovIScaleBit=BIT(9),
57         kSameInitDeltasBit=BIT(14),
58         kSameInitSDDRespBit=BIT(15),
59         kSameInitSDDVDriftBit=BIT(16),
60         kSameDiamondBit=BIT(17),
61         kSameInitSDDCorrMapBit=BIT(18),
62         kSameInitGeomBit=BIT(19) };
63   //
64   enum {kDiamondIgnore,kDiamondCheckIfPrompt,kDiamondUse};
65  public:
66   //
67   AliITSAlignMille2(const Char_t *configFilename="AliITSAlignMille.conf",TList* userInfo=0);
68   virtual ~AliITSAlignMille2();
69   //
70   AliMillePede2* GetMillePede()                                   const {return fMillepede;}
71   AliITSTPArrayFit* GetTPAFitter()                                const {return fTPAFitter;}
72   //
73   // configuration methods
74   //
75   Int_t     IsVIDDefined(UShort_t voluid)                         const;
76   Int_t     IsVIDContained(UShort_t voluid)                       const;
77   Int_t     IsSymDefined(const Char_t* name)                      const;
78   Int_t     IsSymContained(const Char_t* name)                    const;
79   Int_t     GetRequestedModID(UShort_t voluid)                    const;
80   //
81   Int_t     GetModuleIndex(const Char_t *symname);
82   Int_t     GetModuleIndex(UShort_t voluid);
83   UShort_t  GetModuleVolumeID(const Char_t *symname);
84   UShort_t  GetModuleVolumeID(Int_t index);
85   AliITSAlignMille2Module*  GetMilleModuleByVID(UShort_t voluid) const; // get pointer to the defined supermodule
86   AliITSAlignMille2Module*  GetMilleModuleBySymName(const Char_t* symname) const; // get pointer to the defined supermodule
87   AliITSAlignMille2Module*  GetMilleModuleIfContained(const Char_t* symname) const;
88   AliITSAlignMille2Module*  GetMilleModule(Int_t id)             const {return (AliITSAlignMille2Module*)fMilleModule[id];}
89   AliITSAlignMille2Module*  GetCurrentModule()                   const {return fCurrentModule;}
90   AliITSAlignMille2Module*  GetSuperModule(Int_t id)             const {return (AliITSAlignMille2Module*)fSuperModule[id];}
91   AliITSAlignMille2Module*  CreateVertexModule();
92   //
93   AliAlignObjParams*        GetPrealignedObject(const Char_t* symname) const;
94   AliAlignObjParams*        GetConstrRefObject(const Char_t* symname) const;
95   //
96   void          ConvertParamsToGlobal();
97   void          ConvertParamsToLocal();
98   //
99   const Char_t* GetGeometryPath()                                   {return fGeometryPath.Data();}
100   const Char_t* GetPreAlignmentPath()                               {return fPreDeltaPath.Data();}
101   TClonesArray* GetPreAlignmentDeltas()                           const {return fPrealignment;}
102   AliITSresponseSDD* GetSDDPrecalResp()                           const {return fPreRespSDD;}
103   AliITSresponseSDD* GetSDDInitResp()                             const {return fIniRespSDD;}
104   TObjArray*         GetSDDInitVDrift()                           const {return fIniVDriftSDD;}
105   void      PrintCurrentModuleInfo()                              const {if (fCurrentModule) fCurrentModule->Print();}
106   void      Print(Option_t*)                                      const;
107   Bool_t    IsConfigured()                                        const {return fIsConfigured;}
108   Bool_t    GetUseGlobalDelta()                                   const {return fUseGlobalDelta;}
109   Bool_t    IsConstraintWrtRef()                                  const {return fConstrRef!=0;}
110   Bool_t    FixedOrphans()                                        const;
111   Bool_t    IsLocalYError()                                       const {return fUseLocalYErr;}
112   //
113   // geometry stuffs
114   Int_t     GetNModules()                   const {return fNModules;}
115   Int_t     GetCurrentModuleIndex()         const {return fCurrentModule ? fCurrentModule->GetIndex():-1;}
116   TGeoHMatrix *GetCurrentModuleHMatrix()    const {return fCurrentModule ? fCurrentModule->GetMatrix():0;}
117   Double_t *GetCurrentModuleTranslation()   const {return fCurrentModule ? fCurrentModule->GetMatrix()->GetTranslation():0;}
118   Int_t     GetCurrentModuleInternalIndex() const {return fCurrentModule ? Int_t(fCurrentModule->GetUniqueID()):-1;}
119   Int_t     GetTotBadLocEqPoints()          const {return fTotBadLocEqPoints;}
120   Int_t     GetNConstraints()               const {return fConstraints.GetLast()+1;}
121   Int_t     InitModuleParams();
122   //
123   // fitting methods
124   AliTrackFitterRieman *GetRiemanFitter()   const                       {return fRieman;}
125   AliTrackPointArray   *PrepareTrack(const AliTrackPointArray *track); 
126   AliTrackPointArray *GetCurrentTrack()     const                       {return (AliTrackPointArray*)fTrack;}
127   AliTrackPoint      *GetCurrentCluster()   const                       {return (AliTrackPoint*)&fCluster;}
128   void      ProcessSDDPointInfo(const AliTrackPoint* pnt,Int_t sID, Int_t pntID);
129   void      SetCurrentTrack(const AliTrackPointArray *atp)              {fTrack = (AliTrackPointArray*)atp;}
130   void      SetCurrentCluster(const AliTrackPoint &atp);
131   void      InitTrackParams(int meth=1);
132   Int_t     ProcessTrack(const AliTrackPointArray *track, Double_t wgh=1.0);
133   Int_t     FitTrack();
134   Int_t     CheckCurrentTrack();
135   //
136   // methods for point unbiasing (via scaling its inverted cov.matrix)
137   Bool_t    IsCovIScaleTouched()                     const {return TestBit(kCovIScaleBit);}
138   void      TouchCovIScale(Bool_t v=kTRUE)                 {SetBit(kCovIScaleBit,v);}
139   Float_t   GetCovIScale(Int_t ip)                   const {return ip<kMaxPoints ? fCovIScale[ip]:-1.;}
140   Float_t*  GetCovIScale()                           const {return (Float_t*)fCovIScale;}
141   void      SetCovIScale(Int_t ip, Float_t v=-1.)          {if (ip<kMaxPoints) fCovIScale[ip] = v; TouchCovIScale();}
142   void      SetCovIScale(Float_t *v, Int_t np)             {for (int i=TMath::Min(np,kMaxPoints);i--;) fCovIScale[i]=v[i]; TouchCovIScale();}
143   void      ResetCovIScale()                               {for (int i=kMaxPoints;i--;) fCovIScale[i]=-1; TouchCovIScale(kFALSE);}
144   //
145   Int_t     CalcIntersectionPoint(Double_t *lpar, Double_t *gpar);
146   Int_t     CalcDerivatives(Int_t paridx, Bool_t islpar);
147   void      JacobianPosGloLoc(int locid,double* jacobian);
148   Double_t* GetLocalIntersectionPoint()                           const {return (Double_t*)fPintLoc;}
149   Double_t* GetGlobalIntersectionPoint()                          const {return (Double_t*)fPintGlo;}
150   AliTrackPointArray *SortTrack(const AliTrackPointArray *atp);
151   void      SetTemporaryExcludedModule(Int_t index)                     {fTempExcludedModule=index;}
152   Int_t     GetTemporaryExcludedModule()                          const {return fTempExcludedModule;}
153   Double_t  GetMeasGlo(Int_t dim)                                 const {return fMeasGlo[dim];}
154   Double_t  GetMeasLoc(Int_t dim)                                 const {return fMeasLoc[dim];}
155   Int_t     GetCurrentLayer()                                     const;
156   void      SetBField(Double_t b=0);
157   void      SetTypeCosmics()                                            {fDataType = kCosmics;}
158   void      SetTypeCollision()                                          {fDataType = kCollision;}
159   void      SetDataType(Int_t tp=kCosmics)                              {fDataType = tp>=0&&tp< kNDataType ? tp:kCosmics;}
160   void      SetUseLocalYErrors(Bool_t v=kTRUE)                          {fUseLocalYErr = v && fTPAFitter;}
161   void      SetMinPointsPerSensor( Int_t n )                            {fMinPntPerSens = n>0 ? n:0;}
162   Int_t     GetMinPointsPerSensor()                               const {return fMinPntPerSens;}
163   void      ConstrainHelixFitPT(  Int_t q=0,Double_t pt=-1, Double_t err=-1);
164   void      ConstrainHelixFitCurv(Int_t q=0,Double_t crv=-1,Double_t crverr=-1);
165   void      RemoveHelixFitConstraint();
166   void      SetVertexConstraint(const AliESDVertex* vtx);
167   Bool_t    IsVertexSet()                                         const {return fVertexSet;}
168   void      RemoveVertexConstraint()                                    {fVertexSet = kFALSE;}
169   void      SetVertexSet(Bool_t v)                                      {fVertexSet = v;}
170   Double_t  GetHelixContraintCharge()                             const {return fConstrCharge;}
171   Double_t  GetHelixContraintPT()                                 const {return fConstrPT;}
172   Double_t  GetHelixContraintPTErr()                              const {return fConstrPTErr;}
173   Int_t     GetDataType()                                         const {return fDataType;}
174   //
175   TGeoHMatrix* GetSensorOrigMatrixSID(Int_t sid)                  const;
176   TGeoHMatrix* GetSensorOrigMatrixVID(Int_t vid)                  const;
177   //
178   TGeoHMatrix* GetSensorCurrMatrixSID(Int_t sid)                  const;
179   TGeoHMatrix* GetSensorCurrMatrixVID(Int_t vid)                  const;
180   //
181   AliCDBEntry* GetCDBEntry(const char* path);
182   // Hierarchical contraints
183   void      TieSDDVDriftsLR(AliITSAlignMille2Module* mod);
184   Bool_t    PseudoParentsAllowed()                                const {return fAllowPseudoParents;}
185   void      ConstrainModuleSubUnitsMean(Int_t idm, Double_t val=0, UInt_t pattern=0xff);
186   void      ConstrainModuleSubUnitsMedian(Int_t idm, Double_t val=0, UInt_t pattern=0xff);
187   void      ConstrainOrphansMean(Double_t val=0, UInt_t pattern=0xff);
188   void      ConstrainOrphansMedian(Double_t val=0, UInt_t pattern=0xff);
189   void      ConstrainLocal(const Char_t* name,Double_t *parcf,Int_t npar,Double_t val,Double_t err);
190   //
191   void      ApplyGaussianConstraint(const AliITSAlignMille2ConstrArray* cstr);
192   void      ApplyPreConstraints();
193   void      ApplyPostConstraints();
194   //
195   void      SetWeightPt(Double_t w=1)                                   {fWeightPt = w;}
196   void      SetSDDVDCorrMult(Bool_t v=kTRUE)                            {fIsSDDVDriftMult=v;}   
197   Double_t  GetWeightPt()                                         const {return fWeightPt;}
198   Bool_t    IsSDDVDCorrMult()                                     const {return fIsSDDVDriftMult;}
199   Bool_t    IsParModConstrained(const AliITSAlignMille2Module* mod,Int_t par, Bool_t &meanmed, Bool_t &gaussian) const;
200   Bool_t    IsParModFamilyVaried(const AliITSAlignMille2Module* mod,Int_t par,Int_t depth=999)             const;
201   Bool_t    IsParFamilyFree(const AliITSAlignMille2Module* mod,Int_t par,Int_t depth=999)                  const;
202   //
203   // millepede methods
204   Int_t     GlobalFit();
205   void      FixParameter(Int_t param, Double_t value);
206   void      PrintGlobalParameters();
207   //
208   TClonesArray*      CreateDeltas();
209   AliITSresponseSDD* CreateSDDResponse();
210   // module specific 
211   //
212   Double_t  GetTDriftSDD()                  const;
213   Double_t  GetVDriftSDD()                  const;
214   Double_t  GetDriftSpeed(Int_t id)         const {return fDriftSpeed[id];}
215   Double_t  GetDriftSpeed0(Int_t id)        const {return fDriftSpeed0[id];}
216   Double_t  GetDriftTime0(Int_t id)         const {return fDriftTime0[id];}
217
218   //
219   AliITSAlignMille2Constraint* GetConstraint(Int_t i)            const {return (AliITSAlignMille2Constraint*)fConstraints.At(i);}
220   AliITSAlignMille2Constraint* GetConstraint(const char* name)   const {return (AliITSAlignMille2Constraint*)fConstraints.FindObject(name);}
221   //
222   // debug stuffs
223   void       FetchCluster(int ip)                                      {fTrack->GetPoint(fCluster,ip);fCluster.SetUniqueID(ip);} 
224   void       SetLocalInitParams(const Double_t *par)                   {for (int i=kNLocal;i--;) fLocalInitParam[i]=par[i];}
225   Bool_t     IsTypeCosmics()                                     const {return fDataType==kCosmics;}
226   Bool_t     IsTypeCollision()                                   const {return fDataType==kCollision;}
227   Double_t  *GetMeasLoc()                                        const {return (Double_t*)fMeasLoc;}
228   Double_t  *GetSigmaLoc()                                       const {return (Double_t*)fSigmaLoc;}
229   Double_t   GetBField()                                         const {return fBField;}
230   Bool_t     IsFieldON()                                         const {return fBOn;}
231   Bool_t     IsDiamondUsed()                                     const {return fUseDiamond;}
232   Int_t      GetCheckDiamondPoint()                              const {return fCheckDiamondPoint;}
233   void       SetCheckDiamondPoint(Int_t m=kDiamondCheckIfPrompt)       {fCheckDiamondPoint = m;}
234   Bool_t     IsVertexUsed()                                      const {return fUseVertex;}
235   Double_t  *GetLocalInitParam()                                 const {return (Double_t*)fLocalInitParam;}
236   Double_t  *GetLocalInitParEr()                                 const {return (Double_t*)fLocalInitParEr;}
237   Double_t   GetLocalDif(int par, int coor)                      const {return fDerivativeLoc[par][coor];}
238   Double_t   GetGlobalDif(int par, int coor)                     const {return fDerivativeGlo[par][coor];}
239   Int_t      GetPreAlignmentQualityFactor(Int_t index)           const;// if not prealign. return -1
240   void       SetBug(Int_t bug) {fBug=bug;}                             // 1:SSD inversion sens.18-19
241   static     AliITSAlignMille2* GetInstance()                          {return fgInstance;}
242
243   // pepo270809
244   Int_t      GetExtraClustersMode() const {return fExtraClustersMode;}
245   void       SetExtraClustersMode(Int_t mode) {fExtraClustersMode=mode;}  
246   // endpepo270809
247
248   // pepo
249   // flag for AliITSAlignMille compatibility
250   Int_t      GetMilleVersion() const {return fMilleVersion;}
251   void       SetMilleVersion(Int_t m1) {fMilleVersion=m1;}
252   // modified existing methods
253   void      SetCurrentModule(Int_t id);
254   // old methods recovered
255   Int_t     IsDefined(UShort_t voluid) const {return IsVIDDefined(voluid);}
256   Int_t     IsContained(UShort_t voluid) const {return IsVIDContained(voluid);}
257   // moved from private to public
258   void      SetRequiredPoint(Char_t* where, Int_t ndet, Int_t updw, Int_t nreqpts,Int_t runtype=-1); 
259   Bool_t    InitRiemanFit();
260   void      SetMinNPtsPerTrack(Int_t pts=3)  {fMinNPtsPerTrack=pts;}
261   //
262   Int_t     GetRunID()                                            const {return fRunID;}
263   void      SetRunID(int run)                                           {fRunID = run;}
264   //
265   AliITSCorrectSDDPoints * GetPreCorrMapSDD()                    const {return fPreCorrMapSDD;}
266   AliITSCorrectSDDPoints * GetIniCorrMapSDD()                    const {return fIniCorrMapSDD;}
267   static Bool_t    IsZero(Double_t v,Double_t threshold = 1e-15)       { return TMath::Abs(v)<threshold; }
268   static void      SetWordBit(UInt_t word,Int_t bitID)                 { word |= (1<<bitID);}
269   static void      ResetWordBit(UInt_t word,Int_t bitID)               { word &= ~(1<<bitID);}
270   static Bool_t    TestWordBit(UInt_t word,Int_t bitID)                { return (Bool_t)(word&(1<<bitID));}      
271   //
272  protected:
273   //
274   struct Mille2Data { // structure to store data for LocalEquations (X and Z, optionally Y)
275     enum {kMaxLev = 7};
276     Double_t fMeas[3];                // measured coordinates
277     Double_t fSigma[3];               // measured errors
278     Double_t fDerLoc[kNLocal][3];     // calculated local derivatives
279     Int_t    fNModFilled, fNGlobFilled, fModuleID[kMaxLev]; // used module info
280     Int_t    fParMilleID[AliITSAlignMille2Module::kMaxParTot*kMaxLev]; // param id's
281     Double_t fDerGlo[AliITSAlignMille2Module::kMaxParTot*kMaxLev][3]; // global derivatives
282   };
283   //
284   // configuration methods
285   void      Init();
286   Int_t     CacheMatricesOrig();
287   Int_t     CacheMatricesCurr();
288   Int_t     ProcessUserInfo(TList *userInfo=0);
289   Int_t     GetPathFromUserInfo(TList* cdbList,const char* calib,TString& path, Int_t useBit);
290   Int_t     LoadConfig(const Char_t *cfile="AliITSAlignMille.conf");
291   TObjArray* GetConfigRecord(FILE* stream, TString& recTitle, TString& recOpt, Bool_t rew);
292   Int_t     CheckConfigRecords(FILE* stream);
293   Int_t     ReloadInitCalib(TList *userInfo);
294   Int_t     ReloadInitCalib();
295   //
296   void      BuildHierarchy();
297   Int_t     LoadSuperModuleFile(const Char_t *cfile="ITSMilleSuperModules.root");
298   Int_t     LoadGeometry(TString& path);
299   Int_t     LoadSDDResponse(TString& path, AliITSresponseSDD *&resp);
300   Int_t     LoadSDDVDrift(TString& path, TObjArray *&arr);
301   Int_t     LoadSDDCorrMap(TString& path, AliITSCorrectSDDPoints *&map);
302   Int_t     LoadDeltas(TString& path, TClonesArray *&arr);
303   Int_t     LoadDiamond(TString& path);
304   void      ResetLocalEquation();
305   Int_t     ApplyToGeometry();
306   //
307   void      ConstrainModuleSubUnits(Int_t idm, Double_t val=0, UInt_t pattern=0xff);
308   void      ConstrainOrphans(Double_t val=0,UInt_t pattern=0xff);
309   void      PostConstrainModuleSubUnits(Int_t type,Int_t idm, Double_t val, UInt_t pattern);
310   void      PostConstrainOrphans(Int_t type,Double_t val, UInt_t pattern);
311   //
312   void      SetGeometryPath(const Char_t* filename="geometry.root") { fGeometryPath = filename; }
313
314   void      SetInitTrackParamsMeth(Int_t meth=1)                        {fIniTrackParamsMeth=meth;}
315   //
316   void      AddConstraint(Double_t *factor, Double_t value, Double_t sigma=0);
317   void      InitGlobalParameters(Double_t *par);
318   Bool_t    SetLocalDerivative(Int_t index, Double_t value)             {return IsZero(fLocalDerivatives[index]=value);}
319   Bool_t    SetGlobalDerivative(Int_t index, Double_t value)            {return IsZero(fGlobalDerivatives[index]=value);}  
320   //
321   // millepede methods
322   //
323   Int_t     AddLocalEquation(Mille2Data &m);
324   Int_t     AddLocalEquationTPA(Mille2Data &m);
325   void      SetLocalEquations(const Mille2Data *marr, Int_t neq);
326   void      SetUseGlobalDelta(Bool_t v=kTRUE)                           {fUseGlobalDelta = v;}
327   void      SetAllowPseudoParents(Bool_t v=kTRUE)                       {fAllowPseudoParents = v;} 
328   Int_t     SetConstraintWrtRef(const char* reffname);
329   //
330   void      ConvertDeltas();
331   void      ConvSortHierarchically(TObjArray& matArr);
332   Bool_t    ConvIsJParentOfI(const TGeoHMatrix* matI,const TGeoHMatrix* matJ) const;
333   AliAlignObjParams* ConvFindDelta(const TClonesArray* arrDelta,const TString& algname) const;
334
335   AliITSAlignMille2(const AliITSAlignMille2& rhs);
336   AliITSAlignMille2& operator=(const AliITSAlignMille2& rhs);
337   //
338  protected:
339   //
340   enum {
341     kOCDBDefaultPath,
342     kOCDBSpecificPath,
343     kGeomFile,
344     kSuperModileFile,
345     kConstrRefFile,
346     kPreDeltaFile,
347     kPreCalSDDFile,
348     kPreVDriftSDDFile,
349     kPreCorrMapSDDFile,
350     kInitCorrMapSDDFile,
351     kInitCalSDDFile,
352     kInitVDriftSDDFile,
353     kInitDeltaFile,
354     kInitGeomFile,
355     kGlobalDeltas,
356     kConstrLocal,
357     kModVolID,
358     kModIndex,
359     kPseudoParents,
360     kTrackFitMethod,
361     kMinPntTrack,
362     kNStDev,
363     kResCutInit,
364     kResCutOther,
365     kLocalSigFactor,
366     kStartFactor,
367     kFinalFactor,
368     kBField,
369     kSparseMatrix,
370     kRequirePoint,
371     kConstrOrphans,
372     kConstrSubunits,
373     kApplyConstr,
374     kExtraClustersMode,
375     kTPAFitter,
376     kUseLocalYErr,
377     kMinPointsSens,
378     kSDDVDCorrMult,
379     kWeightPt,
380     kUseDiamond,
381     kCorrectDiamond,
382     kUseVertex,
383     kSameSDDT0,
384     //
385     kNKeyWords
386   };                                            // id's of the keywirds for config file records
387
388   // millepede stuffs
389   AliMillePede2 *fMillepede;                    // Detector independent alignment class
390   Double_t      fStartFac;                      // Initial factor for chi2 cut 
391   Double_t      fFinalFac;                      // Final factor for chi2 cut 
392   Double_t      fResCutInitial;                 // Cut on residual for first iteration
393   Double_t      fResCut;                        // Cut on residual for other iterations 
394   Int_t         fNGlobal;                       // Number of global parameters
395   Int_t         fNLocal;                        // Number of local parameters
396   Int_t         fNStdDev;                       // Number of standard deviations for chi2 cut
397   Bool_t        fIsMilleInit;                   // Flag for initialization
398   Bool_t        fAllowPseudoParents;            // For simple constraints don't involve parents into the fit
399   //
400   // fitting stuffs
401   AliITSTPArrayFit        *fTPAFitter;          // TPArrayFitter       
402   AliITSAlignMille2Module *fCurrentModule;      // Current SuperModule index
403   AliTrackPointArray *fTrack;                   // pointer to current track 
404   TObjArray     fTrackBuff;                     // buffer for tracks of min length
405   AliTrackPoint fCluster;                       // current cluster
406   Int_t         fCurrentSensID;                 // sensor index for current cluster
407   TArrayD       fClusLoc;                       // local  coordinates of the clusters
408   TArrayD       fClusGlo;                       // global coordinates of the clusters
409   TArrayD       fClusSigLoc;                    // local cov matrix of the clusters
410   Double_t     *fGlobalDerivatives;             // Array of global derivatives
411   Double_t      fLocalDerivatives[kNLocal];     // Array of local deriv.
412   Double_t      fLocalInitParam[kNLocal];       // Array with inital values for local parameters for current track
413   Double_t      fLocalInitParEr[kNLocal][kNLocal];// Array with inital values for local parameters for current track
414   Double_t      fModuleInitParam[kNParCh];      // Array with inital values for current module parameters (init geometry)
415   Double_t      fPintLoc[3];                    // track/module intersection point in local coordinates
416   Double_t      fPintLoc0[3];                   // track/module intersection point in local coordinates (before variation)
417   Double_t      fPintGlo[3];                    // track/module intersection point in global coordinates
418   Double_t     *fMeasLoc;                       // current point local coordinates (the original ones)
419   Double_t     *fMeasGlo;                       // current point glob. coord (AliTrackPoint)
420   Double_t     *fSigmaLoc;                      // stdev current point
421   Double_t      fSigmaFactor[3];                // multiplicative factor for cluster sigmaX,Y,Z
422   Double_t      fConstrPT;                      // optional PT constraint for helix (abs value)
423   Double_t      fConstrPTErr;                   // error on this constraint (0 - exact)
424   Int_t         fConstrCharge;                  // optional constraint on charge of Helix track (0 - no constraint)
425   Int_t         fRunID;                         // current runID
426   //
427   Double_t      fDerivativeLoc[kNLocal][3];     // XYZ deriv. over local params
428   Double_t      fDerivativeGlo[kNParCh][3];     // XYZ deriv. over global params
429   Int_t         fMinNPtsPerTrack;               // min number of points per track to accept it
430   Int_t         fIniTrackParamsMeth;            // method for track fit
431   Int_t         fTotBadLocEqPoints;             // total number of reject points because of bad EqLoc
432   AliTrackFitterRieman *fRieman;                // riemann fitter for helices
433   //
434   TObjArray     fConstraints;                   // list of constraints
435   TObjArray     fCacheMatrixOrig;               // cach for original geom matrices
436   TObjArray     fCacheMatrixCurr;               // cach for prealigned geom matrices
437   // >> new members
438   Bool_t        fUseGlobalDelta;                // intetpret deltas as global 
439   Bool_t        fRequirePoints[kNDataType];     // required points in specific layers
440   Int_t         fNReqLayUp[kNDataType][6];      // number of points required in layer[n] with Y>0
441   Int_t         fNReqLayDown[kNDataType][6];    // number of points required in layer[n] with Y<0
442   Int_t         fNReqLay[kNDataType][6];        // number of points required in layer[n] 
443   Int_t         fNReqDetUp[kNDataType][3];      // number of points required in Detector[n] with Y>0
444   Int_t         fNReqDetDown[kNDataType][3];    // number of points required in Detector[n] with Y<0
445   Int_t         fNReqDet[kNDataType][3];        // number of points required in Detector[n]
446   Int_t         fTempExcludedModule; /// single module temporary excluded from initial fit
447   UInt_t        fUserProvided;                  // settings which user provided: not to update from the UserUnfo
448   // << new members
449   //
450   // OCDB stuff
451   TList        *fIniUserInfo;                   // initial user info (validity is not guaranteed after initialization)
452   TString       fIniGeomPath;                   // where to take the ideal geometry used to produce the points
453   TString       fIniDeltaPath;                  // where to take the deltas used to produce the points
454   TString       fIniSDDRespPath;                // where to take the initial SDD response used to produce the points
455   TString       fPreCalSDDRespPath;             // precalibration SDD response file name
456   TString       fIniSDDVDriftPath;              // initial SDD vdrift file name
457   TString       fPreSDDVDriftPath;              // precalibration SDD vdrift file name
458   TString       fIniSDDCorrMapPath;             // initial SDD corr.map file name
459   TString       fPreSDDCorrMapPath;             // precalibration SDD corr.map file name
460   // geometry stuffs
461   Bool_t        fConvertPreDeltas;              // when the prealignment deltas come from UserInfo, convert them from UserInfo geometry to target one
462   TString       fGeometryPath;                  // Geometry file name
463   TString       fPreDeltaPath;                  // file with prealigned objects
464   TString       fConstrRefPath;                 // file with prealigned objects wrt which constraints are defined
465   TString       fDiamondPath;                   // file with diamond constraint
466   TGeoManager  *fGeoManager;                    // pointer to Alice geomanager
467   Bool_t        fIsConfigured;                  // flag for loaded config file
468   TArrayS       fPreAlignQF;                    // prealignment flags (not used?)
469   //
470   AliITSresponseSDD* fIniRespSDD;               // array of SDD t0/vdrift calib params used to create the track points
471   AliITSresponseSDD* fPreRespSDD;               // array of SDD t0/vdrift calib params
472   TObjArray*         fIniVDriftSDD;             // array of AliITSDriftSpeedArraySDD objects used for original reco
473   TObjArray*         fPreVDriftSDD;             // array of AliITSDriftSpeedArraySDD objects to be used as a starting point instead of fIniVDriftSDD
474   AliITSCorrectSDDPoints* fIniCorrMapSDD;       // SDD initial correction map
475   AliITSCorrectSDDPoints* fPreCorrMapSDD;       // SDD precalibration correction map
476   AliITSsegmentationSDD* fSegmentationSDD;      // extraction of SDD segmentation params
477   TClonesArray* fPrealignment; // array of prealignment global deltas
478   TClonesArray* fConstrRef;    // array of refererence deltas with respect to which the constraint are defined (survey?)
479   TObjArray     fMilleModule; /// array of super modules to be aligned
480   TObjArray     fSuperModule; /// array of super modules defined in supermodule file
481   Int_t         fNModules;                      // number of defined modules from config file
482   Int_t         fNSuperModules; /// number of custom supermodules in SM file
483   Bool_t        fUsePreAlignment;               // start from prealigned setup 
484   Bool_t        fUseLocalYErr;                  // use local Yerror due to the sensor thickness
485   Bool_t        fBOn;                           // magentic field ON
486   Double_t      fBField;                        // value of magnetic field
487   Int_t         fDataType;                      // is this cosmics or collision processing?
488   Int_t         fMinPntPerSens;                 // min number of points per module to vary it
489   Int_t         fBug;                           /// tag for temporary bug correction
490   // pepo
491   Int_t         fMilleVersion; /// tag for backward compatibility
492   // endpepo
493   // pepo270809
494   Int_t         fExtraClustersMode; /// 1=remove random / 2=remove internal / 10=use only tracks with xcl
495   // endpepo270809
496   //
497   Double_t      fTrackWeight;                      //weight given by the user to current track
498   Double_t      fWeightPt;                         //weight track equations by pT in this power
499   Bool_t        fIsSDDVDriftMult;                  //use multiplicative correction for SDD vdrift
500   Double_t      fDriftSpeed[50];                   //temporary array for corrected drift speed of SDD alitrackpoints
501   Double_t      fDriftSpeed0[50];                  //temporary array for original  drift speed of SDD alitrackpoints
502   Double_t      fDriftTime0[50];                   //temporary array for drift time 0's used for SDD alitrackpoints
503   Double_t      fExtClusterPar[9];                 //array to store the parameters of the externally imposed cluster
504   AliTrackPoint fDiamond;                          //optional constraint on the vertex
505   AliTrackPoint fDiamondI;                         //constraint on the vertex with inverted error matrix
506   Double_t      fCorrDiamond[3];                   //diamond correction
507   Bool_t        fUseDiamond;                       //use diamond as a vertex constraint
508   Bool_t        fUseVertex;                        //use vertex for constraint
509   Bool_t        fVertexSet;                        //vertex is set for current track
510   Int_t         fDiamondPointID;                   //ID of the diamond point in the track
511   Int_t         fDiamondModID;                     //id of the fake diamond module
512   Int_t         fCheckDiamondPoint;                // kDiamondIgnore: ignore in this event, kDiamondCheckIfPrompt: verify if track is prompt, kDiamondUse: use w/o verification
513   Float_t       fCovIScale[kMaxPoints];            //optional scaling for inv.cov matrix (debiasing). MANAGED BY THE USER EXTERNALLY
514   //
515   TObjArray     fConvAlgMatOld;                    //array to keep matrices of alignables for deltas conversion
516   //
517   static AliITSAlignMille2* fgInstance;         // global pointer on itself
518   static Int_t              fgInstanceID;       // global counter of the instances
519   static const Char_t     * fgkRecKeys[];       // keywords for config file records
520   static const Char_t       fgkXYZ[];           // XYZ labels
521   //
522   ClassDef(AliITSAlignMille2, 0)
523 };
524
525
526 //______________________________________________________________________________________
527 inline void AliITSAlignMille2::SetCurrentCluster(const AliTrackPoint &atp) 
528 {
529   // set current cluster
530   fCluster = atp; 
531   fCurrentSensID = AliITSAlignMille2Module::GetIndexFromVolumeID(fCluster.GetVolumeID());
532 }
533
534 //______________________________________________________________________________________
535 inline TGeoHMatrix* AliITSAlignMille2::GetSensorOrigMatrixSID(Int_t sid) const 
536 {
537   // get cached original matrix by sensor ID
538   return sid<0 ? 0 : (TGeoHMatrix*) fCacheMatrixOrig[sid];
539 }
540
541 //______________________________________________________________________________________
542 inline TGeoHMatrix* AliITSAlignMille2::GetSensorOrigMatrixVID(Int_t vid) const
543 {
544   // get cached original matrix by sensor volume ID
545   return GetSensorOrigMatrixSID( AliITSAlignMille2Module::GetIndexFromVolumeID(vid) );
546 }
547
548 //______________________________________________________________________________________
549 inline TGeoHMatrix* AliITSAlignMille2::GetSensorCurrMatrixSID(Int_t sid) const 
550 {
551   // get cached current matrix by sensor ID
552   return sid<0 ? 0 : (TGeoHMatrix*) fCacheMatrixCurr[sid];
553 }
554
555 //______________________________________________________________________________________
556 inline TGeoHMatrix* AliITSAlignMille2::GetSensorCurrMatrixVID(Int_t vid) const
557 {
558   // get cached current matrix by sensor volume ID
559   return GetSensorCurrMatrixSID( AliITSAlignMille2Module::GetIndexFromVolumeID(vid) );
560 }
561
562 #endif
563