]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHParam.h
1D removed, AliRICHParam as static
[u/mrichter/AliRoot.git] / RICH / AliRICHParam.h
1 #ifndef AliRICHParam_h
2 #define AliRICHParam_h
3
4 #include "AliRICHConst.h"
5 #include <TObject.h>
6 #include <TMath.h>
7 #include <TVector3.h>
8 #include <TRandom.h>
9
10 class AliRICHParam :public TObject  
11 {
12 public:
13            AliRICHParam()                    {;}
14   virtual ~AliRICHParam()                    {;}  
15   static Int_t   NpadsX()                   {return 144;}
16   static Int_t   NpadsY()                   {return 160;}   
17   static Int_t   NpadsXsec()                {return NpadsX()/3;}   
18   static Int_t   NpadsYsec()                {return NpadsY()/2;}   
19   static Double_t DeadZone()                 {return 2.6;}
20   static Double_t PadSizeX()                 {return 0.84;}
21   static Double_t PadSizeY()                 {return 0.8;}
22   static Double_t SectorSizeX()              {return NpadsX()*PadSizeX()/3;}
23   static Double_t SectorSizeY()              {return NpadsY()*PadSizeY()/2;}  
24   static Double_t PcSizeX()                  {return NpadsX()*PadSizeX()+2*DeadZone();}
25   static Double_t PcSizeY()                  {return NpadsY()*PadSizeY()+DeadZone();}
26   static Double_t WirePitch()                {return PadSizeX()/2;}
27   static Double_t SizeX()                    {return 132.6;}
28   static Double_t SizeY()                    {return 26;}
29   static Double_t SizeZ()                    {return 136.7;}   
30   static Double_t Offset()                   {return 490+1.267;}  
31   static Double_t AngleYZ()                  {return 19.5*TMath::DegToRad();} 
32   static Double_t AngleXY()                  {return 20*TMath::DegToRad();} 
33   static Double_t FreonThickness()           {return 1.5;}   
34   static Double_t QuartzThickness()          {return 0.5;}   
35   static Double_t GapThickness()             {return 8.0;}      
36   static Double_t RadiatorToPads()           {return FreonThickness()+QuartzThickness()+GapThickness();}   
37   static Double_t ProximityGapThickness()    {return 0.4;}    
38   static Double_t AnodeCathodeGap()          {return 0.2;}
39   static Double_t QuartzLength()             {return 133;}   
40   static Double_t QuartzWidth()              {return 127.9;}
41   static Double_t OuterFreonLength()         {return 133;}   
42   static Double_t OuterFreonWidth()          {return 41.3;}   
43   static Double_t InnerFreonLength()         {return 133;}   
44   static Double_t InnerFreonWidth()          {return 41.3;}   
45   static Double_t IonisationPotential()      {return 26.0e-9;}                            
46   static Double_t MathiensonDeltaX()         {return 5*0.18;}    
47   static Double_t MathiensonDeltaY()         {return 5*0.18;}    
48   static Int_t    MaxQdc()                   {return 4095;}          
49   static Double_t QdcSlope(Int_t sec)        {HV(sec);return 27;}
50   static Double_t AlphaFeedback(Int_t sec)   {HV(sec);return 0.036;}
51   
52   static Bool_t   IsWireSag()                {return fgIsWireSag;}
53   static Int_t    HV(Int_t)                  {return fgHV;}
54   static Double_t AngleRot()                {return fgAngleRot*TMath::DegToRad();} 
55     static void  SetWireSag(Bool_t status)  {fgIsWireSag=status;}  
56     static void  SetHV(Int_t hv)            {fgHV       =hv;}  
57     static void  SetAngleRot(Double_t rot)  {fgAngleRot =rot;}         
58
59   inline static Double_t Mathienson(Double_t lx1,Double_t lx2,Double_t ly1,Double_t ly2);   
60   inline static void    Loc2Area(TVector3 hitX3,Int_t &padxMin,Int_t &padyMin,Int_t &padxMax,Int_t &padyMax);
61   inline static Int_t   PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t aListX[4],Int_t aListY[4]);
62   inline static Int_t   Loc2Pad(Double_t x,Double_t y,Int_t &padx,Int_t &pady); 
63   inline static void    Pad2Loc(Int_t padx,Int_t pady,Double_t &x,Double_t &y);  
64   inline static Double_t GainVariation(Double_t y,Int_t sector);       
65   inline static Int_t   Loc2TotQdc(TVector3 locX3,Double_t eloss,Int_t iPid, Int_t &sector);
66   inline static Double_t Loc2PadFrac(TVector3 locX3,Int_t padx,Int_t pady);
67   
68   inline  void   SigGenInit(Double_t x,Double_t y);
69   inline  Bool_t SigGenCond(Double_t x,Double_t y);
70   inline static Int_t   Loc2Sec(Double_t &x,Double_t &y); 
71   inline static Int_t   Pad2Sec(Int_t &padx,Int_t &pady); 
72   
73 protected:
74   static Bool_t  fgIsWireSag;      //is wire sagitta taken into account
75   static Int_t   fgHV;             //HV applied to anod wires
76   static Double_t fgAngleRot;       //rotation of RICH from up postion (0,0,490)cm
77   
78   ClassDef(AliRICHParam,4)    //RICH main parameters
79 };
80 //__________________________________________________________________________________________________
81 Int_t AliRICHParam::PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t listX[4],Int_t listY[4])
82 {
83   Int_t nPads=0;
84   if(iPadY<NpadsY()){listX[nPads]=iPadX;   listY[nPads]=iPadY+1; nPads++;}       
85   if(iPadX<NpadsX()){listX[nPads]=iPadX+1; listY[nPads]=iPadY;   nPads++;}       
86   if(iPadY>1)       {listX[nPads]=iPadX;   listY[nPads]=iPadY-1; nPads++;}      
87   if(iPadX>1)       {listX[nPads]=iPadX-1; listY[nPads]=iPadY;   nPads++;}       
88   return nPads;
89 }//Pad2ClosePads()
90 //__________________________________________________________________________________________________
91 Int_t AliRICHParam::Loc2Sec(Double_t &x,Double_t &y)
92 {//Determines sector for a given hit (x,y) and trasform this point to the local system of that sector.
93   Int_t sector=kBad;  
94   Double_t x1=-0.5*PcSizeX();      Double_t x2=-0.5*SectorSizeX()-DeadZone();  Double_t x3=-0.5*SectorSizeX();
95   Double_t x4= 0.5*SectorSizeX();  Double_t x5= 0.5*SectorSizeX()+DeadZone();  Double_t x6= 0.5*PcSizeX();
96
97   if     (x>=x1&&x<=x2)    {sector=1;x+=0.5*PcSizeX();}
98   else if(x>=x3&&x<=x4)    {sector=2;x+=0.5*SectorSizeX();}
99   else if(x>=x5&&x<=x6)    {sector=3;x-=0.5*SectorSizeX()+DeadZone();}
100   else if(x< x1||x> x6)    {return kBad;}
101   else                                                        {return kBad;} //in dead zone
102
103   if     (y>=-0.5*PcSizeY()   &&y<=-0.5*DeadZone())  {y+=0.5*PcSizeY();  return -sector;}
104   else if(y> -0.5*DeadZone()  &&y<  0.5*DeadZone())  {return kBad;} //in dead zone
105   else if(y>= 0.5*DeadZone()  &&y<= 0.5*PcSizeY())   {y-=0.5*DeadZone(); return  sector;}
106   else                                               {return kBad;}
107 }//Loc2Sec(Double_t x, Double_t y)
108 //__________________________________________________________________________________________________
109 Int_t AliRICHParam::Pad2Sec(Int_t &padx, Int_t &pady)
110 {//Determines sector for a given pad (padx,pady) and trasform this point to the local system of that sector.
111   Int_t sector=kBad;      
112   if     (padx>=1            &&padx<=NpadsXsec())      {sector=1;}
113   else if(padx> NpadsXsec()  &&padx<=NpadsXsec()*2)    {sector=2;padx-=NpadsXsec();}
114   else if(padx> NpadsXsec()*2&&padx<=NpadsX())         {sector=3;padx-=NpadsXsec()*2;}
115   else                                                 {return kBad;}
116
117   if     (pady>=1         &&pady<= NpadsYsec())     {return -sector;}
118   else if(pady>NpadsYsec()&&pady<= NpadsY())        {pady-=NpadsYsec();return sector;} 
119   else                                              {return kBad;}
120 }//Pad2Sec()
121 //__________________________________________________________________________________________________
122 Int_t AliRICHParam::Loc2Pad(Double_t x, Double_t y, Int_t &padx, Int_t &pady)
123 {//returns pad numbers (iPadX,iPadY) for given point in local coordinates (x,y) 
124  //count starts in lower left corner from 1,1 to 144,180
125   
126   padx=pady=kBad;
127   Int_t sector=Loc2Sec(x,y);
128   if(sector==kBad) return sector;
129   
130   padx=Int_t(x/PadSizeX())+1; 
131   if(padx>NpadsXsec())            padx= NpadsXsec();
132   if(sector==2||sector==-2)       padx+=NpadsXsec();
133   else if(sector==3||sector==-3)  padx+=NpadsXsec()*2;
134   
135   pady=Int_t(y/PadSizeY())+1;
136   if(pady>NpadsYsec())            padx= NpadsYsec();
137   if(sector>0)                    pady+=NpadsYsec();    
138
139   return sector;
140 }//Loc2Pad()
141 //__________________________________________________________________________________________________
142 void AliRICHParam::Pad2Loc(Int_t padx,Int_t pady,Double_t &x,Double_t &y)
143 {
144   Int_t sector=Pad2Sec(padx,pady);  
145   if(sector>0)
146     y=0.5*DeadZone()+pady*PadSizeY()-0.5*PadSizeY();
147   else{
148     sector=-sector;
149     y=-0.5*PcSizeY()+pady*PadSizeY()-0.5*PadSizeY();
150   }
151   if(sector==1)
152     x=-0.5*PcSizeX()+padx*PadSizeX()-0.5*PadSizeX();
153   else if(sector==2)
154     x=-0.5*SectorSizeX()+padx*PadSizeX()-0.5*PadSizeX();
155   else
156     x= 0.5*SectorSizeX()+DeadZone()+padx*PadSizeX()-0.5*PadSizeX();
157   return;
158 }//Pad2Loc()
159 //__________________________________________________________________________________________________
160 Double_t AliRICHParam::GainVariation(Double_t y,Int_t sector)
161 {
162   if(IsWireSag()){
163     if(y>0) y-=SectorSizeY()/2; else  y+=SectorSizeY()/2; 
164     switch(HV(sector)){
165       case 2150:
166       default:  
167         return 9e-6*TMath::Power(y,4)+2e-7*TMath::Power(y,3)-0.0316*TMath::Power(y,2)-3e-4*y+25.367;//%
168     }
169   }else
170     return 0;
171 }
172 //__________________________________________________________________________________________________
173 Int_t AliRICHParam::Loc2TotQdc(TVector3 x3,Double_t eloss,Int_t iPid,Int_t &sector)
174 {//calculates the total charge produced by the hit given in local refenrence system
175   Double_t x=x3.X(),y=x3.Y();
176   
177   sector=Loc2Sec(x,y);
178   
179   Double_t gain=QdcSlope(sector)*(1+GainVariation(x3.Y(),sector)/100);
180
181   
182   if(iPid>50000){//it's photon => 1 electron
183     return Int_t(gain*-TMath::Log(gRandom->Rndm()));
184   }else{//it's MIP  
185     Int_t iNelectrons=Int_t(eloss/IonisationPotential());
186     if(iNelectrons==0) return 0;
187     Double_t qdc=0;
188     for(Int_t i=1;i<=iNelectrons;i++) qdc+=gain*-TMath::Log(gRandom->Rndm());
189     return Int_t(qdc);
190   }
191 }
192 //__________________________________________________________________________________________________
193 Double_t AliRICHParam::Loc2PadFrac(TVector3 hitX3,Int_t padx,Int_t pady)
194 {//
195   Double_t padXcenter=0,padYcenter=0;  Pad2Loc(padx,pady,padXcenter,padYcenter);  
196
197   //correction to the position of the nearest wire
198   
199   Double_t normXmin=(hitX3.X()-padXcenter-PadSizeX()/2)  /AnodeCathodeGap();
200   Double_t normXmax=(hitX3.X()-padXcenter+PadSizeX()/2)  /AnodeCathodeGap();
201   Double_t normYmin=(hitX3.Y()-padYcenter-PadSizeY()/2)  /AnodeCathodeGap();
202   Double_t normYmax=(hitX3.Y()-padYcenter+PadSizeY()/2)  /AnodeCathodeGap();
203   
204   return Mathienson(normXmin,normYmin,normXmax,normYmax);
205 }//Loc2PadQdc()
206 //__________________________________________________________________________________________________
207 Double_t AliRICHParam::Mathienson(Double_t xMin,Double_t yMin,Double_t xMax,Double_t yMax)
208 {//see NIM A370(1988)602-603 
209   const Double_t SqrtKx3=0.77459667;const Double_t Kx2=0.962;const Double_t Kx4=0.379;
210   const Double_t SqrtKy3=0.77459667;const Double_t Ky2=0.962;const Double_t Ky4=0.379;
211
212   Double_t ux1=SqrtKx3*TMath::TanH(Kx2*xMin);
213   Double_t ux2=SqrtKx3*TMath::TanH(Kx2*xMax);    
214   Double_t uy1=SqrtKy3*TMath::TanH(Ky2*yMin);
215   Double_t uy2=SqrtKy3*TMath::TanH(Ky2*yMax);
216   return 4*Kx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*Ky4*(TMath::ATan(uy2)-TMath::ATan(uy1));
217 }  
218 //__________________________________________________________________________________________________
219 void AliRICHParam::Loc2Area(TVector3 hitX3,Int_t &iPadXmin,Int_t &iPadYmin,Int_t &iPadXmax,Int_t &iPadYmax)
220 {//calculates the area of disintegration for a given hit. Area is a rectangulare set pf pads
221  //defined by its left-down and right-up coners
222   //  hitX3.SetX(Shift2NearestWire(hitX3.X());
223   Loc2Pad(hitX3.X()-MathiensonDeltaX(),hitX3.X()-MathiensonDeltaY(),iPadXmin,iPadYmin);   
224   Loc2Pad(hitX3.X()+MathiensonDeltaX(),hitX3.X()+MathiensonDeltaY(),iPadXmax,iPadYmax);     
225 }//
226 #endif //AliRICHParam_h