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