Updated documentation (Ivana)
[u/mrichter/AliRoot.git] / FASTSIM / AliFastMuonTrackingRes.cxx
... / ...
CommitLineData
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
16/*
17$Log$
18Revision 1.6 2003/11/13 14:21:57 morsch
19Coding Rule violation corrections.
20
21Revision 1.5 2003/08/13 17:37:29 hristov
22Bug fix (Alpha)
23
24Revision 1.4 2003/08/05 16:14:20 morsch
25Some problems with too big fluctuations corrected. (A. de Falco)
26
27Revision 1.1 2003/01/06 10:13:09 morsch
28First commit.
29
30*/
31
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
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{
50// Deafault constructor
51 SetBackground();
52}
53
54void AliFastMuonTrackingRes::Init()
55{
56// Initialisation
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{
66//
67// Evaluate Gaussian smearing from given kinematics
68//
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;
78 fFastTracking->GetIpIthetaIphi(p, theta, phi, Int_t(fCharge), ip, itheta, iphi);
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);
91 }
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));
97
98 if (sigmatheta<0 || sigmaphi<0)
99 printf ("bin %d %d %d sigmatheta = %f, sigmaphi = %f\n",
100 ip,itheta,iphi,sigmatheta,sigmaphi);
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
107 pS = -1.;
108 // Float_t dpmax = 5. + ip * 2.5;
109 // Float_t dpmax = 5. + ip * 2;
110 Float_t dpmax;
111 if (sigmag2<999.) dpmax = 5. * TMath::Abs(sigmap + sigmag2);
112 else dpmax = 5. * TMath::Abs(sigmap);
113 Float_t dp = 100;
114 while (pS<0 || TMath::Abs(dp)>dpmax) {
115 pS = p + fitp->GetRandom();
116 dp = pS - p;
117 }
118 // Smeared phi
119 Float_t sigmaphiold=sigmaphi;
120 if (ip==0) sigmaphi *= pphp[0] + pphp[1] * dp + pphp[2] * dp*dp;
121 if (sigmaphi<0.5 * sigmaphiold) sigmaphi = 0.5 * sigmaphiold;
122 if (sigmaphi>2. * sigmaphiold) sigmaphi = 2. * sigmaphiold;
123 phiS = phi + gRandom->Gaus(meanphi, sigmaphi);
124 Float_t dphi = phiS - phi;
125 // Smeared theta
126 Float_t sigmathetaold=sigmatheta;
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;
129 if (sigmatheta<0.5 * sigmathetaold) sigmatheta = 0.5 * sigmathetaold;
130 if (sigmatheta>2. * sigmathetaold) sigmatheta = 2. * sigmathetaold;
131 thetaS = theta + gRandom->Gaus(meantheta,sigmatheta);
132}
133
134
135
136
137
138