update version number
[u/mrichter/AliRoot.git] / RICH / AliRICHParam.cxx
CommitLineData
53fd478b 1// **************************************************************************
2// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3// * *
4// * Author: The ALICE Off-line Project. *
5// * Contributors are mentioned in the code where appropriate. *
6// * *
7// * Permission to use, copy, modify and distribute this software and its *
8// * documentation strictly for non-commercial purposes is hereby granted *
9// * without fee, provided that the above copyright notice appears in all *
10// * copies and that both the copyright notice and this permission notice *
11// * appear in the supporting documentation. The authors make no claims *
12// * about the suitability of this software for any purpose. It is *
13// * provided "as is" without express or implied warranty. *
14// **************************************************************************
56148d0e 15#include "AliRICHParam.h"
101624cd 16#include "AliESD.h"
e42a7b46 17#include "AliRICHChamber.h"
a25b3368 18#include <TCanvas.h>
19#include <TLatex.h>
20#include <THStack.h>
21#include <TLegend.h>
22#include <TView.h>
23#include <TPolyMarker3D.h>
24#include <TPolyLine3D.h>
d3eb6079 25#include <TPolyLine.h>
101624cd 26#include <TSystem.h>
d0831219 27#include <TVector2.h>
28#include <TVector3.h>
29#include <TRotation.h>
30
56148d0e 31
ed3ceb24 32ClassImp(AliRICHParam)
a25b3368 33Bool_t AliRICHParam::fgIsWireSag =kTRUE; //take ware sagita into account?
34Bool_t AliRICHParam::fgIsResolveClusters =kTRUE; //do cluster resolving?
d3eb6079 35Bool_t AliRICHParam::fgIsFeedback =kTRUE; //generate feedback photons?
a25b3368 36Bool_t AliRICHParam::fgIsRadioSrc =kFALSE; //put radioactive source instead of radiators?
37Bool_t AliRICHParam::fgIsAerogel =kFALSE; //special aerogel configuration
38Bool_t AliRICHParam::fgIsTestBeam =kFALSE; //special test beam configuration
39
e42a7b46 40Int_t AliRICHParam::fgHV[kNsectors] ={2050,2050,2050,2050,2050,2050};
08479a10 41Int_t AliRICHParam::fgNsigmaTh =4;
e42a7b46 42Float_t AliRICHParam::fgSigmaThMean =1.132; //QDC
43Float_t AliRICHParam::fgSigmaThSpread =0.035; //
101624cd 44Double_t AliRICHParam::fgErrChrom[4][330]; //
45Double_t AliRICHParam::fgErrGeom[4][330]; //
46Double_t AliRICHParam::fgErrLoc[4][330]; //Chromatic, Geometric and Localization array to parametrize SigmaCerenkov
773e6d59 47Double_t AliRICHParam::fgMass[5] ={0.00051,0.10566,0.13957,0.49360,0.93828};
08479a10 48
3582c1f9 49//__________________________________________________________________________________________________
c4a03891 50void AliRICHParam::Print(Option_t*) const
3582c1f9 51{
ae754cdf 52//print some usefull (hopefully) info on some internal guts of RICH parametrisation
d3eb6079 53 AliInfo(Form("Pads in chamber (%3i,%3i) in sector (%2i,%2i) pad size (%4.2f,%4.2f)",NpadsX(),NpadsY(),NpadsXsec(),NpadsYsec(),PadSizeX(),PadSizeY()));
a25b3368 54 AliInfo(Form("Resolve clusters %i sagita %i Radio source %i Aerogel %i TestBeam %i",
55 IsResolveClusters(),IsWireSag(),IsRadioSrc(),IsAerogel(),IsTestBeam()));
56 fpChambers->Print();
998b831f 57}//Print()
3582c1f9 58//__________________________________________________________________________________________________
e42a7b46 59void AliRICHParam::CreateChambers()
60{
61//Create all RICH Chambers on each call. Previous chambers deleted.
62 if(fpChambers) delete fpChambers;
a25b3368 63 if(fgIsTestBeam){
998b831f 64 fpChambers=new TObjArray(1);//test beam configuration 1 chamber
65 fpChambers->AddAt(new AliRICHChamber(0),0);
66 }else{
67 fpChambers=new TObjArray(kNchambers);//normal configuration 7 chambers
68 for(int iChamberN=0;iChamberN<kNchambers;iChamberN++) fpChambers->AddAt(new AliRICHChamber(iChamberN+1),iChamberN);
69 }
e42a7b46 70 fpChambers->SetOwner();
998b831f 71}//CreateChambers()
a25b3368 72//__________________________________________________________________________________________________
73Float_t AliRICHParam::AbsCH4(Float_t eV)
74{
75//Evaluate the absorbtion lenght of CH4 for a photon of energy eV in electron-volts
76 const Float_t kLoschmidt=2.686763e19; // LOSCHMIDT NUMBER IN CM-3
77 const Float_t kPressure=750.0; //mm of Hg
78 const Float_t kTemperature=283.0; //K (10 grad C)
79 const Float_t kPn=kPressure/760.;
80 const Float_t kTn=kTemperature/273.16;
81 const Float_t kC0=-1.655279e-1;
82 const Float_t kC1= 6.307392e-2;
83 const Float_t kC2=-8.011441e-3;
84 const Float_t kC3= 3.392126e-4;
85
86 Float_t crossSection=0;
87 if (eV<7.75)
88 crossSection=0.06e-22;
89 else //------ METHANE CROSS SECTION cm-2 ASTROPH. J. 214, L47 (1978)
90 crossSection=(kC0+kC1*eV+kC2*eV*eV+kC3*eV*eV*eV)*1.e-18;
91
92 Float_t density=kLoschmidt*kPn/kTn; //CH4 molecular concentration (cm^-3)
93 return 1.0/(density*crossSection);
94}//AbsoCH4()
95//__________________________________________________________________________________________________
96void AliRICHParam::TestSeg()
ae754cdf 97{
98//Provides a set of pictures to test segementation currently in use.
d3eb6079 99 new TCanvas("pads","PC segmentation - pads display",700,600);
100 gPad->Range(-5,-5,PcSizeX()+5,PcSizeY()+15);
101 TVector p(2); TVector2 c; TVector2 b; //current: pad, pad center, pad boundary
102// list of corners:
103 Double_t x0=0,x1=SectorSizeX(),x2=SectorSizeX()+DeadZone(), x3=PcSizeX();
104 Double_t y0=0,y1=SectorSizeY(),y2=SectorSizeY()+DeadZone(),y3=2*SectorSizeY()+DeadZone(),y4=PcSizeY()-SectorSizeY(),y5=PcSizeY();
105 DrawSectors();
106//header
107 TLatex t;
108 t.SetTextSize(0.02); t.SetTextColor(kBlack); t.SetTextAlign(11);
109 t.DrawLatex(0,PcSizeY()+10,Form("IP in front of this page. pad size %.2fx%.2fcm dead zone %.2fcm",PadSizeX(),PadSizeY(),DeadZone()));
110 t.DrawLatex(0,PcSizeY()+ 5,Form("Pc %.2fx%.2f cm %ix%i pads Sec %.2fx%.2f cm %ix%i pads",
111 PcSizeX() , PcSizeY() , NpadsX() , NpadsY() ,
112 SectorSizeX() , SectorSizeY() , NpadsXsec() , NpadsYsec() ));
113//sectors
114 t.SetTextSize(0.015); t.SetTextColor(kRed); t.SetTextAlign(22);
115 c=Pad2Loc( 40, 24); t.DrawText(c.X(),c.Y(),Form("sec 1 (%.2f,%.2f)",c.X(),c.Y() ));
116 c=Pad2Loc( 40, 75); t.DrawText(c.X(),c.Y(),Form("sec 3 (%.2f,%.2f)",c.X(),c.Y() ));
117 c=Pad2Loc( 40,121); t.DrawText(c.X(),c.Y(),Form("sec 5 (%.2f,%.2f)",c.X(),c.Y() ));
118 c=Pad2Loc(120, 24); t.DrawText(c.X(),c.Y(),Form("sec 2 (%.2f,%.2f)",c.X(),c.Y() ));
119 c=Pad2Loc(120, 75); t.DrawText(c.X(),c.Y(),Form("sec 4 (%.2f,%.2f)",c.X(),c.Y() ));
120 c=Pad2Loc(120,121); t.DrawText(c.X(),c.Y(),Form("sec 6 (%.2f,%.2f)",c.X(),c.Y() ));
121//coners
122 t.SetTextSize(0.015); t.SetTextColor(kBlue);
123
124 b.Set(x0,y0);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(11);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
125 b.Set(x0,y1);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(13);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
126 b.Set(x0,y2);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(11);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
127 b.Set(x0,y3);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(13);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
128 b.Set(x0,y4);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(11);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
129 b.Set(x0,y5);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(13);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
a25b3368 130
d3eb6079 131 b.Set(x1,y0);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(31);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
132 b.Set(x1,y1);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(33);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
133 b.Set(x1,y2);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(31);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
134 b.Set(x1,y3);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(33);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
135 b.Set(x1,y4);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(31);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
136 b.Set(x1,y5);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(33);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
a25b3368 137
d3eb6079 138 b.Set(x2,y0);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(11);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
139 b.Set(x2,y1);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(13);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
140 b.Set(x2,y2);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(11);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
141 b.Set(x2,y3);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(13);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
142 b.Set(x2,y4);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(11);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
143 b.Set(x2,y5);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(13);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
a25b3368 144
d3eb6079 145 b.Set(x3,y0);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(31);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
146 b.Set(x3,y1);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(33);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
147 b.Set(x3,y2);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(31);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
148 b.Set(x3,y3);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(33);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
149 b.Set(x3,y4);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(31);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
150 b.Set(x3,y5);p=Loc2Pad(b);c=Pad2Loc(p);t.SetTextAlign(33);t.DrawText(c.X(),c.Y(),Form("(%.2f,%.2f)-(%.0f,%.0f)-(%.2f,%.2f)",b.X(),b.Y(),p(0),p(1),c.X(),c.Y()));
a25b3368 151}//TestSeg()
152//__________________________________________________________________________________________________
153void AliRICHParam::TestResp()
154{
ae754cdf 155//Provides a set of plot to check the response parametrisation currently in use.
a25b3368 156 TCanvas *pC=new TCanvas("c","Amplification test",900,800);
157 pC->Divide(1,2);
158
159
ae754cdf 160 const Int_t kNpoints=8;
a25b3368 161 THStack *pStackPhot=new THStack("StackPhot","photons");
162 THStack *pStackMip =new THStack("StackMip","mips");
163 TLegend *pLeg=new TLegend(0.6,0.2,0.9,0.5,"legend");
ae754cdf 164 TH1F *apHphot[kNpoints];
165 TH1F *apHmip[kNpoints];
a25b3368 166
167 Double_t starty=0;
ae754cdf 168 Double_t deltay=AliRICHParam::SectorSizeY()/kNpoints;
a25b3368 169
ae754cdf 170 for(int i=0;i<kNpoints;i++){
a25b3368 171 apHphot[i]=new TH1F(Form("hphot%i",i),"Qdc for Photon;QDC;Counts",500,0,500); apHphot[i]->SetLineColor(i);pStackPhot->Add(apHphot[i]);
172 apHmip[i] =new TH1F(Form("hmip%i",i),"Qdc for Mip;QDC;Counts",4000,0,4000); apHmip[i]->SetLineColor(i);pStackMip->Add(apHmip[i]);
173
174 pLeg->AddEntry(apHphot[i],Form("@(10,%5.2f->%5.2f)",starty+i*deltay,starty+i*deltay-SectorSizeY()/2));
175 }
176
177
178 TVector2 x2(0,0);
179 for(Int_t i=0;i<10000;i++){//events loop
ae754cdf 180 for(int j=0;j<kNpoints;j++){
a25b3368 181 x2.Set(10,starty+j*deltay);
182 apHphot[j]->Fill(TotQdc(x2,0));
183 apHmip[j]->Fill(TotQdc(x2,gRandom->Landau(600,150)*1e-9));
184 }
185 }
186
187 pC->cd(1); pStackMip->Draw("nostack");
188 pC->cd(2); pStackPhot->Draw("nostack"); pLeg->Draw();
189}//TestResp()
190//__________________________________________________________________________________________________
191void AliRICHParam::TestTrans()
192{
ae754cdf 193//Provides a set of plots to test transformation methods
a25b3368 194 new TCanvas("trasform","Test LRS-MRS transform");
195 TLatex t; t.SetTextSize(0.02);
196
197 TView *pView=new TView(1);
198 pView->SetRange(-600,-600,-600,600,600,600);
199 DrawAxis();
200//Draw PC for all chambers by trasfering Pc plane using Pc2Mrs methode
201 Int_t iNpointsX=50,iNpointsY=50;
202 for(Int_t iChamberN=1;iChamberN<=7;iChamberN++){//chamber loop
203 TPolyMarker3D *pChamber=new TPolyMarker3D(iNpointsX*iNpointsY);
204 Int_t i=0;
205 for(Double_t x=0;x<PcSizeX();x+=PcSizeX()/iNpointsX)
206 for(Double_t y=0;y<PcSizeY();y+=PcSizeY()/iNpointsY){//step loop
207 TVector3 v3=C(iChamberN)->Pc2Mrs(TVector2(x,y));//from regular grid of local PC points to MRS presentation
208 pChamber->SetPoint(i++,v3.X(),v3.Y(),v3.Z());//Pc plane poing in MRS
209 }//step loop
210 pChamber->SetMarkerSize(1);
211 pChamber->SetMarkerColor(iChamberN);
212 pChamber->Draw();
213 t.SetNDC();t.SetTextColor(iChamberN); t.DrawText(0.1,iChamberN*0.1,Form("Chamber %i",iChamberN));
214 }//chamber loop
215// gPad->GetView()->RotateView(94,45);
216}//TestTrans()
217//__________________________________________________________________________________________________
218void AliRICHParam::DrawAxis()
219{
ae754cdf 220//Utility: draws axis on geometry scene
221 Double_t x[6]={0,0,0,300,0,0}; Double_t y[6]={0,0,0,0,300,0}; Double_t z[6]={0,0,0,0,0,300};
222 TPolyLine3D *pXaxis=new TPolyLine3D(2,x);pXaxis->SetLineColor(kRed); pXaxis->Draw();
223 TPolyLine3D *pYaxis=new TPolyLine3D(2,y);pYaxis->SetLineColor(kGreen); pYaxis->Draw();
224 TPolyLine3D *pZaxis=new TPolyLine3D(2,z);pZaxis->SetLineColor(kBlue); pZaxis->Draw();
a25b3368 225}
d3eb6079 226//__________________________________________________________________________________________________
227void AliRICHParam::DrawSectors()
228{
ae754cdf 229//Utility: draws RICH chamber sectors on event display.
d3eb6079 230 Double_t xLeft[5] = {0,0,SectorSizeX(),SectorSizeX(),0};
231 Double_t xRight[5] = {SectorSizeX()+DeadZone(),SectorSizeX()+DeadZone(),PcSizeX(),PcSizeX(),SectorSizeX()+DeadZone()};
232
233 Double_t yDown[5] = {0,SectorSizeY(),SectorSizeY(),0,0};
234 Double_t yCenter[5] = { SectorSizeY()+DeadZone(),2*SectorSizeY()+DeadZone(),2*SectorSizeY()+DeadZone(),
235 SectorSizeY()+DeadZone(),SectorSizeY()+DeadZone()};
236 Double_t yUp[5] = {2*SectorSizeY()+2*DeadZone(),PcSizeY(),PcSizeY(),2*SectorSizeY()+2*DeadZone(),2*SectorSizeY()+2*DeadZone()};
237
238 TPolyLine *sec1 = new TPolyLine(5,xLeft ,yDown); sec1->SetLineColor(21); sec1->Draw();
239 TPolyLine *sec2 = new TPolyLine(5,xRight,yDown); sec2->SetLineColor(21); sec2->Draw();
240 TPolyLine *sec3 = new TPolyLine(5,xLeft ,yCenter); sec3->SetLineColor(21); sec3->Draw();
241 TPolyLine *sec4 = new TPolyLine(5,xRight,yCenter); sec4->SetLineColor(21); sec4->Draw();
242 TPolyLine *sec5 = new TPolyLine(5,xLeft, yUp); sec5->SetLineColor(21); sec5->Draw();
243 TPolyLine *sec6 = new TPolyLine(5,xRight,yUp); sec6->SetLineColor(21); sec6->Draw();
244}//DrawSectors()
101624cd 245//__________________________________________________________________________________________________
246void AliRICHParam::ReadErrFiles()
247{
248// Read the three files corresponding to Chrom,Geom and Loc
249// They are parameters of a polynomial of 6th order...
250
251 static Bool_t count = kFALSE;
252
253 Float_t c0,c1,c2,c3,c;
254 Float_t g0,g1,g2,g3,g;
255 Float_t l0,l1,l2,l3,l;
256
257 FILE *pChromErr, *pGeomErr, *pLocErr;
258
259 if(!count) {
01c81d9d 260 AliInfoGeneral("ReadErrFiles","reading RICH error parameters...");
101624cd 261 pChromErr = fopen(Form("%s/RICH/RICHConfig/SigmaChromErr.txt",gSystem->Getenv("ALICE_ROOT")),"r");
262 pGeomErr = fopen(Form("%s/RICH/RICHConfig/SigmaGeomErr.txt",gSystem->Getenv("ALICE_ROOT")),"r");
263 pLocErr = fopen(Form("%s/RICH/RICHConfig/SigmaLocErr.txt",gSystem->Getenv("ALICE_ROOT")),"r");
264 if(!pChromErr||!pGeomErr||!pLocErr) {AliErrorGeneral("ReadErrFiles"," RICH ERROR READING Parameter FILES: can't open files!!! ");return;}
265 for(Int_t i=0;i<330;i++) {
266 fscanf(pChromErr,"%f%f%f%f%f\n",&c0,&c1,&c2,&c3,&c);
267 fscanf(pGeomErr,"%f%f%f%f%f\n",&g0,&g1,&g2,&g3,&g);
268 fscanf(pLocErr,"%f%f%f%f%f\n",&l0,&l1,&l2,&l3,&l);
269 fgErrChrom[0][i] = c0;
270 fgErrChrom[1][i] = c1;
271 fgErrChrom[2][i] = c2;
272 fgErrChrom[3][i] = c3;
273 fgErrGeom[0][i] = g0;
274 fgErrGeom[1][i] = g1;
275 fgErrGeom[2][i] = g2;
276 fgErrGeom[3][i] = g3;
277 fgErrLoc[0][i] = l0;
278 fgErrLoc[1][i] = l1;
279 fgErrLoc[2][i] = l2;
280 fgErrLoc[3][i] = l3;
281 }
01c81d9d 282 AliInfoGeneral("ReadErrFiles","DONE successfully!");
101624cd 283 fclose(pChromErr);
284 fclose(pGeomErr);
285 fclose(pLocErr);
286 }
287 count = kTRUE;
288}//ReadErrFiles()
289//__________________________________________________________________________________________________
290TVector3 AliRICHParam::SigmaSinglePhoton(Int_t partID, Double_t mom, Double_t theta, Double_t phi)
291
292{
293// Find sigma for single photon. It returns the thrree different errors. If you want
294// to have the error---> TVector3.Mag()
773e6d59 295// partID = 0,1,2,3,4 ---> e,mu,pi,k,p in agreement with AliPID
101624cd 296 TVector3 v(-999,-999,-999);
297 Double_t pmom;
298
299 ReadErrFiles();
773e6d59 300 Double_t mass = fgMass[partID];
301 Double_t massRef = fgMass[4]; // all the files are calculated for protons...so mass ref is proton mass
101624cd 302 pmom = mom*massRef/mass; // normalized momentum respect to proton...
fab9e039 303 if(pmom>PmodMax()) pmom = PmodMax();
304 Double_t oneOverRefIndex = 1/RefIdxC6F14(MeanCkovEnergy());
101624cd 305 Double_t pmin = mass*oneOverRefIndex/TMath::Sqrt(1-oneOverRefIndex*oneOverRefIndex);
306 if(pmom<pmin) return v;
fab9e039 307 Double_t Theta = theta*TMath::RadToDeg();
308 if(phi<0) phi+=TMath::TwoPi();
309 Double_t Phi = phi*TMath::RadToDeg();
310 v.SetX(Interpolate(fgErrChrom,pmom,Theta,Phi));
311 v.SetY(Interpolate(fgErrGeom,pmom,Theta,Phi));
312 v.SetZ(Interpolate(fgErrLoc,pmom,Theta,Phi));
313// v*=1.5; // take into account bigger errors due to multiplicity...to change in future
314
315 return v;
316}//SigmaSinglePhoton
317//__________________________________________________________________________________________________
318TVector3 AliRICHParam::SigmaSinglePhoton(Double_t thetaCer, Double_t theta, Double_t phi)
319
320{
321// Find sigma for single photon. It returns the thrree different errors. If you want
322// to have the error---> TVector3.Mag()
323// partID = 0,1,2,3,4 ---> e,mu,pi,k,p in agreement with AliPID
324 TVector3 v(-999,-999,-999);
325 Double_t pmom;
326
327 ReadErrFiles();
328 Double_t massRef = fgMass[4]; // all the files are calculated for protons...so mass ref is proton mass
329 Double_t beta=1./(RefIdxC6F14(MeanCkovEnergy())*TMath::Cos(thetaCer));
330 if(beta>=1) {
331 pmom=6.5; // above physical limi the error is calculated at the saturation...
332 } else {
333 Double_t gamma=1./TMath::Sqrt(1-beta*beta);
334 pmom = beta*gamma*massRef; // normalized momentum respect to proton...
335 }
336 if(pmom>PmodMax()) pmom = PmodMax();
337 Double_t oneOverRefIndex = 1/RefIdxC6F14(MeanCkovEnergy());
338 Double_t pmin = massRef*oneOverRefIndex/TMath::Sqrt(1-oneOverRefIndex*oneOverRefIndex);
339 if(pmom<pmin) return v;
340 Double_t Theta = theta*TMath::RadToDeg();
341 if(phi<0) phi+=TMath::TwoPi();
342 Double_t Phi = phi*TMath::RadToDeg();
343 v.SetX(Interpolate(fgErrChrom,pmom,Theta,Phi));
344 v.SetY(Interpolate(fgErrGeom,pmom,Theta,Phi));
345 v.SetZ(Interpolate(fgErrLoc,pmom,Theta,Phi));
346// v*=1.5; // take into account bigger errors due to multiplicity...to change in future
101624cd 347
348 return v;
349}//SigmaSinglePhoton
350//__________________________________________________________________________________________________
351Double_t AliRICHParam::Interpolate(Double_t par[4][330], Double_t x, Double_t y, Double_t phi)
352
353{
354 static Double_t amin = 1.15; static Double_t astep = 0.2;
355 static Double_t bmin = 0; static Double_t bstep = 1;
356
357 Double_t Phi = (phi - 180)/300.;
358
359 Double_t Sigma[30][11];
360
361 for(Int_t j=0;j<11;j++) { for(Int_t i=0;i<30;i++) {
362 Sigma[i][j] = par[0][j+11*i] + par[1][j+11*i]*Phi*Phi + par[2][j+11*i]*TMath::Power(Phi,4) + par[3][j+11*i]*TMath::Power(Phi,6);
363 }
364 }
365
366 Int_t i=0;Int_t j=0;
367
368 i = (Int_t)((x-amin)/astep);
369 j = (Int_t)((y-bmin)/bstep);
370 Double_t ai = amin+i*astep;
371 Double_t ai1 = ai+astep;
372 Double_t bj = bmin+j*bstep;
373 Double_t bj1 = bj+bstep;
374 Double_t t = (x-ai)/(ai1-ai);
375 Double_t gj = (1-t)*Sigma[i][j]+t*Sigma[i+1][j];
376 Double_t gj1 = (1-t)*Sigma[i][j+1]+t*Sigma[i+1][j+1];
377 Double_t u = (y-bj)/(bj1-bj);
378 return (1-u)*gj+u*gj1;
379}//Interpolate
d0831219 380//__________________________________________________________________________________________________
56030c8d 381TVector3 AliRICHParam::ForwardTracing(TVector3 entranceTrackPoint, TVector3 vectorTrack, Double_t thetaC, Double_t phiC)
d0831219 382{
383//
f770edb5 384 TVector3 vBad(-999,-999,-999);
d0831219 385 TVector3 nPlane(0,0,1);
386 Double_t planeZposition = 0.5*Zfreon();
387 TVector3 planePoint(0,0,planeZposition);
388 TVector3 emissionPoint = PlaneIntersect(vectorTrack,entranceTrackPoint,nPlane,planePoint);
56030c8d 389// emissionPoint.Dump();
d0831219 390 Double_t thetaout,phiout;
391 AnglesInDRS(vectorTrack.Theta(),vectorTrack.Phi(),thetaC,phiC,thetaout,phiout);
392// cout << "thetaout "<<thetaout << " phiout " << phiout << endl;
393 TVector3 vectorPhotonInC6F14;
394 vectorPhotonInC6F14.SetMagThetaPhi(1,thetaout,phiout);
56030c8d 395// vectorPhotonInC6F14.Dump();
d0831219 396// planeZposition=AliRICHParam::C6F14Thickness();
397 planeZposition=Zfreon();
398 planePoint.SetXYZ(0,0,planeZposition);
399 TVector3 entranceToSiO2Point = PlaneIntersect(vectorPhotonInC6F14,emissionPoint,nPlane,planePoint);
56030c8d 400// entranceToSiO2Point.Dump();
d0831219 401
402 Double_t photonEn = MeanCkovEnergy();
f770edb5 403 Double_t angleInSiO2 = SnellAngle(RefIdxC6F14(photonEn),RefIdxSiO2(photonEn),vectorPhotonInC6F14.Theta());if(angleInSiO2<0) return vBad;
d0831219 404 TVector3 vectorPhotonInSiO2;
56030c8d 405 vectorPhotonInSiO2.SetMagThetaPhi(1,angleInSiO2,phiout);
d0831219 406// planeZposition+=AliRICHParam::SiO2Thickness();
407 planeZposition+=Zwin();
408 planePoint.SetXYZ(0,0,planeZposition);
409 TVector3 entranceToCH4 = PlaneIntersect(vectorPhotonInSiO2,entranceToSiO2Point,nPlane,planePoint);
56030c8d 410// entranceToCH4.Dump();
d0831219 411
412 // Double_t angleInCH4 = SnellAngle(AliRICHParam::IndOfRefSiO2(6.755),AliRICHParam::IndOfRefCH4,angleInSiO2);
f770edb5 413 Double_t angleInCH4 = SnellAngle(RefIdxSiO2(photonEn),RefIdxCH4(photonEn),vectorPhotonInSiO2.Theta());if(angleInCH4<0) return vBad;
d0831219 414 TVector3 vectorPhotonInCH4;
56030c8d 415 vectorPhotonInCH4.SetMagThetaPhi(1,angleInCH4,phiout);
d0831219 416// planeZposition+=AliRICHParam::GapProx();
417 planeZposition+=Pc2Win();
418 planePoint.SetXYZ(0,0,planeZposition);
419 TVector3 impactToPC = PlaneIntersect(vectorPhotonInCH4,entranceToCH4,nPlane,planePoint);
56030c8d 420// impactToPC.Dump();
421 return impactToPC;
d0831219 422}//FowardTracing
423//__________________________________________________________________________________________________
424TVector3 AliRICHParam::PlaneIntersect(TVector3 vstart,TVector3 p0,TVector3 n,TVector3 v0)
425{
426//
427 TVector3 parallel(-999,-999,-999);
428 // vstart = given vector
429 // p0 = origin of the given vector
430 // n = normal to a given plane
431 // v0 = point of the given plane
432// cout << " n*vstart = " << n*vstart << endl;
433 if(n*vstart==0) return parallel;
434 TVector3 diff=v0-p0;
435 Double_t sint=(n*diff)/(n*vstart);
436 return p0+sint*vstart;
437}//PlaneIntersect
438//__________________________________________________________________________________________________
439Double_t AliRICHParam::SnellAngle(Float_t n1, Float_t n2, Float_t theta1)
440{
441// Snell law
442// Compute the Snell angle
443
444 Double_t sinrefractangle;
445 Double_t refractangle;
446
447 sinrefractangle = (n1/n2)*sin(theta1);
448
449 if(sinrefractangle>1.) {
450 // cout << " PROBLEMS IN SNELL ANGLE !!!!! " << endl;
f770edb5 451 refractangle = -999.;
d0831219 452 return refractangle;
453 }
454
455 refractangle = asin(sinrefractangle);
456 return refractangle;
457}//SnellAngle
458//__________________________________________________________________________________________________
459void AliRICHParam::AnglesInDRS(Double_t trackTheta,Double_t trackPhi,Double_t thetaCerenkov,Double_t phiCerenkov,Double_t &tout,Double_t &pout)
460{
461// Setup the rotation matrix of the track...
462
463 TRotation mtheta;
464 TRotation mphi;
465 TRotation minv;
466 TRotation mrot;
467
468 mtheta.RotateY(trackTheta);
469 mphi.RotateZ(trackPhi);
470
471 mrot = mphi * mtheta;
472 // minv = mrot.Inverse();
473
474 TVector3 photonInRadiator(1,1,1);
475
476 photonInRadiator.SetTheta(thetaCerenkov);
477 photonInRadiator.SetPhi(phiCerenkov);
478 photonInRadiator = mrot * photonInRadiator;
479 tout=photonInRadiator.Theta();
480 pout=photonInRadiator.Phi();
481}//AnglesInDRS
482//__________________________________________________________________________________________________
56030c8d 483
484//__________________________________________________________________________________________________
d0831219 485//__________________________________________________________________________________________________
486/*
487void DrawRing()
488{
489
490 // Float_t xGraph[1000],yGraph[1000];
491
492 Float_t type;
493 Float_t MassOfParticle;
494 Float_t beta;
495 Float_t nfreon;
496
497 Float_t ThetaCerenkov;
498
499 Float_t Xtoentr = GetEntranceX();
500 Float_t Ytoentr = GetEntranceY();
501
502 Float_t pmod = GetTrackMomentum();
503 Float_t TrackTheta = GetTrackTheta();
504 Float_t TrackPhi = GetTrackPhi();
505
506 SetPhotonEnergy(AliRICHParam::MeanCkovEnergy());
507 SetFreonRefractiveIndex();
508
509 SetEmissionPoint(RadiatorWidth/2.);
510
511 ThetaCerenkov = GetThetaCerenkov();
512 FindBetaFromTheta(ThetaCerenkov);
513 nfreon = GetFreonRefractiveIndex();
514
515 Int_t nPoints = 100;
516
517 Int_t nPointsToDraw = 0;
518 for(Int_t i=0;i<nPoints;i++)
519 {
520 Float_t phpad = 2*TMath::Pi()*i/nPoints;
521 SetThetaPhotonInTRS(thetacer);
522 SetPhiPhotonInTRS(phpad);
523 FindPhotonAnglesInDRS();
524 Float_t Radius = FromEmissionToCathode();
525 if (Radius == 999.) continue;
526 xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
527 yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
528 nPointsToDraw++;
529 }
530 gra = new TGraph(nPointsToDraw,xGraph,yGraph);
531 gra->Draw("AC");
532}
533//__________________________________________________________________________________________________
534*/