]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHParam.cxx
First interation on SplitByLocalMaxima with Nico
[u/mrichter/AliRoot.git] / RICH / AliRICHParam.cxx
1 #include "AliRICHParam.h"
2 #include <TMath.h>
3 #include <TRandom.h>
4 #include <iostream.h> 
5 ClassImp(AliRICHParam)
6
7 // RICH main parameters manipulator
8 //__________________________________________________________________________________________________
9 AliRICHParam::AliRICHParam():
10 fCurrentPadX(0),fCurrentPadY(0),fCurrentWire(0),
11 fSizeZ(0),
12 fAngleRot(0),fAngleYZ(0),fAngleXY(0),
13 fOffset(0),
14 fGapThickness(0),
15 fProximityGapThickness(0),
16 fQuartzLength(0),
17 fQuartzWidth(0),
18 fQuartzThickness(0),
19 fOuterFreonLength(0),
20 fOuterFreonWidth(0),
21 fInnerFreonLength(0),
22 fInnerFreonWidth(0),
23 fFreonThickness(0),
24 fRadiatorToPads(0),
25 fChargeSlope(0),
26 fChargeSpreadX(0),
27 fChargeSpreadY(0),
28 fSigmaIntegration(0),
29 fAlphaFeedback(0),
30 fEIonisation(0),
31 fMaxAdc(0),
32 fWireSag(0),
33 fVoltage(0)
34 {//defines the default parameters
35   Size                 (132.6*kcm,26*kcm,136.7*kcm);  //full length, not GEANT half notation
36   AngleRot             (-60);                         //rotation of the whole RICH around Z, deg
37   Angles               (20,19.5);                     //XY angle, YZ angle  deg  
38   Offset               (490*kcm+1.267*kcm);           //1.267???????cm distance from IP to the center of module 
39   GapThickness         (8*kcm);              
40   ProximityGapThickness(0.4*kcm);            
41   QuartzLength         (133*kcm);            
42   QuartzWidth          (127.9*kcm);          
43   QuartzThickness      (0.5*kcm);            
44   OuterFreonLength     (133*kcm);            
45   OuterFreonWidth      (41.3*kcm);           
46   InnerFreonLength     (133*kcm);            
47   InnerFreonWidth      (41.3*kcm);           
48   FreonThickness       (1.5*kcm);            
49   RadiatorToPads       (80*kmm);                 
50   
51   ChargeSlope(27.);
52   ChargeSpreadX(0.18);ChargeSpreadY(0.18);
53   SigmaIntegration(5.);
54   MaxAdc(4096);
55   AlphaFeedback(0.036);
56   EIonisation(26.e-9);
57   WireSag(1);                 // 1->On, 0->Off
58   Voltage(2150);              // Should only be 2000, 2050, 2100 or 2150  
59 }//AliRICHParam::named ctor 
60 //__________________________________________________________________________________________________
61 Int_t AliRICHParam::Local2Sector(Float_t &x, Float_t &y)
62 {//Determines sector for a given hit (x,y) and trasform this point to the local system of that sector.
63   Int_t sector=kBad;  
64   Float_t x1=-0.5*PcSizeX();      Float_t x2=-0.5*SectorSizeX()-DeadZone();  Float_t x3=-0.5*SectorSizeX();
65   Float_t x4= 0.5*SectorSizeX();  Float_t x5= 0.5*SectorSizeX()+DeadZone();  Float_t x6= 0.5*PcSizeX();
66
67   if     (x>=x1&&x<=x2)    {sector=1;x+=0.5*PcSizeX();}
68   else if(x>=x3&&x<=x4)    {sector=2;x+=0.5*SectorSizeX();}
69   else if(x>=x5&&x<=x6)    {sector=3;x-=0.5*SectorSizeX()+DeadZone();}
70   else if(x< x1||x> x6)    {return kBad;}
71   else                                                        {return kBad;} //in dead zone
72
73   if     (y>=-0.5*PcSizeY()   &&y<=-0.5*DeadZone())  {y+=0.5*PcSizeY();  return -sector;}
74   else if(y> -0.5*DeadZone()  &&y<  0.5*DeadZone())  {return kBad;} //in dead zone
75   else if(y>= 0.5*DeadZone()  &&y<= 0.5*PcSizeY())   {y-=0.5*DeadZone(); return  sector;}
76   else                                               {return kBad;}
77 }//Int_t AliRICHParam::Local2Sector(Float_t x, Float_t y)
78 //__________________________________________________________________________________________________
79 Int_t AliRICHParam::Pad2Sector(Int_t &padx, Int_t &pady)
80 {//Determines sector for a given pad (padx,pady) and trasform this point to the local system of that sector.
81   Int_t sector=kBad;      
82   if     (padx>=1            &&padx<=NpadsXsec())      {sector=1;}
83   else if(padx> NpadsXsec()  &&padx<=NpadsXsec()*2)    {sector=2;padx-=NpadsXsec();}
84   else if(padx> NpadsXsec()*2&&padx<=NpadsX())         {sector=3;padx-=NpadsXsec()*2;}
85   else                                                 {return kBad;}
86
87   if     (pady>=1         &&pady<= NpadsYsec())     {return -sector;}
88   else if(pady>NpadsYsec()&&pady<= NpadsY())        {pady-=NpadsYsec();return sector;} 
89   else                                              {return kBad;}
90 }//Local2Sector()
91 //__________________________________________________________________________________________________
92 Int_t AliRICHParam::Local2Pad(Float_t x, Float_t y, Int_t &padx, Int_t &pady)
93 {//returns pad numbers (iPadX,iPadY) for given point in local coordinates (x,y) 
94  //count starts in lower left corner from 1,1 to 144,180
95   
96   padx=pady=kBad;
97   Int_t sector=Local2Sector(x,y);
98   if(sector==kBad) return sector;
99   
100   padx=Int_t(x/PadSizeX())+1; 
101   if(padx>NpadsXsec())            padx= NpadsXsec();
102   if(sector==2||sector==-2)       padx+=NpadsXsec();
103   else if(sector==3||sector==-3)  padx+=NpadsXsec()*2;
104   
105   pady=Int_t(y/PadSizeY())+1;
106   if(pady>NpadsYsec())            padx= NpadsYsec();
107   if(sector>0)                    pady+=NpadsYsec();    
108
109   return sector;
110 }//Local2Pad()
111 //__________________________________________________________________________________________________
112 void AliRICHParam::Pad2Local(Int_t padx,Int_t pady,Float_t &x,Float_t &y)
113 {
114   Int_t sector=Pad2Sector(padx,pady);  
115   if(sector>0)
116     y=0.5*DeadZone()+pady*PadSizeY()-0.5*PadSizeY();
117   else{
118     sector=-sector;
119     y=-0.5*PcSizeY()+pady*PadSizeY()-0.5*PadSizeY();
120   }
121   if(sector==1)
122     x=-0.5*PcSizeX()+padx*PadSizeX()-0.5*PadSizeX();
123   else if(sector==2)
124     x=-0.5*SectorSizeX()+padx*PadSizeX()-0.5*PadSizeX();
125   else
126     x= 0.5*SectorSizeX()+DeadZone()+padx*PadSizeX()-0.5*PadSizeX();
127   return;
128 }//Pad2Local()
129 //__________________________________________________________________________________________________
130 Float_t AliRICHParam::Gain(Float_t y)
131 {//Calculates the gain
132   if(fWireSag){
133     Float_t gainK=9e-6*TMath::Power(y,4)+2e-7*TMath::Power(y,3)-0.0316*TMath::Power(y,2)-3e-4*y+25.367;
134     Float_t gain = (ChargeSlope()+ChargeSlope()*gainK/100)*0.9;
135     return -gain*TMath::Log(gRandom->Rndm());
136   }else     
137     return -ChargeSlope()*TMath::Log(gRandom->Rndm());
138 }//Float_t AliRICHParam::IntPH(Float_t yhit)
139 //__________________________________________________________________________________________________
140 Float_t AliRICHParam::TotalCharge(Int_t iPID,Float_t eloss,Float_t y)
141 {//Get number of electrons and return charge
142     
143   if(iPID>50000)//it's photon no more then 1 electron after photoelectron conversion
144     return Gain(y);
145   else{  
146     Int_t iNelectrons=Int_t(eloss/fEIonisation);if(iNelectrons==0) iNelectrons=1;
147     Float_t charge=0;
148     for(Int_t i=1;i<=iNelectrons;i++)
149       charge+=Gain(y);
150     return charge;
151   }
152 }//Float_t AliRICHParam::TotalCharge(Int_t iPID,Float_t eloss, Float_t y)
153 //__________________________________________________________________________________________________
154 void AliRICHParam::FirstPad(Float_t x,Float_t y)
155 {
156   Int_t padx,pady;
157   Local2Pad(x,y,padx,pady);
158 }//void AliRICHParam::FirstPad(Float_t x,Float_t y)
159 //__________________________________________________________________________________________________
160 Float_t AliRICHParam::AssignChargeToPad(Float_t hitx,Float_t hity,Int_t padx,Int_t pady)
161 {//
162   Float_t padXcenter=0,padYcenter=0;
163   Pad2Local(padx,pady,padXcenter,padYcenter);
164   
165   Float_t xi1=hitx-padXcenter-PadSizeX()/2;
166   Float_t xi2=hitx-padXcenter+PadSizeX()/2; 
167   Float_t yi1=hity-padYcenter-PadSizeY()/2;
168   Float_t yi2=hity-padYcenter+PadSizeY()/2;
169   xi1/=AnodeCathodeGap();
170   xi2/=AnodeCathodeGap();
171   yi1/=AnodeCathodeGap();
172   yi2/=AnodeCathodeGap();
173 // The Mathieson function 
174   Double_t ux1=SqrtKx3()*TMath::TanH(Kx2()*xi1);
175   Double_t ux2=SqrtKx3()*TMath::TanH(Kx2()*xi2);    
176   Double_t uy1=SqrtKy3()*TMath::TanH(Ky2()*yi1);
177   Double_t uy2=SqrtKy3()*TMath::TanH(Ky2()*yi2);
178   return 4.*Kx4()*(TMath::ATan(ux2)-TMath::ATan(ux1))*Ky4()*(TMath::ATan(uy2)-TMath::ATan(uy1));
179 }//AssignChargeToPad()
180 //__________________________________________________________________________________________________