-//__________________________________________________________________________________________________
-Int_t AliRICHParam::PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t listX[4],Int_t listY[4])
-{
-// Determines all the neighbouring pads for the given one (iPadX,iPadY). Returns total number of these pads.
-// Dead zones are taken into account.
-// 1
-// 2 3
-// 4
- Int_t nPads=0;
- if(iPadY!=NpadsY()&&iPadY!=2*NpadsYsec()&&iPadY!=NpadsYsec()){listX[nPads]=iPadX; listY[nPads]=iPadY+1; nPads++;} //1
- if(iPadX!=1&&iPadX!=NpadsXsec()+1) {listX[nPads]=iPadX-1; listY[nPads]=iPadY; nPads++;} //2
- if(iPadX!=NpadsXsec()&&iPadX!=NpadsX()) {listX[nPads]=iPadX+1; listY[nPads]=iPadY; nPads++;} //3
- if(iPadY!=1&&iPadY!=NpadsYsec()+1&&2*NpadsYsec()+1) {listX[nPads]=iPadX; listY[nPads]=iPadY-1; nPads++;} //4
-
- return nPads;
-}//Pad2ClosePads()
-//__________________________________________________________________________________________________
-Int_t AliRICHParam::Loc2Sec(TVector2 &v2)
-{
-// Determines sector containing the given point and trasform this point to the local system of that sector.
-// Returns sector code:
-//y ^ 5 6
-// | 3 4
-// | 1 2
-// -------> x
- Double_t x0=0; Double_t x1=SectorSizeX(); Double_t x2=SectorSizeX()+DeadZone(); Double_t x3=PcSizeX();
- Double_t y0=0; Double_t y1=SectorSizeY(); Double_t y2=SectorSizeY()+DeadZone(); Double_t y3=2*SectorSizeY()+DeadZone();
- Double_t y4=PcSizeY()-SectorSizeY(); Double_t y5=PcSizeY();
-
- Int_t sector=kBad;
- Double_t x=v2.X(),y=v2.Y();
- if (v2.X() >= x0 && v2.X() <= x1 ) {sector=1;}
- else if(v2.X() >= x2 && v2.X() <= x3 ) {sector=2; x=v2.X()-x2;}
- else {return kBad;}
-
- if (v2.Y() >= y0 && v2.Y() <= y1 ) {} //sectors 1 or 2
- else if(v2.Y() >= y2 && v2.Y() <= y3 ) {sector+=2; y=v2.Y()-y2;} //sectors 3 or 4
- else if(v2.Y() >= y4 && v2.Y() <= y5 ) {sector+=4; y=v2.Y()-y4;} //sectors 5 or 6
- else {return kBad;}
- v2.Set(x,y);
- return sector;
-}//Loc2Sec(Double_t x, Double_t y)
-//__________________________________________________________________________________________________
-TVector AliRICHParam::Loc2Pad(TVector2 x2)
-{
-// Determines pad number TVector(padx,pady) containing the given point x2 defined the chamber RS.
-// Pad count starts in lower left corner from 1,1 to 144,160 in upper right corner of a chamber.
-// Returns sector number of the determined pad.
-//y ^ 5 6
-// | 3 4
-// | 1 2
-// -------> x
- TVector pad(2);
- Int_t sector=Loc2Sec(x2);//trasforms x2 to sector reference system
- if(sector==kBad) {pad[0]=pad[1]=kBad; return pad;}
-
- pad[0]=Int_t(x2.X()/PadSizeX())+1; if(pad[0]>NpadsXsec()) pad[0]= NpadsXsec();
- if(sector==2||sector==4||sector==6) pad[0]+= NpadsXsec();
-
- pad[1]=Int_t(x2.Y()/PadSizeY())+1; if(pad[1]>NpadsYsec()) pad[1]= NpadsYsec();
- if(sector==3||sector==4) pad[1]+=NpadsYsec();
- if(sector==5||sector==6) pad[1]+=2*NpadsYsec();
- return pad;
-}
-//__________________________________________________________________________________________________
-Int_t AliRICHParam::Pad2Sec(const TVector &pad)
-{
-// Determines sector containing the given pad.
- Int_t sector=kBad;
- if (pad[0] >= 1 && pad[0] <= NpadsXsec() ) {sector=1;}
- else if(pad[0] > NpadsXsec() && pad[0] <= NpadsX() ) {sector=2;}
- else AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
-
- if (pad[1] >= 1 && pad[1] <= NpadsYsec() ) {}
- else if(pad[1] > NpadsYsec() && pad[1] <= 2*NpadsYsec() ) {sector+=2;}
- else if(pad[1] > 2*NpadsYsec() && pad[1] <= NpadsY() ) {sector+=4;}
- else AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
-
- return sector;
-}//Pad2Sec()
-//__________________________________________________________________________________________________
-TVector2 AliRICHParam::Pad2Loc(TVector pad)
-{
-// Returns position of the center of the given pad in local system of the chamber (cm)
-// y ^ 5 6
-// | 3 4 sector numbers
-// | 1 2
-// -------> x
- Double_t x=kBad,y=kBad;
- if(pad[0] > 0 && pad[0] <= NpadsXsec())//it's 1 or 3 or 5
- x=(pad[0]-0.5)*PadSizeX();
- else if(pad[0] > NpadsXsec() && pad[0] <= NpadsX())//it's 2 or 4 or 6
- x=(pad[0]-0.5)*PadSizeX()+DeadZone();
- else
- AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
-
- if(pad[1] > 0 && pad[1] <= NpadsYsec())//it's 1 or 2
- y=(pad[1]-0.5)*PadSizeY();
- else if(pad[1] > NpadsYsec() && pad[1] <= 2*NpadsYsec())//it's 3 or 4
- y=(pad[1]-0.5)*PadSizeY()+DeadZone();
- else if(pad[1] > 2*NpadsYsec() && pad[1]<= NpadsY())//it's 5 or 6
- y=(pad[1]-0.5)*PadSizeY()+2*DeadZone();
- else
- AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
-
- return TVector2(x,y);
-}
-//__________________________________________________________________________________________________
-Double_t AliRICHParam::GainSag(Double_t x,Int_t sector)
-{
-// Returns % of gain variation due to wire sagita.
-// All curves are parametrized as per sector basis, so x must be apriory transformed to the Sector RS.
-// Here x is a distance along wires.
- x-=SectorSizeX()/2;
- if(x>SectorSizeX()) x-=SectorSizeX();
- switch(HV(sector)){
- 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;//%
- 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;
- 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;
- 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;
- default: return 0;
- }
-}
-//__________________________________________________________________________________________________
-Int_t AliRICHParam::TotQdc(TVector2 x2,Double_t eloss)
-{
-// Calculates the total charge produced by the eloss in point x2 (Chamber RS).
-// Returns this change parametrised in QDC channels, or 0 if the hit in the dead zone.
-// eloss=0 means photon which produces 1 electron only eloss > 0 for Mip
- if(Loc2Sec(x2)==kBad) return 0; //hit in the dead zone
- Int_t iNelectrons=Int_t(eloss/IonisationPotential()); if(iNelectrons==0) iNelectrons=1;
- Double_t qdc=0;
- for(Int_t i=1;i<=iNelectrons;i++) qdc+=-Gain(x2)*TMath::Log(gRandom->Rndm());
- return Int_t(qdc);
-}
-//__________________________________________________________________________________________________
-Double_t AliRICHParam::FracQdc(TVector2 x2,TVector pad)
-{
-// Calculates the charge fraction induced to given pad by the hit from the given point.
-// Integrated Mathieson distribution is used.
- TVector2 center2=Pad2Loc(pad);//gives center of requested pad
- Double_t normXmin=(x2.X()-center2.X()-PadSizeX()/2) /Pc2Cath();//parametrise for Mathienson
- Double_t normXmax=(x2.X()-center2.X()+PadSizeX()/2) /Pc2Cath();
- Double_t normYmin=(x2.Y()-center2.Y()-PadSizeY()/2) /Pc2Cath();
- Double_t normYmax=(x2.Y()-center2.Y()+PadSizeY()/2) /Pc2Cath();
-
-//requested pad might not belong to the sector of the given hit position, hence the check:
- return (Loc2Sec(x2)!=Pad2Sec(pad)) ? 0:Mathieson(normXmin, normYmin, normXmax, normYmax);
-}
-//__________________________________________________________________________________________________
-Double_t AliRICHParam::Mathieson(Double_t xMin,Double_t yMin,Double_t xMax,Double_t yMax)
-{
-// All arguments are parametrised according to NIM A370(1988)602-603
-// Returns a charge fraction.
- const Double_t kSqrtKx3=0.77459667;const Double_t kX2=0.962;const Double_t kX4=0.379;
- const Double_t kSqrtKy3=0.77459667;const Double_t kY2=0.962;const Double_t kY4=0.379;
-
- Double_t ux1=kSqrtKx3*TMath::TanH(kX2*xMin);
- Double_t ux2=kSqrtKx3*TMath::TanH(kX2*xMax);
- Double_t uy1=kSqrtKy3*TMath::TanH(kY2*yMin);
- Double_t uy2=kSqrtKy3*TMath::TanH(kY2*yMax);
- return 4*kX4*(TMath::ATan(ux2)-TMath::ATan(ux1))*kY4*(TMath::ATan(uy2)-TMath::ATan(uy1));
-}
-//__________________________________________________________________________________________________
-TVector AliRICHParam::Loc2Area(TVector2 x2)
-{
-// Calculates the area of disintegration for a given point. It's assumed here that this points lays on anode wire.
-// Area is a rectangulare set of pads defined by its left-down and right-up coners.
- TVector area(4);
- TVector pad=Loc2Pad(x2);
- area[0]=area[2]=pad[0]; area[1]=area[3]=pad[1];//area is just a pad fired
- if(pad[0]!=1 && pad[0]!= NpadsXsec()+1 ) area[0]--; //left down coner X
- if(pad[1]!=1 && pad[1]!= NpadsYsec()+1 && pad[1]!= 2*NpadsYsec()+1) area[1]--; //left down coner Y
- if(pad[0]!=NpadsXsec() && pad[0]!= NpadsX() ) area[2]++; //right up coner X
- if(pad[1]!=NpadsYsec() && pad[1]!= 2*NpadsYsec() && pad[1]!= NpadsY() ) area[3]++; //right up coner Y
- return area;
-}
-//__________________________________________________________________________________________________
-Bool_t AliRICHParam::IsOverTh(Int_t ,TVector ,Double_t q)
-{
-// Checks if the current q is over threshold and FEE will save this value to data concentrator.
- return (q>NsigmaTh()*(SigmaThMean()+(1.-2*gRandom->Rndm())*SigmaThSpread()));
-}
-#endif //AliRICHParam_h