]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSAlignMille2Module.h
Coverity fix
[u/mrichter/AliRoot.git] / ITS / AliITSAlignMille2Module.h
1 #ifndef ALIITSALIGNMILLE2MODULE_H
2 #define ALIITSALIGNMILLE2MODULE_H 
3 /* Copyright(c) 2007-2009 , ALICE Experiment at CERN, All rights reserved. * 
4  * See cxx source for full Copyright notice                               */  
5  
6 /// \ingroup rec 
7 /// \class AliITSAlignMille2Module
8 /// \brief Class for alignment of ITS 
9 // 
10 // Authors: Marcello Lunardon 
11 //
12 // RS Converted static arrays fSensVolVolumeID and fSensVolIndex
13 // to TArrays in user transparent way.
14 //
15 /* $Id$  */ 
16 //#include <TString.h> 
17 //#include <TObject.h> 
18 #include <TNamed.h> 
19 #include <TArrayI.h> 
20 #include <TArrayS.h> 
21 #include <TObjArray.h> 
22 class AliITSAlignMille2;
23
24 class AliAlignObjParams; 
25 class TGeoHMatrix; 
26
27 class AliITSAlignMille2Module : public TNamed 
28
29 public: 
30   enum {kSPD,kSDD,kSSD};
31   enum {kMaxParGeom=6,kMaxParTot=9,kSensDefBit=BIT(14),kGlobalGeomBit=BIT(15),kNotInConfBit=BIT(16),kVdSDDSameLRBit=BIT(17)};
32   enum {kDOFTX,kDOFTY,kDOFTZ,kDOFPS,kDOFTH,kDOFPH,kDOFT0,kDOFDVL,kDOFDVR};
33   //
34   AliITSAlignMille2Module(); 
35   AliITSAlignMille2Module(UShort_t volid);
36   AliITSAlignMille2Module(Int_t index, UShort_t volid, const char* symname, const TGeoHMatrix *m, Int_t nsv=0, const UShort_t *volidsv=NULL);
37   AliITSAlignMille2Module(const AliITSAlignMille2Module& rhs); // copy constructor
38   AliITSAlignMille2Module& operator=(const AliITSAlignMille2Module& rhs);  
39   //
40   virtual ~AliITSAlignMille2Module(); 
41   //
42   // geometry methods  
43   Int_t        GetIndex()                             const {return fIndex;} 
44   UShort_t     GetVolumeID()                          const {return fVolumeID;}  
45   Int_t        GetNSensitiveVolumes()                 const {return fNSensVol;} 
46   Int_t        GetSensVolIndex(Int_t at)              const {return fSensVolIndex[at];}
47   Short_t      GetSensVolVolumeID(Int_t at)           const {return fSensVolVolumeID[at];}
48   TGeoHMatrix *GetMatrix()                            const {return fMatrix;}
49   void         GetLocalMatrix(TGeoHMatrix& mat)       const;
50   UShort_t    *GetSensitiveVolumeVolumeID()           const {return (UShort_t*)fSensVolVolumeID.GetArray();}
51   Float_t      GetSigmaFactor(Int_t i)                const {return fSigmaFactor[i];}
52   Float_t      GetSigmaXFactor()                      const {return fSigmaFactor[0];}
53   Float_t      GetSigmaYFactor()                      const {return fSigmaFactor[1];}
54   Float_t      GetSigmaZFactor()                      const {return fSigmaFactor[2];}
55   Int_t        GetNProcessedPoints()                  const {return fNProcPoints;}
56   Bool_t       IsFreeDOF(Int_t dof)                   const {return dof<fNParTot && fParCstr[dof]>0;}
57   Bool_t       AreSensorsProvided()                   const {return TestBit(kSensDefBit);}
58   Bool_t       GeomParamsGlobal()                     const {return TestBit(kGlobalGeomBit);}
59   Bool_t       IsNotInConf()                          const {return TestBit(kNotInConfBit);}
60   Bool_t       IsVDriftLRSame()                       const {return TestBit(kVdSDDSameLRBit);}
61   //
62   Bool_t       IsIn(UShort_t volid)                   const;
63   Bool_t       IsAlignable()                          const;
64   Bool_t       BelongsTo(AliITSAlignMille2Module* parent) const;
65   AliITSAlignMille2Module* GetParent()                const {return fParent;}
66   AliITSAlignMille2Module* GetChild(Int_t i)          const {return (AliITSAlignMille2Module*)fChildren[i];}
67   Int_t        GetNChildren()                         const {return fChildren.GetLast()+1;}
68   //
69   void         Print(Option_t* opt="")                const; 
70   //
71   void         EvaluateDOF();
72   UShort_t     GetNParTot()                           const {return fNParTot;}
73   UShort_t     GetNParFree()                          const {return fNParFree;}
74   Float_t     *GetParVals()                           const {return fParVals;}
75   Double_t     GetParVal(int par)                     const {return par<fNParTot ? fParVals[par] : 0;}
76   Double_t     GetParErr(int par)                     const {return par<fNParTot ? fParErrs[par] : 0;}
77   Double_t     GetParConstraint(int par)              const {return par<fNParTot ? fParCstr[par] : 0;}
78   Int_t        GetParOffset(Int_t par)                const {return par<fNParTot ? fParOffs[par] : -1;}
79   Int_t        GetDetType()                           const {return fDetType;}
80   Bool_t       IsParConstrained(Int_t par)            const {return fParCstr[par]>0 && fParCstr[par]<fgkDummyConstraint;}
81   Bool_t       IsSPD()                                const {return fDetType == kSPD;}
82   Bool_t       IsSDD()                                const {return fDetType == kSDD;}
83   Bool_t       IsSSD()                                const {return fDetType == kSSD;}
84   Bool_t       IsSensor()                             const {return IsSensor(fVolumeID);}
85   void         SetDetType(Int_t tp)                         {fDetType = tp;}
86   void         SetParOffset(Int_t par,Int_t offs)           {fParOffs[par] = offs;}
87   //
88   void         SetParVals(Double_t *vl,Int_t npar);          
89   void         SetParVal(Int_t par,Double_t v=0)            {fParVals[par] = v;}
90   void         SetParErr(Int_t par,Double_t e=0)            {fParErrs[par] = e;}
91   void         SetParConstraint(Int_t par,Double_t s=1e6)   {fParCstr[par] = s>0. ? s:0.0;}
92   void         SetSigmaFactor(Int_t i,Float_t v)            {fSigmaFactor[i]=TMath::Max(0.001F,v);}
93   void         SetSigmaXFactor(Float_t v)                   {SetSigmaFactor(0,v);}
94   void         SetSigmaYFactor(Float_t v)                   {SetSigmaFactor(1,v);}
95   void         SetSigmaZFactor(Float_t v)                   {SetSigmaFactor(2,v);}
96   void         IncNProcessedPoints(Int_t step=1)            {fNProcPoints += step;}
97   void         SetNProcessedPoints(Int_t v)                 {fNProcPoints = v;}
98   void         SetParent(AliITSAlignMille2Module* par)      {fParent = par;}
99   void         AddChild(AliITSAlignMille2Module* cld)       {fChildren.Add(cld);}
100   void         SetFreeDOF(Int_t dof,Double_t cstr);
101   void         SetSensorsProvided(Bool_t v=kTRUE)           {SetBit(kSensDefBit,v);}
102   void         SetGeomParamsGlobal(Bool_t v=kTRUE)          {SetBit(kGlobalGeomBit,v);}
103   void         SetNotInConf(Bool_t v=kTRUE)                 {SetBit(kNotInConfBit,v);}
104   void         SetVDriftLRSame(Bool_t v=kTRUE)              {SetBit(kVdSDDSameLRBit,v);}
105   Int_t        Set(Int_t index,UShort_t volid, const char* symname, const TGeoHMatrix *m,Int_t nsv=0, const UShort_t *volidsv=0);
106   //
107   void         AddSensitiveVolume(UShort_t volid);
108   void         DelSensitiveVolume(Int_t at);
109   void         DelSensitiveVolumes()                        {fNSensVol = 0;}
110   //
111   void         GetGeomParamsGlo(Double_t *pars);
112   void         GetGeomParamsLoc(Double_t *pars);
113   //
114   TGeoHMatrix *GetSensitiveVolumeMatrix(UShort_t voluid);
115   TGeoHMatrix *GetSensitiveVolumeOrigGlobalMatrix(UShort_t voluid);
116   TGeoHMatrix *GetSensitiveVolumeModifiedMatrix(UShort_t voluid, const Double_t *delta,Bool_t local=kTRUE); 
117   AliAlignObjParams *GetSensitiveVolumeMisalignment(UShort_t voluid, const AliAlignObjParams *a); 
118   AliAlignObjParams *GetSensitiveVolumeMisalignment(UShort_t voluid, const Double_t *deltalocal); 
119   //
120   void         GetGlobalParams(Double_t *t, Double_t *r) const;
121   void         GetGlobalParams(const Double_t *loct, const Double_t *locr,Double_t *t, Double_t *r);
122   void         GetLocalParams(const Double_t *loct, const Double_t *locr,Double_t *t, Double_t *r);
123   //
124   void         GetSensVolGlobalParams(UShort_t volid,Double_t *t, Double_t *r);
125   void         GetSensVolLocalParams(UShort_t volid,Double_t *t, Double_t *r);
126   void         GetSensVolGlobalParams(UShort_t volid,const Double_t* loct,const Double_t* locr,Double_t *t, Double_t *r);
127   void         GetSensVolLocalParams(UShort_t volid,const Double_t* loct,const Double_t* locr,Double_t *t, Double_t *r);
128   //
129   void         CalcDerivLocGlo(Double_t *deriv);
130   void         CalcDerivGloLoc(Int_t idx,Double_t *deriv);
131   void         CalcDerivGloLoc(Int_t sensVol,Int_t paridx,Double_t* derivative);
132   void         CalcDerivCurLoc(Int_t sensVol,Int_t paridx,Double_t* derivative);
133   void         CalcDerivDPosDPar(Int_t sensVol,const Double_t *pl,Double_t *deriv);
134   //
135   // forse non serve...
136   AliAlignObjParams *GetSensitiveVolumeGlobalMisalignment(UShort_t voluid, const Double_t *deltalocal); 
137   // mo' proviamo questo
138   AliAlignObjParams *GetSensitiveVolumeTotalMisalignment(UShort_t voluid, const Double_t *deltalocal); 
139   //
140   static Int_t    GetIndexFromVolumeID(UShort_t volid);
141   static UShort_t GetVolumeIDFromSymname(const Char_t *symname);
142   static UShort_t GetVolumeIDFromIndex(Int_t index);
143   static Bool_t   IsSensor(UShort_t vid);
144   static Int_t    SensVolMatrix(UShort_t volid, TGeoHMatrix *m); 
145   static Int_t    SensVolOrigGlobalMatrix(UShort_t volid, TGeoHMatrix *m); 
146
147   //
148 protected:
149   //
150   void         AssignDetType();
151   //
152 protected:
153   //
154   Int_t          fNSensVol;                       // number of sensor it refers to
155   Int_t          fIndex;                          // aliroot index
156   Int_t          fDetType;                        // Detector type
157   UShort_t       fVolumeID;                       // aliroot volune ID
158   UShort_t       fNParTot;                        // total number of parameters
159   UShort_t       fNParFree;                       // number of free parameters
160   TArrayS        fParOffs;                        // offsets of free params in the fit results
161   Int_t          fNProcPoints;                    // number of processed points
162   Float_t        fSigmaFactor[3];                 // multiplicative factor for referred sensor X,Y,Z error
163   Float_t       *fParVals;                        // values of the fitted params
164   Float_t       *fParErrs;                        // errors of the fitted params
165   Float_t       *fParCstr;                        // Gaussian type constraint on parameter, 0 means fixed param
166   //
167   TArrayI        fSensVolIndex;                   // aliroot indices for sensors
168   TArrayS        fSensVolVolumeID;                // aliroot indices for sensors volumes
169   TGeoHMatrix   *fMatrix;                         // ideal TGeoHMatrix of the supermodule
170   TGeoHMatrix   *fSensVolMatrix;                  // sensor's ideal matrices
171   TGeoHMatrix   *fSensVolModifMatrix;             // sensor's modified matrices
172   //
173   AliITSAlignMille2Module* fParent;               // optional parent pointer
174   TObjArray      fChildren;                       // array of optional children
175   //
176   static const Float_t fgkDummyConstraint;        // dummy (lose) contraint on parameter
177   //
178   ClassDef(AliITSAlignMille2Module, 0)
179 }; 
180
181 #endif