]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutBetheBloch.cxx
619042c7284b0b32c9028fff221e731ad06b5044
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutBetheBloch.cxx
1 //
2 // Class AliRsnCutBetheBloch
3 //
4 // General implementation of a single cut strategy, which can be:
5 // - a value contained in a given interval  [--> IsBetween()   ]
6 // - a value equal to a given reference     [--> MatchesValue()]
7 //
8 // In all cases, the reference value(s) is (are) given as data members
9 // and each kind of cut requires a given value type (Int, UInt, Double),
10 // but the cut check procedure is then automatized and chosen thanks to
11 // an enumeration of the implemented cut types.
12 // At the end, the user (or any other point which uses this object) has
13 // to use the method IsSelected() to check if this cut has been passed.
14 //
15 // authors: Martin Vala (martin.vala@cern.ch)
16 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
17 //
18 #include "TMath.h"
19
20 #include "AliExternalTrackParam.h"
21
22 #include "AliRsnDaughter.h"
23 #include "AliRsnCutBetheBloch.h"
24
25 ClassImp(AliRsnCutBetheBloch)
26
27 //_________________________________________________________________________________________________
28 AliRsnCutBetheBloch::AliRsnCutBetheBloch() :
29   AliRsnCut(AliRsnCut::kDaughter),
30   fCorrect(kTRUE),
31   fMIP(50.0),
32   fType(AliPID::kUnknown)
33 {
34 //
35 // Default constructor.
36 //
37
38   fConst[0] = fConst[1] = fConst[2] = fConst[3] = fConst[4] = 0.0;
39 }
40
41 //_________________________________________________________________________________________________
42 AliRsnCutBetheBloch::AliRsnCutBetheBloch
43 (const char *name, Double_t fractionRange, AliPID::EParticleType type, Double_t mip, Bool_t correct) :
44   AliRsnCut(name, AliRsnCut::kDaughter, 0.0, fractionRange),
45   fCorrect(correct),
46   fMIP(mip),
47   fType(type)
48 {
49 //
50 // Main constructor.
51 // the cut range is the relative fraction of the value:
52 // BB*(1-fraction) < TPC < BB*(1+fraction)
53 // which means:
54 // -fraction < (TPC - BB)/BB < fraction
55 //
56
57   fConst[0] = fConst[1] = fConst[2] = fConst[3] = fConst[4] = 0.0;
58 }
59
60 //_____________________________________________________________________________
61 Double_t AliRsnCutBetheBloch::BetheBloch(AliRsnDaughter * const trackRef)
62 {
63 //
64 // Computes the theoretical dE/dx according to
65 // a given mass hypothesis, from which betaGamma is computed
66 //
67 // This is the empirical ALEPH parameterization of the Bethe-Bloch formula.
68 // It is normalized to 1 at the minimum.
69 //
70 // The default values for the kp* parameters are for ALICE TPC.
71 // The value is computed in MIP units, multiplied by 50 to have it in energy.
72 //
73
74   AliPID pid;
75   Double_t mass = pid.ParticleMass(fType);
76
77   // get the track momentum at the inner wall of TPC: if absent cut is not passed
78   AliExternalTrackParam track(*trackRef->GetRefESDtrack()->GetInnerParam());
79
80   Double_t betaGamma = track.P() / mass;
81   Double_t beta = betaGamma / TMath::Sqrt(1.0 + betaGamma * betaGamma);
82   Double_t aa = TMath::Power(beta, fConst[3]);
83   Double_t bb = TMath::Power(1.0 / betaGamma, fConst[4]);
84
85   bb = TMath::Log(fConst[2] + bb);
86
87   Double_t out = (fConst[1] - aa - bb) * fConst[0] / aa;
88
89   if (fCorrect) {
90     Double_t kMeanCorr = 0.1;
91     Double_t meanCorr = (1 + (out - 1) * kMeanCorr);
92     out *= meanCorr;
93   }
94
95   return out * fMIP;
96 }
97
98 //_____________________________________________________________________________
99 Double_t AliRsnCutBetheBloch::RelDiff(AliRsnDaughter *track)
100 {
101 //
102 // Relative difference between BB value and TPC signal
103 //
104
105   if (!track->GetRefESDtrack()) return -99999.9;
106
107   // compute Bethe-Bloch with the given mass hypothesis
108   Double_t bb = BetheBloch(track);
109   return TMath::Abs((track->GetRefESDtrack()->GetTPCsignal() - bb) / bb);
110 }
111
112 //_________________________________________________________________________________________________
113 Bool_t AliRsnCutBetheBloch::IsSelected(TObject *obj1, TObject* /*obj2*/)
114 {
115 //
116 // Cut checker.
117 //
118
119   // dynamic cast the object into AliRsnDaughter
120   AliRsnDaughter *track = dynamic_cast<AliRsnDaughter*>(obj1);
121   if (!track)
122   {
123     AliError(Form("[%s]: this cut works only with AliRsnDaughter objects", GetName()));
124     return kTRUE;
125   }
126
127   // retrieve the TPC signal
128   AliESDtrack *esd = track->GetRefESDtrack();
129   if (!esd) {
130     AliError("ESD information unavailable");
131     return kTRUE;
132   }
133   if (!track->GetRefESDtrack()->GetInnerParam()) {
134     AliDebug(AliLog::kDebug+2, "Rejecting a track with no info at the TPC inner wall");
135     return kFALSE;
136   }
137
138   // the cut range is the relative fraction of the value:
139   // BB*(1-fraction) < TPC < BB*(1+fraction)
140   // which means:
141   // -fraction < (TPC - BB)/BB < fraction
142   // so we must compute the cut value accordingly
143   fCutValueD = RelDiff(track);
144
145   // then, this cut is checked inside the range
146   return OkRange();
147 }