Included cut on primary vertex into compilation
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutBetheBloch.cxx
CommitLineData
5eb970a4 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 "AliLog.h"
21#include "AliESDtrack.h"
22
23#include "AliRsnDaughter.h"
24#include "AliRsnCutBetheBloch.h"
25
26ClassImp(AliRsnCutBetheBloch)
27
28//_________________________________________________________________________________________________
29AliRsnCutBetheBloch::AliRsnCutBetheBloch() :
30 AliRsnCut(),
31 fCorrect(kTRUE),
cff22d54 32 fMIP(50.0),
33 fType(AliPID::kUnknown)
5eb970a4 34{
35//
36// Default constructor.
37//
38
39 fConst[0] = fConst[1] = fConst[2] = fConst[3] = fConst[4] = 0.0;
40}
41
42//_________________________________________________________________________________________________
43AliRsnCutBetheBloch::AliRsnCutBetheBloch
5eb970a4 44(const char *name, Double_t fractionRange, AliPID::EParticleType type, Double_t mip, Bool_t correct) :
45 AliRsnCut(name, -fractionRange, fractionRange),
46 fCorrect(correct),
cff22d54 47 fMIP(mip),
48 fType(type)
5eb970a4 49{
50//
51// Main constructor.
52// the cut range is the relative fraction of the value:
53// BB*(1-fraction) < TPC < BB*(1+fraction)
54// which means:
55// -fraction < (TPC - BB)/BB < fraction
56//
57
5eb970a4 58 fConst[0] = fConst[1] = fConst[2] = fConst[3] = fConst[4] = 0.0;
59}
60
61//_____________________________________________________________________________
62Double_t AliRsnCutBetheBloch::BetheBloch(AliRsnDaughter *track)
63{
64//
65// Computes the theoretical dE/dx according to
66// a given mass hypothesis, from which betaGamma is computed
67//
68// This is the empirical ALEPH parameterization of the Bethe-Bloch formula.
69// It is normalized to 1 at the minimum.
70//
71// The default values for the kp* parameters are for ALICE TPC.
72// The value is computed in MIP units, multiplied by 50 to have it in energy.
73//
74
cff22d54 75 AliPID pid;
76 Double_t mass = pid.ParticleMass(fType);
77
78 Double_t betaGamma = track->P() / mass;
5eb970a4 79 Double_t beta = betaGamma / TMath::Sqrt(1.0 + betaGamma * betaGamma);
80 Double_t aa = TMath::Power(beta, fConst[3]);
81 Double_t bb = TMath::Power(1.0 / betaGamma, fConst[4]);
82
83 bb = TMath::Log(fConst[2] + bb);
84
85 Double_t out = (fConst[1] - aa - bb) * fConst[0] / aa;
86
87 if (fCorrect)
88 {
89 Double_t kMeanCorr = 0.1;
90 Double_t meanCorr = (1 + (out - 1) * kMeanCorr);
91 out *= meanCorr;
92 }
93
94 return out * fMIP;
95}
96
97//_________________________________________________________________________________________________
98Bool_t AliRsnCutBetheBloch::IsSelected(ETarget tgt, AliRsnDaughter *track)
99{
100//
101// Cut checker.
102//
103
104 // coherence check
105 if (tgt != AliRsnCut::kParticle)
106 {
107 AliError(Form("Wrong target. Skipping cut", GetName()));
108 return kTRUE;
109 }
110
cff22d54 111 // if the required PID of the track is not the same as the
112 // reference of the cut, the cut is automatically skipped
113 if (track->RequiredPID() != fType) return kTRUE;
114
5eb970a4 115 // retrieve the TPC signal
116 AliVParticle *vpart = track->GetRef();
117 AliESDtrack *esd = dynamic_cast<AliESDtrack*>(vpart);
118 if (!esd) {
119 AliError("ESD information unavailable");
120 return kTRUE;
121 }
122
123 // compute Bethe-Bloch with the given mass hypothesis
124 Double_t bb = BetheBloch(track);
125
126 // the cut range is the relative fraction of the value:
127 // BB*(1-fraction) < TPC < BB*(1+fraction)
128 // which means:
129 // -fraction < (TPC - BB)/BB < fraction
130 // so we must compute the cut value accordingly
131 fCutValueD = (esd->GetTPCsignal() - bb) / bb;
132
133 // then, this cut is checked inside the range
134 return OkRange();
135}
136
137//_________________________________________________________________________________________________
e79f56bd 138Bool_t AliRsnCutBetheBloch::IsSelected(ETarget /*tgt*/, AliRsnPairParticle* /*pair*/)
5eb970a4 139{
140//
141// Cut checker
142//
143
144 AliWarning("Cannot apply this cut to pairs");
145 return kTRUE;
146}
147
148//_________________________________________________________________________________________________
e79f56bd 149Bool_t AliRsnCutBetheBloch::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*event*/)
5eb970a4 150{
151//
152// Cut checker
153//
154
155 AliWarning("Cannot apply this cut to events");
156 return kTRUE;
157}
158
159//_________________________________________________________________________________________________
e79f56bd 160Bool_t AliRsnCutBetheBloch::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*ev1*/, AliRsnEvent* /*ev2*/)
5eb970a4 161{
162//
163// Cut checker
164//
165
166 AliWarning("Cannot apply this cut to event mixing");
167 return kTRUE;
168}