1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Class AliMUONFastTracking
21 // Manager for the fast simulation of tracking in the muon spectrometer
22 // This class reads the lookup tables containing the parameterization
23 // of the deltap, deltatheta, deltaphi for different background levels
24 // and provides the related smeared parameters.
25 // Used by AliFastMuonTrackingEff, AliFastMuonTrackingAcc,
26 // AliFastMuonTrackingRes.
27 //-------------------------------------------------------------------------
33 #include <Riostream.h>
41 #include "AliMUONFastTracking.h"
42 #include "AliMUONFastTrackingEntry.h"
44 ClassImp(AliMUONFastTracking)
47 AliMUONFastTracking* AliMUONFastTracking::fgMUONFastTracking=NULL;
49 static Double_t FitP(Double_t *x, Double_t *par){
51 Double_t dx = x[0] - par[0];
52 Double_t dx2 = x[0] - par[4];
53 Double_t sigma = par[1] * ( 1 + par[2] * dx);
58 Double_t fasymm = TMath::Exp(-0.5 * dx * dx / (sigma * sigma));
59 Double_t sigma2 = par[1] * par[5];
60 Double_t fgauss = TMath::Exp(-0.5 * dx2 * dx2 / (sigma2 * sigma2));
61 Double_t value = fasymm + par[3] * fgauss;
62 return TMath::Abs(value);
65 AliMUONFastTracking::AliMUONFastTracking(const AliMUONFastTracking & ft):
70 fDeltaP((fPmax-fPmin)/fNbinp),
74 fDeltaTheta((fThetamax-fThetamin)/fNbintheta),
78 fDeltaPhi((fPhimax-fPhimin)/fNbinphi),
89 AliMUONFastTracking* AliMUONFastTracking::Instance()
91 // Set random number generator
92 if (fgMUONFastTracking) {
93 return fgMUONFastTracking;
95 fgMUONFastTracking = new AliMUONFastTracking();
96 return fgMUONFastTracking;
100 AliMUONFastTracking::AliMUONFastTracking():
104 fDeltaP((fPmax-fPmin)/fNbinp),
108 fDeltaTheta((fThetamax-fThetamin)/fNbintheta),
112 fDeltaPhi((fPhimax-fPhimin)/fNbinphi),
121 for (Int_t i = 0; i<20;i++) {
122 for (Int_t j = 0; j<20; j++) {
123 for (Int_t k = 0; k<20; k++) {
124 fFitp[i][j][k] = 0x0;
130 void AliMUONFastTracking::Init(Float_t bkg)
135 for (Int_t ip=0; ip< fNbinp; ip++){
136 for (Int_t itheta=0; itheta< fNbintheta; itheta++){
137 for (Int_t iphi=0; iphi< fNbinphi; iphi++){
138 fCurrentEntry[ip][itheta][iphi] = new AliMUONFastTrackingEntry;
139 for (Int_t ibkg=0; ibkg<4; ibkg++){
140 fEntry[ip][itheta][iphi][ibkg] = new AliMUONFastTrackingEntry;
147 if (fClusterFinder==kOld) snprintf (filename, 100, "$(ALICE_ROOT)/FASTSIM/data/MUONtrackLUT.root");
148 else snprintf (filename, 100, "$(ALICE_ROOT)/FASTSIM/data/MUONtrackLUT-AZ.root");
150 TFile *file = new TFile(filename);
157 void AliMUONFastTracking::ReadLUT(TFile* file)
160 // read the lookup tables from file
162 TH3F *heff[5][3], *hacc[5][3], *hmeanp, *hsigmap, *hsigma1p, *hchi2p;
163 TH3F *hnormg2, *hmeang2, *hsigmag2, *hmeantheta, *hsigmatheta, *hchi2theta;
164 TH3F *hmeanphi, *hsigmaphi, *hchi2phi;
165 char tag[40], tag2[40];
167 printf ("Reading parameters from LUT file %s...\n",file->GetName());
169 const Float_t kBkg[4] = {0, 0.5, 1, 2};
170 for (Int_t ibkg=0; ibkg<4; ibkg++) {
171 snprintf (tag, 40, "BKG%g",kBkg[ibkg]);
173 for (Int_t isplp = 0; isplp<kSplitP; isplp++) {
174 for (Int_t ispltheta = 0; ispltheta<kSplitTheta; ispltheta++) {
175 snprintf (tag2, 40, "heff[%d][%d]",isplp,ispltheta);
176 heff[isplp][ispltheta] = (TH3F*)gDirectory->Get(tag2);
177 snprintf (tag2, 40, "hacc[%d][%d]",isplp,ispltheta);
178 hacc[isplp][ispltheta] = (TH3F*)gDirectory->Get(tag2);
181 hmeanp = (TH3F*)gDirectory->Get("hmeanp");
182 hsigmap = (TH3F*)gDirectory->Get("hsigmap");
183 hsigma1p = (TH3F*)gDirectory->Get("hsigma1p");
184 hchi2p = (TH3F*)gDirectory->Get("hchi2p");
185 hnormg2 = (TH3F*)gDirectory->Get("hnormg2");
186 hmeang2 = (TH3F*)gDirectory->Get("hmeang2");
187 hsigmag2 = (TH3F*)gDirectory->Get("hsigmag2");
188 hmeantheta = (TH3F*)gDirectory->Get("hmeantheta");
189 hsigmatheta = (TH3F*)gDirectory->Get("hsigmatheta");
190 hchi2theta = (TH3F*)gDirectory->Get("hchi2theta");
191 hmeanphi = (TH3F*)gDirectory->Get("hmeanphi");
192 hsigmaphi = (TH3F*)gDirectory->Get("hsigmaphi");
193 hchi2phi = (TH3F*)gDirectory->Get("hchi2phi");
195 for (Int_t ip=0; ip<fNbinp ;ip++) {
196 for (Int_t itheta=0; itheta<fNbintheta ;itheta++) {
197 for (Int_t iphi=0; iphi<fNbinphi ;iphi++) {
198 Float_t p = fPmin + fDeltaP * (ip + 0.5);
199 Float_t theta = fThetamin + fDeltaTheta * (itheta + 0.5);
200 Float_t phi = fPhimin + fDeltaPhi * (iphi + 0.5);
202 fEntry[ip][itheta][iphi][ibkg]->SetP(p);
203 fEntry[ip][itheta][iphi][ibkg]->SetMeanp(hmeanp->GetBinContent(ip+1,itheta+1,iphi+1));
204 fEntry[ip][itheta][iphi][ibkg]->SetSigmap(TMath::Abs(hsigmap->GetBinContent(ip+1,itheta+1,iphi+1)));
205 fEntry[ip][itheta][iphi][ibkg]->SetSigma1p(hsigma1p->GetBinContent(ip+1,itheta+1,iphi+1));
206 fEntry[ip][itheta][iphi][ibkg]->SetChi2p(hchi2p->GetBinContent(ip+1,itheta+1,iphi+1));
207 fEntry[ip][itheta][iphi][ibkg]->SetNormG2(hnormg2->GetBinContent(ip+1,itheta+1,iphi+1));
208 fEntry[ip][itheta][iphi][ibkg]->SetMeanG2(hmeang2->GetBinContent(ip+1,itheta+1,iphi+1));
209 if (ibkg == 0) fEntry[ip][itheta][iphi][ibkg]->SetSigmaG2(9999);
210 else fEntry[ip][itheta][iphi][ibkg]->SetSigmaG2(hsigmag2->GetBinContent(ip+1,itheta+1,iphi+1));
211 fEntry[ip][itheta][iphi][ibkg]->SetTheta(theta);
212 fEntry[ip][itheta][iphi][ibkg]->SetMeantheta(hmeantheta->GetBinContent(ip+1,itheta+1,iphi+1));
213 fEntry[ip][itheta][iphi][ibkg]->SetSigmatheta(TMath::Abs(hsigmatheta->GetBinContent(ip+1,itheta+1,iphi+1)));
214 fEntry[ip][itheta][iphi][ibkg]->SetChi2theta(hchi2theta->GetBinContent(ip+1,itheta+1,iphi+1));
215 fEntry[ip][itheta][iphi][ibkg]->SetPhi(phi);
216 fEntry[ip][itheta][iphi][ibkg]->SetMeanphi(hmeanphi->GetBinContent(ip+1,itheta+1,iphi+1));
217 fEntry[ip][itheta][iphi][ibkg]->SetSigmaphi(TMath::Abs(hsigmaphi->GetBinContent(ip+1,itheta+1,iphi+1)));
218 fEntry[ip][itheta][iphi][ibkg]->SetChi2phi(hchi2phi->GetBinContent(ip+1,itheta+1,iphi+1));
219 for (Int_t i=0; i<kSplitP; i++) {
220 for (Int_t j=0; j<kSplitTheta; j++) {
221 fEntry[ip][itheta][iphi][ibkg]->SetAcc(i,j,hacc[i][j]->GetBinContent(ip+1,itheta+1,iphi+1));
222 fEntry[ip][itheta][iphi][ibkg]->SetEff(i,j,heff[i][j]->GetBinContent(ip+1,itheta+1,iphi+1));
230 TGraph *graph = new TGraph(3);
231 TF1 *f = new TF1("f","[0]+[1]*x");
233 for (Int_t ip=0; ip< fNbinp; ip++){
234 for (Int_t itheta=0; itheta< fNbintheta; itheta++){
235 for (Int_t iphi=0; iphi< fNbinphi; iphi++){
236 graph->SetPoint(0,0.5,fEntry[ip][itheta][iphi][1]->GetSigmaG2());
237 graph->SetPoint(1,1,fEntry[ip][itheta][iphi][2]->GetSigmaG2());
238 graph->SetPoint(2,2,fEntry[ip][itheta][iphi][3]->GetSigmaG2());
240 fEntry[ip][itheta][iphi][0]->SetSigmaG2(f->Eval(0));
246 printf ("parameters read. \n");
249 void AliMUONFastTracking::GetBinning(Int_t &nbinp, Float_t &pmin, Float_t &pmax,
250 Int_t &nbintheta, Float_t &thetamin,
252 Int_t &nbinphi, Float_t &phimin, Float_t &phimax) const
255 // gets the binning for the discrete parametrizations in the lookup table
260 nbintheta = fNbintheta;
261 thetamin = fThetamin;
262 thetamax = fThetamax;
269 void AliMUONFastTracking::GetIpIthetaIphi(Float_t p, Float_t theta, Float_t phi,
270 Int_t charge, Int_t &ip, Int_t &itheta,
274 // gets the id of the cells in the LUT for a given (p,theta,phi, charge)
276 if (charge < 0) phi = -phi;
277 ip = Int_t (( p - fPmin ) / fDeltaP);
278 itheta = Int_t (( theta - fThetamin ) / fDeltaTheta);
279 iphi = Int_t (( phi - fPhimin ) / fDeltaPhi);
283 if (ip>= fNbinp) ip = fNbinp-1;
284 if (itheta< 0) itheta = 0;
285 if (itheta>= fNbintheta) itheta = fNbintheta-1;
287 if (iphi< 0) iphi = 0;
288 if (iphi>= fNbinphi) iphi = fNbinphi-1;
291 void AliMUONFastTracking::GetSplit(Int_t ip, Int_t itheta,
292 Int_t &nSplitP, Int_t &nSplitTheta) const
295 // the first cell is splitted in more bins for theta and momentum
296 // parameterizations. Get the number of divisions for the splitted bins
298 if (ip==0) nSplitP = 5;
300 if (itheta==0) nSplitTheta = 3;
301 else nSplitTheta = 1;
304 Float_t AliMUONFastTracking::Efficiency(Float_t p, Float_t theta,
305 Float_t phi, Int_t charge){
307 // gets the tracking efficiency
309 Int_t ip=0, itheta=0, iphi=0;
310 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
311 Int_t nSplitP, nSplitTheta;
312 GetSplit(ip,itheta,nSplitP,nSplitTheta);
314 Float_t dp = p - fPmin;
315 Int_t ibinp = Int_t(nSplitP*(dp - fDeltaP * Int_t(dp / fDeltaP))/fDeltaP);
316 Float_t dtheta = theta - fThetamin;
317 Int_t ibintheta = Int_t(nSplitTheta*(dtheta - fDeltaTheta * Int_t(dtheta / fDeltaTheta))/fDeltaTheta);
318 Float_t eff = fCurrentEntry[ip][itheta][iphi]->GetEff(ibinp,ibintheta);
322 Float_t AliMUONFastTracking::Acceptance(Float_t p, Float_t theta,
323 Float_t phi, Int_t charge){
325 // gets the geometrical acceptance
327 if (theta<fThetamin || theta>fThetamax) return 0;
329 Int_t ip=0, itheta=0, iphi=0;
330 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
331 Int_t nSplitP, nSplitTheta;
332 GetSplit(ip,itheta,nSplitP,nSplitTheta);
333 // central value and corrections with spline
335 Float_t dp = p - fPmin;
336 Int_t ibinp = Int_t(nSplitP*(dp - fDeltaP * Int_t(dp / fDeltaP))/fDeltaP);
337 Float_t dtheta = theta - fThetamin;
338 Int_t ibintheta = Int_t(nSplitTheta*(dtheta - fDeltaTheta * Int_t(dtheta / fDeltaTheta))/fDeltaTheta);
339 Float_t acc = fCurrentEntry[ip][itheta][iphi]->GetAcc(ibinp,ibintheta);
343 Float_t AliMUONFastTracking::MeanP(Float_t p, Float_t theta,
344 Float_t phi, Int_t charge) const
347 // gets the mean value of the prec-pgen distribution
349 Int_t ip=0, itheta=0, iphi=0;
350 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
351 return fCurrentEntry[ip][itheta][iphi]->GetMeanp();
354 Float_t AliMUONFastTracking::SigmaP(Float_t p, Float_t theta,
355 Float_t phi, Int_t charge) const
358 // gets the width of the prec-pgen distribution
360 Int_t ip=0, itheta=0, iphi=0;
362 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
363 // central value and corrections with spline
364 Float_t sigmap = fCurrentEntry[ip][itheta][iphi]->GetSigmap();
365 if (!fSpline) return sigmap;
366 // corrections vs p, theta, phi
367 index = iphi + fNbinphi * itheta;
368 Double_t xmin,ymin,xmax,ymax;
369 Float_t frac1 = fSplineSigmap[index][0]->Eval(p)/sigmap;
371 if (p>fPmax-fDeltaP/2.) {
372 Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigmap();
373 Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigmap();
374 Float_t s3 = fCurrentEntry[fNbinp-3][itheta][iphi]->GetSigmap();
375 Float_t p1 = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
376 Float_t p2 = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
377 Float_t p3 = fDeltaP * (fNbinp - 3 + 0.5) + fPmin;
378 Float_t p12 = p1 * p1, p22 = p2 * p2, p32 = p3 * p3;
379 Float_t d = p12*p2 + p1*p32 + p22*p3 - p32*p2 - p3*p12 - p22*p1;
380 Float_t a = (s1*p2 + p1*s3 + s2*p3 - s3*p2 - p3*s1 - s2*p1) / d;
381 Float_t b = (p12*s2 + s1*p32 + p22*s3 - p32*s2 - s3*p12 - p22*s1)/d;
382 Float_t c = (p12*p2*s3 + p1*p32*s2 + p22*p3*s1
383 - p32*p2*s1 - p3*p12*s2 - p22*p1*s3) / d;
384 Float_t sigma = a * p * p + b * p + c;
385 frac1 = sigma/sigmap;
387 index = iphi + fNbinphi * ip;
388 fSplineEff[index][1]->GetKnot(0,xmin,ymin);
389 fSplineEff[index][1]->GetKnot(9,xmax,ymax);
390 if (theta>xmax) theta = xmax;
391 Float_t frac2 = fSplineSigmap[index][1]->Eval(theta)/sigmap;
392 index = itheta + fNbintheta * ip;
393 fSplineEff[index][2]->GetKnot(0,xmin,ymin);
394 fSplineEff[index][2]->GetKnot(9,xmax,ymax);
395 if (phi>xmax) phi = xmax;
396 Float_t frac3 = fSplineSigmap[index][2]->Eval(phi)/sigmap;
397 Float_t sigmatot = sigmap * frac1 * frac2 * frac3;
398 if (sigmatot<0) sigmatot = sigmap;
402 Float_t AliMUONFastTracking::Sigma1P(Float_t p, Float_t theta,
403 Float_t phi, Int_t charge) const
406 // gets the width correction of the prec-pgen distribution (see FitP)
408 Int_t ip=0, itheta=0, iphi=0;
409 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
411 // linear extrapolation of sigmap for p out of range
412 Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigma1p();
413 Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigma1p();
414 Float_t p1 = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
415 Float_t p2 = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
416 Float_t sigma = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) );
419 else return fCurrentEntry[ip][itheta][iphi]->GetSigma1p();
422 Float_t AliMUONFastTracking::NormG2(Float_t p, Float_t theta,
423 Float_t phi, Int_t charge) const
426 // gets the relative normalization of the background
427 // (gaussian) component in the prec-pgen distribution
429 Int_t ip=0, itheta=0, iphi=0;
430 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
432 // linear extrapolation of sigmap for p out of range
433 Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetNormG2();
434 Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetNormG2();
435 Float_t p1 = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
436 Float_t p2 = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
437 Float_t norm = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) );
440 else return fCurrentEntry[ip][itheta][iphi]->GetNormG2();
443 Float_t AliMUONFastTracking::MeanG2(Float_t p, Float_t theta,
444 Float_t phi, Int_t charge) const
447 // gets the mean value of the background
448 // (gaussian) component in the prec-pgen distribution
450 Int_t ip=0, itheta=0, iphi=0;
451 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
453 // linear extrapolation of sigmap for p out of range
454 Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetMeanG2();
455 Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetMeanG2();
456 Float_t p1 = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
457 Float_t p2 = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
458 Float_t norm = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) );
461 else return fCurrentEntry[ip][itheta][iphi]->GetMeanG2();
464 Float_t AliMUONFastTracking::SigmaG2(Float_t p, Float_t theta,
465 Float_t phi, Int_t charge) const
468 // gets the width of the background
469 // (gaussian) component in the prec-pgen distribution
471 Int_t ip=0, itheta=0, iphi=0;
472 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
474 // linear extrapolation of sigmap for p out of range
475 Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigmaG2();
476 Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigmaG2();
477 Float_t p1 = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
478 Float_t p2 = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
479 Float_t sigma = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) );
482 else return fCurrentEntry[ip][itheta][iphi]->GetSigmaG2();
486 Float_t AliMUONFastTracking::MeanTheta(Float_t p, Float_t theta,
487 Float_t phi, Int_t charge) const
490 // gets the mean value of the thetarec-thetagen distribution
492 Int_t ip=0, itheta=0, iphi=0;
493 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
494 return fCurrentEntry[ip][itheta][iphi]->GetMeantheta();
497 Float_t AliMUONFastTracking::SigmaTheta(Float_t p, Float_t theta,
498 Float_t phi, Int_t charge) const
501 // gets the width of the thetarec-thetagen distribution
503 Int_t ip=0, itheta=0, iphi=0;
505 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
506 // central value and corrections with spline
507 Float_t sigmatheta = fCurrentEntry[ip][itheta][iphi]->GetSigmatheta();
508 if (!fSpline) return sigmatheta;
509 // corrections vs p, theta, phi
510 index = iphi + fNbinphi * itheta;
511 Double_t xmin,ymin,xmax,ymax;
512 Float_t frac1 = fSplineSigmatheta[index][0]->Eval(p)/sigmatheta;
513 if (p>fPmax-fDeltaP/2.) {
514 // linear extrapolation of sigmap for p out of range
515 Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigmatheta();
516 Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigmatheta();
517 Float_t p1 = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
518 Float_t p2 = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
519 Float_t sigma = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) );
520 frac1=sigma/sigmatheta;
522 index = iphi + fNbinphi * ip;
523 fSplineEff[index][1]->GetKnot(0,xmin,ymin);
524 fSplineEff[index][1]->GetKnot(9,xmax,ymax);
525 if (theta>xmax) theta = xmax;
526 Float_t frac2 = fSplineSigmatheta[index][1]->Eval(theta)/sigmatheta;
527 index = itheta + fNbintheta * ip;
528 fSplineEff[index][2]->GetKnot(0,xmin,ymin);
529 fSplineEff[index][2]->GetKnot(9,xmax,ymax);
530 if (phi>xmax) phi = xmax;
531 Float_t frac3 = fSplineSigmatheta[index][2]->Eval(phi)/sigmatheta;
532 return sigmatheta * frac1 * frac2 * frac3;
536 Float_t AliMUONFastTracking::MeanPhi(Float_t p, Float_t theta,
537 Float_t phi, Int_t charge) const
540 // gets the mean value of the phirec-phigen distribution
542 Int_t ip=0, itheta=0, iphi=0;
543 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
544 return fCurrentEntry[ip][itheta][iphi]->GetMeanphi();
547 Float_t AliMUONFastTracking::SigmaPhi(Float_t p, Float_t theta,
548 Float_t phi, Int_t charge){
550 // gets the width of the phirec-phigen distribution
552 Int_t ip=0, itheta=0, iphi=0;
554 GetIpIthetaIphi(p,theta,phi,charge,ip,itheta,iphi);
555 // central value and corrections with spline
556 Float_t sigmaphi = fCurrentEntry[ip][itheta][iphi]->GetSigmaphi();
557 if (!fSpline) return sigmaphi;
558 // corrections vs p, theta, phi
559 index = iphi + fNbinphi * itheta;
560 Float_t frac1 = fSplineSigmaphi[index][0]->Eval(p)/sigmaphi;
561 Double_t xmin,ymin,xmax,ymax;
562 if (p>fPmax-fDeltaP/2.) {
563 Float_t s1 = fCurrentEntry[fNbinp-1][itheta][iphi]->GetSigmaphi();
564 Float_t s2 = fCurrentEntry[fNbinp-2][itheta][iphi]->GetSigmaphi();
565 Float_t p1 = fDeltaP * (fNbinp - 1 + 0.5) + fPmin;
566 Float_t p2 = fDeltaP * (fNbinp - 2 + 0.5) + fPmin;
567 Float_t sigma = 1./(p1-p2) * ( (s1-s2)*p + (s2-s1)*p1 + s1*(p1-p2) );
568 frac1 = sigma/sigmaphi;
571 index = iphi + fNbinphi * ip;
572 fSplineEff[index][1]->GetKnot(0,xmin,ymin);
573 fSplineEff[index][1]->GetKnot(9,xmax,ymax);
574 if (theta>xmax) theta = xmax;
575 Float_t frac2 = fSplineSigmaphi[index][1]->Eval(theta)/sigmaphi;
576 index = itheta + fNbintheta * ip;
577 fSplineEff[index][2]->GetKnot(0,xmin,ymin);
578 fSplineEff[index][2]->GetKnot(9,xmax,ymax);
579 if (phi>xmax) phi = xmax;
580 Float_t frac3 = fSplineSigmaphi[index][2]->Eval(phi)/sigmaphi;
581 return sigmaphi * frac1 * frac2 * frac3;
584 void AliMUONFastTracking::SetSpline(){
586 // sets the spline functions for a smooth behaviour of the parameters
587 // when going from one cell to another
589 printf ("Setting spline functions...");
593 Int_t nbins[3] = {fNbinp, fNbintheta, fNbinphi};
594 Double_t xspl[20],yeff[50],ysigmap[20],ysigma1p[20];
595 Double_t yacc[50], ysigmatheta[20],ysigmaphi[20];
597 // let's calculate the x axis for p, theta, phi
599 Int_t i, ispline, ivar;
600 for (i=0; i< fNbinp; i++) x[i][0] = fPmin + fDeltaP * (i + 0.5);
601 for (i=0; i< fNbintheta; i++) x[i][1] = fThetamin + fDeltaTheta * (i + 0.5);
602 for (i=0; i< fNbinphi; i++) x[i][2] = fPhimin + fDeltaPhi * (i + 0.5);
604 for (i=0; i< 5 * fNbinp; i++) x2[i][0] = fPmin + fDeltaP * (i + 0.5)/5.;
605 for (i=0; i< 5 * fNbintheta; i++) x2[i][1] = fThetamin + fDeltaTheta * (i + 0.5)/5.;
606 for (i=0; i< 5 * fNbinphi; i++) x2[i][2] = fPhimin + fDeltaPhi * (i + 0.5)/5.;
610 for (i=0; i<nbins[ivar]; i++) xspl[i] = x[i][ivar];
611 for (i=0; i<5 * nbins[ivar]; i++) xsp2[i] = x2[i][ivar];
613 for (Int_t itheta=0; itheta< fNbintheta; itheta++){
614 for (Int_t iphi=0; iphi< fNbinphi; iphi++){
615 for (Int_t ip=0; ip<fNbinp; ip++) {
616 ysigmap[ip] = fCurrentEntry[ip][itheta][iphi]->GetSigmap();
617 ysigma1p[ip] = fCurrentEntry[ip][itheta][iphi]->GetSigma1p();
618 ysigmatheta[ip] = fCurrentEntry[ip][itheta][iphi]->GetSigmatheta();
619 ysigmaphi[ip] = fCurrentEntry[ip][itheta][iphi]->GetSigmaphi();
621 if (fPrintLevel>3) cout << " creating new spline " << splname << endl;
622 snprintf (splname, 40, "fSplineEff[%d][%d]",ispline,ivar);
623 fSplineEff[ispline][ivar] = new TSpline3(splname,xsp2,yeff,5 * nbins[ivar]);
624 snprintf (splname, 40, "fSplineAcc[%d][%d]",ispline,ivar);
625 fSplineAcc[ispline][ivar] = new TSpline3(splname,xsp2,yacc,5 * nbins[ivar]);
626 snprintf (splname, 40, "fSplineSigmap[%d][%d]",ispline,ivar);
627 fSplineSigmap[ispline][ivar] = new TSpline3(splname,xspl,ysigmap,nbins[ivar]);
628 snprintf (splname, 40, "fSplineSigma1p[%d][%d]",ispline,ivar);
629 fSplineSigma1p[ispline][ivar] = new TSpline3(splname,xspl,ysigma1p,nbins[ivar]);
630 snprintf (splname, 40, "fSplineSigmatheta[%d][%d]",ispline,ivar);
631 fSplineSigmatheta[ispline][ivar] = new TSpline3(splname,xspl,ysigmatheta,nbins[ivar]);
632 snprintf (splname, 40, "fSplineSigmaphi[%d][%d]",ispline,ivar);
633 fSplineSigmaphi[ispline][ivar] = new TSpline3(splname,xspl,ysigmaphi,nbins[ivar]);
639 for (i=0; i<nbins[ivar]; i++) xspl[i] = x[i][ivar];
641 for (Int_t ip=0; ip<fNbinp; ip++) {
642 for (Int_t iphi=0; iphi< fNbinphi; iphi++){
643 for (Int_t itheta=0; itheta< fNbintheta; itheta++){
644 // for efficiency and acceptance let's take the central value
645 ysigmap[itheta] = fCurrentEntry[ip][itheta][iphi]->GetSigmap();
646 ysigma1p[itheta] = fCurrentEntry[ip][itheta][iphi]->GetSigma1p();
647 ysigmatheta[itheta] = fCurrentEntry[ip][itheta][iphi]->GetSigmatheta();
648 ysigmaphi[itheta] = fCurrentEntry[ip][itheta][iphi]->GetSigmaphi();
650 if (fPrintLevel>3) cout << " creating new spline " << splname << endl;
651 snprintf (splname, 40, "fSplineEff[%d][%d]",ispline,ivar);
652 fSplineEff[ispline][ivar] = new TSpline3(splname,xspl,yeff, nbins[ivar]);
653 snprintf (splname, 40, "fSplineAcc[%d][%d]",ispline,ivar);
654 fSplineAcc[ispline][ivar] = new TSpline3(splname,xspl,yacc, nbins[ivar]);
655 snprintf (splname, 40, "fSplineSigmap[%d][%d]",ispline,ivar);
656 fSplineSigmap[ispline][ivar] = new TSpline3(splname,xspl,ysigmap,nbins[ivar]);
657 snprintf (splname, 40, "fSplineSigma1p[%d][%d]",ispline,ivar);
658 fSplineSigma1p[ispline][ivar] = new TSpline3(splname,xspl,ysigma1p,nbins[ivar]);
659 snprintf (splname, 40, "fSplineSigmatheta[%d][%d]",ispline,ivar);
660 fSplineSigmatheta[ispline][ivar] = new TSpline3(splname,xspl,ysigmatheta,nbins[ivar]);
661 snprintf (splname, 40, "fSplineSigmaphi[%d][%d]",ispline,ivar);
662 fSplineSigmaphi[ispline][ivar] = new TSpline3(splname,xspl,ysigmaphi,nbins[ivar]);
668 for (i=0; i<nbins[ivar]; i++) xspl[i] = x[i][ivar];
670 for (Int_t ip=0; ip<fNbinp; ip++) {
671 for (Int_t itheta=0; itheta< fNbintheta; itheta++){
672 for (Int_t iphi=0; iphi< fNbinphi; iphi++){
673 // for efficiency and acceptance let's take the central value
674 ysigmap[iphi] = fCurrentEntry[ip][itheta][iphi]->GetSigmap();
675 ysigma1p[iphi] = fCurrentEntry[ip][itheta][iphi]->GetSigma1p();
676 ysigmatheta[iphi] = fCurrentEntry[ip][itheta][iphi]->GetSigmatheta();
677 ysigmaphi[iphi] = fCurrentEntry[ip][itheta][iphi]->GetSigmaphi();
679 if (fPrintLevel>3) cout << " creating new spline " << splname << endl;
680 snprintf (splname, 40, "fSplineEff[%d][%d]",ispline,ivar);
681 fSplineEff[ispline][ivar] = new TSpline3(splname,xspl,yeff, nbins[ivar]);
682 snprintf (splname, 40, "fSplineAcc[%d][%d]",ispline,ivar);
683 fSplineAcc[ispline][ivar] = new TSpline3(splname,xspl,yacc, nbins[ivar]);
684 snprintf (splname, 40, "fSplineSigmap[%d][%d]",ispline,ivar);
685 fSplineSigmap[ispline][ivar] = new TSpline3(splname,xspl,ysigmap,nbins[ivar]);
686 snprintf (splname, 40, "fSplineSigma1p[%d][%d]",ispline,ivar);
687 fSplineSigma1p[ispline][ivar] = new TSpline3(splname,xspl,ysigma1p,nbins[ivar]);
688 snprintf (splname, 40, "fSplineSigmatheta[%d][%d]",ispline,ivar);
689 fSplineSigmatheta[ispline][ivar] = new TSpline3(splname,xspl,ysigmatheta,nbins[ivar]);
690 snprintf (splname, 40, "fSplineSigmaphi[%d][%d]",ispline,ivar);
691 fSplineSigmaphi[ispline][ivar] = new TSpline3(splname,xspl,ysigmaphi,nbins[ivar]);
695 printf ("...done\n");
698 void AliMUONFastTracking::SetBackground(Float_t bkg){
700 // linear interpolation of the parameters in the LUT between 2 values where
701 // the background has been actually calculated
703 if (bkg>2) printf ("WARNING: unsafe extrapolation!\n");
706 Float_t bkgLevel[4] = {0, 0.5, 1, 2}; // bkg values for which LUT is calculated
708 for (ibkg=0; ibkg<4; ibkg++) if ( bkg < bkgLevel[ibkg]) break;
709 if (ibkg == 4) ibkg--;
710 if (ibkg == 0) ibkg++;
712 Float_t x0 = bkgLevel[ibkg-1];
713 Float_t x1 = bkgLevel[ibkg];
714 Float_t x = (bkg - x0) / (x1 - x0);
718 for (Int_t ip=0; ip< fNbinp; ip++){
719 for (Int_t itheta=0; itheta< fNbintheta; itheta++){
720 for (Int_t iphi=0; iphi< fNbinphi; iphi++){
721 fCurrentEntry[ip][itheta][iphi]->SetP(fEntry[ip][itheta][iphi][ibkg]->GetP());
722 fCurrentEntry[ip][itheta][iphi]->SetTheta(fEntry[ip][itheta][iphi][ibkg]->GetTheta());
723 fCurrentEntry[ip][itheta][iphi]->SetPhi(fEntry[ip][itheta][iphi][ibkg]->GetPhi());
724 fCurrentEntry[ip][itheta][iphi]->SetChi2p(-1);
725 fCurrentEntry[ip][itheta][iphi]->SetChi2theta(-1);
726 fCurrentEntry[ip][itheta][iphi]->SetChi2phi(-1);
728 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetMeanp();
729 y1 = fEntry[ip][itheta][iphi][ibkg]->GetMeanp();
730 fCurrentEntry[ip][itheta][iphi] ->SetMeanp((y1 - y0) * x + y0);
731 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetMeantheta();
732 y1 = fEntry[ip][itheta][iphi][ibkg]->GetMeantheta();
733 fCurrentEntry[ip][itheta][iphi] ->SetMeantheta((y1 - y0) * x +y0);
734 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetMeanphi();
735 y1 = fEntry[ip][itheta][iphi][ibkg]->GetMeanphi();
736 fCurrentEntry[ip][itheta][iphi] ->SetMeanphi((y1 - y0) * x + y0);
737 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigmap();
738 y1 = fEntry[ip][itheta][iphi][ibkg]->GetSigmap();
739 fCurrentEntry[ip][itheta][iphi] ->SetSigmap((y1 - y0) * x + y0);
740 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigmatheta();
741 y1 = fEntry[ip][itheta][iphi][ibkg]->GetSigmatheta();
742 fCurrentEntry[ip][itheta][iphi] ->SetSigmatheta((y1 - y0) * x+y0);
743 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigmaphi();
744 y1 = fEntry[ip][itheta][iphi][ibkg]->GetSigmaphi();
745 fCurrentEntry[ip][itheta][iphi] ->SetSigmaphi((y1 - y0) * x + y0);
746 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigma1p();
747 y1 = fEntry[ip][itheta][iphi][ibkg]->GetSigma1p();
748 fCurrentEntry[ip][itheta][iphi] ->SetSigma1p((y1 - y0) * x + y0);
749 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetNormG2();
750 y1 = fEntry[ip][itheta][iphi][ibkg]->GetNormG2();
751 fCurrentEntry[ip][itheta][iphi] ->SetNormG2((y1 - y0) * x + y0);
752 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetMeanG2();
753 y1 = fEntry[ip][itheta][iphi][ibkg]->GetMeanG2();
754 fCurrentEntry[ip][itheta][iphi] ->SetMeanG2((y1 - y0) * x + y0);
756 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetSigmaG2();
757 y1 = fEntry[ip][itheta][iphi][ibkg]->GetSigmaG2();
758 fCurrentEntry[ip][itheta][iphi] ->SetSigmaG2((y1 - y0) * x + y0);
759 for (Int_t i=0; i<kSplitP; i++) {
760 for (Int_t j=0; j<kSplitTheta; j++) {
761 fCurrentEntry[ip][itheta][iphi]->SetAcc(i,j,fEntry[ip][itheta][iphi][ibkg]->GetAcc(i,j));
762 y0 = fEntry[ip][itheta][iphi][ibkg-1]->GetEff(i,j);
763 y1 = fEntry[ip][itheta][iphi][ibkg]->GetEff(i,j);
764 fCurrentEntry[ip][itheta][iphi]->SetEff(i,j, (y1 - y0) * x + y0);
773 TF1* AliMUONFastTracking::GetFitP(Int_t ip,Int_t itheta,Int_t iphi) {
774 // gets the correct prec-pgen distribution for a given LUT cell
775 if (!fFitp[ip][itheta][iphi]) {
777 snprintf(name, 256, "fit_%d_%d_%d", ip, itheta, iphi);
778 fFitp[ip][itheta][iphi] = new TF1(name ,FitP,-20.,20.,6);
779 fFitp[ip][itheta][iphi]->SetNpx(500);
780 fFitp[ip][itheta][iphi]->SetParameters(0.,0.,0.,0.,0.,0.);
782 return fFitp[ip][itheta][iphi];
785 AliMUONFastTracking& AliMUONFastTracking::operator=(const AliMUONFastTracking& rhs)
787 // Assignment operator
792 void AliMUONFastTracking::Copy(TObject&) const
797 Fatal("Copy","Not implemented!\n");