Changes to obey the coding conventions
[u/mrichter/AliRoot.git] / RICH / AliRICHParam.h
CommitLineData
d48cca74 1#ifndef AliRICHParam_h
2#define AliRICHParam_h
3
d48cca74 4#include "AliRICHConst.h"
c712cb2f 5#include <TObject.h>
6#include <TMath.h>
7#include <TVector3.h>
8#include <TRandom.h>
9e23b054 9
d48cca74 10class AliRICHParam :public TObject
11{
12public:
c712cb2f 13 AliRICHParam() {;}
08479a10 14 virtual ~AliRICHParam() {;}
15 static const Int_t NpadsX() {return kNpadsX;}
16 static const Int_t NpadsY() {return kNpadsY;}
c712cb2f 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;}
9d6f9427 46 static Double_t MathiesonDeltaX() {return 5*0.18;}
47 static Double_t MathiesonDeltaY() {return 5*0.18;}
c712cb2f 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;}
853634d3 51
e33758d8 52 static Bool_t IsResolveClusters() {return fgIsResolveClusters;}
c712cb2f 53 static Bool_t IsWireSag() {return fgIsWireSag;}
54 static Int_t HV(Int_t) {return fgHV;}
e33758d8 55 static Double_t AngleRot() {return fgAngleRot*TMath::DegToRad();}
56 static void SetResolveClusters(Bool_t a){fgIsResolveClusters=a;}
57 static void SetWireSag(Bool_t status) {fgIsWireSag=status;}
58 static void SetHV(Int_t hv) {fgHV =hv;}
08479a10 59 static void SetAngleRot(Double_t rot) {fgAngleRot =rot;}
c712cb2f 60
9d6f9427 61 inline static Double_t Mathieson(Double_t lx1,Double_t lx2,Double_t ly1,Double_t ly2);
c712cb2f 62 inline static void Loc2Area(TVector3 hitX3,Int_t &padxMin,Int_t &padyMin,Int_t &padxMax,Int_t &padyMax);
63 inline static Int_t PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t aListX[4],Int_t aListY[4]);
64 inline static Int_t Loc2Pad(Double_t x,Double_t y,Int_t &padx,Int_t &pady);
65 inline static void Pad2Loc(Int_t padx,Int_t pady,Double_t &x,Double_t &y);
66 inline static Double_t GainVariation(Double_t y,Int_t sector);
67 inline static Int_t Loc2TotQdc(TVector3 locX3,Double_t eloss,Int_t iPid, Int_t &sector);
68 inline static Double_t Loc2PadFrac(TVector3 locX3,Int_t padx,Int_t pady);
543d5224 69
c712cb2f 70 inline static Int_t Loc2Sec(Double_t &x,Double_t &y);
71 inline static Int_t Pad2Sec(Int_t &padx,Int_t &pady);
08479a10 72 inline Bool_t IsOverTh(Int_t iChamber, Int_t x, Int_t y, Double_t q);
73 static Int_t NsigmaTh() {return fgNsigmaTh;}
74 static Float_t SigmaThMean() {return fgSigmaThMean;}
75 static Float_t SigmaThSpread() {return fgSigmaThSpread;}
76 void GenSigmaThMap();
d48cca74 77protected:
08479a10 78 static Bool_t fgIsWireSag; //is wire sagitta taken into account
79 static Bool_t fgIsResolveClusters; //performs declustering or not
80 static Int_t fgHV; //HV applied to anod wires
81 static Double_t fgAngleRot; //rotation of RICH from up postion (0,0,490)cm
82 Float_t fSigmaThMap[kNCH][kNpadsX][kNpadsY]; // sigma of the pedestal distributions for all pads
83 static Int_t fgNsigmaTh; // n. of sigmas to cut for zero suppression
84 static Float_t fgSigmaThMean; // sigma threshold value
85 static Float_t fgSigmaThSpread; // spread of sigma
c712cb2f 86 ClassDef(AliRICHParam,4) //RICH main parameters
d48cca74 87};
c2c6679b 88//__________________________________________________________________________________________________
c712cb2f 89Int_t AliRICHParam::PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t listX[4],Int_t listY[4])
90{
91 Int_t nPads=0;
92 if(iPadY<NpadsY()){listX[nPads]=iPadX; listY[nPads]=iPadY+1; nPads++;}
93 if(iPadX<NpadsX()){listX[nPads]=iPadX+1; listY[nPads]=iPadY; nPads++;}
94 if(iPadY>1) {listX[nPads]=iPadX; listY[nPads]=iPadY-1; nPads++;}
95 if(iPadX>1) {listX[nPads]=iPadX-1; listY[nPads]=iPadY; nPads++;}
96 return nPads;
97}//Pad2ClosePads()
98//__________________________________________________________________________________________________
99Int_t AliRICHParam::Loc2Sec(Double_t &x,Double_t &y)
100{//Determines sector for a given hit (x,y) and trasform this point to the local system of that sector.
101 Int_t sector=kBad;
6a005d35 102 Double_t x1=-PcSizeX()/2; Double_t x2=-SectorSizeX()/2-DeadZone(); Double_t x3=-SectorSizeX()/2;
103 Double_t x4= SectorSizeX()/2; Double_t x5= SectorSizeX()/2+DeadZone(); Double_t x6= PcSizeX()/2;
c712cb2f 104
6a005d35 105 if (x>=x1&&x<=x2) {sector=1;x+=PcSizeX()/2;}
106 else if(x>=x3&&x<=x4) {sector=2;x+=SectorSizeX()/2;}
107 else if(x>=x5&&x<=x6) {sector=3;x-=SectorSizeX()/2+DeadZone();}
108 else {return kBad;} //in dead zone
c712cb2f 109
c1863e3c 110 if (y>=-PcSizeY()/2 &&y<=-DeadZone()/2) {y+=PcSizeY()/2; return sector;}
6a005d35 111 else if(y> -DeadZone()/2 &&y< DeadZone()/2) {return kBad;} //in dead zone
c1863e3c 112 else if(y>= DeadZone()/2 &&y<= PcSizeY()/2) {y-=DeadZone()/2; return sector+3;}
6a005d35 113 else {return kBad;}
c712cb2f 114}//Loc2Sec(Double_t x, Double_t y)
c2c6679b 115//__________________________________________________________________________________________________
c712cb2f 116Int_t AliRICHParam::Pad2Sec(Int_t &padx, Int_t &pady)
117{//Determines sector for a given pad (padx,pady) and trasform this point to the local system of that sector.
118 Int_t sector=kBad;
119 if (padx>=1 &&padx<=NpadsXsec()) {sector=1;}
120 else if(padx> NpadsXsec() &&padx<=NpadsXsec()*2) {sector=2;padx-=NpadsXsec();}
121 else if(padx> NpadsXsec()*2&&padx<=NpadsX()) {sector=3;padx-=NpadsXsec()*2;}
122 else {return kBad;}
123
c1863e3c 124 if (pady>=1 &&pady<= NpadsYsec()) {return sector;}
125 else if(pady>NpadsYsec()&&pady<= NpadsY()) {pady-=NpadsYsec();return sector+3;}
c712cb2f 126 else {return kBad;}
127}//Pad2Sec()
128//__________________________________________________________________________________________________
129Int_t AliRICHParam::Loc2Pad(Double_t x, Double_t y, Int_t &padx, Int_t &pady)
130{//returns pad numbers (iPadX,iPadY) for given point in local coordinates (x,y)
131 //count starts in lower left corner from 1,1 to 144,180
132
133 padx=pady=kBad;
134 Int_t sector=Loc2Sec(x,y);
135 if(sector==kBad) return sector;
136
137 padx=Int_t(x/PadSizeX())+1;
138 if(padx>NpadsXsec()) padx= NpadsXsec();
c1863e3c 139 if(sector==2||sector==5) padx+=NpadsXsec();
140 else if(sector==3||sector==6) padx+=NpadsXsec()*2;
c712cb2f 141
142 pady=Int_t(y/PadSizeY())+1;
143 if(pady>NpadsYsec()) padx= NpadsYsec();
144 if(sector>0) pady+=NpadsYsec();
145
146 return sector;
147}//Loc2Pad()
148//__________________________________________________________________________________________________
149void AliRICHParam::Pad2Loc(Int_t padx,Int_t pady,Double_t &x,Double_t &y)
150{
151 Int_t sector=Pad2Sec(padx,pady);
c1863e3c 152 if(sector>3)
c712cb2f 153 y=0.5*DeadZone()+pady*PadSizeY()-0.5*PadSizeY();
154 else{
c712cb2f 155 y=-0.5*PcSizeY()+pady*PadSizeY()-0.5*PadSizeY();
156 }
c1863e3c 157 if(sector==1||sector==4)
c712cb2f 158 x=-0.5*PcSizeX()+padx*PadSizeX()-0.5*PadSizeX();
c1863e3c 159 else if(sector==2||sector==5)
c712cb2f 160 x=-0.5*SectorSizeX()+padx*PadSizeX()-0.5*PadSizeX();
c2c6679b 161 else
c712cb2f 162 x= 0.5*SectorSizeX()+DeadZone()+padx*PadSizeX()-0.5*PadSizeX();
163 return;
164}//Pad2Loc()
c60862bf 165//__________________________________________________________________________________________________
c712cb2f 166Double_t AliRICHParam::GainVariation(Double_t y,Int_t sector)
c60862bf 167{
c712cb2f 168 if(IsWireSag()){
169 if(y>0) y-=SectorSizeY()/2; else y+=SectorSizeY()/2;
170 switch(HV(sector)){
171 case 2150:
172 default:
173 return 9e-6*TMath::Power(y,4)+2e-7*TMath::Power(y,3)-0.0316*TMath::Power(y,2)-3e-4*y+25.367;//%
174 }
175 }else
176 return 0;
177}
178//__________________________________________________________________________________________________
179Int_t AliRICHParam::Loc2TotQdc(TVector3 x3,Double_t eloss,Int_t iPid,Int_t &sector)
180{//calculates the total charge produced by the hit given in local refenrence system
181 Double_t x=x3.X(),y=x3.Y();
182
183 sector=Loc2Sec(x,y);
184
185 Double_t gain=QdcSlope(sector)*(1+GainVariation(x3.Y(),sector)/100);
186
187
188 if(iPid>50000){//it's photon => 1 electron
189 return Int_t(gain*-TMath::Log(gRandom->Rndm()));
190 }else{//it's MIP
191 Int_t iNelectrons=Int_t(eloss/IonisationPotential());
192 if(iNelectrons==0) return 0;
193 Double_t qdc=0;
194 for(Int_t i=1;i<=iNelectrons;i++) qdc+=gain*-TMath::Log(gRandom->Rndm());
195 return Int_t(qdc);
196 }
543d5224 197}
c2c6679b 198//__________________________________________________________________________________________________
c712cb2f 199Double_t AliRICHParam::Loc2PadFrac(TVector3 hitX3,Int_t padx,Int_t pady)
200{//
201 Double_t padXcenter=0,padYcenter=0; Pad2Loc(padx,pady,padXcenter,padYcenter);
202
203 //correction to the position of the nearest wire
204
205 Double_t normXmin=(hitX3.X()-padXcenter-PadSizeX()/2) /AnodeCathodeGap();
206 Double_t normXmax=(hitX3.X()-padXcenter+PadSizeX()/2) /AnodeCathodeGap();
207 Double_t normYmin=(hitX3.Y()-padYcenter-PadSizeY()/2) /AnodeCathodeGap();
208 Double_t normYmax=(hitX3.Y()-padYcenter+PadSizeY()/2) /AnodeCathodeGap();
209
9d6f9427 210 return Mathieson(normXmin,normYmin,normXmax,normYmax);
c712cb2f 211}//Loc2PadQdc()
212//__________________________________________________________________________________________________
9d6f9427 213Double_t AliRICHParam::Mathieson(Double_t xMin,Double_t yMin,Double_t xMax,Double_t yMax)
c712cb2f 214{//see NIM A370(1988)602-603
53fd478b 215 const Double_t kSqrtKx3=0.77459667;const Double_t kX2=0.962;const Double_t kX4=0.379;
216 const Double_t kSqrtKy3=0.77459667;const Double_t kY2=0.962;const Double_t kY4=0.379;
c712cb2f 217
53fd478b 218 Double_t ux1=kSqrtKx3*TMath::TanH(kX2*xMin);
219 Double_t ux2=kSqrtKx3*TMath::TanH(kX2*xMax);
220 Double_t uy1=kSqrtKy3*TMath::TanH(kY2*yMin);
221 Double_t uy2=kSqrtKy3*TMath::TanH(kY2*yMax);
222 return 4*kX4*(TMath::ATan(ux2)-TMath::ATan(ux1))*kY4*(TMath::ATan(uy2)-TMath::ATan(uy1));
c712cb2f 223}
224//__________________________________________________________________________________________________
225void AliRICHParam::Loc2Area(TVector3 hitX3,Int_t &iPadXmin,Int_t &iPadYmin,Int_t &iPadXmax,Int_t &iPadYmax)
226{//calculates the area of disintegration for a given hit. Area is a rectangulare set pf pads
227 //defined by its left-down and right-up coners
228 // hitX3.SetX(Shift2NearestWire(hitX3.X());
9d6f9427 229 Loc2Pad(hitX3.X()-MathiesonDeltaX(),hitX3.Y()-MathiesonDeltaY(),iPadXmin,iPadYmin);
230 Loc2Pad(hitX3.X()+MathiesonDeltaX(),hitX3.Y()+MathiesonDeltaY(),iPadXmax,iPadYmax);
c712cb2f 231}//
08479a10 232//__________________________________________________________________________________________________
233Bool_t AliRICHParam::IsOverTh(Int_t iChamber, Int_t x, Int_t y, Double_t q)
234{// Calculate the new charge subtracting pedestal and if the current digit is over threshold
235 if(q>NsigmaTh()*fSigmaThMap[iChamber-1][x-1][y-1]) return kTRUE; else return kFALSE;
236}//
d48cca74 237#endif //AliRICHParam_h