two track study as function of pt
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDNSigma.cxx
CommitLineData
c865cb1d 1//
2// Class AliRsnCutPIDNSigma
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
19#include "AliPIDResponse.h"
20#include "AliAnalysisManager.h"
21#include "AliInputEventHandler.h"
22#include "AliMultiInputEventHandler.h"
23
24#include "AliRsnCutPIDNSigma.h"
25
26ClassImp(AliRsnCutPIDNSigma)
27
28//_________________________________________________________________________________________________
29AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
30(const char *name, AliPID::EParticleType species, EDetector det, Double_t nsigma) :
31 AliRsnCut(name, AliRsnCut::kDaughter, -nsigma, nsigma),
32 fSpecies(species),
33 fDetector(det),
34 fMomMin(0.0),
f34f960b 35 fMomMax(1E20),
c865cb1d 36 fRejectUnmatched(kFALSE)
37{
38//
39// Main constructor.
40//
41}
42
43//_________________________________________________________________________________________________
44AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
45(const AliRsnCutPIDNSigma& copy) :
46 AliRsnCut(copy),
47 fSpecies(copy.fSpecies),
48 fDetector(copy.fDetector),
49 fMomMin(copy.fMomMin),
50 fMomMax(copy.fMomMax),
c865cb1d 51 fRejectUnmatched(copy.fRejectUnmatched)
52{
53//
54// Copy constructor.
55//
56}
57
58//_________________________________________________________________________________________________
59AliRsnCutPIDNSigma& AliRsnCutPIDNSigma::operator=(const AliRsnCutPIDNSigma& copy)
60{
61//
62// Assignment operator
63//
64
65 AliRsnCut::operator=(copy);
66
67 fSpecies = copy.fSpecies;
68 fDetector = copy.fDetector;
69 fMomMin = copy.fMomMin;
70 fMomMax = copy.fMomMax;
c865cb1d 71 fRejectUnmatched = copy.fRejectUnmatched;
72
73 return (*this);
74}
75
76//_________________________________________________________________________________________________
77Bool_t AliRsnCutPIDNSigma::IsSelected(TObject *object)
78{
79//
80// Cut checker.
81//
82
83 // coherence check
84 if (!TargetOK(object)) return kFALSE;
85
86 // check initialization of PID object
87 AliPIDResponse *pid = fEvent->GetPIDResponse();
88 if (!pid) {
89 AliFatal("NULL PID response");
90 return kFALSE;
91 }
92
93 // get reference momentum, for range cut
94 Double_t momentum = -1.0;
f34f960b 95 if (!fDaughter->Ref2Vtrack()) {
c865cb1d 96 AliDebugClass(2, "Referenced daughter is not a track");
97 return kFALSE;
98 }
99 if (fDetector == kTPC)
f34f960b 100 momentum = fDaughter->Ref2Vtrack()->GetTPCmomentum();
c865cb1d 101 else
102 momentum = fDaughter->GetRef()->P();
103
104 // check momentum range, if required
f34f960b 105 if (momentum < fMomMin || momentum > fMomMax) {
106 AliDebugClass(2, Form("Track momentum = %.5f, outside allowed range [%.2f - %.2f]", momentum, fMomMin, fMomMax));
107 return kFALSE;
c865cb1d 108 }
109
110 // matching check, if required
111 if (fRejectUnmatched) {
112 switch (fDetector) {
113 case kITS:
f34f960b 114 if (!IsITS(fDaughter->Ref2Vtrack())) {
c865cb1d 115 AliDebug(3, "Rejecting track not matched in ITS");
116 return kFALSE;
117 }
118 break;
119 case kTPC:
f34f960b 120 if (!IsTPC(fDaughter->Ref2Vtrack())) {
c865cb1d 121 AliDebug(3, "Rejecting track not matched in TPC");
122 return kFALSE;
123 }
124 break;
125 case kTOF:
f34f960b 126 if (!IsTOF(fDaughter->Ref2Vtrack())) {
c865cb1d 127 AliDebug(3, "Rejecting track not matched in TOF");
128 return kFALSE;
129 }
130 break;
131 default:
132 AliWarning("Required to reject unmatched tracks, but no detector defined. Track rejected");
133 return kFALSE;
134 }
135 }
136
137 // check PID
138 // the number of sigmas is set as cut value, which is then checked
139 // using the basic functions available in AliRsnCut
140 switch (fDetector) {
141 case kITS:
142 fCutValueD = pid->NumberOfSigmasITS(fDaughter->GetRef(), fSpecies);
143 break;
144 case kTPC:
145 fCutValueD = pid->NumberOfSigmasTPC(fDaughter->GetRef(), fSpecies);
146 break;
147 case kTOF:
148 fCutValueD = pid->NumberOfSigmasTOF(fDaughter->GetRef(), fSpecies);
149 break;
150 default:
c865cb1d 151 return kFALSE;
152 }
153
154 return OkRangeD();
155}
156
157//_________________________________________________________________________________________________
158void AliRsnCutPIDNSigma::Print(const Option_t *) const
159{
160//
161// Print information on this cut
162//
163
4f926d1d 164 Char_t mom[200], det[100], match[200];
c865cb1d 165
166 if (fRejectUnmatched)
e187bd70 167 snprintf(match, 200, "Unmatched tracks are rejected");
c865cb1d 168 else
e187bd70 169 snprintf(match, 200, "No check on track matching");
c865cb1d 170
171 switch (fDetector) {
4f926d1d 172 case kITS: snprintf(det, 3, "ITS"); break;
173 case kTPC: snprintf(det, 3, "TPC"); break;
174 case kTOF: snprintf(det, 3, "TOF"); break;
175 default : snprintf(det, 3, "undefined");
c865cb1d 176 }
177
178 AliInfo(Form("Cut name : %s", GetName()));
179 AliInfo(Form("--> PID detector : %s", det));
180 AliInfo(Form("--> match criteria: %s", match));
181 AliInfo(Form("--> momentum range: %s", mom));
182}