]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FASTSIM/AliFastMuonTrackingRes.cxx
Coding conventions (Annalisa)
[u/mrichter/AliRoot.git] / FASTSIM / AliFastMuonTrackingRes.cxx
CommitLineData
6255180c 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
d53fc881 16/*
17$Log$
9a226b7e 18Revision 1.6 2003/11/13 14:21:57 morsch
19Coding Rule violation corrections.
20
041f7f97 21Revision 1.5 2003/08/13 17:37:29 hristov
22Bug fix (Alpha)
23
de4a225a 24Revision 1.4 2003/08/05 16:14:20 morsch
25Some problems with too big fluctuations corrected. (A. de Falco)
26
d53fc881 27Revision 1.1 2003/01/06 10:13:09 morsch
28First commit.
29
30*/
6255180c 31
041f7f97 32// Implementation of AliFastResponse for the Muon Spectrometer resolution.
33// The response depends on the charge of the muon and
34// the background level.
35// The class uses the instance of an object of type AliMUONFastTracking to
36// obtain the smearing parameters.
37// Author: andreas.morsch@cern.ch
38
6255180c 39#include "AliFastMuonTrackingRes.h"
40#include "AliMUONFastTracking.h"
41#include <TRandom.h>
42#include <TF1.h>
43
44ClassImp(AliFastMuonTrackingRes)
45
46
47AliFastMuonTrackingRes::AliFastMuonTrackingRes() :
48 AliFastResponse("Resolution", "Muon Tracking Resolution")
49{
041f7f97 50// Deafault constructor
6255180c 51 SetBackground();
52}
53
54void AliFastMuonTrackingRes::Init()
55{
041f7f97 56// Initialisation
6255180c 57 fFastTracking = AliMUONFastTracking::Instance();
58 fFastTracking->Init(fBackground);
59}
60
61
62
63void AliFastMuonTrackingRes::Evaluate(Float_t p, Float_t theta , Float_t phi,
64 Float_t& pS, Float_t& thetaS, Float_t& phiS)
65{
041f7f97 66//
67// Evaluate Gaussian smearing from given kinematics
68//
6255180c 69
70 Double_t meanp = fFastTracking->MeanP (p, theta, phi, Int_t(fCharge));
71 Double_t sigmap = fFastTracking->SigmaP (p, theta, phi, Int_t(fCharge));
72 Double_t sigma1p = fFastTracking->Sigma1P(p, theta, phi, Int_t(fCharge));
73 Double_t normg2 = fFastTracking->NormG2 (p, theta, phi, Int_t(fCharge));
74 Double_t meang2 = fFastTracking->MeanG2 (p, theta, phi, Int_t(fCharge));
75 Double_t sigmag2 = fFastTracking->SigmaG2(p, theta, phi, Int_t(fCharge));
76
77 Int_t ip,itheta,iphi;
6255180c 78 fFastTracking->GetIpIthetaIphi(p, theta, phi, Int_t(fCharge), ip, itheta, iphi);
d53fc881 79 TF1* fitp = fFastTracking->GetFitP(ip,itheta,iphi);
80
81 Float_t curmeanp = fitp->GetParameter(0);
82 Float_t cursigmap = fitp->GetParameter(1);
83 Float_t cursigma1p = fitp->GetParameter(2);
84 Float_t curnormg2 = fitp->GetParameter(3);
85 Float_t curmeang2 = fitp->GetParameter(4);
86 Float_t cursigmag2 = fitp->GetParameter(5);
87 if (curmeanp != meanp || cursigmap != sigmap || cursigma1p != sigma1p ||
88 curnormg2 != normg2 || curmeang2 != meang2 || cursigmag2 != sigmag2){
89 printf ("Setting new parameters for ip=%d itheta=%d iphi=%d\n",ip,itheta,iphi);
90 fitp->SetParameters(meanp,sigmap,sigma1p,normg2,meang2,sigmag2);
6255180c 91 }
6255180c 92
93 Double_t meantheta = fFastTracking->MeanTheta (p, theta, phi, Int_t(fCharge));
94 Double_t sigmatheta = fFastTracking->SigmaTheta(p, theta, phi, Int_t(fCharge));
95 Double_t meanphi = fFastTracking->MeanPhi (p, theta, phi, Int_t(fCharge));
96 Double_t sigmaphi = fFastTracking->SigmaPhi (p, theta, phi, Int_t(fCharge));
d53fc881 97
de4a225a 98 if (sigmatheta<0 || sigmaphi<0)
d53fc881 99 printf ("bin %d %d %d sigmatheta = %f, sigmaphi = %f\n",
100 ip,itheta,iphi,sigmatheta,sigmaphi);
6255180c 101 // Components different from ip=0 have the RMS bigger than mean
102 Float_t ptp[3] = { 1.219576,-0.354764,-0.690117 };
103 Float_t ptph[3] = { 0.977522, 0.016269, 0.023158 };
104 Float_t pphp[3] = { 1.303256,-0.464847,-0.869322 };
105
106 // Smeared momentum
d53fc881 107 pS = -1.;
108 // Float_t dpmax = 5. + ip * 2.5;
109 // Float_t dpmax = 5. + ip * 2;
110 Float_t dpmax;
9a226b7e 111 if (sigmag2<999.) dpmax = 5. * TMath::Abs(sigmap + sigmag2);
112 else dpmax = 5. * TMath::Abs(sigmap);
d53fc881 113 Float_t dp = 100;
114 while (pS<0 || TMath::Abs(dp)>dpmax) {
115 pS = p + fitp->GetRandom();
116 dp = pS - p;
117 }
6255180c 118 // Smeared phi
d53fc881 119 Float_t sigmaphiold=sigmaphi;
6255180c 120 if (ip==0) sigmaphi *= pphp[0] + pphp[1] * dp + pphp[2] * dp*dp;
d53fc881 121 if (sigmaphi<0.5 * sigmaphiold) sigmaphi = 0.5 * sigmaphiold;
122 if (sigmaphi>2. * sigmaphiold) sigmaphi = 2. * sigmaphiold;
6255180c 123 phiS = phi + gRandom->Gaus(meanphi, sigmaphi);
124 Float_t dphi = phiS - phi;
125 // Smeared theta
d53fc881 126 Float_t sigmathetaold=sigmatheta;
6255180c 127 if (ip==0) sigmatheta *= ptp[0] + ptp[1] * dp + ptp[2] * dp*dp;
128 if (ip==0) sigmatheta *= ptph[0] + ptph[1] * dphi + ptph[2] * dphi*dphi;
d53fc881 129 if (sigmatheta<0.5 * sigmathetaold) sigmatheta = 0.5 * sigmathetaold;
130 if (sigmatheta>2. * sigmathetaold) sigmatheta = 2. * sigmathetaold;
6255180c 131 thetaS = theta + gRandom->Gaus(meantheta,sigmatheta);
132}
133
134
135
136
137
138