]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FASTSIM/AliFastMuonTrackingRes.cxx
Some problems with too big fluctuations corrected. (A. de Falco)
[u/mrichter/AliRoot.git] / FASTSIM / AliFastMuonTrackingRes.cxx
index e192c4e506d9c2c8ad627e35dab729b8d474d2c9..6adb6661b9c34ae4b758021378bfc9b715c0c017 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
 
 /*
 $Log$
+Revision 1.1  2003/01/06 10:13:09  morsch
+First commit.
+
 */
 
 #include "AliFastMuonTrackingRes.h"
 */
 
 #include "AliFastMuonTrackingRes.h"
@@ -51,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;
     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);
     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));
   
     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
     // 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
     // Smeared phi
+    Float_t sigmaphiold=sigmaphi;
     if (ip==0) sigmaphi *= pphp[0] + pphp[1] * dp + pphp[2] * dp*dp; 
     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
     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 (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);
 }
 
     thetaS = theta + gRandom->Gaus(meantheta,sigmatheta);
 }