]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/src/AliHLTTransform.h
New version of SPD raw-data reconstruction. The format now correponds to the actual...
[u/mrichter/AliRoot.git] / HLT / src / AliHLTTransform.h
1 // @(#) $Id$
2
3 #ifndef ALIL3TRANSFORM_H
4 #define ALIL3TRANSFORM_H
5
6 #ifdef use_aliroot
7   class AliRunLoader;
8 #endif
9
10 #include "AliHLTRootTypes.h"
11
12 class AliHLTTransform {
13
14  public:
15   enum VersionType { kVdefault=0, kVdeprecated=1, kValiroot=10, kVcosmics=100};
16
17  private:
18   static const Double_t fgkBFACT; //bfield
19   static const Double_t fgkPi;    //pi
20   static const Double_t fgkPi2;   //2pi
21   static const Double_t fgk2Pi;   //pi/2
22   static const Double_t fgkAnodeWireSpacing; //anode wire spacing 
23   static const Double_t fgkToDeg; //rad to deg
24
25   static Int_t fgNPatches;   //6 (dont change this) 
26   static Int_t fgRows[6][2]; //rows per patch
27   static Int_t fgNRows[6];   //rows per patch
28
29   static Double_t fgBField;         //field
30   static Double_t fgBFieldFactor;   //field 
31   static Double_t fgSolenoidBField; //field
32   static Int_t fgNTimeBins;  //ntimebins
33   static Int_t fgNRowLow;    //nrows
34   static Int_t fgNRowUp;     //nrows
35   static Int_t fgNRowUp1;    //nrows
36   static Int_t fgNRowUp2;    //nrows
37   static Int_t fgNSectorLow; //nsector
38   static Int_t fgNSectorUp;  //nsector
39   static Int_t fgSlice2Sector[36][2]; //nslice
40   static Int_t fgSector2Slice[72];    //nslice
41   static Int_t fgSectorLow[72];       //nsector
42   static Double_t fgPadPitchWidthLow; //pad pitch
43   static Double_t fgPadPitchWidthUp;  //pad pitch
44   static Double_t fgZWidth;  //width
45   static Double_t fgZSigma;  //sigma
46   static Double_t fgZLength; //length
47   static Double_t fgZOffset; //offset
48   static Int_t fgNSector; //72  (dont change this)
49   static Int_t fgNSlice;  //36  (dont change this)
50   static Int_t fgNRow;    //159 (dont change this)
51   static Double_t fgNRotShift; //Rotation shift (eg. 0.5 for 10 degrees)
52   static Int_t fgNPads[159]; //fill this following Init and fVersion
53   static Double_t fgX[159];  //X position in local coordinates
54   static Int_t fgVersion;  //flags the version
55   static Double_t fgDiffT; //Transversal diffusion constant
56   static Double_t fgDiffL; //Longitudinal diffusion constant
57   static Double_t fgOmegaTau; //ExB effects
58   static Double_t fgInnerPadLength;  //innner pad length
59   static Double_t fgOuter1PadLength; //outer pad length
60   static Double_t fgOuter2PadLength; //outer pad length
61   static Double_t fgInnerPRFSigma;   //inner pad response function
62   static Double_t fgOuter1PRFSigma;  //outer pad response function
63   static Double_t fgOuter2PRFSigma;  //outer pad response function
64   static Double_t fgTimeSigma; //Minimal longitudinal width
65   static Int_t fgADCSat; //ADC Saturation (1024 = 10 bit)
66   static Int_t fgZeroSup; //Zero suppression threshold
67   static Double_t fgCos[36]; //stores the cos value for local to global rotations  
68   static Double_t fgSin[36]; //stores the sin value for local to global rotations  
69
70  public:
71   virtual ~AliHLTTransform() {}
72 #ifdef use_aliroot
73   static Bool_t Init(AliRunLoader *runLoader); //init transformer params using a run loader
74 #endif
75   static Bool_t Init(Char_t* path,Bool_t UseAliTPCParam=kFALSE); //init transformer settings (versions)
76   static Bool_t MakeInitFile(Char_t *rootfilename,Char_t *filename); //create the init file from rootfile
77   static Bool_t ReadInit(Char_t *path);         //read init (possibly from root file)
78   static Bool_t ReadInitFile(Char_t *path);     //read init from text file 
79   static Bool_t SaveInitFile(Char_t *filename); //save parameters in init file
80
81   //setters
82   static void SetNPatches(Int_t i){fgNPatches = i;}
83   static void SetNRows(Int_t s[6]){for(Int_t i=0;i<fgNPatches;i++) fgNRows[i] = s[i];}
84   static void SetRows(Int_t s[6][2]){
85     for(Int_t i=0;i<fgNPatches;i++){
86       fgRows[i][0] = s[i][0];
87       fgRows[i][1] = s[i][1];
88     }
89   }
90   static void SetBField(Double_t f) {fgBField = f;} //careful, these 3 are not independent!
91   static void SetBFieldFactor(Double_t f) {
92     fgBFieldFactor = f;
93     fgBField=fgBFieldFactor*fgSolenoidBField*0.1;
94   }
95   static void SetSolenoidBField(Double_t f){
96     fgSolenoidBField = f;
97     fgBField=fgBFieldFactor*fgSolenoidBField*0.1;
98   }
99   static void SetNTimeBins(Int_t i){fgNTimeBins = i;}
100   static void SetNRowLow(Int_t i){fgNRowLow = i;}
101   static void SetNRowUp(Int_t i){fgNRowUp = i;}
102   static void SetNRowUp1(Int_t i){fgNRowUp1 = i;}
103   static void SetNRowUp2(Int_t i){fgNRowUp2 = i;}
104   static void SetSlice2Sector(Int_t s[36][2]){
105     for(Int_t i=0;i<fgNSlice;i++){
106       fgSlice2Sector[i][0] = s[i][0];
107       fgSlice2Sector[i][1] = s[i][1];
108     }
109   }
110   static void SetSector2Slice(Int_t s[72]){
111     for(Int_t i=0;i<fgNSector;i++) fgSector2Slice[i] = s[i];}
112   static void SetSectorLow(Int_t s[72]){
113     for(Int_t i=0;i<fgNSector;i++) fgSectorLow[i] = s[i];}
114   static void SetNSectorLow(Int_t i){fgNSectorLow = i;}
115   static void SetNSectorUp(Int_t i){fgNSectorUp = i;}
116   static void SetPadPitchWidthLow(Double_t f){fgPadPitchWidthLow = f;}
117   static void SetPadPitchWidthUp(Double_t f){fgPadPitchWidthUp = f;}
118   static void SetZWidth(Double_t f){fgZWidth = f;}
119   static void SetZSigma(Double_t f){fgZSigma = f;}
120   static void SetZLength(Double_t f){fgZLength = f;}
121   static void SetZOffset(Double_t f){fgZOffset = f;}
122   static void SetNSector(Int_t i){fgNSector = i;}
123   static void SetNSlice(Int_t i){fgNSlice = i;}
124   static void SetNRow(Int_t i){fgNRow = i;}
125   static void SetNRotShift(Double_t f){fgNRotShift = f;}
126   static void SetNPads(Int_t pads[159]){
127     for(Int_t i=0;i<fgNRow;i++) fgNPads[i] = pads[i];}
128   static void SetX(Double_t xs[159]){
129     for(Int_t i=0;i<fgNRow;i++) fgX[i] = xs[i];}
130   static void SetVersion(Int_t i){fgVersion = i;}
131   static void SetDiffT(Double_t f){fgDiffT = f;}
132   static void SetDiffL(Double_t f){fgDiffL = f;}
133   static void SetOmegaTau(Double_t f){fgOmegaTau = f;}
134   static void SetInnerPadLength(Double_t f){fgInnerPadLength = f;}
135   static void SetOuter1PadLength(Double_t f){fgOuter1PadLength = f;}
136   static void SetOuter2PadLength(Double_t f){fgOuter2PadLength = f;}
137   static void SetInnerPRFSigma(Double_t f){fgInnerPRFSigma = f;}
138   static void SetOuter1PRFSigma(Double_t f){fgOuter1PRFSigma = f;}
139   static void SetOuter2PRFSigma(Double_t f){fgOuter2PRFSigma = f;}
140   static void SetTimeSigma(Double_t f){fgTimeSigma = f;}
141   static void SetADCSat(Int_t i) {fgADCSat = i;}
142   static void SetZeroSup(Int_t i) {fgZeroSup = i;}
143
144   //getters
145   static const Char_t* GetParamName() {return "75x40_100x60_150x60";}
146   static Double_t Pi()     {return fgkPi;}
147   static Double_t PiHalf() {return fgkPi2;}
148   static Double_t TwoPi()  {return fgk2Pi;}
149   static Double_t GetAnodeWireSpacing() {return fgkAnodeWireSpacing;}
150   static Double_t GetBFact() {return fgkBFACT;}
151   static Double_t ToRad() {return 1./fgkToDeg;}
152   static Double_t ToDeg() {return fgkToDeg;}
153
154   static Int_t GetFirstRow(Int_t patch);
155   static Int_t GetLastRow(Int_t patch);
156   static Int_t GetFirstRowOnDDL(Int_t patch);
157   static Int_t GetLastRowOnDDL(Int_t patch);
158   static Int_t GetNRows(Int_t patch);
159   static Int_t GetPatch(Int_t padrow);
160   static Int_t GetNRows() {return fgNRow;}
161   static Int_t GetNRowLow() {return fgNRowLow;}
162   static Int_t GetNRowUp1() {return fgNRowUp1;}
163   static Int_t GetNRowUp2() {return fgNRowUp2;}
164   static Int_t GetPadRow(Float_t x);
165   static Int_t GetNPatches() {return fgNPatches;}
166   static Int_t GetNPads(Int_t row);
167   static Int_t GetNTimeBins(){return fgNTimeBins;}
168   static Double_t GetBField() {return fgBField;}
169   static Double_t GetSolenoidField() {return fgSolenoidBField;}
170   static Double_t GetBFactFactor() {return fgBFieldFactor;}
171   static Double_t GetBFieldValue() {return (fgBField*fgkBFACT);}
172   static Float_t Deg2Rad(Float_t angle) {return angle/fgkToDeg;}
173   static Float_t Rad2Deg(Float_t angle) {return angle*fgkToDeg;}
174   static Int_t GetVersion(){return fgVersion;}
175   static Double_t GetPadPitchWidthLow() {return fgPadPitchWidthLow;}
176   static Double_t GetPadPitchWidthUp() {return fgPadPitchWidthUp;}
177   static Double_t GetPadPitchWidth(Int_t patch);
178   static Double_t GetZWidth() {return fgZWidth;}
179   static Double_t GetZLength() {return fgZLength;}
180   static Double_t GetZOffset() {return fgZOffset;}
181   static Double_t GetDiffT() {return fgDiffT;}
182   static Double_t GetDiffL() {return fgDiffL;}
183   static Double_t GetParSigmaY2(Int_t padrow,Float_t z,Float_t angle);
184   static Double_t GetParSigmaZ2(Int_t padrow,Float_t z,Float_t tgl);
185   static Double_t GetOmegaTau() {return fgOmegaTau;}
186   static Double_t GetPadLength(Int_t padrow);
187   static Double_t GetPRFSigma(Int_t padrow);
188   static Double_t GetTimeSigma() {return fgTimeSigma;}
189   static Double_t GetZSigma() {return fgZSigma;}
190   static Int_t GetADCSat() {return fgADCSat;}
191   static Int_t GetZeroSup() {return fgZeroSup;}
192   static Int_t GetNSlice() {return fgNSlice;}
193   static Int_t GetNSector() {return fgNSector;}
194   static Int_t GetNSectorLow() {return fgNSectorLow;}
195   static Int_t GetNSectorUp() {return fgNSectorUp;}
196   
197   static Bool_t Slice2Sector(Int_t slice, Int_t slicerow, Int_t &sector, Int_t &row);
198   static Bool_t Sector2Slice(Int_t &slice, Int_t sector);
199   static Bool_t Sector2Slice(Int_t &slice, Int_t &slicerow, Int_t sector, Int_t row);
200
201   static Double_t Row2X(Int_t slicerow);
202   static Double_t GetMaxY(Int_t slicerow);
203   static Double_t GetEta(Float_t *xyz);
204   static Double_t GetEta(Int_t slice,Int_t padrow, Int_t pad, Int_t time);
205   static Double_t GetPhi(Float_t *xyz);
206   static Double_t GetZFast(Int_t slice, Int_t time, Float_t vertex=0.);
207
208   static void XYZtoRPhiEta(Float_t *rpe, Float_t *xyz);
209   static void Local2Global(Float_t *xyz, Int_t slice);
210   static void Local2GlobalAngle(Float_t *angle, Int_t slice);
211   static void Global2LocalAngle(Float_t *angle, Int_t slice);
212
213   //we have 3 different system: Raw   : row, pad, time
214   //                            Local : x,y and global z
215   //                            Global: global x,y and global z
216   //the methods with HLT in the name differ from the other
217   //as you specify slice and slicerow, instead of sector
218   //and sector row. In that way we safe "a few ifs"
219   static void Raw2Local(Float_t *xyz, Int_t sector, Int_t row, Float_t pad, Float_t time);
220   static void RawHLT2Local(Float_t *xyz,Int_t slice,Int_t slicerow,Float_t pad,Float_t time);
221   static void Raw2Local(Float_t *xyz, Int_t sector, Int_t row, Int_t pad, Int_t time);
222   static void RawHLT2Local(Float_t *xyz,Int_t slice,Int_t slicerow,Int_t pad,Int_t time);
223   static void Local2Global(Float_t *xyz, Int_t sector, Int_t row);
224   static void LocHLT2Global(Float_t *xyz, Int_t slice, Int_t slicerow);
225   static void Global2Local(Float_t *xyz, Int_t sector);
226   static void Global2LocHLT(Float_t *xyz, Int_t slice);
227   static void Raw2Global(Float_t *xyz, Int_t sector, Int_t row, Float_t pad, Float_t time);
228   static void RawHLT2Global(Float_t *xyz, Int_t slice, 
229                             Int_t slicerow, Float_t pad, Float_t time);
230   static void Raw2Global(Float_t *xyz, Int_t sector, Int_t row, Int_t pad, Int_t time);
231   static void RawHLT2Global(Float_t *xyz, Int_t slice, 
232                             Int_t slicerow, Int_t pad, Int_t time);
233   static void Local2Raw(Float_t *xyz, Int_t sector, Int_t row);
234   static void LocHLT2Raw(Float_t *xyz, Int_t slice, Int_t slicerow);
235   static void Global2Raw(Float_t *xyz, Int_t sector, Int_t row);
236   static void Global2HLT(Float_t *xyz, Int_t slice, Int_t slicerow);
237
238   static void PrintCompileOptions();
239   
240   ClassDef(AliHLTTransform,1)
241 };
242
243 typedef AliHLTTransform AliL3Transform; // for backward compatibility
244
245 #endif