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