]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHParam.h
No return in void function (Alpha)
[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:
a25b3368 34//ctor&dtor
e42a7b46 35 AliRICHParam():TObject(),fpChambers(0) {CreateChambers();}
36 virtual ~AliRICHParam() {delete fpChambers;}
a25b3368 37//test methodes
38 void Print(const Option_t *opt=""); //print current parametrization
39 void Test() {TestSeg();TestTrans();TestResp();} //test all groups of methodes
40 void TestResp(); //test the response group of methodes
41 void TestSeg(); //test the segmentation group of methodes
42 void TestTrans(); //test the transform group of methodes
43 void DrawAxis();
44//flags staff
45 static void SetAerogel(Bool_t a) {fgIsAerogel=a;}
46 static Bool_t IsAerogel() {return fgIsAerogel;}
47 static void SetRadioSrc(Bool_t a) {fgIsRadioSrc=a;}
48 static Bool_t IsRadioSrc() {return fgIsRadioSrc;}
49 static void SetTestBeam(Bool_t a) {fgIsTestBeam=a;}
50 static Bool_t IsTestBeam() {return fgIsTestBeam;}
51 static void SetWireSag(Bool_t a) {fgIsWireSag=a;}
52 static Bool_t IsWireSag() {return fgIsWireSag;}
53 static void SetResolveClusters(Bool_t a) {fgIsResolveClusters=a;}
54 static Bool_t IsResolveClusters() {return fgIsResolveClusters;}
55//Chambers manipulation methodes
56 void CreateChambers(); //form chamber structure
998b831f 57 AliRICHChamber* C(Int_t i) {return (AliRICHChamber*)fpChambers->UncheckedAt(i-1);} //returns pointer to chamber i
a25b3368 58 Int_t Nchambers() {return fpChambers->GetEntriesFast();} //returns number of chambers
59//Geometrical properties
e42a7b46 60 static Int_t NpadsX() {return kNpadsX;} //pads along X in chamber
61 static Int_t NpadsY() {return kNpadsY;} //pads along Y in chamber
62 static Int_t NpadsXsec() {return NpadsX()/2;} //pads along X in sector
63 static Int_t NpadsYsec() {return NpadsY()/3;} //pads along Y in sector
3582c1f9 64 static Double_t DeadZone() {return 2.6;} //dead zone size in cm
a25b3368 65 static Double_t PadSizeX() {return 0.8;} //pad size x, cm
66 static Double_t PadSizeY() {return 0.84;} //pad size y, cm
998b831f 67
a25b3368 68 static Double_t SectorSizeX() {return NpadsX()*PadSizeX()/2;} //sector size x, cm
69 static Double_t SectorSizeY() {return NpadsY()*PadSizeY()/3;} //sector size y, cm
998b831f 70 static Double_t PcSizeX() {return NpadsX()*PadSizeX()+DeadZone();} //PC size x, cm
71 static Double_t PcSizeY() {return NpadsY()*PadSizeY()+2*DeadZone();} //PC size y, cm
a25b3368 72//
998b831f 73 static Double_t Zfreon() {return 1.5;} //freon thinkness, cm
74 static Double_t Zwin() {return 0.5;} //radiator quartz window, cm
75 static Double_t Pc2Win() {return 8.0;} //cm between CsI PC and radiator quartz window
76 static Double_t Pc2Coll() {return 7.0;} //cm between CsI PC and third wire grid (collection wires)
77 static Double_t Pc2Anod() {return 0.204;} //cm between CsI PC and first wire grid (anod wires)
78 static Double_t Pc2Cath() {return 0.445;} //cm between CsI PC and second wire grid (cathode wires)
79 static Double_t Freon2Pc() {return Zfreon()+Zwin()+Pc2Win();} //cm between CsI PC and entrance to freon
e42a7b46 80 static Double_t PitchAnod() {return PadSizeY()/2;} //cm between anode wires
81 static Double_t PitchCath() {return PadSizeY()/4;} //cm between cathode wires
998b831f 82 static Double_t PitchColl() {return 0.5;} //cm between collection wires
e42a7b46 83
e42a7b46 84 static Double_t IonisationPotential() {return 26.0e-9;} //for CH4 in GeV taken from ????
85 static TVector2 MathiesonDelta() {return TVector2(5*0.18,5*0.18);} //area of 5 sigmas of Mathieson distribution (cm)
86 static Int_t MaxQdc() {return 4095;} //QDC number of channels
a25b3368 87
88 static Int_t HV(Int_t sector) {
f037571e 89 if (sector>=1 && sector <=6)
90 return fgHV[sector-1];
91 else {
f037571e 92 return kBad;
93 }
94 } //high voltage for this sector
3582c1f9 95 static void SetHV(Int_t sector,Int_t hv){fgHV[sector-1]=hv;}
a25b3368 96//optical properties methodes
97 static Float_t PhotonEnergy(Int_t i) {return 0.1*i+5.5;} //photon energy (eV) for i-th point
98 static Float_t AbsCH4(Float_t ev); //CH4 absorption length (cm) for photon with given energy (eV)
99 static Float_t AbsGel(Float_t) {return 500;} //Aerogel absorption length (cm) for photon with given energy (eV)
100 static Float_t RefIdxC6F14(Float_t eV) {return eV*0.0172+1.177;} //Freon ref index for photon with given energy (eV)
101 static Float_t RefIdxCH4(Float_t) {return 1.000444;} //Methane ref index for photon with given energy (eV)
102 static Float_t RefIdxSiO2(Float_t eV) {Float_t e1=10.666,e2=18.125,f1=46.411,f2= 228.71;
103 return TMath::Sqrt(1.+f1/(e1*e1-eV*eV)+f2/(e2*e2-eV*eV));}//Quartz window ref index from TDR p.35
104 static Float_t RefIdxGel(Float_t) {return 1.05;} //aerogel ref index
105 static Float_t DenGel() {return (RefIdxGel(0)-1)/0.21;} //aerogel density gr/cm^3 parametrization by E.Nappi
106//trasformation methodes
107 inline static TVector Loc2Area(const TVector2 &x2); //return area affected by hit x2
108 inline static Int_t Loc2Sec(const TVector2 &x2); //return sector for given position
109 inline static TVector Loc2Pad(const TVector2 &x2); //return pad containing given position
e42a7b46 110 inline static TVector2 Pad2Loc(TVector pad); //return center of the pad
a25b3368 111 static TVector2 Pad2Loc(Int_t x,Int_t y) {TVector pad(2);pad[0]=x;pad[1]=y;return Pad2Loc(pad);}//return center of the pad (x,y)
112 inline static Int_t Pad2Sec(const TVector &pad); //return sector of given pad
3582c1f9 113 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
a25b3368 114 static Bool_t IsAccepted(const TVector2 &x2) {return ( x2.X()>=0 && x2.X()<=PcSizeX() && x2.Y()>=0 && x2.Y()<=PcSizeY() ) ? kTRUE:kFALSE;}
115//charge response methodes
116 inline static Double_t Mathieson(Double_t x1,Double_t x2,Double_t y1,Double_t y2); //Mathienson integral over given limits
e42a7b46 117 inline static Double_t GainSag(Double_t x,Int_t sector); //gain variations in %
118 static Double_t QdcSlope(Int_t sec){switch(sec){case kBad: return 0; default: return 33;}} //weight of electon in QDC channels
a25b3368 119 static Double_t Gain(const TVector2 &x2){//gives chamber gain in terms of QDC channels for given point in local ref system
120 if(fgIsWireSag) return QdcSlope(Loc2Sec(x2))*(1+GainSag(x2.X(),Loc2Sec(x2))/100);
121 else return QdcSlope(Loc2Sec(x2));}
122 inline static Double_t FracQdc(const TVector2 &x2,const TVector &pad); //charge fraction to pad from hit
3582c1f9 123 inline static Int_t TotQdc(TVector2 x2,Double_t eloss); //total charge for hit eloss=0 for photons
e42a7b46 124 inline Bool_t IsOverTh(Int_t c,TVector pad,Double_t q); //is QDC of the pad registered by FEE
125 static Int_t NsigmaTh() {return fgNsigmaTh;} //
126 static Float_t SigmaThMean() {return fgSigmaThMean;} //QDC electronic noise mean
127 static Float_t SigmaThSpread() {return fgSigmaThSpread;} //QDC electronic noise width
e42a7b46 128
a25b3368 129 inline static Double_t CogCorr(Double_t x) {return 3.31267e-2*TMath::Sin(2*TMath::Pi()/PadSizeX()*x) //correction of cluster CoG due to sinoidal
ed83829e 130 -2.66575e-3*TMath::Sin(4*TMath::Pi()/PadSizeX()*x)
131 +2.80553e-3*TMath::Sin(6*TMath::Pi()/PadSizeX()*x);}
a25b3368 132
133 static Bool_t fgIsAerogel; //aerogel geometry instead of normal RICH flag
e42a7b46 134protected:
a25b3368 135 static Bool_t fgIsRadioSrc; //radioactive source instead of radiators flag
136 static Bool_t fgIsTestBeam; //test beam geometry instead of normal RICH flag
e42a7b46 137 static Bool_t fgIsWireSag; //wire sagitta ON/OFF flag
138 static Bool_t fgIsResolveClusters; //declustering ON/OFF flag
a25b3368 139
140 TObjArray *fpChambers; //list of chambers
e42a7b46 141 static Int_t fgHV[6]; //HV applied to anod wires
e42a7b46 142 static Int_t fgNsigmaTh; //n. of sigmas to cut for zero suppression
143 static Float_t fgSigmaThMean; //sigma threshold value
144 static Float_t fgSigmaThSpread; //spread of sigma
145 ClassDef(AliRICHParam,5) //RICH main parameters class
d48cca74 146};
c2c6679b 147//__________________________________________________________________________________________________
c712cb2f 148Int_t AliRICHParam::PadNeighbours(Int_t iPadX,Int_t iPadY,Int_t listX[4],Int_t listY[4])
149{
a25b3368 150//Determines all the neighbouring pads for the given one (iPadX,iPadY). Returns total number of these pads.
151//Dead zones are taken into account, meaning pads from different sector are not taken.
e42a7b46 152// 1
153// 2 3
154// 4
c712cb2f 155 Int_t nPads=0;
e42a7b46 156 if(iPadY!=NpadsY()&&iPadY!=2*NpadsYsec()&&iPadY!=NpadsYsec()){listX[nPads]=iPadX; listY[nPads]=iPadY+1; nPads++;} //1
157 if(iPadX!=1&&iPadX!=NpadsXsec()+1) {listX[nPads]=iPadX-1; listY[nPads]=iPadY; nPads++;} //2
158 if(iPadX!=NpadsXsec()&&iPadX!=NpadsX()) {listX[nPads]=iPadX+1; listY[nPads]=iPadY; nPads++;} //3
159 if(iPadY!=1&&iPadY!=NpadsYsec()+1&&2*NpadsYsec()+1) {listX[nPads]=iPadX; listY[nPads]=iPadY-1; nPads++;} //4
ed3ceb24 160
c712cb2f 161 return nPads;
162}//Pad2ClosePads()
163//__________________________________________________________________________________________________
a25b3368 164Int_t AliRICHParam::Loc2Sec(const TVector2 &v2)
3582c1f9 165{
a25b3368 166//Determines sector containing the given point.
167//Returns sector code:
e42a7b46 168//y ^ 5 6
169// | 3 4
170// | 1 2
171// -------> x
172 Double_t x0=0; Double_t x1=SectorSizeX(); Double_t x2=SectorSizeX()+DeadZone(); Double_t x3=PcSizeX();
173 Double_t y0=0; Double_t y1=SectorSizeY(); Double_t y2=SectorSizeY()+DeadZone(); Double_t y3=2*SectorSizeY()+DeadZone();
174 Double_t y4=PcSizeY()-SectorSizeY(); Double_t y5=PcSizeY();
175
c712cb2f 176 Int_t sector=kBad;
a25b3368 177 if (v2.X() >= x0 && v2.X() <= x1 ) sector=1;
178 else if(v2.X() >= x2 && v2.X() <= x3 ) sector=2;
179 else return kBad;
3582c1f9 180
a25b3368 181 if (v2.Y() >= y0 && v2.Y() <= y1 ) ; //sectors 1 or 2
182 else if(v2.Y() >= y2 && v2.Y() <= y3 ) sector+=2; //sectors 3 or 4
183 else if(v2.Y() >= y4 && v2.Y() <= y5 ) sector+=4; //sectors 5 or 6
184 else return kBad;
3582c1f9 185 return sector;
c712cb2f 186}//Loc2Sec(Double_t x, Double_t y)
c2c6679b 187//__________________________________________________________________________________________________
a25b3368 188TVector AliRICHParam::Loc2Pad(const TVector2 &loc)
3582c1f9 189{
a25b3368 190//Determines pad number TVector(padx,pady) containing the given point x2 defined in the chamber RS.
191//Pad count starts in lower left corner from 1,1 to 144,160 in upper right corner of a chamber.
e42a7b46 192//y ^ 5 6
193// | 3 4
194// | 1 2
195// -------> x
196 TVector pad(2);
a25b3368 197 Int_t sec=Loc2Sec(loc);//trasforms x2 to sector reference system
198 if(sec==kBad) {pad[0]=pad[1]=kBad; return pad;}
199//first we deal with x
200 if(sec==1||sec==3||sec==5) pad[0]= Int_t( loc.X() / PadSizeX() )+1; //sector 1 or 3 or 5
201 else pad[0]=NpadsX() - Int_t( (PcSizeX()-loc.X()) / PadSizeX() ) ; //sector 2 or 4 or 6
202//second deal with y
203 if(sec==1||sec==2) pad[1]=Int_t( loc.Y() / PadSizeY() )+1; //sector 1 or 2
204 else if(sec==3||sec==4) pad[1]=Int_t( (loc.Y()-SectorSizeY()-DeadZone()) / PadSizeY() )+NpadsYsec(); //sector 3 or 4
205 else pad[1]=NpadsY() - Int_t( (PcSizeY()-loc.Y()) / PadSizeY() ); //sector 5 or 6
e42a7b46 206 return pad;
3582c1f9 207}
208//__________________________________________________________________________________________________
998b831f 209Int_t AliRICHParam::Pad2Sec(const TVector &pad)
3582c1f9 210{
a25b3368 211//Determines sector containing the given pad.
c712cb2f 212 Int_t sector=kBad;
e42a7b46 213 if (pad[0] >= 1 && pad[0] <= NpadsXsec() ) {sector=1;}
214 else if(pad[0] > NpadsXsec() && pad[0] <= NpadsX() ) {sector=2;}
998b831f 215 else AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
e42a7b46 216
217 if (pad[1] >= 1 && pad[1] <= NpadsYsec() ) {}
218 else if(pad[1] > NpadsYsec() && pad[1] <= 2*NpadsYsec() ) {sector+=2;}
219 else if(pad[1] > 2*NpadsYsec() && pad[1] <= NpadsY() ) {sector+=4;}
998b831f 220 else AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
c712cb2f 221
e42a7b46 222 return sector;
c712cb2f 223}//Pad2Sec()
224//__________________________________________________________________________________________________
e42a7b46 225TVector2 AliRICHParam::Pad2Loc(TVector pad)
c712cb2f 226{
a25b3368 227//Returns position of the center of the given pad in local system of the chamber (cm)
e42a7b46 228// y ^ 5 6
998b831f 229// | 3 4 sector numbers
e42a7b46 230// | 1 2
231// -------> x
232 Double_t x=kBad,y=kBad;
233 if(pad[0] > 0 && pad[0] <= NpadsXsec())//it's 1 or 3 or 5
234 x=(pad[0]-0.5)*PadSizeX();
235 else if(pad[0] > NpadsXsec() && pad[0] <= NpadsX())//it's 2 or 4 or 6
236 x=(pad[0]-0.5)*PadSizeX()+DeadZone();
c2c6679b 237 else
998b831f 238 AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
e42a7b46 239
240 if(pad[1] > 0 && pad[1] <= NpadsYsec())//it's 1 or 2
241 y=(pad[1]-0.5)*PadSizeY();
242 else if(pad[1] > NpadsYsec() && pad[1] <= 2*NpadsYsec())//it's 3 or 4
243 y=(pad[1]-0.5)*PadSizeY()+DeadZone();
244 else if(pad[1] > 2*NpadsYsec() && pad[1]<= NpadsY())//it's 5 or 6
245 y=(pad[1]-0.5)*PadSizeY()+2*DeadZone();
246 else
998b831f 247 AliDebugClass(1,Form("Wrong pad (%3.0f,%3.0f)",pad[0],pad[1]));
e42a7b46 248
3582c1f9 249 return TVector2(x,y);
250}
c60862bf 251//__________________________________________________________________________________________________
e42a7b46 252Double_t AliRICHParam::GainSag(Double_t x,Int_t sector)
c60862bf 253{
a25b3368 254//Returns % of gain variation due to wire sagita.
255//All curves are parametrized as per sector basis, so x must be apriory transformed to the Sector RS.
256//Here x is a distance along wires.
e42a7b46 257 x-=SectorSizeX()/2;
258 if(x>SectorSizeX()) x-=SectorSizeX();
3582c1f9 259 switch(HV(sector)){
e42a7b46 260 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;//%
261 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;
262 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;
263 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 264 default: return 0;
265 }
c712cb2f 266}
267//__________________________________________________________________________________________________
3582c1f9 268Int_t AliRICHParam::TotQdc(TVector2 x2,Double_t eloss)
269{
a25b3368 270//Calculates the total charge produced by the eloss in point x2 (Chamber RS).
271//Returns this change parametrised in QDC channels, or 0 if the hit in the dead zone.
272//eloss=0 means photon which produces 1 electron only eloss > 0 for Mip
e42a7b46 273 if(Loc2Sec(x2)==kBad) return 0; //hit in the dead zone
3582c1f9 274 Int_t iNelectrons=Int_t(eloss/IonisationPotential()); if(iNelectrons==0) iNelectrons=1;
275 Double_t qdc=0;
276 for(Int_t i=1;i<=iNelectrons;i++) qdc+=-Gain(x2)*TMath::Log(gRandom->Rndm());
277 return Int_t(qdc);
278}
279//__________________________________________________________________________________________________
a25b3368 280Double_t AliRICHParam::FracQdc(const TVector2 &x2,const TVector &pad)
3582c1f9 281{
a25b3368 282//Calculates the charge fraction induced to given pad by the hit from the given point.
283//Integrated Mathieson distribution is used.
e42a7b46 284 TVector2 center2=Pad2Loc(pad);//gives center of requested pad
998b831f 285 Double_t normXmin=(x2.X()-center2.X()-PadSizeX()/2) /Pc2Cath();//parametrise for Mathienson
286 Double_t normXmax=(x2.X()-center2.X()+PadSizeX()/2) /Pc2Cath();
287 Double_t normYmin=(x2.Y()-center2.Y()-PadSizeY()/2) /Pc2Cath();
288 Double_t normYmax=(x2.Y()-center2.Y()+PadSizeY()/2) /Pc2Cath();
289
290//requested pad might not belong to the sector of the given hit position, hence the check:
291 return (Loc2Sec(x2)!=Pad2Sec(pad)) ? 0:Mathieson(normXmin, normYmin, normXmax, normYmax);
3582c1f9 292}
c712cb2f 293//__________________________________________________________________________________________________
9d6f9427 294Double_t AliRICHParam::Mathieson(Double_t xMin,Double_t yMin,Double_t xMax,Double_t yMax)
3582c1f9 295{
a25b3368 296//All arguments are parametrised according to NIM A370(1988)602-603
297//Returns a charge fraction.
53fd478b 298 const Double_t kSqrtKx3=0.77459667;const Double_t kX2=0.962;const Double_t kX4=0.379;
299 const Double_t kSqrtKy3=0.77459667;const Double_t kY2=0.962;const Double_t kY4=0.379;
c712cb2f 300
53fd478b 301 Double_t ux1=kSqrtKx3*TMath::TanH(kX2*xMin);
302 Double_t ux2=kSqrtKx3*TMath::TanH(kX2*xMax);
303 Double_t uy1=kSqrtKy3*TMath::TanH(kY2*yMin);
304 Double_t uy2=kSqrtKy3*TMath::TanH(kY2*yMax);
305 return 4*kX4*(TMath::ATan(ux2)-TMath::ATan(ux1))*kY4*(TMath::ATan(uy2)-TMath::ATan(uy1));
c712cb2f 306}
307//__________________________________________________________________________________________________
a25b3368 308TVector AliRICHParam::Loc2Area(const TVector2 &x2)
3582c1f9 309{
a25b3368 310//Calculates the area of disintegration for a given point. It's assumed here that this points lays on anode wire.
311//Area is a rectangulare set of pads defined by its left-down and right-up coners.
e42a7b46 312 TVector area(4);
313 TVector pad=Loc2Pad(x2);
314 area[0]=area[2]=pad[0]; area[1]=area[3]=pad[1];//area is just a pad fired
315 if(pad[0]!=1 && pad[0]!= NpadsXsec()+1 ) area[0]--; //left down coner X
316 if(pad[1]!=1 && pad[1]!= NpadsYsec()+1 && pad[1]!= 2*NpadsYsec()+1) area[1]--; //left down coner Y
317 if(pad[0]!=NpadsXsec() && pad[0]!= NpadsX() ) area[2]++; //right up coner X
318 if(pad[1]!=NpadsYsec() && pad[1]!= 2*NpadsYsec() && pad[1]!= NpadsY() ) area[3]++; //right up coner Y
319 return area;
3582c1f9 320}
08479a10 321//__________________________________________________________________________________________________
e42a7b46 322Bool_t AliRICHParam::IsOverTh(Int_t ,TVector ,Double_t q)
3582c1f9 323{
a25b3368 324//Checks if the current q is over threshold and FEE will save this value to data concentrator.
e42a7b46 325 return (q>NsigmaTh()*(SigmaThMean()+(1.-2*gRandom->Rndm())*SigmaThSpread()));
3582c1f9 326}
d48cca74 327#endif //AliRICHParam_h
a25b3368 328
329