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 "AliESDpid.h"
21 #include "AliAODpidUtil.h"
23 #include "AliRsnCutPIDNSigma.h"
25 ClassImp(AliRsnCutPIDNSigma)
27 //_________________________________________________________________________________________________
28 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma() :
29 AliRsnCut("cut", AliRsnTarget::kDaughter),
30 fSpecies(AliPID::kUnknown),
31 fDetector(kDetectors),
32 fRejectUnmatched(kFALSE),
36 fRanges("AliRsnPIDRange", 0)
43 //_________________________________________________________________________________________________
44 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
45 (const char *name, AliPID::EParticleType species, EDetector det) :
46 AliRsnCut(name, AliRsnTarget::kDaughter),
49 fRejectUnmatched(kFALSE),
53 fRanges("AliRsnPIDRange", 0)
60 //_________________________________________________________________________________________________
61 AliRsnCutPIDNSigma::AliRsnCutPIDNSigma
62 (const AliRsnCutPIDNSigma ©) :
64 fSpecies(copy.fSpecies),
65 fDetector(copy.fDetector),
66 fRejectUnmatched(copy.fRejectUnmatched),
77 //_________________________________________________________________________________________________
78 AliRsnCutPIDNSigma &AliRsnCutPIDNSigma::operator=(const AliRsnCutPIDNSigma ©)
81 // Assignment operator
84 AliRsnCut::operator=(copy);
87 fSpecies = copy.fSpecies;
88 fDetector = copy.fDetector;
89 fRejectUnmatched = copy.fRejectUnmatched;
91 fRanges = copy.fRanges;
96 //__________________________________________________________________________________________________
97 void AliRsnCutPIDNSigma::InitMyPID(Bool_t isMC, Bool_t isESD)
100 // Initialize manual PID object
104 fMyPID = new AliESDpid(isMC);
106 fMyPID = new AliAODpidUtil(isMC);
109 //_________________________________________________________________________________________________
110 Bool_t AliRsnCutPIDNSigma::IsSelected(TObject *object)
114 // As usual, there are 'kFALSE' exit points whenever one of the conditions is not passed,
115 // and at the end, it returns kTRUE since it bypassed all possible exit points.
119 if (!TargetOK(object)) return kFALSE;
121 // check initialization of PID object
122 // if manual PID is used, use that, otherwise get from source event
123 AliPIDResponse *pid = 0x0;
127 pid = fEvent->GetPIDResponse();
129 AliFatal("NULL PID response");
133 // convert input object into AliVTrack
134 // if this fails, the cut cannot be checked
135 AliVTrack *vtrack = fDaughter->Ref2Vtrack();
137 AliDebugClass(2, "Referenced daughter is not a track");
141 // check matching, if required
142 // a) if detector is not matched and matching is required, reject the track
143 // b) if detector is not matched and matching is not required, accept blindly the track
144 // since missing the matching causes one not to be able to rely that detector
145 if (!MatchDetector(vtrack)) {
146 AliDebugClass(2, Form("Detector not matched. fRejectUnmatched = %s --> track is %s", (fRejectUnmatched ? "true" : "false"), (fRejectUnmatched ? "rejected" : "accepted")));
147 return (!fRejectUnmatched);
150 // get reference momentum
151 fTrackMom = (fDetector == kTPC) ? vtrack->GetTPCmomentum() : vtrack->P();
153 // get number of sigmas
156 fTrackNSigma = TMath::Abs(pid->NumberOfSigmasITS(vtrack, fSpecies));
159 fTrackNSigma = TMath::Abs(pid->NumberOfSigmasTPC(vtrack, fSpecies));
162 fTrackNSigma = TMath::Abs(pid->NumberOfSigmasTOF(vtrack, fSpecies));
165 AliError("Bad detector chosen. Rejecting track");
169 // loop on all ranges, and use the one which contains this momentum
170 // if none is found, the cut is not passed
171 Bool_t accept = kFALSE;
172 Int_t i, goodRange = -1, nRanges = fRanges.GetEntriesFast();
173 for (i = 0; i < nRanges; i++) {
174 AliRsnPIDRange *range = (AliRsnPIDRange *)fRanges[i];
175 if (!range) continue;
176 if (!range->IsInRange(fTrackMom)) continue;
179 accept = range->CutPass(fTrackNSigma);
180 AliDebugClass(2, Form("[%s] NSigma = %.3f, max = %.3f, track %s", GetName(), fTrackNSigma, range->NSigmaCut(), (accept ? "accepted" : "rejected")));
185 AliDebugClass(2, Form("[%s] No good range found. Rejecting track", GetName()));
188 AliDebugClass(2, Form("[%s] Mom = %.3f, good range found (#%d), track was %s", GetName(), fTrackMom, goodRange, (accept ? "accepted" : "rejected")));
193 //_________________________________________________________________________________________________
194 void AliRsnCutPIDNSigma::Print(const Option_t *) const
197 // Print information on this cut
200 Char_t mom[200], det[100], match[200];
202 if (fRejectUnmatched)
203 snprintf(match, 200, "Unmatched tracks are rejected");
205 snprintf(match, 200, "No check on track matching");
208 case kITS: snprintf(det, 3, "ITS"); break;
209 case kTPC: snprintf(det, 3, "TPC"); break;
210 case kTOF: snprintf(det, 3, "TOF"); break;
211 default : snprintf(det, 3, "undefined");
214 AliInfo(Form("Cut name : %s", GetName()));
215 AliInfo(Form("--> PID detector : %s", det));
216 AliInfo(Form("--> match criteria: %s", match));
217 AliInfo(Form("--> momentum range: %s", mom));