Added the possibility to use a manually set up TPC BB definition
[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//_________________________________________________________________________________________________
64129b35 29AliRsnCutPIDNSigma::AliRsnCutPIDNSigma() :
30 AliRsnCut("cut", AliRsnTarget::kDaughter),
31 fSpecies(AliPID::kUnknown),
32 fDetector(kDetectors),
33 fRejectUnmatched(kFALSE),
34 fMomMin(0.0),
35 fMomMax(1E20),
36 fNSigma(1E20)
37{
38//
39// Main constructor.
40//
41}
42
43//_________________________________________________________________________________________________
c865cb1d 44AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
45(const char *name, AliPID::EParticleType species, EDetector det, Double_t nsigma) :
64129b35 46 AliRsnCut(name, AliRsnTarget::kDaughter),
c865cb1d 47 fSpecies(species),
48 fDetector(det),
64129b35 49 fRejectUnmatched(kFALSE),
c865cb1d 50 fMomMin(0.0),
f34f960b 51 fMomMax(1E20),
64129b35 52 fNSigma(nsigma)
c865cb1d 53{
54//
55// Main constructor.
56//
57}
58
59//_________________________________________________________________________________________________
60AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
61(const AliRsnCutPIDNSigma& copy) :
62 AliRsnCut(copy),
63 fSpecies(copy.fSpecies),
64 fDetector(copy.fDetector),
64129b35 65 fRejectUnmatched(copy.fRejectUnmatched),
c865cb1d 66 fMomMin(copy.fMomMin),
67 fMomMax(copy.fMomMax),
64129b35 68 fNSigma(copy.fNSigma)
c865cb1d 69{
70//
71// Copy constructor.
72//
73}
74
75//_________________________________________________________________________________________________
76AliRsnCutPIDNSigma& AliRsnCutPIDNSigma::operator=(const AliRsnCutPIDNSigma& copy)
77{
78//
79// Assignment operator
80//
81
82 AliRsnCut::operator=(copy);
83
84 fSpecies = copy.fSpecies;
85 fDetector = copy.fDetector;
64129b35 86 fRejectUnmatched = copy.fRejectUnmatched;
c865cb1d 87 fMomMin = copy.fMomMin;
88 fMomMax = copy.fMomMax;
64129b35 89 fNSigma = copy.fNSigma;
c865cb1d 90
91 return (*this);
92}
93
94//_________________________________________________________________________________________________
95Bool_t AliRsnCutPIDNSigma::IsSelected(TObject *object)
96{
97//
98// Cut checker.
99//
100
101 // coherence check
102 if (!TargetOK(object)) return kFALSE;
103
104 // check initialization of PID object
105 AliPIDResponse *pid = fEvent->GetPIDResponse();
106 if (!pid) {
107 AliFatal("NULL PID response");
108 return kFALSE;
109 }
110
111 // get reference momentum, for range cut
112 Double_t momentum = -1.0;
64129b35 113 AliVTrack *vtrack = fDaughter->Ref2Vtrack();
114 if (!vtrack) {
c865cb1d 115 AliDebugClass(2, "Referenced daughter is not a track");
116 return kFALSE;
117 }
118 if (fDetector == kTPC)
64129b35 119 momentum = vtrack->GetTPCmomentum();
c865cb1d 120 else
64129b35 121 momentum = vtrack->P();
c865cb1d 122
64129b35 123 // check momentum range
f34f960b 124 if (momentum < fMomMin || momentum > fMomMax) {
125 AliDebugClass(2, Form("Track momentum = %.5f, outside allowed range [%.2f - %.2f]", momentum, fMomMin, fMomMax));
126 return kFALSE;
c865cb1d 127 }
128
c865cb1d 129 // check PID
64129b35 130 Bool_t matched;
131 Double_t nsigma;
c865cb1d 132 switch (fDetector) {
133 case kITS:
64129b35 134 matched = IsITS(vtrack);
135 nsigma = pid->NumberOfSigmasITS(vtrack, fSpecies);
c865cb1d 136 break;
137 case kTPC:
64129b35 138 matched = IsTPC(vtrack);
139 nsigma = pid->NumberOfSigmasTPC(vtrack, fSpecies);
c865cb1d 140 break;
141 case kTOF:
64129b35 142 matched = IsTOF(vtrack);
143 nsigma = pid->NumberOfSigmasTOF(vtrack, fSpecies);
c865cb1d 144 break;
145 default:
64129b35 146 AliError("Bad detector chosen. Rejecting track");
c865cb1d 147 return kFALSE;
148 }
149
64129b35 150 // determine cut result
151 if (fRejectUnmatched && (matched == kFALSE)) {
152 AliDebugClass(2, "Required to reject unmatched traks, and this track is not matched in the detector");
153 return kFALSE;
154 } else {
155 AliDebugClass(2, Form("Nsigma = %.5f, maximum allowed = %.2f", nsigma, fNSigma));
156 if (TMath::Abs(nsigma) <= fNSigma) {
157 AliDebugClass(2, "Track accepted");
158 return kTRUE;
159 } else {
160 AliDebugClass(2, "Track rejected");
161 return kFALSE;
162 }
163 }
c865cb1d 164}
165
166//_________________________________________________________________________________________________
167void AliRsnCutPIDNSigma::Print(const Option_t *) const
168{
169//
170// Print information on this cut
171//
172
4f926d1d 173 Char_t mom[200], det[100], match[200];
c865cb1d 174
175 if (fRejectUnmatched)
e187bd70 176 snprintf(match, 200, "Unmatched tracks are rejected");
c865cb1d 177 else
e187bd70 178 snprintf(match, 200, "No check on track matching");
c865cb1d 179
180 switch (fDetector) {
4f926d1d 181 case kITS: snprintf(det, 3, "ITS"); break;
182 case kTPC: snprintf(det, 3, "TPC"); break;
183 case kTOF: snprintf(det, 3, "TOF"); break;
184 default : snprintf(det, 3, "undefined");
c865cb1d 185 }
186
187 AliInfo(Form("Cut name : %s", GetName()));
188 AliInfo(Form("--> PID detector : %s", det));
189 AliInfo(Form("--> match criteria: %s", match));
190 AliInfo(Form("--> momentum range: %s", mom));
191}