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 (const char *name, AliPID::EParticleType species, EDetector det, Double_t nsigma) :
31 AliRsnCut(name, AliRsnCut::kDaughter, -nsigma, nsigma),
36 fRejectUnmatched(kFALSE)
43 //_________________________________________________________________________________________________
44 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
45 (const AliRsnCutPIDNSigma& copy) :
47 fSpecies(copy.fSpecies),
48 fDetector(copy.fDetector),
49 fMomMin(copy.fMomMin),
50 fMomMax(copy.fMomMax),
51 fRejectUnmatched(copy.fRejectUnmatched)
58 //_________________________________________________________________________________________________
59 AliRsnCutPIDNSigma& AliRsnCutPIDNSigma::operator=(const AliRsnCutPIDNSigma& copy)
62 // Assignment operator
65 AliRsnCut::operator=(copy);
67 fSpecies = copy.fSpecies;
68 fDetector = copy.fDetector;
69 fMomMin = copy.fMomMin;
70 fMomMax = copy.fMomMax;
71 fRejectUnmatched = copy.fRejectUnmatched;
76 //_________________________________________________________________________________________________
77 Bool_t AliRsnCutPIDNSigma::IsSelected(TObject *object)
84 if (!TargetOK(object)) return kFALSE;
86 // check initialization of PID object
87 AliPIDResponse *pid = fEvent->GetPIDResponse();
89 AliFatal("NULL PID response");
93 // get reference momentum, for range cut
94 Double_t momentum = -1.0;
95 if (!fDaughter->Ref2Vtrack()) {
96 AliDebugClass(2, "Referenced daughter is not a track");
99 if (fDetector == kTPC)
100 momentum = fDaughter->Ref2Vtrack()->GetTPCmomentum();
102 momentum = fDaughter->GetRef()->P();
104 // check momentum range, if required
105 if (momentum < fMomMin || momentum > fMomMax) {
106 AliDebugClass(2, Form("Track momentum = %.5f, outside allowed range [%.2f - %.2f]", momentum, fMomMin, fMomMax));
110 // matching check, if required
111 if (fRejectUnmatched) {
114 if (!IsITS(fDaughter->Ref2Vtrack())) {
115 AliDebug(3, "Rejecting track not matched in ITS");
120 if (!IsTPC(fDaughter->Ref2Vtrack())) {
121 AliDebug(3, "Rejecting track not matched in TPC");
126 if (!IsTOF(fDaughter->Ref2Vtrack())) {
127 AliDebug(3, "Rejecting track not matched in TOF");
132 AliWarning("Required to reject unmatched tracks, but no detector defined. Track rejected");
138 // the number of sigmas is set as cut value, which is then checked
139 // using the basic functions available in AliRsnCut
142 fCutValueD = pid->NumberOfSigmasITS(fDaughter->GetRef(), fSpecies);
145 fCutValueD = pid->NumberOfSigmasTPC(fDaughter->GetRef(), fSpecies);
148 fCutValueD = pid->NumberOfSigmasTOF(fDaughter->GetRef(), fSpecies);
157 //_________________________________________________________________________________________________
158 void AliRsnCutPIDNSigma::Print(const Option_t *) const
161 // Print information on this cut
164 Char_t mom[200], det[100], match[200];
166 if (fRejectUnmatched)
167 snprintf(match, 200, "Unmatched tracks are rejected");
169 snprintf(match, 200, "No check on track matching");
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");
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));