]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHParam.h
Bug Correction
[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>
e42a7b46 7#include <TVector3.h>
c712cb2f 8#include <TRandom.h>
f037571e 9#include <TError.h>
e42a7b46 10#include <TObjArray.h>
9e23b054 11
ed3ceb24 12
e42a7b46 13static const int kNCH=7; //number of RICH chambers ???
14static const int kNchambers=7; //number of RICH chambers
15static const int kNpadsX = 160; //number of pads along X in single chamber
16static const int kNpadsY = 144; //number of pads along Y in single chamber
ed3ceb24 17static const int kBad=-101; //useful static const to mark initial (uninitalised) values
e42a7b46 18static const int kNsectors=6; //number of sectors per chamber
ed3ceb24 19
e42a7b46 20static const int kadc_satm = 4096; //dynamic range (10 bits)
ed3ceb24 21static const int kCerenkov=50000050; //??? go to something more general like TPDGCode
22static const int kFeedback=50000051; //??? go to something more general like TPDGCode
23
e42a7b46 24class AliRICHChamber;
ed3ceb24 25
d48cca74 26class AliRICHParam :public TObject
27{
28public:
e42a7b46 29 AliRICHParam():TObject(),fpChambers(0) {CreateChambers();}
30 virtual ~AliRICHParam() {delete fpChambers;}
31 void CreateChambers();
32 AliRICHChamber* C(Int_t i) {return (AliRICHChamber*)fpChambers->UncheckedAt(i-1);} //returns pointer to chamber i
33 static Int_t NpadsX() {return kNpadsX;} //pads along X in chamber
34 static Int_t NpadsY() {return kNpadsY;} //pads along Y in chamber
35 static Int_t NpadsXsec() {return NpadsX()/2;} //pads along X in sector
36 static Int_t NpadsYsec() {return NpadsY()/3;} //pads along Y in sector
3582c1f9 37 static Double_t DeadZone() {return 2.6;} //dead zone size in cm
e42a7b46 38 static Double_t PadSizeX() {return 0.8;} //pad size x in cm
39 static Double_t PadSizeY() {return 0.84;} //pad size y in cm
40 static Double_t SectorSizeX() {return NpadsX()*PadSizeX()/2;} //sector size x in cm
41 static Double_t SectorSizeY() {return NpadsY()*PadSizeY()/3;} //sector size y in cm
42 static Double_t PcSizeX() {return NpadsX()*PadSizeX()+DeadZone();} //photocathode size x in cm
43 static Double_t PcSizeY() {return NpadsY()*PadSizeY()+2*DeadZone();} //photocathode size y in cm
c712cb2f 44 static Double_t SizeX() {return 132.6;}
45 static Double_t SizeY() {return 26;}
3582c1f9 46 static Double_t SizeZ() {return 136.7;}
47 static Double_t Offset() {return 490+1.267;} //distance from IP to center of chamber in cm
48 static Double_t AngleYZ() {return 19.5*TMath::DegToRad();} //angle between chambers in YZ plane, rad
49 static Double_t AngleXY() {return 20*TMath::DegToRad();} //angle between chambers in XY plane, rad
50 static Double_t AngleRot() {return fgAngleRot*TMath::DegToRad();} //RICH rotation around Z, rad
c712cb2f 51 static Double_t FreonThickness() {return 1.5;}
52 static Double_t QuartzThickness() {return 0.5;}
e42a7b46 53
54 static Double_t GapProx() {return 8.0;} //cm between CsI PC and radiator quartz window
55 static Double_t GapColl() {return 7.0;} //cm between CsI PC and third wire grid (collection wires)
56 static Double_t GapAnod() {return 0.204;} //cm between CsI PC and first wire grid (anod wires)
57 static Double_t GapAmp() {return 0.445;} //cm between CsI PC and second wire grid (cathode wires)
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 collect wires
61
c712cb2f 62 static Double_t GapThickness() {return 8.0;}
63 static Double_t RadiatorToPads() {return FreonThickness()+QuartzThickness()+GapThickness();}
e42a7b46 64 static Double_t AnodeCathodeGap() {return 0.2;} //between CsI PC and first wire grid
c712cb2f 65 static Double_t QuartzLength() {return 133;}
66 static Double_t QuartzWidth() {return 127.9;}
67 static Double_t OuterFreonLength() {return 133;}
68 static Double_t OuterFreonWidth() {return 41.3;}
69 static Double_t InnerFreonLength() {return 133;}
70 static Double_t InnerFreonWidth() {return 41.3;}
e42a7b46 71 static Double_t IonisationPotential() {return 26.0e-9;} //for CH4 in GeV taken from ????
72 static TVector2 MathiesonDelta() {return TVector2(5*0.18,5*0.18);} //area of 5 sigmas of Mathieson distribution (cm)
73 static Int_t MaxQdc() {return 4095;} //QDC number of channels
74 static Double_t AlphaFeedback(Int_t ) {return 0.030;} //determines number of feedback photons
75
3582c1f9 76 static Bool_t IsResolveClusters() {return fgIsResolveClusters;} //go after resolved clusters?
77 static Bool_t IsWireSag() {return fgIsWireSag;} //take wire sagita in account?
e42a7b46 78 static Bool_t IsRadioSrc() {return fgIsRadioSrc;} //add radioactive source inside CH4?
f037571e 79 static Int_t HV(Int_t sector) {
80 if (sector>=1 && sector <=6)
81 return fgHV[sector-1];
82 else {
83 ::Error("HV","Wrong sector %d",sector);
84 return kBad;
85 }
86 } //high voltage for this sector
e42a7b46 87 static void SetDeclustering(Bool_t a) {fgIsResolveClusters=a;}
88 static void SetRadioSrc(Bool_t a) {fgIsRadioSrc=a;}
3582c1f9 89 static void SetWireSag(Bool_t status) {fgIsWireSag=status;}
90 static void SetHV(Int_t sector,Int_t hv){fgHV[sector-1]=hv;}
91 static void SetAngleRot(Double_t rot) {fgAngleRot =rot;}
c712cb2f 92
e42a7b46 93 inline static TVector Loc2Area(TVector2 x2); //return area affected by hit x2
94 inline static TVector Loc2Pad(TVector2 x2); //return pad containing given position
95 inline static TVector2 Pad2Loc(TVector pad); //return center of the pad
96 static TVector2 Pad2Loc(Int_t x,Int_t y) {TVector pad(2);pad[0]=x;pad[1]=y;return Pad2Loc(pad);}
3582c1f9 97 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
543d5224 98
e42a7b46 99 inline static Double_t Mathieson(Double_t x1,Double_t x2,Double_t y1,Double_t y2); //Mathienson integral over these limits
100 inline static Double_t GainSag(Double_t x,Int_t sector); //gain variations in %
101 static Double_t QdcSlope(Int_t sec){switch(sec){case kBad: return 0; default: return 33;}} //weight of electon in QDC channels
102 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
103 inline static Double_t FracQdc(TVector2 x2,TVector pad); //charge fraction to pad from hit
3582c1f9 104 inline static Int_t TotQdc(TVector2 x2,Double_t eloss); //total charge for hit eloss=0 for photons
e42a7b46 105 inline Bool_t IsOverTh(Int_t c,TVector pad,Double_t q); //is QDC of the pad registered by FEE
106 static Int_t NsigmaTh() {return fgNsigmaTh;} //
107 static Float_t SigmaThMean() {return fgSigmaThMean;} //QDC electronic noise mean
108 static Float_t SigmaThSpread() {return fgSigmaThSpread;} //QDC electronic noise width
109 void Print(const Option_t *opt=""); //virtual
110 inline static void PropogateHelix(TVector3 x0,TVector3 p0,Double_t s,TVector3 *x,TVector3 *p);
111
3582c1f9 112 inline static Int_t Loc2Sec(TVector2 &x2); //return sector, x2->Sector RS
e42a7b46 113 inline static Int_t Pad2Sec(TVector pad); //return sector
114protected:
115 TObjArray *fpChambers; //list of chambers
116 static Bool_t fgIsWireSag; //wire sagitta ON/OFF flag
117 static Bool_t fgIsResolveClusters; //declustering ON/OFF flag
118 static Bool_t fgIsRadioSrc; //radioactive source ON/OFF flag
119 static Int_t fgHV[6]; //HV applied to anod wires
120 static Double_t fgAngleRot; //module rotation from up postion (0,0,490)cm
121 static Int_t fgNsigmaTh; //n. of sigmas to cut for zero suppression
122 static Float_t fgSigmaThMean; //sigma threshold value
123 static Float_t fgSigmaThSpread; //spread of sigma
124 ClassDef(AliRICHParam,5) //RICH main parameters class
d48cca74 125};
c2c6679b 126//__________________________________________________________________________________________________
c712cb2f 127Int_t AliRICHParam::PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t listX[4],Int_t listY[4])
128{
e42a7b46 129// Determines all the neighbouring pads for the given one (iPadX,iPadY). Returns total number of these pads.
3582c1f9 130// Dead zones are taken into account.
e42a7b46 131// 1
132// 2 3
133// 4
c712cb2f 134 Int_t nPads=0;
e42a7b46 135 if(iPadY!=NpadsY()&&iPadY!=2*NpadsYsec()&&iPadY!=NpadsYsec()){listX[nPads]=iPadX; listY[nPads]=iPadY+1; nPads++;} //1
136 if(iPadX!=1&&iPadX!=NpadsXsec()+1) {listX[nPads]=iPadX-1; listY[nPads]=iPadY; nPads++;} //2
137 if(iPadX!=NpadsXsec()&&iPadX!=NpadsX()) {listX[nPads]=iPadX+1; listY[nPads]=iPadY; nPads++;} //3
138 if(iPadY!=1&&iPadY!=NpadsYsec()+1&&2*NpadsYsec()+1) {listX[nPads]=iPadX; listY[nPads]=iPadY-1; nPads++;} //4
ed3ceb24 139
c712cb2f 140 return nPads;
141}//Pad2ClosePads()
142//__________________________________________________________________________________________________
e42a7b46 143Int_t AliRICHParam::Loc2Sec(TVector2 &v2)
3582c1f9 144{
145// Determines sector containing the given point and trasform this point to the local system of that sector.
e42a7b46 146// Returns sector code:
147//y ^ 5 6
148// | 3 4
149// | 1 2
150// -------> x
151 Double_t x0=0; Double_t x1=SectorSizeX(); Double_t x2=SectorSizeX()+DeadZone(); Double_t x3=PcSizeX();
152 Double_t y0=0; Double_t y1=SectorSizeY(); Double_t y2=SectorSizeY()+DeadZone(); Double_t y3=2*SectorSizeY()+DeadZone();
153 Double_t y4=PcSizeY()-SectorSizeY(); Double_t y5=PcSizeY();
154
c712cb2f 155 Int_t sector=kBad;
e42a7b46 156 Double_t x=v2.X(),y=v2.Y();
157 if (v2.X() >= x0 && v2.X() <= x1 ) {sector=1;}
158 else if(v2.X() >= x2 && v2.X() <= x3 ) {sector=2; x=v2.X()-x2;}
159 else {sector=kBad; ::Error("Loc2Sec","Position %6.2f,%6.2f is out of chamber in X",v2.X(),v2.Y());return kBad;}
3582c1f9 160
e42a7b46 161 if (v2.Y() >= y0 && v2.Y() <= y1 ) {} //sectors 1 or 2
162 else if(v2.Y() >= y2 && v2.Y() <= y3 ) {sector+=2; y=v2.Y()-y2;} //sectors 3 or 4
163 else if(v2.Y() >= y4 && v2.Y() <= y5 ) {sector+=4; y=v2.Y()-y4;} //sectors 5 or 6
164 else {sector=kBad; ::Error("Loc2Sec","Position %6.2f,%6.2f is out of chamber in Y",v2.X(),v2.Y());return kBad;}
165 v2.Set(x,y);
3582c1f9 166 return sector;
c712cb2f 167}//Loc2Sec(Double_t x, Double_t y)
c2c6679b 168//__________________________________________________________________________________________________
e42a7b46 169TVector AliRICHParam::Loc2Pad(TVector2 x2)
3582c1f9 170{
e42a7b46 171// Determines pad number TVector(padx,pady) containing the given point x2 defined the chamber RS.
3582c1f9 172// Pad count starts in lower left corner from 1,1 to 144,160 in upper right corner of a chamber.
173// Returns sector number of the determined pad.
e42a7b46 174//y ^ 5 6
175// | 3 4
176// | 1 2
177// -------> x
178 TVector pad(2);
3582c1f9 179 Int_t sector=Loc2Sec(x2);//trasforms x2 to sector reference system
e42a7b46 180 if(sector==kBad) {pad[0]=pad[1]=kBad; return pad;}
3582c1f9 181
e42a7b46 182 pad[0]=Int_t(x2.X()/PadSizeX())+1; if(pad[0]>NpadsXsec()) pad[0]= NpadsXsec();
183 if(sector==2||sector==4||sector==6) pad[0]+= NpadsXsec();
3582c1f9 184
e42a7b46 185 pad[1]=Int_t(x2.Y()/PadSizeY())+1; if(pad[1]>NpadsYsec()) pad[1]= NpadsYsec();
186 if(sector==3||sector==4) pad[1]+=NpadsYsec();
187 if(sector==5||sector==6) pad[1]+=2*NpadsYsec();
188 return pad;
3582c1f9 189}
190//__________________________________________________________________________________________________
e42a7b46 191Int_t AliRICHParam::Pad2Sec(TVector pad)
3582c1f9 192{
e42a7b46 193// Determines sector containing the given pad.
c712cb2f 194 Int_t sector=kBad;
e42a7b46 195 if (pad[0] >= 1 && pad[0] <= NpadsXsec() ) {sector=1;}
196 else if(pad[0] > NpadsXsec() && pad[0] <= NpadsX() ) {sector=2;}
197 else ::Error("Pad2Sec","Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]);
198
199 if (pad[1] >= 1 && pad[1] <= NpadsYsec() ) {}
200 else if(pad[1] > NpadsYsec() && pad[1] <= 2*NpadsYsec() ) {sector+=2;}
201 else if(pad[1] > 2*NpadsYsec() && pad[1] <= NpadsY() ) {sector+=4;}
202 else ::Error("Pad2Sec","Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]);
c712cb2f 203
e42a7b46 204 return sector;
c712cb2f 205}//Pad2Sec()
206//__________________________________________________________________________________________________
e42a7b46 207TVector2 AliRICHParam::Pad2Loc(TVector pad)
c712cb2f 208{
e42a7b46 209// Returns position of the center of the given pad in local system of the chamber
210// y ^ 5 6
211// | 3 4 chamber structure
212// | 1 2
213// -------> x
214 Double_t x=kBad,y=kBad;
215 if(pad[0] > 0 && pad[0] <= NpadsXsec())//it's 1 or 3 or 5
216 x=(pad[0]-0.5)*PadSizeX();
217 else if(pad[0] > NpadsXsec() && pad[0] <= NpadsX())//it's 2 or 4 or 6
218 x=(pad[0]-0.5)*PadSizeX()+DeadZone();
c2c6679b 219 else
e42a7b46 220 ::Error("Pad2Loc","Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]);
221
222 if(pad[1] > 0 && pad[1] <= NpadsYsec())//it's 1 or 2
223 y=(pad[1]-0.5)*PadSizeY();
224 else if(pad[1] > NpadsYsec() && pad[1] <= 2*NpadsYsec())//it's 3 or 4
225 y=(pad[1]-0.5)*PadSizeY()+DeadZone();
226 else if(pad[1] > 2*NpadsYsec() && pad[1]<= NpadsY())//it's 5 or 6
227 y=(pad[1]-0.5)*PadSizeY()+2*DeadZone();
228 else
229 ::Error("Pad2Loc","Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]);
230
3582c1f9 231 return TVector2(x,y);
232}
c60862bf 233//__________________________________________________________________________________________________
e42a7b46 234Double_t AliRICHParam::GainSag(Double_t x,Int_t sector)
c60862bf 235{
3582c1f9 236// Returns % of gain variation due to wire sagita.
e42a7b46 237// All curves are parametrized as per sector basis, so y must be apriory transformed to the Sector RS.
238 x-=SectorSizeX()/2;
239 if(x>SectorSizeX()) x-=SectorSizeX();
3582c1f9 240 switch(HV(sector)){
e42a7b46 241 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;//%
242 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;
243 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;
244 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;
3582c1f9 245 default: return 0;
246 }
c712cb2f 247}
248//__________________________________________________________________________________________________
3582c1f9 249Int_t AliRICHParam::TotQdc(TVector2 x2,Double_t eloss)
250{
251// Calculates the total charge produced by the eloss in point x2 (Chamber RS).
e42a7b46 252// Returns this change parametrised in QDC channels, or 0 if the hit in the dead zone.
3582c1f9 253// eloss=0 means photons which provided for only 1 electron
09c52ebc 254// eloss > 0 for Mip
e42a7b46 255 if(Loc2Sec(x2)==kBad) return 0; //hit in the dead zone
3582c1f9 256 Int_t iNelectrons=Int_t(eloss/IonisationPotential()); if(iNelectrons==0) iNelectrons=1;
257 Double_t qdc=0;
258 for(Int_t i=1;i<=iNelectrons;i++) qdc+=-Gain(x2)*TMath::Log(gRandom->Rndm());
259 return Int_t(qdc);
260}
261//__________________________________________________________________________________________________
e42a7b46 262Double_t AliRICHParam::FracQdc(TVector2 x2,TVector pad)
3582c1f9 263{
e42a7b46 264// Calculates the charge fraction induced to given pad by the hit from the given point.
265// Integrated Mathieson distribution is used.
266 TVector2 center2=Pad2Loc(pad);//gives center of requested pad
3582c1f9 267 Double_t normXmin=(x2.X()-center2.X()-PadSizeX()/2) /AnodeCathodeGap();
268 Double_t normXmax=(x2.X()-center2.X()+PadSizeX()/2) /AnodeCathodeGap();
269 Double_t normYmin=(x2.Y()-center2.Y()-PadSizeY()/2) /AnodeCathodeGap();
270 Double_t normYmax=(x2.Y()-center2.Y()+PadSizeY()/2) /AnodeCathodeGap();
c712cb2f 271
e42a7b46 272 if(Loc2Sec(x2)!=Pad2Sec(pad)) return 0;//requested pad does not belong to the sector of the given hit position
273 else return Mathieson(normXmin, normYmin, normXmax, normYmax);
3582c1f9 274}
c712cb2f 275//__________________________________________________________________________________________________
9d6f9427 276Double_t AliRICHParam::Mathieson(Double_t xMin,Double_t yMin,Double_t xMax,Double_t yMax)
3582c1f9 277{
278// All arguments are parametrised according to NIM A370(1988)602-603
279// Returns a charge fraction.
53fd478b 280 const Double_t kSqrtKx3=0.77459667;const Double_t kX2=0.962;const Double_t kX4=0.379;
281 const Double_t kSqrtKy3=0.77459667;const Double_t kY2=0.962;const Double_t kY4=0.379;
c712cb2f 282
53fd478b 283 Double_t ux1=kSqrtKx3*TMath::TanH(kX2*xMin);
284 Double_t ux2=kSqrtKx3*TMath::TanH(kX2*xMax);
285 Double_t uy1=kSqrtKy3*TMath::TanH(kY2*yMin);
286 Double_t uy2=kSqrtKy3*TMath::TanH(kY2*yMax);
287 return 4*kX4*(TMath::ATan(ux2)-TMath::ATan(ux1))*kY4*(TMath::ATan(uy2)-TMath::ATan(uy1));
c712cb2f 288}
289//__________________________________________________________________________________________________
e42a7b46 290TVector AliRICHParam::Loc2Area(TVector2 x2)
3582c1f9 291{
292// Calculates the area of disintegration for a given point. It's assumed here that this points lays on anode wire.
293// Area is a rectangulare set of pads defined by its left-down and right-up coners.
e42a7b46 294 TVector area(4);
295 TVector pad=Loc2Pad(x2);
296 area[0]=area[2]=pad[0]; area[1]=area[3]=pad[1];//area is just a pad fired
297 if(pad[0]!=1 && pad[0]!= NpadsXsec()+1 ) area[0]--; //left down coner X
298 if(pad[1]!=1 && pad[1]!= NpadsYsec()+1 && pad[1]!= 2*NpadsYsec()+1) area[1]--; //left down coner Y
299 if(pad[0]!=NpadsXsec() && pad[0]!= NpadsX() ) area[2]++; //right up coner X
300 if(pad[1]!=NpadsYsec() && pad[1]!= 2*NpadsYsec() && pad[1]!= NpadsY() ) area[3]++; //right up coner Y
301 return area;
3582c1f9 302}
08479a10 303//__________________________________________________________________________________________________
e42a7b46 304Bool_t AliRICHParam::IsOverTh(Int_t ,TVector ,Double_t q)
3582c1f9 305{
e42a7b46 306// Checks if the current q is over threshold and FEE will save this value to data concentrator.
307 return (q>NsigmaTh()*(SigmaThMean()+(1.-2*gRandom->Rndm())*SigmaThSpread()));
3582c1f9 308}
309//__________________________________________________________________________________________________
e42a7b46 310void AliRICHParam::PropogateHelix(TVector3 x0,TVector3 p0,Double_t s,TVector3 *x,TVector3 *p)
3582c1f9 311{
e42a7b46 312// Propogates the helix given by (x0,p0) in MRS to the position of interest defined by helix length s
313 const Double_t c = 0.00299792458;
314 const Double_t Bz = 0.5; //field in Tesla
315 const Double_t q = 1; //charge in electron units
316 Double_t a = -c*Bz*q;
317
318 Double_t rho = a/p0.Mag();
319 p->SetX(p0.X()*TMath::Cos(rho*s)-p0.Y()*TMath::Sin(rho*s));
320 p->SetY(p0.Y()*TMath::Cos(rho*s)+p0.X()*TMath::Sin(rho*s));
321 p->SetZ(p0.Z());
322 x->SetX(x0.X()+p0.X()*TMath::Sin(rho*s)/a-p0.Y()*(1-TMath::Cos(rho*s))/a);
323 x->SetY(x0.Y()+p0.Y()*TMath::Sin(rho*s)/a+p0.X()*(1-TMath::Cos(rho*s))/a);
324 x->SetZ(x0.Z()+p0.Z()*s/p->Mag());
3582c1f9 325}
d48cca74 326#endif //AliRICHParam_h