From d53fc881f6575897cf1fc4148e2ef84ad2538c3c Mon Sep 17 00:00:00 2001 From: morsch Date: Tue, 5 Aug 2003 16:14:20 +0000 Subject: [PATCH 1/1] Some problems with too big fluctuations corrected. (A. de Falco) --- FASTSIM/AliFastMuonTrackingRes.cxx | 52 +++++++++--- FASTSIM/AliMUONFastTracking.cxx | 127 ++++++++--------------------- FASTSIM/AliMUONFastTracking.h | 11 +-- 3 files changed, 77 insertions(+), 113 deletions(-) diff --git a/FASTSIM/AliFastMuonTrackingRes.cxx b/FASTSIM/AliFastMuonTrackingRes.cxx index 6012be486d3..6adb6661b9c 100644 --- a/FASTSIM/AliFastMuonTrackingRes.cxx +++ b/FASTSIM/AliFastMuonTrackingRes.cxx @@ -13,7 +13,12 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* $Id$ */ +/* +$Log$ +Revision 1.1 2003/01/06 10:13:09 morsch +First commit. + +*/ #include "AliFastMuonTrackingRes.h" #include "AliMUONFastTracking.h" @@ -49,38 +54,59 @@ void AliFastMuonTrackingRes::Evaluate(Float_t p, Float_t theta , Float_t p Double_t sigmag2 = fFastTracking->SigmaG2(p, theta, phi, Int_t(fCharge)); Int_t ip,itheta,iphi; - TF1* fitp = fFastTracking->GetFitP(); - fFastTracking->GetIpIthetaIphi(p, theta, phi, Int_t(fCharge), ip, itheta, iphi); - if (sigmap == 0) { - printf ("WARNING!!! sigmap=0: "); - printf ("ip= %d itheta = %d iphi = %d ", ip, itheta, iphi); - printf ("p= %f theta = %f phi = %f\n", p, theta, phi); + TF1* fitp = fFastTracking->GetFitP(ip,itheta,iphi); + + Float_t curmeanp = fitp->GetParameter(0); + Float_t cursigmap = fitp->GetParameter(1); + Float_t cursigma1p = fitp->GetParameter(2); + Float_t curnormg2 = fitp->GetParameter(3); + Float_t curmeang2 = fitp->GetParameter(4); + Float_t cursigmag2 = fitp->GetParameter(5); + if (curmeanp != meanp || cursigmap != sigmap || cursigma1p != sigma1p || + curnormg2 != normg2 || curmeang2 != meang2 || cursigmag2 != sigmag2){ + printf ("Setting new parameters for ip=%d itheta=%d iphi=%d\n",ip,itheta,iphi); + fitp->SetParameters(meanp,sigmap,sigma1p,normg2,meang2,sigmag2); } - - fitp->SetParameters(meanp,sigmap,sigma1p,normg2,meang2,sigmag2); Double_t meantheta = fFastTracking->MeanTheta (p, theta, phi, Int_t(fCharge)); Double_t sigmatheta = fFastTracking->SigmaTheta(p, theta, phi, Int_t(fCharge)); Double_t meanphi = fFastTracking->MeanPhi (p, theta, phi, Int_t(fCharge)); Double_t sigmaphi = fFastTracking->SigmaPhi (p, theta, phi, Int_t(fCharge)); - + + if (sigmatheta<0 or sigmaphi<0) + printf ("bin %d %d %d sigmatheta = %f, sigmaphi = %f\n", + ip,itheta,iphi,sigmatheta,sigmaphi); // Components different from ip=0 have the RMS bigger than mean Float_t ptp[3] = { 1.219576,-0.354764,-0.690117 }; Float_t ptph[3] = { 0.977522, 0.016269, 0.023158 }; Float_t pphp[3] = { 1.303256,-0.464847,-0.869322 }; // Smeared momentum - pS = p + fitp->GetRandom(); - Float_t dp = pS - p; - + pS = -1.; + // Float_t dpmax = 5. + ip * 2.5; + // Float_t dpmax = 5. + ip * 2; + Float_t dpmax; + if (sigmag2<999.) dpmax = 5. * (sigmap + sigmag2); + else dpmax = 5. * sigmap; + Float_t dp = 100; + while (pS<0 || TMath::Abs(dp)>dpmax) { + pS = p + fitp->GetRandom(); + dp = pS - p; + } // Smeared phi + Float_t sigmaphiold=sigmaphi; if (ip==0) sigmaphi *= pphp[0] + pphp[1] * dp + pphp[2] * dp*dp; + if (sigmaphi<0.5 * sigmaphiold) sigmaphi = 0.5 * sigmaphiold; + if (sigmaphi>2. * sigmaphiold) sigmaphi = 2. * sigmaphiold; phiS = phi + gRandom->Gaus(meanphi, sigmaphi); Float_t dphi = phiS - phi; // Smeared theta + Float_t sigmathetaold=sigmatheta; if (ip==0) sigmatheta *= ptp[0] + ptp[1] * dp + ptp[2] * dp*dp; if (ip==0) sigmatheta *= ptph[0] + ptph[1] * dphi + ptph[2] * dphi*dphi; + if (sigmatheta<0.5 * sigmathetaold) sigmatheta = 0.5 * sigmathetaold; + if (sigmatheta>2. * sigmathetaold) sigmatheta = 2. * sigmathetaold; thetaS = theta + gRandom->Gaus(meantheta,sigmatheta); } diff --git a/FASTSIM/AliMUONFastTracking.cxx b/FASTSIM/AliMUONFastTracking.cxx index c4e4eb7e8b7..679e8e9ac22 100644 --- a/FASTSIM/AliMUONFastTracking.cxx +++ b/FASTSIM/AliMUONFastTracking.cxx @@ -13,7 +13,15 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* $Id$ */ +/* +$Log$ +Revision 1.2 2003/01/08 10:29:33 morsch +Path to data file changed. + +Revision 1.1 2003/01/06 10:13:33 morsch +First commit. + +*/ #include "AliMUONFastTracking.h" #include "AliMUONFastTrackingEntry.h" @@ -44,7 +52,8 @@ static Double_t FitP(Double_t *x, Double_t *par){ Double_t fasymm = TMath::Exp(-0.5 * dx * dx / (sigma * sigma)); Double_t sigma2 = par[1] * par[5]; Double_t fgauss = TMath::Exp(-0.5 * dx2 * dx2 / (sigma2 * sigma2)); - return TMath::Abs(fasymm + par[3] * fgauss); + Double_t value = fasymm + par[3] * fgauss; + return value; } AliMUONFastTracking* AliMUONFastTracking::Instance() @@ -60,8 +69,7 @@ AliMUONFastTracking* AliMUONFastTracking::Instance() AliMUONFastTracking::AliMUONFastTracking() { -// SetBackground(); - + fClusterFinder = kOld; fPrintLevel = 1; // read binning; temporarily put by hand Float_t pmin = 0, pmax = 200; @@ -106,13 +114,13 @@ void AliMUONFastTracking::Init(Float_t bkg) } char filename [100]; - sprintf (filename,"$(ALICE_ROOT)/FASTSIM/data/MUONtrackLUT.root"); + if (fClusterFinder==kOld) sprintf (filename,"$(ALICE_ROOT)/FASTSIM/data/MUONtrackLUT.root"); + else sprintf (filename,"$(ALICE_ROOT)/FASTSIM/data/MUONtrackLUT.root"); + TFile *file = new TFile(filename); ReadLUT(file); SetBackground(bkg); - UseSpline(1); - fFitp = new TF1("fit1",FitP,-20.,20.,6); - fFitp->SetNpx(200); + UseSpline(0); } @@ -123,6 +131,8 @@ void AliMUONFastTracking::ReadLUT(TFile* file) TH3F *hmeanphi, *hsigmaphi, *hchi2phi; char tag[40], tag2[40]; + printf ("Reading parameters from LUT file %s...\n",file->GetName()); + const Float_t bkg[4] = {0, 0.5, 1, 2}; for (Int_t ibkg=0; ibkg<4; ibkg++) { sprintf (tag,"BKG%g",bkg[ibkg]); @@ -149,7 +159,6 @@ void AliMUONFastTracking::ReadLUT(TFile* file) hsigmaphi = (TH3F*)gDirectory->Get("hsigmaphi"); hchi2phi = (TH3F*)gDirectory->Get("hchi2phi"); - printf ("Reading parameters from LUT file %s...\n",file->GetName()); for (Int_t ip=0; ip= fNbinp) { - // printf ("Warning: ip = %d. Set to %d\n",ip,fNbinp-1); - ip = fNbinp-1; - } - if (itheta< 0) { - // printf ("Warning: itheta= %d. Set to 0\n",itheta); - itheta = 0; - } - if (itheta>= fNbintheta) { - // printf ("Warning: itheta = %d. Set to %d\n",itheta,fNbintheta-1); - itheta = fNbintheta-1; - } + if (ip< 0) ip = 0; + if (ip>= fNbinp) ip = fNbinp-1; + if (itheta< 0) itheta = 0; + if (itheta>= fNbintheta) itheta = fNbintheta-1; - if (iphi< 0) { - printf ("Warning: iphi= %d. Set to 0\n",iphi); - iphi = 0; - } - if (iphi>= fNbinphi) { - printf ("Warning: iphi = %d. Set to %d\n",iphi,fNbinphi-1); - iphi = fNbinphi-1; - } + if (iphi< 0) iphi = 0; + if (iphi>= fNbinphi) iphi = fNbinphi-1; } void AliMUONFastTracking::GetSplit(Int_t ip, Int_t itheta, @@ -637,67 +628,6 @@ void AliMUONFastTracking::SetSpline(){ printf ("...done\n"); } -void AliMUONFastTracking::SmearMuon(Float_t pgen, Float_t thetagen, Float_t phigen, - Int_t charge, Float_t &psmear, Float_t &thetasmear, - Float_t &phismear, Float_t &eff, Float_t &acc){ - - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // IMPORTANT NOTICE TO THE USER - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // THIS METHOD HAS BEEN REPLACED BY AliFastMuonTrackingEff::Evaluate() - // AND WILL BE DELETED SOON - // DO NOT USE THIS METHOD - // - - printf ("AliMUONFastTracking::SmearMuon() THIS METHOD IS OBSOLETE "); - printf ("PLEASE REFER TO AliFastMuonTrackingEff::Evaluate()\n"); - // angles are in degrees - - Double_t meanp = MeanP (pgen, thetagen, phigen, charge); - Double_t sigmap = SigmaP (pgen, thetagen, phigen, charge); - Double_t sigma1p = Sigma1P(pgen, thetagen, phigen, charge); - Double_t normg2 = NormG2 (pgen, thetagen, phigen, charge); - Double_t meang2 = MeanG2 (pgen, thetagen, phigen, charge); - Double_t sigmag2 = SigmaG2(pgen, thetagen, phigen, charge); - - printf ("fBkg = %g normg2 (100,5,0,1) = %g \n",fBkg,NormG2(100,5,0,1)); - printf ("fBkg = %g meang2 (100,5,0,1) = %g \n",fBkg,MeanG2(100,5,0,1)); - printf ("fBkg = %g sigmag2 (100,5,0,1) = %g \n",fBkg,SigmaG2(100,5,0,1)); - Int_t ip,itheta,iphi; - GetIpIthetaIphi(pgen, thetagen, phigen, charge, ip, itheta, iphi); - if (sigmap == 0) { - if (fPrintLevel>0) { - printf ("WARNING!!! sigmap=0: "); - printf ("ip= %d itheta = %d iphi = %d ", ip, itheta, iphi); - printf ("p= %f theta = %f phi = %f\n", pgen, thetagen, phigen); - } - } - - if (fPrintLevel>1) printf ("setting parameters: meanp = %f sigmap = %f sigma1p = %f normg2 = %f meang2 = %f sigmag2 = %f \n",meanp,sigmap,sigma1p,normg2,meang2,sigmag2); - fFitp->SetParameters(meanp,sigmap,sigma1p,normg2,meang2,sigmag2); - - Double_t meantheta = MeanTheta (pgen, thetagen, phigen, charge); - Double_t sigmatheta = SigmaTheta(pgen, thetagen, phigen, charge); - Double_t meanphi = MeanPhi (pgen, thetagen, phigen, charge); - Double_t sigmaphi = SigmaPhi (pgen, thetagen, phigen, charge); - - // components different from ip=0 have the RMS bigger than mean - Float_t ptp[3] = { 1.219576,-0.354764,-0.690117 }; - Float_t ptph[3] = { 0.977522, 0.016269, 0.023158 }; - Float_t pphp[3] = { 1.303256,-0.464847,-0.869322 }; - psmear = pgen + fFitp->GetRandom(); - Float_t dp = psmear - pgen; - if (ip==0) sigmaphi *= pphp[0] + pphp[1] * dp + pphp[2] * dp*dp; - phismear = phigen + gRandom->Gaus(meanphi, sigmaphi); - Float_t dphi = phismear - phigen; - - if (ip==0) sigmatheta *= ptp[0] + ptp[1] * dp + ptp[2] * dp*dp; - if (ip==0) sigmatheta *= ptph[0] + ptph[1] * dphi + ptph[2] * dphi*dphi; - thetasmear = thetagen + gRandom->Gaus(meantheta,sigmatheta); - eff = Efficiency(pgen, thetagen, phigen, charge); - acc = Acceptance(pgen, thetagen, phigen, charge); -} - void AliMUONFastTracking::SetBackground(Float_t bkg){ // linear interpolation of the parameters in the LUT between 2 values where // the background has been actually calculated @@ -772,7 +702,14 @@ void AliMUONFastTracking::SetBackground(Float_t bkg){ SetSpline(); } - +TF1* AliMUONFastTracking::GetFitP(Int_t ip,Int_t itheta,Int_t iphi) { + if (!fFitp[ip][itheta][iphi]) { + fFitp[ip][itheta][iphi] = new TF1("fit1",FitP,-20.,20.,6); + fFitp[ip][itheta][iphi]->SetNpx(500); + fFitp[ip][itheta][iphi]->SetParameters(0,0,0,0,0,0); + } + return fFitp[ip][itheta][iphi]; +} // to guarantee a safe extrapolation for sigmag2 to 0 +enum LUTClusterType {kOld, kNew}; + class AliMUONFastTracking : public TObject { public: static AliMUONFastTracking* Instance(); @@ -39,12 +41,10 @@ class AliMUONFastTracking : public TObject { void SetSpline(); Float_t GetBackground() {return fBkg;} + void SetLUTClusterFinder(LUTClusterType clusterFinder) { fClusterFinder = clusterFinder;} void SetBackground(Float_t bkg); void UseSpline (Int_t splineSwitch=1) {fSpline = splineSwitch;} - void SmearMuon(Float_t pgen, Float_t thetagen, Float_t phigen, Int_t charge, - Float_t &psmear, Float_t &thetasmear, Float_t &phismear, - Float_t &eff, Float_t &acc); - TF1* GetFitP() {return fFitp;} + TF1* GetFitP(Int_t ip, Int_t itheta, Int_t iphi); private: AliMUONFastTracking(); AliMUONFastTracking(Float_t bkg){;} @@ -64,7 +64,7 @@ class AliMUONFastTracking : public TObject { Float_t fDeltaPhi; Int_t fPrintLevel; Float_t fBkg; - TF1 *fFitp; // func for psmear-pgen distr + TF1 *fFitp[20][20][20]; // func for psmear-pgen distr AliMUONFastTrackingEntry *fEntry[20][20][20][4]; // array of LUT parameters AliMUONFastTrackingEntry *fCurrentEntry[20][20][20]; // array of LUT parameters public: @@ -76,6 +76,7 @@ class AliMUONFastTracking : public TObject { TSpline3 *fSplineSigmaphi[200][3]; //! protected: Int_t fSpline; + LUTClusterType fClusterFinder; static AliMUONFastTracking* fgMUONFastTracking; //!Pointer to single instance ClassDef(AliMUONFastTracking,1) // Fast MUON Tracking Data Handler }; -- 2.39.3