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