]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHParam.h
Cog correction improved. Hit position at anod
[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;}
ed83829e 109 inline static Double_t CogCorr(Double_t x) {return 3.31267e-2*TMath::Sin(2*TMath::Pi()/PadSizeX()*x)
110 -2.66575e-3*TMath::Sin(4*TMath::Pi()/PadSizeX()*x)
111 +2.80553e-3*TMath::Sin(6*TMath::Pi()/PadSizeX()*x);}
e42a7b46 112protected:
113 TObjArray *fpChambers; //list of chambers
114 static Bool_t fgIsWireSag; //wire sagitta ON/OFF flag
115 static Bool_t fgIsResolveClusters; //declustering ON/OFF flag
116 static Bool_t fgIsRadioSrc; //radioactive source ON/OFF flag
117 static Int_t fgHV[6]; //HV applied to anod wires
118 static Double_t fgAngleRot; //module rotation from up postion (0,0,490)cm
119 static Int_t fgNsigmaTh; //n. of sigmas to cut for zero suppression
120 static Float_t fgSigmaThMean; //sigma threshold value
121 static Float_t fgSigmaThSpread; //spread of sigma
122 ClassDef(AliRICHParam,5) //RICH main parameters class
d48cca74 123};
c2c6679b 124//__________________________________________________________________________________________________
c712cb2f 125Int_t AliRICHParam::PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t listX[4],Int_t listY[4])
126{
e42a7b46 127// Determines all the neighbouring pads for the given one (iPadX,iPadY). Returns total number of these pads.
3582c1f9 128// Dead zones are taken into account.
e42a7b46 129// 1
130// 2 3
131// 4
c712cb2f 132 Int_t nPads=0;
e42a7b46 133 if(iPadY!=NpadsY()&&iPadY!=2*NpadsYsec()&&iPadY!=NpadsYsec()){listX[nPads]=iPadX; listY[nPads]=iPadY+1; nPads++;} //1
134 if(iPadX!=1&&iPadX!=NpadsXsec()+1) {listX[nPads]=iPadX-1; listY[nPads]=iPadY; nPads++;} //2
135 if(iPadX!=NpadsXsec()&&iPadX!=NpadsX()) {listX[nPads]=iPadX+1; listY[nPads]=iPadY; nPads++;} //3
136 if(iPadY!=1&&iPadY!=NpadsYsec()+1&&2*NpadsYsec()+1) {listX[nPads]=iPadX; listY[nPads]=iPadY-1; nPads++;} //4
ed3ceb24 137
c712cb2f 138 return nPads;
139}//Pad2ClosePads()
140//__________________________________________________________________________________________________
e42a7b46 141Int_t AliRICHParam::Loc2Sec(TVector2 &v2)
3582c1f9 142{
143// Determines sector containing the given point and trasform this point to the local system of that sector.
e42a7b46 144// Returns sector code:
145//y ^ 5 6
146// | 3 4
147// | 1 2
148// -------> x
149 Double_t x0=0; Double_t x1=SectorSizeX(); Double_t x2=SectorSizeX()+DeadZone(); Double_t x3=PcSizeX();
150 Double_t y0=0; Double_t y1=SectorSizeY(); Double_t y2=SectorSizeY()+DeadZone(); Double_t y3=2*SectorSizeY()+DeadZone();
151 Double_t y4=PcSizeY()-SectorSizeY(); Double_t y5=PcSizeY();
152
c712cb2f 153 Int_t sector=kBad;
e42a7b46 154 Double_t x=v2.X(),y=v2.Y();
155 if (v2.X() >= x0 && v2.X() <= x1 ) {sector=1;}
156 else if(v2.X() >= x2 && v2.X() <= x3 ) {sector=2; x=v2.X()-x2;}
998b831f 157 else {return kBad;}
3582c1f9 158
e42a7b46 159 if (v2.Y() >= y0 && v2.Y() <= y1 ) {} //sectors 1 or 2
160 else if(v2.Y() >= y2 && v2.Y() <= y3 ) {sector+=2; y=v2.Y()-y2;} //sectors 3 or 4
161 else if(v2.Y() >= y4 && v2.Y() <= y5 ) {sector+=4; y=v2.Y()-y4;} //sectors 5 or 6
998b831f 162 else {return kBad;}
e42a7b46 163 v2.Set(x,y);
3582c1f9 164 return sector;
c712cb2f 165}//Loc2Sec(Double_t x, Double_t y)
c2c6679b 166//__________________________________________________________________________________________________
e42a7b46 167TVector AliRICHParam::Loc2Pad(TVector2 x2)
3582c1f9 168{
e42a7b46 169// Determines pad number TVector(padx,pady) containing the given point x2 defined the chamber RS.
3582c1f9 170// Pad count starts in lower left corner from 1,1 to 144,160 in upper right corner of a chamber.
171// Returns sector number of the determined pad.
e42a7b46 172//y ^ 5 6
173// | 3 4
174// | 1 2
175// -------> x
176 TVector pad(2);
3582c1f9 177 Int_t sector=Loc2Sec(x2);//trasforms x2 to sector reference system
e42a7b46 178 if(sector==kBad) {pad[0]=pad[1]=kBad; return pad;}
3582c1f9 179
e42a7b46 180 pad[0]=Int_t(x2.X()/PadSizeX())+1; if(pad[0]>NpadsXsec()) pad[0]= NpadsXsec();
181 if(sector==2||sector==4||sector==6) pad[0]+= NpadsXsec();
3582c1f9 182
e42a7b46 183 pad[1]=Int_t(x2.Y()/PadSizeY())+1; if(pad[1]>NpadsYsec()) pad[1]= NpadsYsec();
184 if(sector==3||sector==4) pad[1]+=NpadsYsec();
185 if(sector==5||sector==6) pad[1]+=2*NpadsYsec();
186 return pad;
3582c1f9 187}
188//__________________________________________________________________________________________________
998b831f 189Int_t AliRICHParam::Pad2Sec(const TVector &pad)
3582c1f9 190{
e42a7b46 191// Determines sector containing the given pad.
c712cb2f 192 Int_t sector=kBad;
e42a7b46 193 if (pad[0] >= 1 && pad[0] <= NpadsXsec() ) {sector=1;}
194 else if(pad[0] > NpadsXsec() && pad[0] <= NpadsX() ) {sector=2;}
998b831f 195 else AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
e42a7b46 196
197 if (pad[1] >= 1 && pad[1] <= NpadsYsec() ) {}
198 else if(pad[1] > NpadsYsec() && pad[1] <= 2*NpadsYsec() ) {sector+=2;}
199 else if(pad[1] > 2*NpadsYsec() && pad[1] <= NpadsY() ) {sector+=4;}
998b831f 200 else AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
c712cb2f 201
e42a7b46 202 return sector;
c712cb2f 203}//Pad2Sec()
204//__________________________________________________________________________________________________
e42a7b46 205TVector2 AliRICHParam::Pad2Loc(TVector pad)
c712cb2f 206{
998b831f 207// Returns position of the center of the given pad in local system of the chamber (cm)
e42a7b46 208// y ^ 5 6
998b831f 209// | 3 4 sector numbers
e42a7b46 210// | 1 2
211// -------> x
212 Double_t x=kBad,y=kBad;
213 if(pad[0] > 0 && pad[0] <= NpadsXsec())//it's 1 or 3 or 5
214 x=(pad[0]-0.5)*PadSizeX();
215 else if(pad[0] > NpadsXsec() && pad[0] <= NpadsX())//it's 2 or 4 or 6
216 x=(pad[0]-0.5)*PadSizeX()+DeadZone();
c2c6679b 217 else
998b831f 218 AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
e42a7b46 219
220 if(pad[1] > 0 && pad[1] <= NpadsYsec())//it's 1 or 2
221 y=(pad[1]-0.5)*PadSizeY();
222 else if(pad[1] > NpadsYsec() && pad[1] <= 2*NpadsYsec())//it's 3 or 4
223 y=(pad[1]-0.5)*PadSizeY()+DeadZone();
224 else if(pad[1] > 2*NpadsYsec() && pad[1]<= NpadsY())//it's 5 or 6
225 y=(pad[1]-0.5)*PadSizeY()+2*DeadZone();
226 else
998b831f 227 AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
e42a7b46 228
3582c1f9 229 return TVector2(x,y);
230}
c60862bf 231//__________________________________________________________________________________________________
e42a7b46 232Double_t AliRICHParam::GainSag(Double_t x,Int_t sector)
c60862bf 233{
3582c1f9 234// Returns % of gain variation due to wire sagita.
998b831f 235// All curves are parametrized as per sector basis, so x must be apriory transformed to the Sector RS.
236// Here x is a distance along wires.
e42a7b46 237 x-=SectorSizeX()/2;
238 if(x>SectorSizeX()) x-=SectorSizeX();
3582c1f9 239 switch(HV(sector)){
e42a7b46 240 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;//%
241 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;
242 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;
243 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 244 default: return 0;
245 }
c712cb2f 246}
247//__________________________________________________________________________________________________
3582c1f9 248Int_t AliRICHParam::TotQdc(TVector2 x2,Double_t eloss)
249{
250// Calculates the total charge produced by the eloss in point x2 (Chamber RS).
e42a7b46 251// Returns this change parametrised in QDC channels, or 0 if the hit in the dead zone.
998b831f 252// eloss=0 means photon which produces 1 electron only eloss > 0 for Mip
e42a7b46 253 if(Loc2Sec(x2)==kBad) return 0; //hit in the dead zone
3582c1f9 254 Int_t iNelectrons=Int_t(eloss/IonisationPotential()); if(iNelectrons==0) iNelectrons=1;
255 Double_t qdc=0;
256 for(Int_t i=1;i<=iNelectrons;i++) qdc+=-Gain(x2)*TMath::Log(gRandom->Rndm());
257 return Int_t(qdc);
258}
259//__________________________________________________________________________________________________
e42a7b46 260Double_t AliRICHParam::FracQdc(TVector2 x2,TVector pad)
3582c1f9 261{
e42a7b46 262// Calculates the charge fraction induced to given pad by the hit from the given point.
263// Integrated Mathieson distribution is used.
264 TVector2 center2=Pad2Loc(pad);//gives center of requested pad
998b831f 265 Double_t normXmin=(x2.X()-center2.X()-PadSizeX()/2) /Pc2Cath();//parametrise for Mathienson
266 Double_t normXmax=(x2.X()-center2.X()+PadSizeX()/2) /Pc2Cath();
267 Double_t normYmin=(x2.Y()-center2.Y()-PadSizeY()/2) /Pc2Cath();
268 Double_t normYmax=(x2.Y()-center2.Y()+PadSizeY()/2) /Pc2Cath();
269
270//requested pad might not belong to the sector of the given hit position, hence the check:
271 return (Loc2Sec(x2)!=Pad2Sec(pad)) ? 0:Mathieson(normXmin, normYmin, normXmax, normYmax);
3582c1f9 272}
c712cb2f 273//__________________________________________________________________________________________________
9d6f9427 274Double_t AliRICHParam::Mathieson(Double_t xMin,Double_t yMin,Double_t xMax,Double_t yMax)
3582c1f9 275{
276// All arguments are parametrised according to NIM A370(1988)602-603
277// Returns a charge fraction.
53fd478b 278 const Double_t kSqrtKx3=0.77459667;const Double_t kX2=0.962;const Double_t kX4=0.379;
279 const Double_t kSqrtKy3=0.77459667;const Double_t kY2=0.962;const Double_t kY4=0.379;
c712cb2f 280
53fd478b 281 Double_t ux1=kSqrtKx3*TMath::TanH(kX2*xMin);
282 Double_t ux2=kSqrtKx3*TMath::TanH(kX2*xMax);
283 Double_t uy1=kSqrtKy3*TMath::TanH(kY2*yMin);
284 Double_t uy2=kSqrtKy3*TMath::TanH(kY2*yMax);
285 return 4*kX4*(TMath::ATan(ux2)-TMath::ATan(ux1))*kY4*(TMath::ATan(uy2)-TMath::ATan(uy1));
c712cb2f 286}
287//__________________________________________________________________________________________________
e42a7b46 288TVector AliRICHParam::Loc2Area(TVector2 x2)
3582c1f9 289{
290// Calculates the area of disintegration for a given point. It's assumed here that this points lays on anode wire.
291// Area is a rectangulare set of pads defined by its left-down and right-up coners.
e42a7b46 292 TVector area(4);
293 TVector pad=Loc2Pad(x2);
294 area[0]=area[2]=pad[0]; area[1]=area[3]=pad[1];//area is just a pad fired
295 if(pad[0]!=1 && pad[0]!= NpadsXsec()+1 ) area[0]--; //left down coner X
296 if(pad[1]!=1 && pad[1]!= NpadsYsec()+1 && pad[1]!= 2*NpadsYsec()+1) area[1]--; //left down coner Y
297 if(pad[0]!=NpadsXsec() && pad[0]!= NpadsX() ) area[2]++; //right up coner X
298 if(pad[1]!=NpadsYsec() && pad[1]!= 2*NpadsYsec() && pad[1]!= NpadsY() ) area[3]++; //right up coner Y
299 return area;
3582c1f9 300}
08479a10 301//__________________________________________________________________________________________________
e42a7b46 302Bool_t AliRICHParam::IsOverTh(Int_t ,TVector ,Double_t q)
3582c1f9 303{
e42a7b46 304// Checks if the current q is over threshold and FEE will save this value to data concentrator.
305 return (q>NsigmaTh()*(SigmaThMean()+(1.-2*gRandom->Rndm())*SigmaThSpread()));
3582c1f9 306}
d48cca74 307#endif //AliRICHParam_h