2 // Class AliRsnCutESD2010
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 <Riostream.h>
21 #include "AliESDpid.h"
22 #include "AliTOFT0maker.h"
23 #include "AliTOFcalib.h"
24 #include "AliCDBManager.h"
25 #include "AliITSPIDResponse.h"
27 #include "AliRsnEvent.h"
28 #include "AliRsnDaughter.h"
29 #include "AliRsnCutESD2010.h"
31 ClassImp(AliRsnCutESD2010)
33 //_________________________________________________________________________________________________
34 AliRsnCutESD2010::AliRsnCutESD2010
35 (const char *name, Bool_t isMC) :
36 AliRsnCut(name, AliRsnCut::kDaughter, 0.0, 0.0),
62 //_________________________________________________________________________________________________
63 AliRsnCutESD2010::AliRsnCutESD2010
64 (const AliRsnCutESD2010& copy) :
67 fCheckITS(copy.fCheckITS),
68 fCheckTPC(copy.fCheckTPC),
69 fCheckTOF(copy.fCheckTOF),
70 fUseITSTPC(copy.fUseITSTPC),
71 fUseITSSA(copy.fUseITSSA),
73 fMaxITSPIDmom(copy.fMaxITSPIDmom),
74 fMaxITSband(copy.fMaxITSband),
75 fTPCpLimit(copy.fTPCpLimit),
76 fMinTPCband(copy.fMinTPCband),
77 fMaxTPCband(copy.fMaxTPCband),
78 fESDpid(copy.fESDpid),
79 fESDtrackCutsTPC(copy.fESDtrackCutsTPC),
80 fESDtrackCutsITS(copy.fESDtrackCutsITS),
81 fMinTOF(copy.fMinTOF),
91 for (i = 0; i < 5; i++) fTPCpar[i] = copy.fTPCpar[i];
94 //_________________________________________________________________________________________________
95 AliRsnCutESD2010& AliRsnCutESD2010::operator=(const AliRsnCutESD2010& copy)
98 // Assignment operator
101 AliRsnCut::operator=(copy);
105 fCheckITS = copy.fCheckITS;
106 fCheckTPC = copy.fCheckTPC;
107 fCheckTOF = copy.fCheckTOF;
108 fUseITSTPC = copy.fUseITSTPC;
109 fUseITSSA = copy.fUseITSSA;
111 fMaxITSPIDmom = copy.fMaxITSPIDmom;
112 fMaxITSband = copy.fMaxITSband;
113 fTPCpLimit = copy.fTPCpLimit;
114 fMinTPCband = copy.fMinTPCband;
115 fMaxTPCband = copy.fMaxTPCband;
116 fMinTOF = copy.fMinTOF;
117 fMaxTOF = copy.fMaxTOF;
118 fESDpid = copy.fESDpid;
121 for (i = 0; i < 5; i++) fTPCpar[i] = copy.fTPCpar[i];
124 fESDtrackCutsTPC = copy.fESDtrackCutsTPC;
125 fESDtrackCutsITS = copy.fESDtrackCutsITS;
130 //_________________________________________________________________________________________________
131 void AliRsnCutESD2010::SetMC(Bool_t isMC)
134 // Sets some aspects of cuts depending on the fact that runs on MC or not
139 AliITSPIDResponse itsresponse(fIsMC);
140 fESDpid.GetITSResponse() = itsresponse;
143 //_________________________________________________________________________________________________
144 Bool_t AliRsnCutESD2010::IsSelected(TObject *object)
150 // coherence check: require an ESD track
151 AliRsnDaughter *daughter = dynamic_cast<AliRsnDaughter*>(object);
152 if (!daughter) return kFALSE;
153 AliESDtrack *track = daughter->GetRefESDtrack();
154 if (!track) return kFALSE;
156 // if no reference event, skip
157 AliRsnEvent *rsn = AliRsnTarget::GetCurrentEvent();
158 if (!rsn) return kFALSE;
159 fESDpid.SetTOFResponse(rsn->GetRefESD(), AliESDpid::kTOF_T0);
161 // check quality and track type and reject tracks not passing this step
162 if (!OkQuality(track)) {
163 AliDebug(AliLog::kDebug + 2, "Failed quality cut");
167 // ITS PID can be checked always
168 // if PID is not required, the flag is sed as
169 // if the cut was alsways passed
170 Bool_t okITSpid = OkITSPID(track);
171 if (!fCheckITS) okITSpid = kTRUE;
173 // TPC PID can be checked only for TPC+ITS tracks
174 // if PID is not required, the flag is sed as
175 // if the cut was alsways passed
176 Bool_t okTPCpid = kFALSE;
177 if (IsITSTPC(track)) okTPCpid = OkTPCPID(track);
178 if (!fCheckTPC) okTPCpid = kTRUE;
180 // TOF PID can be checked only if TOF is matched
181 // if PID is not required, the flag is sed as
182 // if the cut was alsways passed
183 Bool_t okTOFpid = kFALSE;
184 if (IsITSTPC(track) && MatchTOF(track)) okTOFpid = OkTOFPID(track);
185 if (!fCheckTOF) okTOFpid = kTRUE;
187 // now combine all outcomes according to the different possibilities:
188 // -- ITS standalone:
189 // --> only ITS PID, always
191 // --> ITS PID, only for momenta lower than 'fMaxITSPIDmom' and when the ITSpid flag is active
192 // --> TPC PID, always --> MASTER (first to be checked, if fails, track is rejected)
193 // --> TOF PID, only if matched
194 if (IsITSSA(track)) {
196 AliDebug(AliLog::kDebug + 2, "ITS standalone track --> ITS PID failed");
199 } else { // checking IsITSTPC() is redundant due to OkQuality() cut check
201 AliDebug(AliLog::kDebug + 2, "ITS+TPC track --> TPC PID failed");
203 } else if (MatchTOF(track) && !okTOFpid) {
204 AliDebug(AliLog::kDebug + 2, "ITS+TPC track --> TOF matched but TOF PID failed");
206 } else if (track->IsOn(AliESDtrack::kITSpid) && track->P() <= fMaxITSPIDmom && !okITSpid) {
207 AliDebug(AliLog::kDebug + 2, Form("ITS+TPC track --> Momentum lower than limit (%.2f) and ITS PID failed", fMaxITSPIDmom));
212 // arriving here, the track has survived all checks
216 //______________________________________________________________________________
217 Bool_t AliRsnCutESD2010::OkQuality(AliESDtrack *track)
220 // Check track quality parameters.
221 // Rejects all tracks which are not either TPC+ITS nor ITS standalone.
222 // If tracks of any type are not flagged to be used, they are rejected anyway.
225 if (IsITSTPC(track)) return (fUseITSTPC && fESDtrackCutsTPC.IsSelected(track));
226 if (IsITSSA(track)) return (fUseITSSA && fESDtrackCutsITS.IsSelected(track));
231 //______________________________________________________________________________
232 Bool_t AliRsnCutESD2010::OkITSPID(AliESDtrack *track)
235 // Check ITS particle identification with 3sigma cut
238 // count PID layers and reject if they are too few
239 Int_t k, nITSpidLayers = 0;
240 UChar_t itsCluMap = track->GetITSClusterMap();
241 for (k = 2; k < 6; k++) if (itsCluMap & (1 << k)) ++nITSpidLayers;
242 if (nITSpidLayers < 3) {
243 AliDebug(AliLog::kDebug + 2, "Rejecting track with too few ITS pid layers");
247 // check the track type (ITS+TPC or ITS standalone)
248 // and reject it if it is of none of the allowed types
249 Bool_t isSA = kFALSE;
250 if (IsITSTPC(track)) isSA = kFALSE;
251 else if (IsITSSA(track)) isSA = kTRUE;
253 AliWarning("Track is neither ITS+TPC nor ITS standalone");
257 // create the PID response object and compute nsigma
258 AliITSPIDResponse &itsrsp = fESDpid.GetITSResponse();
259 Double_t mom = track->P();
260 Double_t nSigma = itsrsp.GetNumberOfSigmas(mom, track->GetITSsignal(), fPID, nITSpidLayers, isSA);
263 Bool_t ok = (TMath::Abs(nSigma) <= fMaxITSband);
266 AliDebug(AliLog::kDebug + 2, Form("ITS nsigma = %f -- max = %f -- cut %s", nSigma, fMaxITSband, (ok ? "passed" : "failed")));
272 //______________________________________________________________________________
273 Bool_t AliRsnCutESD2010::OkTPCPID(AliESDtrack *track)
276 // Check TPC particle identification with {3|5}sigmacut,
277 // depending on the track total momentum.
280 // setup TPC PID response
281 AliTPCPIDResponse &tpcrsp = fESDpid.GetTPCResponse();
282 //tpcrsp.SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]);
284 // get momentum and number of sigmas and choose the reference band
285 Double_t mom = track->GetInnerParam()->P();
286 Double_t nSigma = tpcrsp.GetNumberOfSigmas(mom, track->GetTPCsignal(), track->GetTPCsignalN(), fPID);
287 Double_t maxNSigma = fMaxTPCband;
288 if (mom < fTPCpLimit) maxNSigma = fMinTPCband;
291 Bool_t ok = (TMath::Abs(nSigma) <= maxNSigma);
294 AliDebug(AliLog::kDebug + 2, Form("TPC nsigma = %f -- max = %f -- cut %s", nSigma, maxNSigma, (ok ? "passed" : "failed")));
300 //______________________________________________________________________________
301 Bool_t AliRsnCutESD2010::OkTOFPID(AliESDtrack *track)
304 // Check TOF particle identification if matched there.
307 // reject not TOF-matched tracks
308 if (!MatchTOF(track)) return kFALSE;
310 // setup TOF PID response
311 AliTOFPIDResponse &tofrsp = fESDpid.GetTOFResponse();
313 // get info for computation
314 Double_t momentum = track->P();
315 Double_t time = track->GetTOFsignal();
316 Double_t timeint[AliPID::kSPECIES];
317 tofrsp.GetStartTime(momentum);
318 track->GetIntegratedTimes(timeint);
321 Double_t timeDiff = time - timeint[(Int_t)fPID];
322 Double_t sigmaRef = tofrsp.GetExpectedSigma(momentum, timeint[(Int_t)fPID], AliPID::ParticleMass(fPID));
323 Double_t nSigma = timeDiff / sigmaRef;
326 Bool_t ok = (nSigma >= fMinTOF && nSigma <= fMaxTOF);
329 AliDebug(AliLog::kDebug + 2, Form("TOF nsigma = %f -- range = %f - %f -- cut %s", nSigma, fMinTOF, fMaxTOF, (ok ? "passed" : "failed")));
335 //_________________________________________________________________________________________________
336 void AliRsnCutESD2010::Print(const Option_t *) const
339 // Print information on this cut
342 AliInfo(Form("Cut name : %s", GetName()));
343 AliInfo(Form("Using MC settings : %s", (fIsMC ? "YES" : "NO")));
344 AliInfo(Form("Using TPC+ITS tracks : %s", (fUseITSTPC ? "YES" : "NO")));
345 AliInfo(Form("Using ITS SA tracks : %s", (fUseITSSA ? "YES" : "NO")));
346 AliInfo(Form("Check ITS PID : %s", (fCheckITS ? "YES" : "NO")));
347 AliInfo(Form("Check TPC PID : %s", (fCheckTPC ? "YES" : "NO")));
348 AliInfo(Form("Check TOF PID : %s", (fCheckTOF ? "YES" : "NO")));
349 AliInfo(Form("Reference particle : %s", AliPID::ParticleName(fPID)));
350 AliInfo(Form("ITS PID range (sigmas): %f", fMaxITSband));
351 AliInfo(Form("ITS PID range (pt) : %f", fMaxITSPIDmom));
352 AliInfo(Form("TPC PID ranges (sigmas): %f %f", fMinTPCband, fMaxTPCband));
353 AliInfo(Form("TPC PID limit (p) : %f", fTPCpLimit));
354 AliInfo(Form("TOF range (sigmas) : %f - %f", fMinTOF, fMaxTOF));