]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/AliHMPIDParam.h
impoved num precision
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDParam.h
1 #ifndef AliHMPIDParam_h
2 #define AliHMPIDParam_h
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 #include <TMath.h>
9 #include <TNamed.h>        //base class
10 #include <TGeoManager.h>   //Instance()
11 #include <TGeoMatrix.h>   //Instance()
12 #include <TVector3.h>      //Lors2Mars() Mars2Lors()
13  
14 // Class providing all the needed parametrised information
15 // to construct the geometry, to define segmentation and to provide response model
16 // In future will also provide all the staff needed for alignment and calibration
17
18 class AliHMPIDParam :public TNamed  
19 {
20 public:
21 //ctor&dtor    
22   virtual        ~AliHMPIDParam() {if (fgInstance){for(Int_t i=0;i<7;i++){delete fM[i];fM[i] = 0x0;};fgInstance=0;}}
23   
24   void     Print(Option_t *opt="") const;                                         //print current parametrization
25          
26   static inline AliHMPIDParam* Instance();                                //pointer to AliHMPIDParam singleton
27   static inline AliHMPIDParam* InstanceNoGeo();                           //pointer to AliHMPIDParam singleton without geometry.root for MOOD, displays, ...
28 //geo info
29   enum EChamberData{kMinCh=0,kMaxCh=6,kMinPc=0,kMaxPc=5};      //Segmenation
30   enum EPadxData{kPadPcX=80,kMinPx=0,kMaxPx=79,kMaxPcx=159};   //Segmentation structure along x
31   enum EPadyData{kPadPcY=48,kMinPy=0,kMaxPy=47,kMaxPcy=143};   //Segmentation structure along y 
32   enum EPedestalData{kPadMeanZeroCharge=4000,kPadSigmaZeroCharge=1000,kPadMeanMasked=4001,kPadSigmaMasked=1001}; //Pedestal pad data information
33       
34   static Float_t SizePadX    (                               )     {return fgCellX;                                  }  //pad size x, [cm]  
35   static Float_t SizePadY    (                               )     {return fgCellY;                                  }  //pad size y, [cm]  
36
37   static Float_t SizePcX    (                                )     {return fgPcX;                                    }  // PC size x
38   static Float_t SizePcY    (                                )     {return fgPcY;                                    }  // PC size y
39   static Float_t MaxPcX      (Int_t iPc                      )     {return fgkMaxPcX[iPc];                           }  // PC limits
40   static Float_t MaxPcY      (Int_t iPc                      )     {return fgkMaxPcY[iPc];                           }  // PC limits
41   static Float_t MinPcX      (Int_t iPc                      )     {return fgkMinPcX[iPc];                           }  // PC limits
42   static Float_t MinPcY      (Int_t iPc                      )     {return fgkMinPcY[iPc];                           }  // PC limits
43   static Int_t   Nsig        (                               )     {return fgSigmas;                                 }  //Getter n. sigmas for noise
44   static Float_t SizeAllX    (                               )     {return fgAllX;                                   }  //all PCs size x, [cm]        
45   static Float_t SizeAllY    (                               )     {return fgAllY;                                   }  //all PCs size y, [cm]    
46
47   static Float_t LorsX       (Int_t pc,Int_t padx             )    {return (padx    +0.5)*SizePadX()+fgkMinPcX[pc]; }   //center of the pad x, [cm]
48   static Float_t LorsY       (Int_t pc,Int_t pady            )     {return (pady    +0.5)*SizePadY()+fgkMinPcY[pc];  }  //center of the pad y, [cm]
49
50   inline static void   Lors2Pad(Float_t x,Float_t y,Int_t &pc,Int_t &px,Int_t &py);                                     //(x,y)->(pc,px,py) 
51
52   static Int_t   Abs         (Int_t ch,Int_t pc,Int_t x,Int_t y)   {return ch*100000000+pc*1000000+x*1000+y;         }  //(ch,pc,padx,pady)-> abs pad
53   static Int_t   DDL2C       (Int_t ddl                      )     {return ddl/2;                                    }  //ddl -> chamber
54   static Int_t   A2C         (Int_t pad                      )     {return pad/100000000;                            }  //abs pad -> chamber
55   static Int_t   A2P         (Int_t pad                      )     {return pad%100000000/1000000;                    }  //abs pad -> pc 
56   static Int_t   A2X         (Int_t pad                      )     {return pad%1000000/1000;                         }  //abs pad -> pad X 
57   static Int_t   A2Y         (Int_t pad                      )     {return pad%1000;                                 }  //abs pad -> pad Y 
58
59   static Bool_t  IsOverTh    (Float_t q                      )     {return q >= fgSigmas;                            }  //is digit over threshold?
60   
61   Bool_t  GetInstType        (                               )const{return fgInstanceType;                            }  //return if the instance is from geom or ideal                        
62   
63   inline static Bool_t IsInDead(Float_t x,Float_t y        );                                                           //is the point in dead area?
64   inline static Int_t  InHVSector(           Float_t y     );                                                           //find HV sector
65   static Int_t  Radiator(          Float_t y               )       {if (InHVSector(y)<0) return -1; return InHVSector(y)/2;}
66   static Bool_t  IsInside    (Float_t x,Float_t y,Float_t d=0)     {return  x>-d&&y>-d&&x<fgkMaxPcX[kMaxPc]+d&&y<fgkMaxPcY[kMaxPc]+d; } //is point inside chamber boundaries?
67
68   //For optical properties
69   static Double_t   EPhotMin()                       {return 5.5;}           //
70   static Double_t   EPhotMax()                       {return 8.5;}           //Photon energy range,[eV]
71   static Double_t NIdxRad(Double_t eV,Double_t temp) {return TMath::Sqrt(1+0.554*(1239.84/eV)*(1239.84/eV)/((1239.84/eV)*(1239.84/eV)-5769)-0.0005*(temp-20));}
72   static Double_t NIdxWin(Double_t eV)               {return TMath::Sqrt(1+46.411/(10.666*10.666-eV*eV)+228.71/(18.125*18.125-eV*eV));}  
73   static Double_t NMgF2Idx(Double_t eV)              {return 1.7744 - 2.866e-3*(1239.842609/eV) + 5.5564e-6*(1239.842609/eV)*(1239.842609/eV);}          // MgF2 idx of trasparency system
74   static Double_t NIdxGap(Double_t eV)               {return 1+0.12489e-6/(2.62e-4 - eV*eV/1239.84/1239.84);}
75   static Double_t LAbsRad(Double_t eV)               {return (eV<7.8)*(GausPar(eV,3.20491e16,-0.00917890,0.742402)+GausPar(eV,3035.37,4.81171,0.626309))+(eV>=7.8)*0.0001;}
76   static Double_t LAbsWin(Double_t eV)               {return (eV<8.2)*(818.8638-301.0436*eV+36.89642*eV*eV-1.507555*eV*eV*eV)+(eV>=8.2)*0.0001;}//fit from DiMauro data 28.10.03
77   static Double_t LAbsGap(Double_t eV)               {return (eV<7.75)*6512.399+(eV>=7.75)*3.90743e-2/(-1.655279e-1+6.307392e-2*eV-8.011441e-3*eV*eV+3.392126e-4*eV*eV*eV);}
78   static Double_t QEffCSI(Double_t eV)               {return (eV>6.07267)*0.344811*(1-exp(-1.29730*(eV-6.07267)));}//fit from DiMauro data 28.10.03
79   static Double_t GausPar(Double_t x,Double_t a1,Double_t a2,Double_t a3) {return a1*TMath::Exp(-0.5*((x-a2)/a3)*((x-a2)/a3));}
80   inline static Double_t FindTemp(Double_t tLow,Double_t tUp,Double_t y);    //find the temperature of the C6F14 in a given point with coord. y (in x is uniform)
81   
82   
83   Double_t   GetEPhotMean            ()const {return fPhotEMean;} 
84   Double_t   GetRefIdx               ()const {return fRefIdx;}                       //running refractive index
85   
86   Double_t   MeanIdxRad              ()const {return NIdxRad(fPhotEMean,fTemp);}
87   Double_t   MeanIdxWin              ()const {return NIdxWin(fPhotEMean);}
88   //
89   Float_t    DistCut                 ()const {return 1.0;}       //<--TEMPORAR--> to be removed in future. Cut for MIP-TRACK residual 
90   Float_t    QCut                    ()const {return 100;}       //<--TEMPORAR--> to be removed in future. Separation PHOTON-MIP charge 
91   Float_t    MultCut                 ()const {return 200;}       //<--TEMPORAR--> to be removed in future. Multiplicity cut to activate WEIGHT procedure 
92
93   Double_t   RadThick                ()const {return 1.5;}       //<--TEMPORAR--> to be removed in future. Radiator thickness
94   Double_t   WinThick                ()const {return 0.5;}       //<--TEMPORAR--> to be removed in future. Window thickness
95   Double_t   GapThick                ()const {return 8.0;}       //<--TEMPORAR--> to be removed in future. Proximity gap thickness
96   Double_t   WinIdx                  ()const {return 1.5787;}    //<--TEMPORAR--> to be removed in future. Mean refractive index of WIN material (SiO2) 
97   Double_t   GapIdx                  ()const {return 1.0005;}    //<--TEMPORAR--> to be removed in future. Mean refractive index of GAP material (CH4)
98
99   static        Int_t      Stack(Int_t evt=-1,Int_t tid=-1);              //Print stack info for event and tid
100   static        Int_t      StackCount(Int_t pid,Int_t evt);               //Counts stack particles of given sort in given event  
101   static        void       IdealPosition(Int_t iCh,TGeoHMatrix *m);       //ideal position of given chamber 
102   //trasformation methodes
103   void     Lors2Mars   (Int_t c,Float_t x,Float_t y,Double_t *m,Int_t pl=kPc)const{Double_t z=0; switch(pl){case kPc:z=8.0;break; case kAnod:z=7.806;break; case kRad:z=-1.25; break;}   Double_t l[3]={x-fX,y-fY,z};  fM[c]->LocalToMaster(l,m); }    
104   TVector3 Lors2Mars   (Int_t c,Float_t x,Float_t y,            Int_t pl=kPc)const{Double_t m[3];Lors2Mars(c,x,y,m,pl); return TVector3(m);    }//MRS->LRS  
105   void     Mars2Lors   (Int_t c,Double_t *m,Float_t &x ,Float_t &y          )const{Double_t l[3];fM[c]->MasterToLocal(m,l);x=l[0]+fX;y=l[1]+fY;}//MRS->LRS
106   void     Mars2LorsVec(Int_t c,Double_t *m,Float_t &th,Float_t &ph         )const{Double_t l[3]; fM[c]->MasterToLocalVect(m,l); 
107                                                                                    Float_t pt=TMath::Sqrt(l[0]*l[0]+l[1]*l[1]); 
108                                                                                            th=TMath::ATan(pt/l[2]); 
109                                                                                            ph=TMath::ATan2(l[1],l[0]);}    
110   void     Lors2MarsVec(Int_t c,Double_t *m,Double_t *l                     )const{fM[c]->LocalToMasterVect(m,l);                              }//LRS->MRS 
111   TVector3 Norm        (Int_t c                                             )const{Double_t n[3]; Norm(c,n); return TVector3(n);               }//norm 
112   void     Norm        (Int_t c,Double_t *n                                 )const{Double_t l[3]={0,0,1};fM[c]->LocalToMasterVect(l,n);        }//norm
113   void     Point       (Int_t c,Double_t *p,Int_t plane                     )const{Lors2Mars(c,0,0,p,plane);}         //point of given chamber plane
114
115   void     SetTemp        (Double_t temp                                       ) {fTemp = temp;}                      //set actual temperature of the C6F14
116   void     SetEPhotMean   (Double_t ePhotMean                                  ) {fPhotEMean = ePhotMean;}            //set mean photon energy
117   
118   void     SetRefIdx      (Double_t refRadIdx                                  ) {fRefIdx = refRadIdx;}               //set running refractive index
119   
120   void     SetSigmas      (Int_t sigmas                                        ) {fgSigmas = sigmas;}                 //set sigma cut    
121   void     SetInstanceType(Bool_t inst                                         ) {fgInstanceType = inst;}             //kTRUE if from geomatry kFALSE if from ideal geometry
122   //For PID
123   Double_t SigLoc      (Double_t trkTheta,Double_t trkPhi,Double_t ckovTh,Double_t ckovPh,Double_t beta);//error due to cathode segmetation
124   Double_t SigGeom     (Double_t trkTheta,Double_t trkPhi,Double_t ckovTh,Double_t ckovPh,Double_t beta);//error due to unknown photon origin
125   Double_t SigCrom     (Double_t trkTheta,Double_t trkPhi,Double_t ckovTh,Double_t ckovPh,Double_t beta);//error due to unknonw photon energy
126   Double_t Sigma2      (Double_t trkTheta,Double_t trkPhi,Double_t ckovTh,Double_t ckovPh              );//photon candidate sigma^2
127
128   //Mathieson Getters
129   
130   static Double_t PitchAnodeCathode()  {return fgkD;}
131   static Double_t SqrtK3x() {return fgkSqrtK3x;}
132   static Double_t K2x    () {return fgkK2x;}
133   static Double_t K1x    () {return fgkK1x;}
134   static Double_t K4x    () {return fgkK4x;}
135   static Double_t SqrtK3y() {return fgkSqrtK3y;}
136   static Double_t K2y    () {return fgkK2y;}
137   static Double_t K1y    () {return fgkK1y;}
138   static Double_t K4y    () {return fgkK4y;}
139   //
140   enum EPlaneId {kPc,kRad,kAnod};            //3 planes in chamber 
141   enum ETrackingFlags {kMipDistCut=-9,kMipQdcCut=-5,kNoPhotAccept=-11};     //flags for Reconstruction
142
143 protected:
144   static /*const*/ Float_t fgkMinPcX[6];                                                           //limits PC
145   static /*const*/ Float_t fgkMinPcY[6];                                                           //limits PC
146   static /*const*/ Float_t fgkMaxPcX[6];                                                           //limits PC
147   static /*const*/ Float_t fgkMaxPcY[6]; 
148   
149 // Mathieson constants
150 // For HMPID --> x direction means parallel      to the wires: K3 = 0.66  (NIM A270 (1988) 602-603) fig.1  
151 // For HMPID --> y direction means perpendicular to the wires: K3 = 0.90  (NIM A270 (1988) 602-603) fig.2  
152 //
153
154   static const Double_t fgkD;  // ANODE-CATHODE distance 0.445/2
155   
156   static const Double_t fgkSqrtK3x,fgkK2x,fgkK1x,fgkK4x;
157   static const Double_t fgkSqrtK3y,fgkK2y,fgkK1y,fgkK4y;
158 //
159     
160   static Int_t    fgSigmas;                                                                        //sigma Cut
161   static Bool_t   fgInstanceType;                                                                  //kTRUE if from geomatry kFALSE if from ideal geometry
162
163   static Float_t fgCellX, fgCellY, fgPcX, fgPcY, fgAllX, fgAllY;                                   //definition of HMPID geometric parameters 
164          AliHMPIDParam(Bool_t noGeo);             //default ctor is protected to enforce it to be singleton
165
166   static AliHMPIDParam *fgInstance;   //static pointer  to instance of AliHMPIDParam singleton
167
168   TGeoHMatrix *fM[7];                 //pointers to matrices defining HMPID chambers rotations-translations
169   Float_t fX;                         //x shift of LORS with respect to rotated MARS 
170   Float_t fY;                         //y shift of LORS with respect to rotated MARS
171   Double_t fRefIdx;                   //running refractive index of C6F14
172   Double_t fPhotEMean;                //mean energy of photon
173   Double_t fTemp;                     //actual temparature of C6F14  
174 private:
175   AliHMPIDParam(const AliHMPIDParam& r);              //dummy copy constructor
176   AliHMPIDParam &operator=(const AliHMPIDParam& r);   //dummy assignment operator
177       
178   ClassDef(AliHMPIDParam,1)           //HMPID main parameters class
179 };
180
181 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
182 AliHMPIDParam* AliHMPIDParam::Instance()
183 {
184 // Return pointer to the AliHMPIDParam singleton. 
185 // Arguments: none
186 //   Returns: pointer to the instance of AliHMPIDParam or 0 if no geometry       
187   if(!fgInstance) new AliHMPIDParam(kFALSE);                                //default setting for reconstruction, if no geometry.root -> AliFatal
188   return fgInstance;  
189 }//Instance()    
190 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
191 AliHMPIDParam* AliHMPIDParam::InstanceNoGeo()
192 {
193 // Return pointer to the AliHMPIDParam singleton without the geometry.root. 
194 // Arguments: none
195 //   Returns: pointer to the instance of AliHMPIDParam or 0 if no geometry       
196   if(!fgInstance) new AliHMPIDParam(kTRUE);                               //to avoid AliFatal, for MOOD and displays, use ideal geometry parameters
197   return fgInstance;  
198 }//Instance()    
199 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
200 Bool_t AliHMPIDParam::IsInDead(Float_t x,Float_t y)
201 {
202 // Check is the current point is outside of sensitive area or in dead zones
203 // Arguments: x,y -position
204 //   Returns: 1 if not in sensitive zone           
205   for(Int_t iPc=0;iPc<6;iPc++)
206     if(x>=fgkMinPcX[iPc] && x<=fgkMaxPcX[iPc] && y>=fgkMinPcY[iPc] && y<=fgkMaxPcY [iPc]) return kFALSE; //in current pc
207   
208   return kTRUE;
209 }
210 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
211 void AliHMPIDParam::Lors2Pad(Float_t x,Float_t y,Int_t &pc,Int_t &px,Int_t &py)
212 {
213 // Check the pad of given position
214 // Arguments: x,y- position [cm] in LORS; pc,px,py- pad where to store the result
215 //   Returns: none
216   pc=px=py=-1;
217   if     (x>fgkMinPcX[0] && x<fgkMaxPcX[0]) {pc=0; px=Int_t( x               / SizePadX());}//PC 0 or 2 or 4
218   else if(x>fgkMinPcX[1] && x<fgkMaxPcX[1]) {pc=1; px=Int_t((x-fgkMinPcX[1]) / SizePadX());}//PC 1 or 3 or 5
219   else return;
220   if     (y>fgkMinPcY[0] && y<fgkMaxPcY[0]) {      py=Int_t( y               / SizePadY());}//PC 0 or 1
221   else if(y>fgkMinPcY[2] && y<fgkMaxPcY[2]) {pc+=2;py=Int_t((y-fgkMinPcY[2]) / SizePadY());}//PC 2 or 3
222   else if(y>fgkMinPcY[4] && y<fgkMaxPcY[4]) {pc+=4;py=Int_t((y-fgkMinPcY[4]) / SizePadY());}//PC 4 or 5
223   else return;
224 }
225 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
226 Int_t AliHMPIDParam::InHVSector(Float_t y)
227 {
228 //Calculate the HV sector corresponding to the cluster position
229 //Arguments: y
230 //Returns the HV sector in the single module
231  
232    Int_t hvsec = -1;
233    Int_t pc,px,py;
234    Lors2Pad(1.,y,pc,px,py);
235    if(py==-1) return hvsec;
236    
237    hvsec = (py+(pc/2)*(kMaxPy+1))/((kMaxPy+1)/2);
238    
239    return hvsec;
240 }
241 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
242 Double_t AliHMPIDParam::FindTemp(Double_t tLow,Double_t tHigh,Double_t y)
243 {
244 //  Model for gradient in temperature
245   
246 //  Double_t gradT = (t2-t1)/SizePcY();  // linear gradient
247 //  return gradT*y+t1;
248   Double_t halfPadSize = 0.5*SizePadY();
249   Double_t gradT = (TMath::Log(SizePcY()) - TMath::Log(halfPadSize))/(TMath::Log(tHigh)-TMath::Log(tLow));
250   if(y<0) y = 0;
251   return tLow + TMath::Power(y/halfPadSize,1./gradT);  
252 }
253 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
254 #endif