2 // Class AliRsnCutPIDNSigma
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()]
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.
15 // authors: Martin Vala (martin.vala@cern.ch)
16 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
19 #include "AliPIDResponse.h"
20 #include "AliAnalysisManager.h"
21 #include "AliInputEventHandler.h"
22 #include "AliMultiInputEventHandler.h"
24 #include "AliRsnCutPIDNSigma.h"
26 ClassImp(AliRsnCutPIDNSigma)
28 //_________________________________________________________________________________________________
29 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma() :
30 AliRsnCut("cut", AliRsnTarget::kDaughter),
31 fSpecies(AliPID::kUnknown),
32 fDetector(kDetectors),
33 fRejectUnmatched(kFALSE),
43 //_________________________________________________________________________________________________
44 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
45 (const char *name, AliPID::EParticleType species, EDetector det, Double_t nsigma) :
46 AliRsnCut(name, AliRsnTarget::kDaughter),
49 fRejectUnmatched(kFALSE),
59 //_________________________________________________________________________________________________
60 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
61 (const AliRsnCutPIDNSigma& copy) :
63 fSpecies(copy.fSpecies),
64 fDetector(copy.fDetector),
65 fRejectUnmatched(copy.fRejectUnmatched),
66 fMomMin(copy.fMomMin),
67 fMomMax(copy.fMomMax),
75 //_________________________________________________________________________________________________
76 AliRsnCutPIDNSigma& AliRsnCutPIDNSigma::operator=(const AliRsnCutPIDNSigma& copy)
79 // Assignment operator
82 AliRsnCut::operator=(copy);
84 fSpecies = copy.fSpecies;
85 fDetector = copy.fDetector;
86 fRejectUnmatched = copy.fRejectUnmatched;
87 fMomMin = copy.fMomMin;
88 fMomMax = copy.fMomMax;
89 fNSigma = copy.fNSigma;
94 //_________________________________________________________________________________________________
95 Bool_t AliRsnCutPIDNSigma::IsSelected(TObject *object)
102 if (!TargetOK(object)) return kFALSE;
104 // check initialization of PID object
105 AliPIDResponse *pid = fEvent->GetPIDResponse();
107 AliFatal("NULL PID response");
111 // get reference momentum, for range cut
112 Double_t momentum = -1.0;
113 AliVTrack *vtrack = fDaughter->Ref2Vtrack();
115 AliDebugClass(2, "Referenced daughter is not a track");
118 if (fDetector == kTPC)
119 momentum = vtrack->GetTPCmomentum();
121 momentum = vtrack->P();
123 // check momentum range
124 if (momentum < fMomMin || momentum > fMomMax) {
125 AliDebugClass(2, Form("Track momentum = %.5f, outside allowed range [%.2f - %.2f]", momentum, fMomMin, fMomMax));
134 matched = IsITS(vtrack);
135 nsigma = pid->NumberOfSigmasITS(vtrack, fSpecies);
138 matched = IsTPC(vtrack);
139 nsigma = pid->NumberOfSigmasTPC(vtrack, fSpecies);
142 matched = IsTOF(vtrack);
143 nsigma = pid->NumberOfSigmasTOF(vtrack, fSpecies);
146 AliError("Bad detector chosen. Rejecting track");
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");
155 AliDebugClass(2, Form("Nsigma = %.5f, maximum allowed = %.2f", nsigma, fNSigma));
156 if (TMath::Abs(nsigma) <= fNSigma) {
157 AliDebugClass(2, "Track accepted");
160 AliDebugClass(2, "Track rejected");
166 //_________________________________________________________________________________________________
167 void AliRsnCutPIDNSigma::Print(const Option_t *) const
170 // Print information on this cut
173 Char_t mom[200], det[100], match[200];
175 if (fRejectUnmatched)
176 snprintf(match, 200, "Unmatched tracks are rejected");
178 snprintf(match, 200, "No check on track matching");
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");
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));