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