]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHParam.h
Separated TOF libraries (base,rec,sim)
[u/mrichter/AliRoot.git] / RICH / AliRICHParam.h
1 #ifndef AliRICHParam_h
2 #define AliRICHParam_h
3
4 #include <TError.h>
5 #include <TMath.h>
6 #include <TObjArray.h>
7 #include <TObject.h>
8 #include <TMath.h>
9 #include <TRandom.h>
10 #include <TVector.h>
11 #include <TVector2.h>
12 #include <TVector3.h>
13 #include <TRandom.h>
14 #include <TError.h>
15 #include <TObjArray.h>
16 #include <AliLog.h>
17 #include <TClass.h>
18
19
20 static const int kNchambers=7;     //number of RICH chambers 
21 static const int kNpadsX = 160;    //number of pads along X in single chamber
22 static const int kNpadsY = 144;    //number of pads along Y in single chamber
23 static const int kBad=-101;        //useful static const to mark initial (uninitalised) values
24 static const int kNsectors=6;      //number of sectors per chamber
25
26 static const int kCerenkov=50000050;  //??? go to something more general like TPDGCode
27 static const int kFeedback=50000051;  //??? go to something more general like TPDGCode
28
29 class AliRICHChamber;
30
31 class AliRICHParam :public TObject  
32 {
33 public:
34                   AliRICHParam():TObject(),fpChambers(0)  {CreateChambers();}
35   virtual        ~AliRICHParam()                          {delete fpChambers;}
36          void     CreateChambers();
37   AliRICHChamber* C(Int_t i)                 {return (AliRICHChamber*)fpChambers->UncheckedAt(i-1);}      //returns pointer to chamber i
38   static Int_t    NpadsX()                   {return kNpadsX;}                           //pads along X in chamber
39   static Int_t    NpadsY()                   {return kNpadsY;}                           //pads along Y in chamber
40   static Int_t    NpadsXsec()                {return NpadsX()/2;}                        //pads along X in sector
41   static Int_t    NpadsYsec()                {return NpadsY()/3;}                        //pads along Y in sector
42   static Double_t DeadZone()                 {return 2.6;}                               //dead zone size in cm  
43   static Double_t PadSizeX()                 {return 0.8;}                               //pad size x in cm 
44   static Double_t PadSizeY()                 {return 0.84;}                              //pad size y in cm   
45   
46   static Double_t SectorSizeX()              {return NpadsX()*PadSizeX()/2;}             //sector size x in cm
47   static Double_t SectorSizeY()              {return NpadsY()*PadSizeY()/3;}             //sector size y in cm 
48   static Double_t PcSizeX()                  {return NpadsX()*PadSizeX()+DeadZone();}    //PC size x, cm
49   static Double_t PcSizeY()                  {return NpadsY()*PadSizeY()+2*DeadZone();}  //PC size y, cm
50    
51   static Double_t Zfreon()                   {return 1.5;}                               //freon thinkness, cm
52   static Double_t Zwin()                     {return 0.5;}                               //radiator quartz window, cm   
53   static Double_t Pc2Win()                   {return 8.0;}                               //cm between CsI PC and radiator quartz window
54   static Double_t Pc2Coll()                  {return 7.0;}                               //cm between CsI PC and third wire grid (collection wires)     
55   static Double_t Pc2Anod()                  {return 0.204;}                             //cm between CsI PC and first wire grid (anod wires)     
56   static Double_t Pc2Cath()                  {return 0.445;}                             //cm between CsI PC and second wire grid (cathode wires)
57   static Double_t Freon2Pc()                 {return Zfreon()+Zwin()+Pc2Win();}          //cm between CsI PC and entrance to freon
58   static Double_t PitchAnod()                {return PadSizeY()/2;}                      //cm between anode wires
59   static Double_t PitchCath()                {return PadSizeY()/4;}                      //cm between cathode wires
60   static Double_t PitchColl()                {return 0.5;}                               //cm between collection wires
61   
62   static Double_t IonisationPotential()      {return 26.0e-9;}                            //for CH4 in GeV taken from ????
63   static TVector2 MathiesonDelta()           {return TVector2(5*0.18,5*0.18);}            //area of 5 sigmas of Mathieson distribution (cm)
64   static Int_t    MaxQdc()                   {return 4095;}                               //QDC number of channels          
65     
66   static Bool_t   IsResolveClusters()         {return fgIsResolveClusters;}  //go after resolved clusters?
67   static Bool_t   IsWireSag()                 {return fgIsWireSag;}          //take wire sagita in account?
68   static Bool_t   IsRadioSrc()                {return fgIsRadioSrc;}         //add radioactive source inside CH4?
69   static Int_t    HV(Int_t sector)            {
70     if (sector>=1 && sector <=6)
71       return fgHV[sector-1];
72     else {
73       ::Error("HV","Wrong sector %d",sector);
74       return kBad;
75     } 
76   }       //high voltage for this sector
77   static void     SetDeclustering(Bool_t a)   {fgIsResolveClusters=a;}  
78   static void     SetRadioSrc(Bool_t a)       {fgIsRadioSrc=a;}  
79   static void     SetWireSag(Bool_t status)   {fgIsWireSag=status;}  
80   static void     SetHV(Int_t sector,Int_t hv){fgHV[sector-1]=hv;}  
81   static void     SetAngleRot(Double_t rot)   {fgAngleRot =rot;}
82   static Double_t IndOfRefC6F14(Double_t eV)  {return eV*0.0172+1.177;}          // eV = photon energy in eV
83   static Double_t IndOfRefSiO2(Double_t eV)   {Double_t e1=10.666,e2=18.125,f1=46.411,f2= 228.71;
84                                      return TMath::Sqrt(1.+f1/(e1*e1-TMath::Power(eV,2))+f2/(e2*e2-TMath::Power(eV,2)));}//TDR p.35
85   static Double_t IndOfRefCH4()               {return 1.000444;}
86
87   inline static TVector  Loc2Area(TVector2 x2);                                                    //return area affected by hit x2
88   inline static TVector  Loc2Pad(TVector2 x2);                                                     //return pad containing given position
89   inline static TVector2 Pad2Loc(TVector pad);                                                     //return center of the pad
90          static TVector2 Pad2Loc(Int_t x,Int_t y) {TVector pad(2);pad[0]=x;pad[1]=y;return Pad2Loc(pad);}
91   inline static Int_t    PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t aListX[4],Int_t aListY[4]);   //number of neighbours for this pad
92   
93   inline static Double_t Mathieson(Double_t x1,Double_t x2,Double_t y1,Double_t y2);               //Mathienson integral over these limits
94   inline static Double_t GainSag(Double_t x,Int_t sector);                                         //gain variations in %
95          static Double_t QdcSlope(Int_t sec){switch(sec){case kBad: return 0;  default:   return 33;}} //weight of electon in QDC channels
96          static Double_t Gain(TVector2 x2){if(IsWireSag()) return QdcSlope(Loc2Sec(x2))*(1+GainSag(x2.X(),Loc2Sec(x2))/100);else return QdcSlope(Loc2Sec(x2));}//gain for point in chamber RS 
97   inline static Double_t FracQdc(TVector2 x2,TVector pad);                                         //charge fraction to pad from hit
98   inline static Int_t    TotQdc(TVector2 x2,Double_t eloss);                                       //total charge for hit eloss=0 for photons
99   inline        Bool_t   IsOverTh(Int_t c,TVector pad,Double_t q);                                 //is QDC of the pad registered by FEE  
100          static Int_t    NsigmaTh()                    {return fgNsigmaTh;}                        //
101          static Float_t  SigmaThMean()                 {return fgSigmaThMean;}                     //QDC electronic noise mean
102          static Float_t  SigmaThSpread()               {return fgSigmaThSpread;}                   //QDC electronic noise width
103                 void     Print(const Option_t *opt="");                                            //virtual
104                 
105   inline static Int_t    Loc2Sec(TVector2 &x2);             //return sector, x2->Sector RS
106   inline static Int_t    Pad2Sec(const TVector &pad);              //return sector
107          static Bool_t   IsAccepted(const TVector2 &x2) {return ( x2.X()>=0 && x2.X()<=PcSizeX() && x2.Y()>=0 && x2.Y()<=PcSizeY() ) 
108 ? kTRUE:kFALSE;}
109 protected:
110          TObjArray *fpChambers;                             //list of chambers    
111   static Bool_t     fgIsWireSag;                            //wire sagitta ON/OFF flag
112   static Bool_t     fgIsResolveClusters;                    //declustering ON/OFF flag
113   static Bool_t     fgIsRadioSrc;                           //radioactive source ON/OFF flag
114   static Int_t      fgHV[6];                                //HV applied to anod wires
115   static Double_t   fgAngleRot;                             //module rotation from up postion (0,0,490)cm
116   static Int_t      fgNsigmaTh;                             //n. of sigmas to cut for zero suppression
117   static Float_t    fgSigmaThMean;                          //sigma threshold value
118   static Float_t    fgSigmaThSpread;                        //spread of sigma
119   ClassDef(AliRICHParam,5)                                  //RICH main parameters class
120 };
121 //__________________________________________________________________________________________________
122 Int_t AliRICHParam::PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t listX[4],Int_t listY[4])
123 {
124 // Determines all the neighbouring pads for the given one (iPadX,iPadY). Returns total number of these pads.
125 // Dead zones are taken into account.    
126 //   1  
127 // 2   3
128 //   4     
129   Int_t nPads=0;
130   if(iPadY!=NpadsY()&&iPadY!=2*NpadsYsec()&&iPadY!=NpadsYsec()){listX[nPads]=iPadX;   listY[nPads]=iPadY+1; nPads++;}       //1
131   if(iPadX!=1&&iPadX!=NpadsXsec()+1)                           {listX[nPads]=iPadX-1; listY[nPads]=iPadY;   nPads++;}       //2
132   if(iPadX!=NpadsXsec()&&iPadX!=NpadsX())                      {listX[nPads]=iPadX+1; listY[nPads]=iPadY;   nPads++;}       //3
133   if(iPadY!=1&&iPadY!=NpadsYsec()+1&&2*NpadsYsec()+1)          {listX[nPads]=iPadX;   listY[nPads]=iPadY-1; nPads++;}       //4
134
135   return nPads;
136 }//Pad2ClosePads()
137 //__________________________________________________________________________________________________
138 Int_t AliRICHParam::Loc2Sec(TVector2 &v2)
139 {
140 // Determines sector containing the given point and trasform this point to the local system of that sector.
141 // Returns sector code:                       
142 //y ^  5 6
143 //  |  3 4
144 //  |  1 2
145 //   -------> x  
146   Double_t x0=0; Double_t x1=SectorSizeX(); Double_t x2=SectorSizeX()+DeadZone(); Double_t x3=PcSizeX();
147   Double_t y0=0; Double_t y1=SectorSizeY(); Double_t y2=SectorSizeY()+DeadZone(); Double_t y3=2*SectorSizeY()+DeadZone(); 
148   Double_t y4=PcSizeY()-SectorSizeY();      Double_t y5=PcSizeY();
149   
150   Int_t sector=kBad;  
151   Double_t x=v2.X(),y=v2.Y();  
152   if     (v2.X() >= x0 && v2.X() <= x1 )  {sector=1;}
153   else if(v2.X() >= x2 && v2.X() <= x3 )  {sector=2; x=v2.X()-x2;}
154   else                                    {return kBad;}
155   
156   if     (v2.Y() >= y0 && v2.Y() <= y1 )  {}                                  //sectors 1 or 2 
157   else if(v2.Y() >= y2 && v2.Y() <= y3 )  {sector+=2; y=v2.Y()-y2;}           //sectors 3 or 4
158   else if(v2.Y() >= y4 && v2.Y() <= y5 )  {sector+=4; y=v2.Y()-y4;}           //sectors 5 or 6
159   else                                    {return kBad;}
160   v2.Set(x,y);
161   return sector;
162 }//Loc2Sec(Double_t x, Double_t y)
163 //__________________________________________________________________________________________________
164 TVector AliRICHParam::Loc2Pad(TVector2 x2)
165 {
166 // Determines pad number TVector(padx,pady) containing the given point x2 defined the chamber RS.
167 // Pad count starts in lower left corner from 1,1 to 144,160 in upper right corner of a chamber.
168 // Returns sector number of the determined pad.      
169 //y ^  5 6
170 //  |  3 4
171 //  |  1 2
172 //   -------> x  
173   TVector pad(2);
174   Int_t sector=Loc2Sec(x2);//trasforms x2 to sector reference system
175   if(sector==kBad) {pad[0]=pad[1]=kBad; return pad;}
176   
177   pad[0]=Int_t(x2.X()/PadSizeX())+1; if(pad[0]>NpadsXsec()) pad[0]= NpadsXsec();       
178   if(sector==2||sector==4||sector==6)   pad[0]+=  NpadsXsec();     
179
180   pad[1]=Int_t(x2.Y()/PadSizeY())+1; if(pad[1]>NpadsYsec()) pad[1]= NpadsYsec();
181   if(sector==3||sector==4)   pad[1]+=NpadsYsec();    
182   if(sector==5||sector==6)   pad[1]+=2*NpadsYsec();     
183   return pad;
184 }
185 //__________________________________________________________________________________________________
186 Int_t AliRICHParam::Pad2Sec(const TVector &pad)
187 {
188 // Determines sector containing the given pad.
189   Int_t sector=kBad;      
190   if     (pad[0] >= 1           && pad[0] <=   NpadsXsec() )    {sector=1;}
191   else if(pad[0] >  NpadsXsec() && pad[0] <=   NpadsX()    )    {sector=2;} 
192   else                                                         AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
193     
194   if     (pad[1] >= 1             && pad[1] <=   NpadsYsec() )    {}
195   else if(pad[1] >  NpadsYsec()   && pad[1] <= 2*NpadsYsec() )    {sector+=2;}
196   else if(pad[1] >  2*NpadsYsec() && pad[1] <=   NpadsY()    )    {sector+=4;}
197   else                                                         AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
198
199   return sector;
200 }//Pad2Sec()
201 //__________________________________________________________________________________________________
202 TVector2 AliRICHParam::Pad2Loc(TVector pad)
203 {
204 // Returns position of the center of the given pad in local system of the chamber (cm)    
205 // y ^  5 6
206 //   |  3 4        sector numbers
207 //   |  1 2
208 //    -------> x  
209   Double_t x=kBad,y=kBad;
210   if(pad[0] > 0 && pad[0] <= NpadsXsec())//it's 1 or 3 or 5
211     x=(pad[0]-0.5)*PadSizeX();
212   else if(pad[0] > NpadsXsec() && pad[0] <= NpadsX())//it's 2 or 4 or 6
213     x=(pad[0]-0.5)*PadSizeX()+DeadZone();
214   else
215     AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
216   
217   if(pad[1] > 0 && pad[1] <= NpadsYsec())//it's 1 or 2
218     y=(pad[1]-0.5)*PadSizeY();
219   else if(pad[1] > NpadsYsec() && pad[1] <= 2*NpadsYsec())//it's 3 or 4
220     y=(pad[1]-0.5)*PadSizeY()+DeadZone();
221   else if(pad[1] > 2*NpadsYsec() && pad[1]<= NpadsY())//it's 5 or 6
222     y=(pad[1]-0.5)*PadSizeY()+2*DeadZone();
223   else
224     AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
225     
226   return TVector2(x,y);
227 }
228 //__________________________________________________________________________________________________
229 Double_t AliRICHParam::GainSag(Double_t x,Int_t sector)
230 {
231 // Returns % of gain variation due to wire sagita.
232 // All curves are parametrized as per sector basis, so x must be apriory transformed to the Sector RS.    
233 // Here x is a distance along wires.  
234   x-=SectorSizeX()/2;
235   if(x>SectorSizeX()) x-=SectorSizeX(); 
236   switch(HV(sector)){
237     case 2150: return 9e-6*TMath::Power(x,4)+2e-7*TMath::Power(x,3)-0.0316*TMath::Power(x,2)-3e-4*x+25.367;//%
238     case 2100: return 8e-6*TMath::Power(x,4)+2e-7*TMath::Power(x,3)-0.0283*TMath::Power(x,2)-2e-4*x+23.015;
239     case 2050: return 7e-6*TMath::Power(x,4)+1e-7*TMath::Power(x,3)-0.0254*TMath::Power(x,2)-2e-4*x+20.888;
240     case 2000: return 6e-6*TMath::Power(x,4)+8e-8*TMath::Power(x,3)-0.0227*TMath::Power(x,2)-1e-4*x+18.961;
241     default:   return 0;
242   }
243 }
244 //__________________________________________________________________________________________________
245 Int_t AliRICHParam::TotQdc(TVector2 x2,Double_t eloss)
246 {
247 // Calculates the total charge produced by the eloss in point x2 (Chamber RS).
248 // Returns this change parametrised in QDC channels, or 0 if the hit in the dead zone.
249 // eloss=0 means photon which produces 1 electron only eloss > 0 for Mip
250   if(Loc2Sec(x2)==kBad) return 0; //hit in the dead zone     
251   Int_t iNelectrons=Int_t(eloss/IonisationPotential()); if(iNelectrons==0) iNelectrons=1;
252   Double_t qdc=0;
253   for(Int_t i=1;i<=iNelectrons;i++) qdc+=-Gain(x2)*TMath::Log(gRandom->Rndm());
254   return Int_t(qdc);
255 }
256 //__________________________________________________________________________________________________
257 Double_t AliRICHParam::FracQdc(TVector2 x2,TVector pad)
258 {
259 // Calculates the charge fraction induced to given pad by the hit from the given point.
260 // Integrated Mathieson distribution is used.  
261   TVector2 center2=Pad2Loc(pad);//gives center of requested pad
262   Double_t normXmin=(x2.X()-center2.X()-PadSizeX()/2)  /Pc2Cath();//parametrise for Mathienson
263   Double_t normXmax=(x2.X()-center2.X()+PadSizeX()/2)  /Pc2Cath();
264   Double_t normYmin=(x2.Y()-center2.Y()-PadSizeY()/2)  /Pc2Cath();
265   Double_t normYmax=(x2.Y()-center2.Y()+PadSizeY()/2)  /Pc2Cath();
266  
267 //requested pad might not belong to the sector of the given hit position, hence the check:
268   return (Loc2Sec(x2)!=Pad2Sec(pad)) ? 0:Mathieson(normXmin, normYmin, normXmax, normYmax);
269 }
270 //__________________________________________________________________________________________________
271 Double_t AliRICHParam::Mathieson(Double_t xMin,Double_t yMin,Double_t xMax,Double_t yMax)
272 {
273 // All arguments are parametrised according to NIM A370(1988)602-603
274 // Returns a charge fraction.   
275   const Double_t kSqrtKx3=0.77459667;const Double_t kX2=0.962;const Double_t kX4=0.379;
276   const Double_t kSqrtKy3=0.77459667;const Double_t kY2=0.962;const Double_t kY4=0.379;
277
278   Double_t ux1=kSqrtKx3*TMath::TanH(kX2*xMin);
279   Double_t ux2=kSqrtKx3*TMath::TanH(kX2*xMax);    
280   Double_t uy1=kSqrtKy3*TMath::TanH(kY2*yMin);
281   Double_t uy2=kSqrtKy3*TMath::TanH(kY2*yMax);
282   return 4*kX4*(TMath::ATan(ux2)-TMath::ATan(ux1))*kY4*(TMath::ATan(uy2)-TMath::ATan(uy1));
283 }  
284 //__________________________________________________________________________________________________
285 TVector AliRICHParam::Loc2Area(TVector2 x2)
286 {
287 // Calculates the area of disintegration for a given point. It's assumed here that this points lays on anode wire.
288 // Area is a rectangulare set of pads defined by its left-down and right-up coners.
289   TVector area(4);
290   TVector pad=Loc2Pad(x2); 
291   area[0]=area[2]=pad[0]; area[1]=area[3]=pad[1];//area is just a pad fired  
292   if(pad[0]!=1           && pad[0]!= NpadsXsec()+1                            ) area[0]--; //left down coner X
293   if(pad[1]!=1           && pad[1]!= NpadsYsec()+1 && pad[1]!= 2*NpadsYsec()+1) area[1]--; //left down coner Y 
294   if(pad[0]!=NpadsXsec() && pad[0]!= NpadsX()                                 ) area[2]++; //right up coner X
295   if(pad[1]!=NpadsYsec() && pad[1]!= 2*NpadsYsec() && pad[1]!= NpadsY()       ) area[3]++; //right up coner Y
296   return area;          
297 }
298 //__________________________________________________________________________________________________
299 Bool_t AliRICHParam::IsOverTh(Int_t ,TVector ,Double_t q)
300 {
301 // Checks if the current q is over threshold and FEE will save this value to data concentrator.
302   return (q>NsigmaTh()*(SigmaThMean()+(1.-2*gRandom->Rndm())*SigmaThSpread()));
303 }
304 #endif //AliRICHParam_h