Additional documentation
[u/mrichter/AliRoot.git] / RICH / AliRICHParam.h
d48cca74 1#ifndef AliRICHParam_h
2#define AliRICHParam_h
c712cb2f 4#include <TObject.h>
5#include <TMath.h>
3582c1f9 6#include <TVector2.h>
c712cb2f 7#include <TRandom.h>
9e23b054 8
ed3ceb24 9
10static const int kNCH=7; //number of RICH chambers
11static const int kNpadsX = 144; //number of pads along X in single chamber
12static const int kNpadsY = 160; //number of pads along Y in single chamber
13static const int kBad=-101; //useful static const to mark initial (uninitalised) values
3582c1f9 14static const int kNsectors=6; // nb. of sectors per chamber
ed3ceb24 15
16static const int kadc_satm = 4096; //dynamic range (10 bits)
17static const int kCerenkov=50000050; //??? go to something more general like TPDGCode
18static const int kFeedback=50000051; //??? go to something more general like TPDGCode
d48cca74 21class AliRICHParam :public TObject
c712cb2f 24 AliRICHParam() {;}
08479a10 25 virtual ~AliRICHParam() {;}
3582c1f9 26 static const Int_t NpadsX() {return kNpadsX;} //pads along X in chamber
27 static const Int_t NpadsY() {return kNpadsY;} //pads along Y in chamber
28 static Int_t NpadsXsec() {return NpadsX()/3;} //pads along X in sector
29 static Int_t NpadsYsec() {return NpadsY()/2;} //pads along Y in sector
30 static Double_t DeadZone() {return 2.6;} //dead zone size in cm
31 static Double_t PadSizeX() {return 0.84;} //pad size x in cm
32 static Double_t PadSizeY() {return 0.8;} //pad size y in cm
33 static Double_t SectorSizeX() {return NpadsX()*PadSizeX()/3;} //sector size x in cm
34 static Double_t SectorSizeY() {return NpadsY()*PadSizeY()/2;} //sector size y in cm
35 static Double_t PcSizeX() {return NpadsX()*PadSizeX()+2*DeadZone();} //photocathode size x in cm
36 static Double_t PcSizeY() {return NpadsY()*PadSizeY()+DeadZone();} //photocathode size y in cm
37 static Double_t WirePitch() {return PadSizeX()/2;} //distance between anode wires
c712cb2f 38 static Double_t SizeX() {return 132.6;}
39 static Double_t SizeY() {return 26;}
3582c1f9 40 static Double_t SizeZ() {return 136.7;}
41 static Double_t Offset() {return 490+1.267;} //distance from IP to center of chamber in cm
42 static Double_t AngleYZ() {return 19.5*TMath::DegToRad();} //angle between chambers in YZ plane, rad
43 static Double_t AngleXY() {return 20*TMath::DegToRad();} //angle between chambers in XY plane, rad
44 static Double_t AngleRot() {return fgAngleRot*TMath::DegToRad();} //RICH rotation around Z, rad
c712cb2f 45 static Double_t FreonThickness() {return 1.5;}
46 static Double_t QuartzThickness() {return 0.5;}
47 static Double_t GapThickness() {return 8.0;}
48 static Double_t RadiatorToPads() {return FreonThickness()+QuartzThickness()+GapThickness();}
3582c1f9 49 static Double_t ProximityGap() {return 0.445;}
c712cb2f 50 static Double_t AnodeCathodeGap() {return 0.2;}
51 static Double_t QuartzLength() {return 133;}
52 static Double_t QuartzWidth() {return 127.9;}
53 static Double_t OuterFreonLength() {return 133;}
54 static Double_t OuterFreonWidth() {return 41.3;}
55 static Double_t InnerFreonLength() {return 133;}
56 static Double_t InnerFreonWidth() {return 41.3;}
57 static Double_t IonisationPotential() {return 26.0e-9;}
3582c1f9 58 static TVector2 MathiesonDelta() {return TVector2(5*0.18,5*0.18);}
c712cb2f 59 static Int_t MaxQdc() {return 4095;}
c712cb2f 60 static Double_t AlphaFeedback(Int_t sec) {HV(sec);return 0.036;}
853634d3 61
3582c1f9 62 static Bool_t IsResolveClusters() {return fgIsResolveClusters;} //go after resolved clusters?
63 static Bool_t IsWireSag() {return fgIsWireSag;} //take wire sagita in account?
64 static Int_t HV(Int_t sector) {return fgHV[sector-1];} //high voltage for this sector
65 static void IsResolveClusters(Bool_t a) {fgIsResolveClusters=a;}
66 static void SetWireSag(Bool_t status) {fgIsWireSag=status;}
67 static void SetHV(Int_t sector,Int_t hv){fgHV[sector-1]=hv;}
68 static void SetAngleRot(Double_t rot) {fgAngleRot =rot;}
c712cb2f 69
3582c1f9 70 inline static void Loc2Area(TVector2 x2,Int_t &padxMin,Int_t &padyMin,Int_t &padxMax,Int_t &padyMax); //
71 inline static Int_t Loc2Pad(TVector2 x2,Int_t &padx,Int_t &pady); //return sector and pad
72 inline static TVector2 Pad2Loc(Int_t padx,Int_t pady); //return center of the pad
73 static Int_t Sector(Int_t padx,Int_t pady) {return Pad2Sec(padx,pady);} //sector of this pad
74 static Int_t Sector(TVector2 x2) {int x,y;return Loc2Pad(x2,x,y);} //sector of this point
75 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
76 inline static TVector2 ShiftToWirePos(TVector2 x2); //shift to the nearest wire
543d5224 77
3582c1f9 78 inline static Double_t Mathieson(Double_t lx1,Double_t lx2,Double_t ly1,Double_t ly2); //Mathienson integral over these limits
79 inline static Double_t GainSag(Double_t y,Int_t sector); //gain variations in %
80 inline static Double_t QdcSlope(Int_t sec); //weight of electon in QDC channels
81 inline static Double_t Gain(TVector2 x2); //gain for point in ChRS
82 inline static Double_t FracQdc(TVector2 x2,Int_t padx,Int_t pady); //charge fraction to pad from hit
83 inline static Int_t TotQdc(TVector2 x2,Double_t eloss); //total charge for hit eloss=0 for photons
84 inline Bool_t IsOverTh(Int_t iChamber, Int_t x, Int_t y, Double_t q); //
85 static Int_t NsigmaTh() {return fgNsigmaTh;} //
86 static Float_t SigmaThMean() {return fgSigmaThMean;} //
87 static Float_t SigmaThSpread() {return fgSigmaThSpread;} //
88 void GenSigmaThMap(); //generate pedestal map
89 static void Print();
d48cca74 90protected:
3582c1f9 91 inline static Int_t Loc2Sec(TVector2 &x2); //return sector, x2->Sector RS
92 inline static Int_t Pad2Sec(Int_t &padx,Int_t &pady); //return sector, (padx,pady)->Sector RS
93 static Bool_t fgIsWireSag; //is wire sagitta taken into account
94 static Bool_t fgIsResolveClusters; //performs declustering or not
95 static Int_t fgHV[6]; //HV applied to anod wires
96 static Double_t fgAngleRot; //rotation of RICH from up postion (0,0,490)cm
97 static Float_t fSigmaThMap[kNCH][kNpadsX][kNpadsY]; //sigma of the pedestal distributions for all pads
98 static Int_t fgNsigmaTh; //n. of sigmas to cut for zero suppression
99 static Float_t fgSigmaThMean; //sigma threshold value
100 static Float_t fgSigmaThSpread; //spread of sigma
c712cb2f 101 ClassDef(AliRICHParam,4) //RICH main parameters
d48cca74 102};
c2c6679b 103//__________________________________________________________________________________________________
c712cb2f 104Int_t AliRICHParam::PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t listX[4],Int_t listY[4])
3582c1f9 106// Determines all the neighbouring pads for the given one. Returns total amount of these pads.
107// Dead zones are taken into account.
c712cb2f 108 Int_t nPads=0;
ed3ceb24 109 if(iPadY!=NpadsY()&&iPadY!=NpadsYsec()) {listX[nPads]=iPadX; listY[nPads]=iPadY+1; nPads++;}
110 if(iPadX!=NpadsXsec()&&iPadX!=2*NpadsXsec()&&iPadX!=NpadsX()){listX[nPads]=iPadX+1; listY[nPads]=iPadY; nPads++;}
111 if(iPadY!=1&&iPadY!=NpadsYsec()+1) {listX[nPads]=iPadX; listY[nPads]=iPadY-1; nPads++;}
112 if(iPadX!=1&&iPadX!=NpadsXsec()+1&&iPadX!=2*NpadsXsec()+1) {listX[nPads]=iPadX-1; listY[nPads]=iPadY; nPads++;}
c712cb2f 114 return nPads;
3582c1f9 117Int_t AliRICHParam::Loc2Sec(TVector2 &x2)
119// Determines sector containing the given point and trasform this point to the local system of that sector.
120// Returns sector code: 1 2 3
121// 4 5 6
c712cb2f 122 Int_t sector=kBad;
3582c1f9 123 Double_t p1=-0.5*PcSizeX(); Double_t p2=-0.5*SectorSizeX()-DeadZone(); Double_t p3=-0.5*SectorSizeX();
124 Double_t p4= 0.5*SectorSizeX(); Double_t p5= 0.5*SectorSizeX()+DeadZone(); Double_t p6= 0.5*PcSizeX();
125 Double_t x,y;
126 if (x2.X()>=p1&&x2.X()<=p2) {sector=1;x=x2.X()+0.5*PcSizeX();}
127 else if(x2.X()>=p3&&x2.X()<=p4) {sector=2;x=x2.X()+0.5*SectorSizeX();}
128 else if(x2.X()>=p5&&x2.X()<=p6) {sector=3;x=x2.X()-0.5*SectorSizeX()-DeadZone();}
129 else {return kBad;} //in dead zone or out of chamber
131 if (x2.Y()>=-0.5*PcSizeY() &&x2.Y()<=-0.5*DeadZone()) {y=x2.Y()+0.5*PcSizeY();sector+=3;} //sectors 4,5,6
132 else if(x2.Y()> -0.5*DeadZone()&&x2.Y()< 0.5*DeadZone()) {return kBad;} //in dead zone
133 else if(x2.Y()>= 0.5*DeadZone()&&x2.Y()<= 0.5*PcSizeY()) {y=x2.Y()-0.5*DeadZone();} //sectors 1,2,3
134 else {return kBad;} //out of chamber
135 x2.Set(x,y);
136 return sector;
c712cb2f 137}//Loc2Sec(Double_t x, Double_t y)
c2c6679b 138//__________________________________________________________________________________________________
3582c1f9 139Int_t AliRICHParam::Loc2Pad(TVector2 x2,Int_t &padx,Int_t &pady)
141// Determines pad number (padx,pady) containing the given point x2 defined the chamber RS.
142// Pad count starts in lower left corner from 1,1 to 144,160 in upper right corner of a chamber.
143// Returns sector number of the determined pad.
144 Int_t sector=Loc2Sec(x2);//trasforms x2 to sector reference system
145 if(sector==kBad) {padx=pady=kBad; return sector;}
147 padx=Int_t(x2.X()/PadSizeX())+1; if(padx>NpadsXsec()) padx= NpadsXsec();
148 if(sector==2||sector==5) padx+= NpadsXsec(); // 1 2 3
149 if(sector==3||sector==6) padx+=2*NpadsXsec(); // 4 5 6
151 pady=Int_t(x2.Y()/PadSizeY())+1; if(pady>NpadsYsec()) pady= NpadsYsec();
152 if(sector<4) pady+=NpadsYsec();
153 return sector;
c712cb2f 156Int_t AliRICHParam::Pad2Sec(Int_t &padx, Int_t &pady)
3582c1f9 157{
158// Determines sector containing the given pad (padx,pady) and trasform it to the local RS of that sector.
c712cb2f 159 Int_t sector=kBad;
160 if (padx>=1 &&padx<=NpadsXsec()) {sector=1;}
161 else if(padx> NpadsXsec() &&padx<=NpadsXsec()*2) {sector=2;padx-=NpadsXsec();}
162 else if(padx> NpadsXsec()*2&&padx<=NpadsX()) {sector=3;padx-=NpadsXsec()*2;}
163 else {return kBad;}
3582c1f9 165 if (pady>=1 &&pady<=NpadsYsec()) {return sector+3;}
166 else if(pady>NpadsYsec() &&pady<=NpadsY()) {pady-=NpadsYsec();return sector;}
167 else {return kBad;}
c712cb2f 168}//Pad2Sec()
3582c1f9 170TVector2 AliRICHParam::Pad2Loc(Int_t padx,Int_t pady)
c712cb2f 171{
3582c1f9 172// Returns position of the center of the given pad (padx,pady) in local RS of the chamber
173 Int_t sector=Pad2Sec(padx,pady);//shifts to sector RS
174 if(sector==kBad) return TVector2(-101,-101);
175 Double_t x,y;
176 if(sector<=3)
177 y=0.5*DeadZone()+pady*PadSizeY()-0.5*PadSizeY(); // 1 2 3
178 else{ // 4 5 6
c712cb2f 179 y=-0.5*PcSizeY()+pady*PadSizeY()-0.5*PadSizeY();
180 }
c1863e3c 181 if(sector==1||sector==4)
c712cb2f 182 x=-0.5*PcSizeX()+padx*PadSizeX()-0.5*PadSizeX();
c1863e3c 183 else if(sector==2||sector==5)
c712cb2f 184 x=-0.5*SectorSizeX()+padx*PadSizeX()-0.5*PadSizeX();
c2c6679b 185 else
c712cb2f 186 x= 0.5*SectorSizeX()+DeadZone()+padx*PadSizeX()-0.5*PadSizeX();
3582c1f9 187 return TVector2(x,y);
c60862bf 189//__________________________________________________________________________________________________
3582c1f9 190Double_t AliRICHParam::GainSag(Double_t y,Int_t sector)
c60862bf 191{
3582c1f9 192// Returns % of gain variation due to wire sagita.
193// All cureves are parametrized per sector basis, so y must be scaled to the Sector RS.
194 if(y>0) y-=SectorSizeY()/2; else y+=SectorSizeY()/2;
195 switch(HV(sector)){
196 case 2150: return 9e-6*TMath::Power(y,4)+2e-7*TMath::Power(y,3)-0.0316*TMath::Power(y,2)-3e-4*y+25.367;//%
197 case 2100: return 8e-6*TMath::Power(y,4)+2e-7*TMath::Power(y,3)-0.0283*TMath::Power(y,2)-2e-4*y+23.015;
198 case 2050: return 7e-6*TMath::Power(y,4)+1e-7*TMath::Power(y,3)-0.0254*TMath::Power(y,2)-2e-4*y+20.888;
199 case 2000: return 6e-6*TMath::Power(y,4)+8e-8*TMath::Power(y,3)-0.0227*TMath::Power(y,2)-1e-4*y+18.961;
200 default: return 0;
201 }
c712cb2f 202}
3582c1f9 204Double_t AliRICHParam::QdcSlope(Int_t sec)
206// Returns number of QDC channels per single electron at the unknown yet ???? point for a given sector
207 switch(sec){
208 case kBad: return 0;
209 default: return 27;
c712cb2f 210 }
543d5224 211}
c2c6679b 212//__________________________________________________________________________________________________
3582c1f9 213Double_t AliRICHParam::Gain(TVector2 x2)
216 if(IsWireSag())
217 return QdcSlope(Sector(x2))*(1+GainSag(x2.Y(),Sector(x2))/100);
218 else
219 return QdcSlope(Sector(x2));
222Int_t AliRICHParam::TotQdc(TVector2 x2,Double_t eloss)
224// Calculates the total charge produced by the eloss in point x2 (Chamber RS).
225// Returns this change parametrised in QDC channels.
226// eloss=0 means photons which provided for only 1 electron
227// eloss > 0 for Mip
228 Int_t iNelectrons=Int_t(eloss/IonisationPotential()); if(iNelectrons==0) iNelectrons=1;
229 Double_t qdc=0;
230 for(Int_t i=1;i<=iNelectrons;i++) qdc+=-Gain(x2)*TMath::Log(gRandom->Rndm());
231 return Int_t(qdc);
234Double_t AliRICHParam::FracQdc(TVector2 x2,Int_t padx,Int_t pady)
236// Calculates the charge fraction for a given pad (padx,pady) from the given hit point.
237// Mathieson distribution integrated is used.
238 TVector2 center2=Pad2Loc(padx,pady);//gives center of requested pad
239 Double_t normXmin=(x2.X()-center2.X()-PadSizeX()/2) /AnodeCathodeGap();
240 Double_t normXmax=(x2.X()-center2.X()+PadSizeX()/2) /AnodeCathodeGap();
241 Double_t normYmin=(x2.Y()-center2.Y()-PadSizeY()/2) /AnodeCathodeGap();
242 Double_t normYmax=(x2.Y()-center2.Y()+PadSizeY()/2) /AnodeCathodeGap();
c712cb2f 243
3582c1f9 244 if(Sector(x2)!=Sector(padx,pady)) return 0;//requested pad does not belong to the sector of given point
245 else return Mathieson(normXmin, normYmin, normXmax, normYmax);
c712cb2f 247//__________________________________________________________________________________________________
9d6f9427 248Double_t AliRICHParam::Mathieson(Double_t xMin,Double_t yMin,Double_t xMax,Double_t yMax)
3582c1f9 249{
250// All arguments are parametrised according to NIM A370(1988)602-603
251// Returns a charge fraction.
53fd478b 252 const Double_t kSqrtKx3=0.77459667;const Double_t kX2=0.962;const Double_t kX4=0.379;
253 const Double_t kSqrtKy3=0.77459667;const Double_t kY2=0.962;const Double_t kY4=0.379;
c712cb2f 254
53fd478b 255 Double_t ux1=kSqrtKx3*TMath::TanH(kX2*xMin);
256 Double_t ux2=kSqrtKx3*TMath::TanH(kX2*xMax);
257 Double_t uy1=kSqrtKy3*TMath::TanH(kY2*yMin);
258 Double_t uy2=kSqrtKy3*TMath::TanH(kY2*yMax);
259 return 4*kX4*(TMath::ATan(ux2)-TMath::ATan(ux1))*kY4*(TMath::ATan(uy2)-TMath::ATan(uy1));
c712cb2f 260}
3582c1f9 262void AliRICHParam::Loc2Area(TVector2 x2,Int_t &iPadXmin,Int_t &iPadYmin,Int_t &iPadXmax,Int_t &iPadYmax)
264// Calculates the area of disintegration for a given point. It's assumed here that this points lays on anode wire.
265// Area is a rectangulare set of pads defined by its left-down and right-up coners.
266 Loc2Pad(x2-MathiesonDelta(),iPadXmin,iPadYmin);
267 Loc2Pad(x2+MathiesonDelta(),iPadXmax,iPadYmax);
08479a10 269//__________________________________________________________________________________________________
3582c1f9 270Bool_t AliRICHParam::IsOverTh(Int_t c,Int_t x,Int_t y,Double_t q)
272// Calculate the new charge subtracting pedestal and if the current digit is over threshold
273 if(q>NsigmaTh()*fSigmaThMap[c-1][x-1][y-1]) return kTRUE; else return kFALSE;
276TVector2 AliRICHParam::ShiftToWirePos(TVector2 x2)
278// Calculate the position of the wire nearest to the hit
279 Int_t padx,pady;
280 Loc2Pad(x2,padx,pady);
281 Double_t x;
282 TVector2 center2=Pad2Loc(padx,pady);
283 if(x2.X()>center2.X()) x=center2.X()+0.5*WirePitch();
284 else x=center2.X()-0.5*WirePitch();
285 x2.Set(x,x2.Y());
286 return x2;
d48cca74 288#endif //AliRICHParam_h