]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHParam.cxx
new way to setup field
[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// **************************************************************************
db910db9 15#include "AliRICHParam.h" //class header
101624cd 16#include "AliESD.h"
db910db9 17#include <TCanvas.h> //TestXXX()
a25b3368 18#include <TLatex.h>
19#include <THStack.h>
20#include <TLegend.h>
21#include <TView.h>
22#include <TPolyMarker3D.h>
23#include <TPolyLine3D.h>
d3eb6079 24#include <TPolyLine.h>
101624cd 25#include <TSystem.h>
d0831219 26#include <TVector2.h>
27#include <TVector3.h>
28#include <TRotation.h>
db910db9 29#include <AliCDBManager.h> //CdbRead()
30#include <AliCDBStorage.h> //CdbRead()
31#include <AliCDBEntry.h> //CdbRead()
32#include <AliRunLoader.h> //Stack()
33#include <AliStack.h> //Stack()
34#include <TParticle.h> //Stack()
35#include "AliRICHHelix.h" //TestTrans()
56148d0e 36
ed3ceb24 37ClassImp(AliRICHParam)
db910db9 38AliRICHParam * AliRICHParam::fgInstance =0x0; //singleton pointer
39Bool_t AliRICHParam::fgIsWireSag =kTRUE; //take ware sagita into account?
40Bool_t AliRICHParam::fgIsResolveClusters =kTRUE; //do cluster resolving?
41Bool_t AliRICHParam::fgIsFeedback =kTRUE; //generate feedback photons?
42Bool_t AliRICHParam::fgIsTestBeam =kFALSE; //special test beam configuration
a25b3368 43
e42a7b46 44Int_t AliRICHParam::fgHV[kNsectors] ={2050,2050,2050,2050,2050,2050};
08479a10 45Int_t AliRICHParam::fgNsigmaTh =4;
e42a7b46 46Float_t AliRICHParam::fgSigmaThMean =1.132; //QDC
47Float_t AliRICHParam::fgSigmaThSpread =0.035; //
101624cd 48Double_t AliRICHParam::fgErrChrom[4][330]; //
49Double_t AliRICHParam::fgErrGeom[4][330]; //
50Double_t AliRICHParam::fgErrLoc[4][330]; //Chromatic, Geometric and Localization array to parametrize SigmaCerenkov
773e6d59 51Double_t AliRICHParam::fgMass[5] ={0.00051,0.10566,0.13957,0.49360,0.93828};
08479a10 52
db910db9 53
54Double_t AliRICHParam::fEckovMin=5.5e-9; //GeV
55Double_t AliRICHParam::fEckovMax=8.5e-9; //GeV
56TF1 AliRICHParam::fgAbsC6F14("RabsC4F14","6512.39*(x<=7.75e-9)+(x>7.75e-9)*0.039/(-0.166+0.063e9*x-8.01e7*x^2+3.39e5*x^3)" ,fEckovMin,fEckovMin);
57TF1 AliRICHParam::fgAbsSiO2 ("RabsSiO2" ,"333" ,fEckovMin,fEckovMin);
58TF1 AliRICHParam::fgAbsCH4 ("RabsCH4" ,"6512.39*(x<=7.75e-9)+(x>7.75e-9)*0.039/(-0.166+0.063e9*x-8.01e7*x^2+3.39e5*x^3)" ,fEckovMin,fEckovMin);
59TF1 AliRICHParam::fgAbsAir ("RabsAir" ,"500" ,fEckovMin,fEckovMin); //len ???
60TF1 AliRICHParam::fgAbsCF4 ("RabsCF4" ,"6512.39*(x<=7.75e-9)+(x>7.75e-9)*0.039/(-0.166+0.063e9*x-8.01e7*x^2+3.39e5*x^3)" ,fEckovMin,fEckovMin);
61TF1 AliRICHParam::fgAbsC4F10("RabsC4F10","1+0.25324e-6/(1.84e-4 - (1239.84e-9/x)^-2)" ,fEckovMin,fEckovMin); //Olav preprint
62TF1 AliRICHParam::fgAbsGel ("RabsGel" ,"400" ,fEckovMin,fEckovMin); //len ???
63
64TF1 AliRICHParam::fgIdxAir ("RidxAir" ,"1+1e-8*(8342.13 + 2406030/(130-(1.23984e-9/x)^2)+15597/(38.9-(1.23984e-9/x)^2))" ,fEckovMin,fEckovMin); //???
65TF1 AliRICHParam::fgIdxSiO2 ("RidxSiO2" ,"sqrt(1+46.411/(10.666*10.666-x*x*1e18)+228.71/(18.125*18.125-x*x*1e18))" ,fEckovMin,fEckovMin); //TDR p.35
66TF1 AliRICHParam::fgIdxCH4 ("RidxCH4" ,"1+0.12489e-6/(2.62e-4 - (1239.84e-9/x)^-2)" ,fEckovMin,fEckovMin); //Olav preprint
67TF1 AliRICHParam::fgIdxG30 ("RidxGel30","1.030" ,fEckovMin,fEckovMin); //???
68TF1 AliRICHParam::fgIdxG28 ("RidxGel28","1.028" ,fEckovMin,fEckovMin); //???
69TF1 AliRICHParam::fgIdxG26 ("RidxGel26","1.026" ,fEckovMin,fEckovMin); //???
70TF1 AliRICHParam::fgIdxG24 ("RidxGel24","1.024" ,fEckovMin,fEckovMin); //???
71TF1 AliRICHParam::fgIdxC4F10("RidxC4F10","1+0.25324e-6/(1.84e-4 - (1239.84e-9/x)^-2)" ,fEckovMin,fEckovMin); //Olav preprint
72TF1 AliRICHParam::fgIdxCF4 ("RidxCF4" ,"1+0.12489e-6/(2.62e-4 - (1239.84e-9/x)^-2)" ,fEckovMin,fEckovMin); //Olav preprint
73
74TF1 AliRICHParam::fgQeApd("QeApd" ,"0+(x>6e-9)*0.27*(1-exp(-(1e9*x-6)/0.3))" ,fEckovMin,fEckovMin); //???
75TF1 AliRICHParam::fgQeCsI("AbsApd" ,"0.03" ,fEckovMin,fEckovMin); //prob
76
77
78//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
79AliRICHParam::AliRICHParam():TNamed("RichParam","default version")
e42a7b46 80{
db910db9 81// Here all the intitializition is taken place when AliRICHParam::Instance() is invoked for the first time.
82// In particulare, matrices to be used for LORS<->MARS trasnformations are initialized from TGeo structure.
83// Note that TGeoManager should be already initialized from geometry.root file
84 for(Int_t iCh=0;iCh<kNchambers;iCh++) fMatrix[iCh]=(TGeoHMatrix*)gGeoManager->GetVolume("ALIC")->GetNode(Form("RICH_%i",iCh+1))->GetMatrix();
85 CdbRead(0,0);
86 fgInstance=this;
87}//ctor
88//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a25b3368 89Float_t AliRICHParam::AbsCH4(Float_t eV)
90{
db910db9 91// Evaluate the absorbtion lenght of CH4 for a photon of energy eV in electron-volts
a25b3368 92 const Float_t kLoschmidt=2.686763e19; // LOSCHMIDT NUMBER IN CM-3
93 const Float_t kPressure=750.0; //mm of Hg
94 const Float_t kTemperature=283.0; //K (10 grad C)
95 const Float_t kPn=kPressure/760.;
96 const Float_t kTn=kTemperature/273.16;
97 const Float_t kC0=-1.655279e-1;
98 const Float_t kC1= 6.307392e-2;
99 const Float_t kC2=-8.011441e-3;
100 const Float_t kC3= 3.392126e-4;
101
102 Float_t crossSection=0;
103 if (eV<7.75)
104 crossSection=0.06e-22;
105 else //------ METHANE CROSS SECTION cm-2 ASTROPH. J. 214, L47 (1978)
106 crossSection=(kC0+kC1*eV+kC2*eV*eV+kC3*eV*eV*eV)*1.e-18;
107
108 Float_t density=kLoschmidt*kPn/kTn; //CH4 molecular concentration (cm^-3)
109 return 1.0/(density*crossSection);
110}//AbsoCH4()
db910db9 111//__________________________________________________________________________________________________sss
112void AliRICHParam::CdbRead(Int_t run,Int_t version)
113{
114// This methode read all the calibration information and initialise corresponding fields for requested run number
115// Arguments: run - run number for which to retrieve calibration
116// version- version number
117// Returns: none
118
119 AliCDBEntry *pEntry=AliCDBManager::Instance()->Get("RICH/RICHConfig/RefIdxC6F14",run,0,version); //try to get from common local storage
120 if(pEntry){
121 fIdxC6F14=(TF2*)pEntry->GetObject(); delete pEntry;
122 }else{
123 AliWarning("No valid calibarion, the hardcoded will be used!");
124 fIdxC6F14=new TF2("RidxC4F14","sqrt(1+0.554*(1239.84e-9/x)^2/((1239.84e-9/x)^2-5796)-0.0005*(y-20))",5.5e-9,8.5e-9,0,50); //DiMauro mail
125 fIdxC6F14->SetUniqueID(20);//T=20 deg C
126 }
127}//CdbRead()
128//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
129void AliRICHParam::Print(Option_t* opt) const
130{
131// print some usefull (hopefully) info on some internal guts of RICH parametrisation
132 Printf("Pads in chamber (%3i,%3i) in sector (%2i,%2i) pad size (%4.2f,%4.2f)",NpadsX(),NpadsY(),NpadsXsec(),NpadsYsec(),PadSizeX(),PadSizeY());
133 Printf("Resolve clusters %i sagita %i",IsResolveClusters(),IsWireSag());
134
135 for(Int_t i=0;i<kNchambers;i++) fMatrix[i]->Print(opt);
136}//Print()
137//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a25b3368 138void AliRICHParam::TestSeg()
ae754cdf 139{
db910db9 140// Provides a set of pictures to test segementation currently in use.
141// Arguments: none
142// Returns: none
d3eb6079 143 new TCanvas("pads","PC segmentation - pads display",700,600);
144 gPad->Range(-5,-5,PcSizeX()+5,PcSizeY()+15);
145 TVector p(2); TVector2 c; TVector2 b; //current: pad, pad center, pad boundary
146// list of corners:
db910db9 147 Double_t x0=0,x1=SecSizeX(),x2=SecSizeX()+DeadZone() ,x3=PcSizeX();
148 Double_t y0=0,y1=SecSizeY(),y2=SecSizeY()+DeadZone(),y3=2*SecSizeY()+DeadZone(),y4=PcSizeY()-SecSizeY(),y5=PcSizeY();
d3eb6079 149 DrawSectors();
150//header
151 TLatex t;
152 t.SetTextSize(0.02); t.SetTextColor(kBlack); t.SetTextAlign(11);
153 t.DrawLatex(0,PcSizeY()+10,Form("IP in front of this page. pad size %.2fx%.2fcm dead zone %.2fcm",PadSizeX(),PadSizeY(),DeadZone()));
154 t.DrawLatex(0,PcSizeY()+ 5,Form("Pc %.2fx%.2f cm %ix%i pads Sec %.2fx%.2f cm %ix%i pads",
155 PcSizeX() , PcSizeY() , NpadsX() , NpadsY() ,
db910db9 156 SecSizeX() , SecSizeY() , NpadsXsec() , NpadsYsec() ));
d3eb6079 157//sectors
158 t.SetTextSize(0.015); t.SetTextColor(kRed); t.SetTextAlign(22);
159 c=Pad2Loc( 40, 24); t.DrawText(c.X(),c.Y(),Form("sec 1 (%.2f,%.2f)",c.X(),c.Y() ));
160 c=Pad2Loc( 40, 75); t.DrawText(c.X(),c.Y(),Form("sec 3 (%.2f,%.2f)",c.X(),c.Y() ));
161 c=Pad2Loc( 40,121); t.DrawText(c.X(),c.Y(),Form("sec 5 (%.2f,%.2f)",c.X(),c.Y() ));
162 c=Pad2Loc(120, 24); t.DrawText(c.X(),c.Y(),Form("sec 2 (%.2f,%.2f)",c.X(),c.Y() ));
163 c=Pad2Loc(120, 75); t.DrawText(c.X(),c.Y(),Form("sec 4 (%.2f,%.2f)",c.X(),c.Y() ));
164 c=Pad2Loc(120,121); t.DrawText(c.X(),c.Y(),Form("sec 6 (%.2f,%.2f)",c.X(),c.Y() ));
165//coners
166 t.SetTextSize(0.015); t.SetTextColor(kBlue);
167
168 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()));
169 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()));
170 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()));
171 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()));
172 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()));
173 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 174
d3eb6079 175 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()));
176 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()));
177 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()));
178 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()));
179 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()));
180 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 181
d3eb6079 182 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()));
183 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()));
184 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()));
185 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()));
186 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()));
187 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 188
d3eb6079 189 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()));
190 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()));
191 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()));
192 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()));
193 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()));
194 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 195}//TestSeg()
196//__________________________________________________________________________________________________
197void AliRICHParam::TestResp()
198{
db910db9 199// Provides a set of plot to check the response parametrisation currently in use.
200// Arguments: none
201// Returns: none
a25b3368 202 TCanvas *pC=new TCanvas("c","Amplification test",900,800);
203 pC->Divide(1,2);
204
205
ae754cdf 206 const Int_t kNpoints=8;
a25b3368 207 THStack *pStackPhot=new THStack("StackPhot","photons");
208 THStack *pStackMip =new THStack("StackMip","mips");
209 TLegend *pLeg=new TLegend(0.6,0.2,0.9,0.5,"legend");
ae754cdf 210 TH1F *apHphot[kNpoints];
211 TH1F *apHmip[kNpoints];
a25b3368 212
213 Double_t starty=0;
db910db9 214 Double_t deltay=AliRICHParam::SecSizeY()/kNpoints;
a25b3368 215
ae754cdf 216 for(int i=0;i<kNpoints;i++){
a25b3368 217 apHphot[i]=new TH1F(Form("hphot%i",i),"Qdc for Photon;QDC;Counts",500,0,500); apHphot[i]->SetLineColor(i);pStackPhot->Add(apHphot[i]);
218 apHmip[i] =new TH1F(Form("hmip%i",i),"Qdc for Mip;QDC;Counts",4000,0,4000); apHmip[i]->SetLineColor(i);pStackMip->Add(apHmip[i]);
219
db910db9 220 pLeg->AddEntry(apHphot[i],Form("@(10,%5.2f->%5.2f)",starty+i*deltay,starty+i*deltay-SecSizeY()/2));
a25b3368 221 }
222
223
224 TVector2 x2(0,0);
225 for(Int_t i=0;i<10000;i++){//events loop
ae754cdf 226 for(int j=0;j<kNpoints;j++){
a25b3368 227 x2.Set(10,starty+j*deltay);
228 apHphot[j]->Fill(TotQdc(x2,0));
229 apHmip[j]->Fill(TotQdc(x2,gRandom->Landau(600,150)*1e-9));
230 }
231 }
232
233 pC->cd(1); pStackMip->Draw("nostack");
234 pC->cd(2); pStackPhot->Draw("nostack"); pLeg->Draw();
235}//TestResp()
236//__________________________________________________________________________________________________
237void AliRICHParam::TestTrans()
238{
db910db9 239// Tests transformation methods
240// Arguments: none
241// Returns: none
a25b3368 242
db910db9 243 AliRICHParam *pParam=AliRICHParam::Instance();
a25b3368 244 Int_t iNpointsX=50,iNpointsY=50;
db910db9 245 new TCanvas("trasform","Test LORS-MARS transform"); TLatex t; t.SetTextSize(0.02);
246
247 TView *pView=new TView(1); pView->SetRange(-400,-400,-400,400,400,400);
248 DrawAxis();
249 for(Int_t iCham=1;iCham<=7;iCham++){//chamber loop
250 AliRICHHelix helix(2.5,Norm(iCham).Theta()*TMath::RadToDeg(),Norm(iCham).Phi()*TMath::RadToDeg());
251 helix.RichIntersect(AliRICHParam::Instance());
a25b3368 252 TPolyMarker3D *pChamber=new TPolyMarker3D(iNpointsX*iNpointsY);
253 Int_t i=0;
254 for(Double_t x=0;x<PcSizeX();x+=PcSizeX()/iNpointsX)
255 for(Double_t y=0;y<PcSizeY();y+=PcSizeY()/iNpointsY){//step loop
db910db9 256 TVector3 v3=pParam->Lors2Mars(iCham,x,y,kPc); TVector2 v2=pParam->Mars2Lors(iCham,v3,kPc);//LORS->MARS->LORS
257 Double_t dx=v2.X()-x , dy=v2.Y()-y;
258 if(dx>0.000001 || dy>0.000001) Printf("Problem in MARS<->LORS transformations dx=%f dy=%f!!!",dx,dy);
259 pChamber->SetPoint(i++,v3.X(),v3.Y(),v3.Z());//Pc plane point in MARS
a25b3368 260 }//step loop
261 pChamber->SetMarkerSize(1);
db910db9 262 pChamber->SetMarkerColor(iCham);
a25b3368 263 pChamber->Draw();
db910db9 264 helix.Draw();
265 t.SetNDC();t.SetTextColor(iCham); t.DrawText(0.1,iCham*0.1,Form("Chamber %i",iCham));
266 }//chambers loop
a25b3368 267}//TestTrans()
268//__________________________________________________________________________________________________
269void AliRICHParam::DrawAxis()
270{
db910db9 271// This utility methode draws axis on geometry scene
272// Arguments: none
273// Returns: none
ae754cdf 274 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};
275 TPolyLine3D *pXaxis=new TPolyLine3D(2,x);pXaxis->SetLineColor(kRed); pXaxis->Draw();
276 TPolyLine3D *pYaxis=new TPolyLine3D(2,y);pYaxis->SetLineColor(kGreen); pYaxis->Draw();
277 TPolyLine3D *pZaxis=new TPolyLine3D(2,z);pZaxis->SetLineColor(kBlue); pZaxis->Draw();
a25b3368 278}
d3eb6079 279//__________________________________________________________________________________________________
280void AliRICHParam::DrawSectors()
281{
db910db9 282// Utility methode draws RICH chamber sectors on event display.
283// Arguments: none
284// Returns: none
285 Double_t xLeft[5] = {0,0,SecSizeX(),SecSizeX(),0};
286 Double_t xRight[5] = {SecSizeX()+DeadZone(),SecSizeX()+DeadZone(),PcSizeX(),PcSizeX(),SecSizeX()+DeadZone()};
d3eb6079 287
db910db9 288 Double_t yDown[5] = {0,SecSizeY(),SecSizeY(),0,0};
289 Double_t yCenter[5] = { SecSizeY()+DeadZone(),2*SecSizeY()+DeadZone(),2*SecSizeY()+DeadZone(),
290 SecSizeY()+DeadZone(),SecSizeY()+DeadZone()};
291 Double_t yUp[5] = {2*SecSizeY()+2*DeadZone(),PcSizeY(),PcSizeY(),2*SecSizeY()+2*DeadZone(),2*SecSizeY()+2*DeadZone()};
d3eb6079 292
293 TPolyLine *sec1 = new TPolyLine(5,xLeft ,yDown); sec1->SetLineColor(21); sec1->Draw();
294 TPolyLine *sec2 = new TPolyLine(5,xRight,yDown); sec2->SetLineColor(21); sec2->Draw();
295 TPolyLine *sec3 = new TPolyLine(5,xLeft ,yCenter); sec3->SetLineColor(21); sec3->Draw();
296 TPolyLine *sec4 = new TPolyLine(5,xRight,yCenter); sec4->SetLineColor(21); sec4->Draw();
297 TPolyLine *sec5 = new TPolyLine(5,xLeft, yUp); sec5->SetLineColor(21); sec5->Draw();
298 TPolyLine *sec6 = new TPolyLine(5,xRight,yUp); sec6->SetLineColor(21); sec6->Draw();
299}//DrawSectors()
101624cd 300//__________________________________________________________________________________________________
301void AliRICHParam::ReadErrFiles()
302{
db910db9 303// Read the three files corresponding to Chrom,Geom and Loc They are parameters of a polynomial of 6th order... ????????? go to CDB?
304// Arguments: none
305// Returns: none
101624cd 306
307 static Bool_t count = kFALSE;
308
309 Float_t c0,c1,c2,c3,c;
310 Float_t g0,g1,g2,g3,g;
311 Float_t l0,l1,l2,l3,l;
312
313 FILE *pChromErr, *pGeomErr, *pLocErr;
314
315 if(!count) {
01c81d9d 316 AliInfoGeneral("ReadErrFiles","reading RICH error parameters...");
101624cd 317 pChromErr = fopen(Form("%s/RICH/RICHConfig/SigmaChromErr.txt",gSystem->Getenv("ALICE_ROOT")),"r");
318 pGeomErr = fopen(Form("%s/RICH/RICHConfig/SigmaGeomErr.txt",gSystem->Getenv("ALICE_ROOT")),"r");
319 pLocErr = fopen(Form("%s/RICH/RICHConfig/SigmaLocErr.txt",gSystem->Getenv("ALICE_ROOT")),"r");
320 if(!pChromErr||!pGeomErr||!pLocErr) {AliErrorGeneral("ReadErrFiles"," RICH ERROR READING Parameter FILES: can't open files!!! ");return;}
321 for(Int_t i=0;i<330;i++) {
322 fscanf(pChromErr,"%f%f%f%f%f\n",&c0,&c1,&c2,&c3,&c);
323 fscanf(pGeomErr,"%f%f%f%f%f\n",&g0,&g1,&g2,&g3,&g);
324 fscanf(pLocErr,"%f%f%f%f%f\n",&l0,&l1,&l2,&l3,&l);
325 fgErrChrom[0][i] = c0;
326 fgErrChrom[1][i] = c1;
327 fgErrChrom[2][i] = c2;
328 fgErrChrom[3][i] = c3;
329 fgErrGeom[0][i] = g0;
330 fgErrGeom[1][i] = g1;
331 fgErrGeom[2][i] = g2;
332 fgErrGeom[3][i] = g3;
333 fgErrLoc[0][i] = l0;
334 fgErrLoc[1][i] = l1;
335 fgErrLoc[2][i] = l2;
336 fgErrLoc[3][i] = l3;
337 }
01c81d9d 338 AliInfoGeneral("ReadErrFiles","DONE successfully!");
101624cd 339 fclose(pChromErr);
340 fclose(pGeomErr);
341 fclose(pLocErr);
342 }
343 count = kTRUE;
344}//ReadErrFiles()
345//__________________________________________________________________________________________________
346TVector3 AliRICHParam::SigmaSinglePhoton(Int_t partID, Double_t mom, Double_t theta, Double_t phi)
347
348{
349// Find sigma for single photon. It returns the thrree different errors. If you want
350// to have the error---> TVector3.Mag()
773e6d59 351// partID = 0,1,2,3,4 ---> e,mu,pi,k,p in agreement with AliPID
101624cd 352 TVector3 v(-999,-999,-999);
353 Double_t pmom;
354
355 ReadErrFiles();
773e6d59 356 Double_t mass = fgMass[partID];
357 Double_t massRef = fgMass[4]; // all the files are calculated for protons...so mass ref is proton mass
101624cd 358 pmom = mom*massRef/mass; // normalized momentum respect to proton...
fab9e039 359 if(pmom>PmodMax()) pmom = PmodMax();
db910db9 360 Double_t oneOverRefIndex = 1/IdxC6F14(EckovMean());
101624cd 361 Double_t pmin = mass*oneOverRefIndex/TMath::Sqrt(1-oneOverRefIndex*oneOverRefIndex);
362 if(pmom<pmin) return v;
fab9e039 363 Double_t Theta = theta*TMath::RadToDeg();
364 if(phi<0) phi+=TMath::TwoPi();
365 Double_t Phi = phi*TMath::RadToDeg();
366 v.SetX(Interpolate(fgErrChrom,pmom,Theta,Phi));
367 v.SetY(Interpolate(fgErrGeom,pmom,Theta,Phi));
368 v.SetZ(Interpolate(fgErrLoc,pmom,Theta,Phi));
369// v*=1.5; // take into account bigger errors due to multiplicity...to change in future
370
371 return v;
372}//SigmaSinglePhoton
373//__________________________________________________________________________________________________
374TVector3 AliRICHParam::SigmaSinglePhoton(Double_t thetaCer, Double_t theta, Double_t phi)
375
376{
377// Find sigma for single photon. It returns the thrree different errors. If you want
378// to have the error---> TVector3.Mag()
379// partID = 0,1,2,3,4 ---> e,mu,pi,k,p in agreement with AliPID
380 TVector3 v(-999,-999,-999);
381 Double_t pmom;
382
383 ReadErrFiles();
384 Double_t massRef = fgMass[4]; // all the files are calculated for protons...so mass ref is proton mass
db910db9 385 Double_t beta=1./(IdxC6F14(EckovMean())*TMath::Cos(thetaCer));
fab9e039 386 if(beta>=1) {
387 pmom=6.5; // above physical limi the error is calculated at the saturation...
388 } else {
389 Double_t gamma=1./TMath::Sqrt(1-beta*beta);
390 pmom = beta*gamma*massRef; // normalized momentum respect to proton...
391 }
392 if(pmom>PmodMax()) pmom = PmodMax();
db910db9 393 Double_t oneOverRefIndex = 1/IdxC6F14(EckovMean());
fab9e039 394 Double_t pmin = massRef*oneOverRefIndex/TMath::Sqrt(1-oneOverRefIndex*oneOverRefIndex);
395 if(pmom<pmin) return v;
396 Double_t Theta = theta*TMath::RadToDeg();
397 if(phi<0) phi+=TMath::TwoPi();
398 Double_t Phi = phi*TMath::RadToDeg();
399 v.SetX(Interpolate(fgErrChrom,pmom,Theta,Phi));
400 v.SetY(Interpolate(fgErrGeom,pmom,Theta,Phi));
401 v.SetZ(Interpolate(fgErrLoc,pmom,Theta,Phi));
402// v*=1.5; // take into account bigger errors due to multiplicity...to change in future
101624cd 403
404 return v;
405}//SigmaSinglePhoton
406//__________________________________________________________________________________________________
407Double_t AliRICHParam::Interpolate(Double_t par[4][330], Double_t x, Double_t y, Double_t phi)
408
409{
410 static Double_t amin = 1.15; static Double_t astep = 0.2;
411 static Double_t bmin = 0; static Double_t bstep = 1;
412
413 Double_t Phi = (phi - 180)/300.;
414
415 Double_t Sigma[30][11];
416
417 for(Int_t j=0;j<11;j++) { for(Int_t i=0;i<30;i++) {
418 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);
419 }
420 }
421
422 Int_t i=0;Int_t j=0;
423
424 i = (Int_t)((x-amin)/astep);
425 j = (Int_t)((y-bmin)/bstep);
426 Double_t ai = amin+i*astep;
427 Double_t ai1 = ai+astep;
428 Double_t bj = bmin+j*bstep;
429 Double_t bj1 = bj+bstep;
430 Double_t t = (x-ai)/(ai1-ai);
431 Double_t gj = (1-t)*Sigma[i][j]+t*Sigma[i+1][j];
432 Double_t gj1 = (1-t)*Sigma[i][j+1]+t*Sigma[i+1][j+1];
433 Double_t u = (y-bj)/(bj1-bj);
434 return (1-u)*gj+u*gj1;
435}//Interpolate
d0831219 436//__________________________________________________________________________________________________
56030c8d 437TVector3 AliRICHParam::ForwardTracing(TVector3 entranceTrackPoint, TVector3 vectorTrack, Double_t thetaC, Double_t phiC)
d0831219 438{
db910db9 439// Trace a single Ckov photon from a given emission point up to photocathode taking into account ref indexes of materials it travereses
f770edb5 440 TVector3 vBad(-999,-999,-999);
d0831219 441 TVector3 nPlane(0,0,1);
db910db9 442 Double_t planeZposition = 0.5*RadThick();
443 TVector3 planePoint(0,0,0.5*RadThick()); //this is plane parallel to window which contains emission point
d0831219 444 TVector3 emissionPoint = PlaneIntersect(vectorTrack,entranceTrackPoint,nPlane,planePoint);
d0831219 445 Double_t thetaout,phiout;
446 AnglesInDRS(vectorTrack.Theta(),vectorTrack.Phi(),thetaC,phiC,thetaout,phiout);
d0831219 447 TVector3 vectorPhotonInC6F14;
448 vectorPhotonInC6F14.SetMagThetaPhi(1,thetaout,phiout);
db910db9 449 planeZposition=RadThick();
d0831219 450 planePoint.SetXYZ(0,0,planeZposition);
451 TVector3 entranceToSiO2Point = PlaneIntersect(vectorPhotonInC6F14,emissionPoint,nPlane,planePoint);
d0831219 452
db910db9 453 Double_t photonEn = EckovMean();
454 Double_t angleInSiO2 = SnellAngle(IdxC6F14(EckovMean()),IdxSiO2(EckovMean()),vectorPhotonInC6F14.Theta());if(angleInSiO2<0) return vBad;
d0831219 455 TVector3 vectorPhotonInSiO2;
56030c8d 456 vectorPhotonInSiO2.SetMagThetaPhi(1,angleInSiO2,phiout);
d0831219 457// planeZposition+=AliRICHParam::SiO2Thickness();
db910db9 458 planeZposition+=WinThick();
d0831219 459 planePoint.SetXYZ(0,0,planeZposition);
460 TVector3 entranceToCH4 = PlaneIntersect(vectorPhotonInSiO2,entranceToSiO2Point,nPlane,planePoint);
56030c8d 461// entranceToCH4.Dump();
d0831219 462
463 // Double_t angleInCH4 = SnellAngle(AliRICHParam::IndOfRefSiO2(6.755),AliRICHParam::IndOfRefCH4,angleInSiO2);
db910db9 464 Double_t angleInCH4 = SnellAngle(IdxSiO2(photonEn),IdxCH4(photonEn),vectorPhotonInSiO2.Theta());if(angleInCH4<0) return vBad;
d0831219 465 TVector3 vectorPhotonInCH4;
56030c8d 466 vectorPhotonInCH4.SetMagThetaPhi(1,angleInCH4,phiout);
d0831219 467// planeZposition+=AliRICHParam::GapProx();
468 planeZposition+=Pc2Win();
469 planePoint.SetXYZ(0,0,planeZposition);
470 TVector3 impactToPC = PlaneIntersect(vectorPhotonInCH4,entranceToCH4,nPlane,planePoint);
56030c8d 471// impactToPC.Dump();
472 return impactToPC;
d0831219 473}//FowardTracing
474//__________________________________________________________________________________________________
db910db9 475TVector3 AliRICHParam::PlaneIntersect(const TVector3 &lineDir,const TVector3 &linePoint,const TVector3 &planeNorm,const TVector3 &planePoint)
d0831219 476{
db910db9 477// Finds an intersection point between a line and plane.
478// Arguments: lineDir,linePoint - vector along the line and any point of the line
479// planeNorm,planePoint - vector normal to the plane and any point of the plane
480// Returns: point of intersection if any
481 if(planeNorm*lineDir==0) return TVector3(-999,-999,-999);
482 TVector3 diff=planePoint-linePoint;
483 Double_t sint=(planeNorm*diff)/(planeNorm*lineDir);
484 return linePoint+sint*lineDir;
d0831219 485}//PlaneIntersect
486//__________________________________________________________________________________________________
487Double_t AliRICHParam::SnellAngle(Float_t n1, Float_t n2, Float_t theta1)
488{
db910db9 489// Compute the angle of refraction out of Snell law
490// Arguments: n1 - ref idx of first substance
491// n2 - ref idx of second substance
492// n1 - photon impact angle in the first substance i.e. angle between the photon direction and vector normal to the surface (radians)
493// Returns: photon refraction angle, i.e. angle in the second substance (radians)
494 Double_t sinref=(n1/n2)*TMath::Sin(theta1);
495 if(sinref>1.) return -999;
496 else return TMath::ASin(sinref);
d0831219 497}//SnellAngle
498//__________________________________________________________________________________________________
499void AliRICHParam::AnglesInDRS(Double_t trackTheta,Double_t trackPhi,Double_t thetaCerenkov,Double_t phiCerenkov,Double_t &tout,Double_t &pout)
500{
501// Setup the rotation matrix of the track...
502
503 TRotation mtheta;
504 TRotation mphi;
505 TRotation minv;
506 TRotation mrot;
507
508 mtheta.RotateY(trackTheta);
509 mphi.RotateZ(trackPhi);
510
511 mrot = mphi * mtheta;
512 // minv = mrot.Inverse();
513
514 TVector3 photonInRadiator(1,1,1);
515
516 photonInRadiator.SetTheta(thetaCerenkov);
517 photonInRadiator.SetPhi(phiCerenkov);
518 photonInRadiator = mrot * photonInRadiator;
519 tout=photonInRadiator.Theta();
520 pout=photonInRadiator.Phi();
521}//AnglesInDRS
d0831219 522/*
523void DrawRing()
524{
525
526 // Float_t xGraph[1000],yGraph[1000];
527
528 Float_t type;
529 Float_t MassOfParticle;
530 Float_t beta;
531 Float_t nfreon;
532
533 Float_t ThetaCerenkov;
534
535 Float_t Xtoentr = GetEntranceX();
536 Float_t Ytoentr = GetEntranceY();
537
538 Float_t pmod = GetTrackMomentum();
539 Float_t TrackTheta = GetTrackTheta();
540 Float_t TrackPhi = GetTrackPhi();
541
542 SetPhotonEnergy(AliRICHParam::MeanCkovEnergy());
543 SetFreonRefractiveIndex();
544
545 SetEmissionPoint(RadiatorWidth/2.);
546
547 ThetaCerenkov = GetThetaCerenkov();
548 FindBetaFromTheta(ThetaCerenkov);
549 nfreon = GetFreonRefractiveIndex();
550
551 Int_t nPoints = 100;
552
553 Int_t nPointsToDraw = 0;
554 for(Int_t i=0;i<nPoints;i++)
555 {
556 Float_t phpad = 2*TMath::Pi()*i/nPoints;
557 SetThetaPhotonInTRS(thetacer);
558 SetPhiPhotonInTRS(phpad);
559 FindPhotonAnglesInDRS();
560 Float_t Radius = FromEmissionToCathode();
561 if (Radius == 999.) continue;
562 xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
563 yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
564 nPointsToDraw++;
565 }
566 gra = new TGraph(nPointsToDraw,xGraph,yGraph);
567 gra->Draw("AC");
568}
569//__________________________________________________________________________________________________
570*/
db910db9 571void AliRICHParam::TestHit2SDigs(Double_t x,Double_t y,Double_t e,Bool_t isNew)
572{
573//Test hit->sdigits procedures
574//Arguments: isNew - if true use new (abs pad) procedure else use old one (TVector)
575// Returns: none
576 TClonesArray *pSDigLst=new TClonesArray("AliRICHDigit");
577 Int_t iQtot=-1;
578 if(isNew){
579 iQtot=Hit2SDigs(10101,e,pSDigLst); //new technique
580 }else{
581 iQtot=Hit2SDigs(TVector2(x,y),e,pSDigLst);//old technique
582 }
583 pSDigLst->Print();
584 Double_t dQsum=0;
585 for(Int_t i=0;i<pSDigLst->GetEntriesFast();i++)
586 dQsum+=((AliRICHDigit*)pSDigLst->At(i))->Qdc();
587 Printf("Qtot=%i Qsum=%.2f ",iQtot,dQsum);
588}
589//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
590Int_t AliRICHParam::Stack(Int_t evt,Int_t tid)
591{
592// Prints some usefull info from stack
593// Arguments: evt - event number. if not -1 print info only for that event
594// tid - track id. if not -1 then print it and all it's mothers if any
595// Returns: mother tid of the given tid if any
596 AliRunLoader *pAL=AliRunLoader::Open();
597 if(pAL->LoadHeader()) return -1;
598 if(pAL->LoadKinematics()) return -1;
599
600 Int_t mtid=-1;
601 Int_t iNevt=pAL->GetNumberOfEvents(); Printf("This session contains %i event(s)",iNevt);
602
603 for(Int_t iEvt=0;iEvt<iNevt;iEvt++){//events loop
604 if(evt!=-1 && evt!=iEvt) continue; //in case one needs to print the requested event, ignore all others
605 pAL->GetEvent(iEvt);
606 AliStack *pStack=pAL->Stack();
607 if(tid==-1){ //print all tids for this event
608 for(Int_t i=0;i<pStack->GetNtrack();i++) pStack->Particle(i)->Print();
609 Printf("totally %i tracks including %i primaries for event %i out of %i event(s)",pStack->GetNtrack(),pStack->GetNprimary(),iEvt,iNevt);
610 }else{ //print only this tid and it;s mothers
611 if(tid<0 || tid>pStack->GetNtrack()) {Printf("Wrong tid, valid tid range for event %i is 0-%i",iEvt,pStack->GetNtrack());break;}
612 TParticle *pTrack=pStack->Particle(tid); mtid=pTrack->GetFirstMother();
613 TString str=pTrack->GetName();
614 while((tid=pTrack->GetFirstMother()) >= 0){
615 pTrack=pStack->Particle(tid);
616 str+=" from ";str+=pTrack->GetName();
617 }
618 Printf("%s",str.Data());
619 }//if(tid==-1)
620 }//events loop
621 pAL->UnloadHeader(); pAL->UnloadKinematics();
622 return mtid;
623}
624//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
625Int_t AliRICHParam::StackCount(Int_t pid,Int_t evt)
626{
627// Counts total number of particles of given sort (including secondary) for a given event
628 AliRunLoader *pAL=AliRunLoader::Open();
629 pAL->GetEvent(evt);
630 if(pAL->LoadHeader()) return 0;
631 if(pAL->LoadKinematics()) return 0;
632 AliStack *pStack=pAL->Stack();
633
634 Int_t iCnt=0;
635 for(Int_t i=0;i<pStack->GetNtrack();i++) if(pStack->Particle(i)->GetPdgCode()==pid) iCnt++;
636
637 pAL->UnloadHeader(); pAL->UnloadKinematics();
638 return iCnt;
639}
640//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++