]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HMPID/AliHMPIDParam.cxx
coding conventions and further work on TPCNoiseMap component (Kelly)
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDParam.cxx
CommitLineData
d3da6dc4 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// **************************************************************************
15#include "AliHMPIDParam.h" //class header
16#include "AliHMPIDDigit.h" //ctor
a8ff381e 17#include "AliLog.h" //general
18#include <AliRunLoader.h> //Stack()
19#include <AliStack.h> //Stack()
20#include <TLatex.h> //TestTrans()
21#include <TView.h> //TestTrans()
22#include <TPolyMarker3D.h> //TestTrans()
d3da6dc4 23#include <TRotation.h>
a8ff381e 24#include <TParticle.h> //Stack()
97eadc2b 25#include <TGeoPhysicalNode.h> //ctor
ae5a42aa 26#include <TGeoBBox.h>
d3da6dc4 27ClassImp(AliHMPIDParam)
28
ae5a42aa 29
30Float_t AliHMPIDParam::fgkMinPcX[]={0.,0.,0.,0.,0.,0.};
31Float_t AliHMPIDParam::fgkMaxPcX[]={0.,0.,0.,0.,0.,0.};
32Float_t AliHMPIDParam::fgkMinPcY[]={0.,0.,0.,0.,0.,0.};
33Float_t AliHMPIDParam::fgkMaxPcY[]={0.,0.,0.,0.,0.,0.};
34
35Float_t AliHMPIDParam::fgCellX=0.;
36Float_t AliHMPIDParam::fgCellY=0.;
37
38Float_t AliHMPIDParam::fgPcX=0;
39Float_t AliHMPIDParam::fgPcY=0;
40
41Float_t AliHMPIDParam::fgAllX=0;
42Float_t AliHMPIDParam::fgAllY=0;
43
b87365d5 44Bool_t AliHMPIDParam::fgInstanceType=kTRUE;
ae5a42aa 45
d3da6dc4 46AliHMPIDParam* AliHMPIDParam::fgInstance=0x0; //singleton pointer
aa03cdbc 47
48Int_t AliHMPIDParam::fgSigmas=4;
49
d3da6dc4 50//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c61a7285 51AliHMPIDParam::AliHMPIDParam(Bool_t noGeo=kFALSE):
52 TNamed("HmpidParam","default version"),
53 fX(0), fY(0), fRadNmean(0)
d3da6dc4 54{
55// Here all the intitializition is taken place when AliHMPIDParam::Instance() is invoked for the first time.
58fc9564 56// In particular, matrices to be used for LORS<->MARS trasnformations are initialized from TGeo structure.
d3da6dc4 57// Note that TGeoManager should be already initialized from geometry.root file
ae5a42aa 58
b38ac33a 59
a8ff381e 60 fRadNmean = MeanIdxRad(); //initialization of the running ref. index of freon
61
8e2a911a 62 Float_t dead=2.6;// cm of the dead zones between PCs-> See 2CRC2099P1
b87365d5 63
64
65 if(noGeo==kTRUE) fgInstanceType=kFALSE; //instance from ideal geometry, no actual geom is present
66
58fc9564 67 if(noGeo==kFALSE && !gGeoManager)
68 {
69 TGeoManager::Import("geometry.root");
70 if(!gGeoManager) AliFatal("!!!!!!No geometry loaded!!!!!!!");
71 }
72
8e2a911a 73 fgCellX=0.8;fgCellY=0.84;
58fc9564 74
8e2a911a 75 if(!noGeo==kTRUE){
76 TGeoVolume *pCellVol = gGeoManager->GetVolume("Hcel");
77 if(pCellVol) {
78 TGeoBBox *bcell = (TGeoBBox *)pCellVol->GetShape();
79 fgCellX=2.*bcell->GetDX(); fgCellY = 2.*bcell->GetDY(); // overwrite the values with the read ones
80 }
81 }
58fc9564 82 fgPcX=80.*fgCellX; fgPcY = 48.*fgCellY;
83 fgAllX=2.*fgPcX+dead;
84 fgAllY=3.*fgPcY+2.*dead;
ae5a42aa 85
58fc9564 86 fgkMinPcX[1]=fgPcX+dead; fgkMinPcX[3]=fgkMinPcX[1]; fgkMinPcX[5]=fgkMinPcX[3];
87 fgkMaxPcX[0]=fgPcX; fgkMaxPcX[2]=fgkMaxPcX[0]; fgkMaxPcX[4]=fgkMaxPcX[2];
88 fgkMaxPcX[1]=fgAllX; fgkMaxPcX[3]=fgkMaxPcX[1]; fgkMaxPcX[5]=fgkMaxPcX[3];
ae5a42aa 89
58fc9564 90 fgkMinPcY[2]=fgPcY+dead; fgkMinPcY[3]=fgkMinPcY[2];
91 fgkMinPcY[4]=2.*fgPcY+2.*dead; fgkMinPcY[5]=fgkMinPcY[4];
92 fgkMaxPcY[0]=fgPcY; fgkMaxPcY[1]=fgkMaxPcY[0];
93 fgkMaxPcY[2]=2.*fgPcY+dead; fgkMaxPcY[3]=fgkMaxPcY[2];
94 fgkMaxPcY[4]=fgAllY; fgkMaxPcY[5]=fgkMaxPcY[4];
ae5a42aa 95
96 fX=0.5*SizeAllX();
97 fY=0.5*SizeAllY();
58fc9564 98
ae5a42aa 99 for(Int_t i=kMinCh;i<=kMaxCh;i++)
97eadc2b 100 if(gGeoManager && gGeoManager->IsClosed()) {
2df6b16e 101 TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(Form("/HMPID/Chamber%i",i));
97eadc2b 102 if (!pne) {
103 AliErrorClass(Form("The symbolic volume %s does not correspond to any physical entry!",Form("HMPID_%i",i)));
104 fM[i]=new TGeoHMatrix;
105 IdealPosition(i,fM[i]);
106 } else {
107 TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
1d6047fb 108 if(pnode) fM[i]=new TGeoHMatrix(*(pnode->GetMatrix()));
f80e1da4 109 else {
110 fM[i]=new TGeoHMatrix;
111 IdealPosition(i,fM[i]);
112 }
97eadc2b 113 }
114 } else{
1d4857c5 115 fM[i]=new TGeoHMatrix;
116 IdealPosition(i,fM[i]);
117 }
d3da6dc4 118 fgInstance=this;
119}//ctor
120//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
121void AliHMPIDParam::Print(Option_t* opt) const
122{
123// print some usefull (hopefully) info on some internal guts of HMPID parametrisation
124
125 for(Int_t i=0;i<7;i++) fM[i]->Print(opt);
126}//Print()
127//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1d4857c5 128void AliHMPIDParam::IdealPosition(Int_t iCh, TGeoHMatrix *pMatrix)
129{
130// Construct ideal position matrix for a given chamber
131// Arguments: iCh- chamber ID; pMatrix- pointer to precreated unity matrix where to store the results
132// Returns: none
423554a3 133 const Double_t kAngHor=19.5; // horizontal angle between chambers 19.5 grad
134 const Double_t kAngVer=20; // vertical angle between chambers 20 grad
135 const Double_t kAngCom=30; // common HMPID rotation with respect to x axis 30 grad
136 const Double_t kTrans[3]={490,0,0}; // center of the chamber is on window-gap surface
137 pMatrix->RotateY(90); // rotate around y since initial position is in XY plane -> now in YZ plane
138 pMatrix->SetTranslation(kTrans); // now plane in YZ is shifted along x
1d4857c5 139 switch(iCh){
140 case 0: pMatrix->RotateY(kAngHor); pMatrix->RotateZ(-kAngVer); break; //right and down
141 case 1: pMatrix->RotateZ(-kAngVer); break; //down
142 case 2: pMatrix->RotateY(kAngHor); break; //right
143 case 3: break; //no rotation
144 case 4: pMatrix->RotateY(-kAngHor); break; //left
145 case 5: pMatrix->RotateZ(kAngVer); break; //up
146 case 6: pMatrix->RotateY(-kAngHor); pMatrix->RotateZ(kAngVer); break; //left and up
147 }
148 pMatrix->RotateZ(kAngCom); //apply common rotation in XY plane
149
150}
151//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
d3da6dc4 152Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
153{
d1bf51e1 154// Prints some useful info from stack
d3da6dc4 155// Arguments: evt - event number. if not -1 print info only for that event
156// tid - track id. if not -1 then print it and all it's mothers if any
157// Returns: mother tid of the given tid if any
158 AliRunLoader *pAL=AliRunLoader::Open();
159 if(pAL->LoadHeader()) return -1;
160 if(pAL->LoadKinematics()) return -1;
161
162 Int_t mtid=-1;
cf7e313e 163 Int_t iNevt=pAL->GetNumberOfEvents();
d3da6dc4 164
165 for(Int_t iEvt=0;iEvt<iNevt;iEvt++){//events loop
166 if(evt!=-1 && evt!=iEvt) continue; //in case one needs to print the requested event, ignore all others
167 pAL->GetEvent(iEvt);
168 AliStack *pStack=pAL->Stack();
169 if(tid==-1){ //print all tids for this event
170 for(Int_t i=0;i<pStack->GetNtrack();i++) pStack->Particle(i)->Print();
a8ff381e 171 Printf("totally %i tracks including %i primaries for event %i out of %i event(s)",
172 pStack->GetNtrack(),pStack->GetNprimary(),iEvt,iNevt);
d3da6dc4 173 }else{ //print only this tid and it;s mothers
174 if(tid<0 || tid>pStack->GetNtrack()) {Printf("Wrong tid, valid tid range for event %i is 0-%i",iEvt,pStack->GetNtrack());break;}
175 TParticle *pTrack=pStack->Particle(tid); mtid=pTrack->GetFirstMother();
176 TString str=pTrack->GetName();
177 while((tid=pTrack->GetFirstMother()) >= 0){
178 pTrack=pStack->Particle(tid);
179 str+=" from ";str+=pTrack->GetName();
180 }
d3da6dc4 181 }//if(tid==-1)
182 }//events loop
183 pAL->UnloadHeader(); pAL->UnloadKinematics();
184 return mtid;
185}
186//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
187Int_t AliHMPIDParam::StackCount(Int_t pid,Int_t evt)
188{
189// Counts total number of particles of given sort (including secondary) for a given event
190 AliRunLoader *pAL=AliRunLoader::Open();
191 pAL->GetEvent(evt);
192 if(pAL->LoadHeader()) return 0;
193 if(pAL->LoadKinematics()) return 0;
194 AliStack *pStack=pAL->Stack();
195
196 Int_t iCnt=0;
197 for(Int_t i=0;i<pStack->GetNtrack();i++) if(pStack->Particle(i)->GetPdgCode()==pid) iCnt++;
198
199 pAL->UnloadHeader(); pAL->UnloadKinematics();
200 return iCnt;
201}
202//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3278403b 203Double_t AliHMPIDParam::Sigma2(Double_t trkTheta,Double_t trkPhi,Double_t ckovTh, Double_t ckovPh)
204{
205// Analithical calculation of total error (as a sum of localization, geometrical and chromatic errors) on Cerenkov angle for a given Cerenkov photon
206// created by a given MIP. Fromulae according to CERN-EP-2000-058
207// Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
208// dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]
209// MIP beta
210// Returns: absolute error on Cerenkov angle, [radians]
211
212 TVector3 v(-999,-999,-999);
213 Double_t trkBeta = 1./(TMath::Cos(ckovTh)*GetRefIdx());
214
215 if(trkBeta > 1) trkBeta = 1; //protection against bad measured thetaCer
216 if(trkBeta < 0) trkBeta = 0.0001; //
217
218 v.SetX(SigLoc (trkTheta,trkPhi,ckovTh,ckovPh,trkBeta));
219 v.SetY(SigGeom(trkTheta,trkPhi,ckovTh,ckovPh,trkBeta));
220 v.SetZ(SigCrom(trkTheta,trkPhi,ckovTh,ckovPh,trkBeta));
221
222 return v.Mag2();
223}
224//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
225Double_t AliHMPIDParam::SigLoc(Double_t trkTheta,Double_t trkPhi,Double_t thetaC, Double_t phiC,Double_t betaM)
226{
227// Analitical calculation of localization error (due to finite segmentation of PC) on Cerenkov angle for a given Cerenkov photon
228// created by a given MIP. Fromulae according to CERN-EP-2000-058
229// Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
230// dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]
231// MIP beta
232// Returns: absolute error on Cerenkov angle, [radians]
233
234 Double_t phiDelta = phiC - trkPhi;
235
236 Double_t sint = TMath::Sin(trkTheta);
237 Double_t cost = TMath::Cos(trkTheta);
238 Double_t sinf = TMath::Sin(trkPhi);
239 Double_t cosf = TMath::Cos(trkPhi);
240 Double_t sinfd = TMath::Sin(phiDelta);
241 Double_t cosfd = TMath::Cos(phiDelta);
242 Double_t tantheta = TMath::Tan(thetaC);
243
244 Double_t alpha =cost-tantheta*cosfd*sint; // formula (11)
245 Double_t k = 1.-GetRefIdx()*GetRefIdx()+alpha*alpha/(betaM*betaM); // formula (after 8 in the text)
246 if (k<0) return 1e10;
247 Double_t mu =sint*sinf+tantheta*(cost*cosfd*sinf+sinfd*cosf); // formula (10)
248 Double_t e =sint*cosf+tantheta*(cost*cosfd*cosf-sinfd*sinf); // formula (9)
249
250 Double_t kk = betaM*TMath::Sqrt(k)/(GapThick()*alpha); // formula (6) and (7)
251 Double_t dtdxc = kk*(k*(cosfd*cosf-cost*sinfd*sinf)-(alpha*mu/(betaM*betaM))*sint*sinfd); // formula (6)
252 Double_t dtdyc = kk*(k*(cosfd*sinf+cost*sinfd*cosf)+(alpha* e/(betaM*betaM))*sint*sinfd); // formula (7) pag.4
253
254 Double_t errX = 0.2,errY=0.25; //end of page 7
255 return TMath::Sqrt(errX*errX*dtdxc*dtdxc + errY*errY*dtdyc*dtdyc);
256}
257//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
258Double_t AliHMPIDParam::SigCrom(Double_t trkTheta,Double_t trkPhi,Double_t thetaC, Double_t phiC,Double_t betaM)
259{
260// Analitical calculation of chromatic error (due to lack of knowledge of Cerenkov photon energy) on Cerenkov angle for a given Cerenkov photon
261// created by a given MIP. Fromulae according to CERN-EP-2000-058
262// Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
263// dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]
264// MIP beta
265// Returns: absolute error on Cerenkov angle, [radians]
266
267 Double_t phiDelta = phiC - trkPhi;
268
269 Double_t sint = TMath::Sin(trkTheta);
270 Double_t cost = TMath::Cos(trkTheta);
271 Double_t cosfd = TMath::Cos(phiDelta);
272 Double_t tantheta = TMath::Tan(thetaC);
273
274 Double_t alpha =cost-tantheta*cosfd*sint; // formula (11)
275 Double_t dtdn = cost*GetRefIdx()*betaM*betaM/(alpha*tantheta); // formula (12)
276
277// Double_t f = 0.00928*(7.75-5.635)/TMath::Sqrt(12.);
278 Double_t f = 0.0172*(7.75-5.635)/TMath::Sqrt(24.);
279
280 return f*dtdn;
281}//SigCrom()
282//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
283Double_t AliHMPIDParam::SigGeom(Double_t trkTheta,Double_t trkPhi,Double_t thetaC, Double_t phiC,Double_t betaM)
284{
285// Analitical calculation of geometric error (due to lack of knowledge of creation point in radiator) on Cerenkov angle for a given Cerenkov photon
286// created by a given MIP. Formulae according to CERN-EP-2000-058
287// Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
288// dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]
289// MIP beta
290// Returns: absolute error on Cerenkov angle, [radians]
291
292 Double_t phiDelta = phiC - trkPhi;
293
294 Double_t sint = TMath::Sin(trkTheta);
295 Double_t cost = TMath::Cos(trkTheta);
296 Double_t sinf = TMath::Sin(trkPhi);
297 Double_t cosfd = TMath::Cos(phiDelta);
298 Double_t costheta = TMath::Cos(thetaC);
299 Double_t tantheta = TMath::Tan(thetaC);
300
301 Double_t alpha =cost-tantheta*cosfd*sint; // formula (11)
302
303 Double_t k = 1.-GetRefIdx()*GetRefIdx()+alpha*alpha/(betaM*betaM); // formula (after 8 in the text)
304 if (k<0) return 1e10;
305
306 Double_t eTr = 0.5*RadThick()*betaM*TMath::Sqrt(k)/(GapThick()*alpha); // formula (14)
307 Double_t lambda = 1.-sint*sint*sinf*sinf; // formula (15)
308
309 Double_t c1 = 1./(1.+ eTr*k/(alpha*alpha*costheta*costheta)); // formula (13.a)
310 Double_t c2 = betaM*TMath::Power(k,1.5)*tantheta*lambda/(GapThick()*alpha*alpha); // formula (13.b)
311 Double_t c3 = (1.+eTr*k*betaM*betaM)/((1+eTr)*alpha*alpha); // formula (13.c)
312 Double_t c4 = TMath::Sqrt(k)*tantheta*(1-lambda)/(GapThick()*betaM); // formula (13.d)
313 Double_t dtdT = c1 * (c2+c3*c4);
314 Double_t trErr = RadThick()/(TMath::Sqrt(12.)*cost);
315
316 return trErr*dtdT;
317}//SigGeom()
318//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++