@@ -251,9 +251,151 @@ class TrackSelectorPID
251251 }
252252 }
253253
254- // / Returns status of combined PID selection for a given track.
254+ // RICH
255+
256+ // / Set pT range where RICH PID is applicable.
257+ void setRangePtRICH (float ptMin, float ptMax)
258+ {
259+ mPtRICHMin = ptMin;
260+ mPtRICHMax = ptMax;
261+ }
262+
263+ // / Set RICH nσ range in which a track should be accepted.
264+ void setRangeNSigmaRICH (float nsMin, float nsMax)
265+ {
266+ mNSigmaRICHMin = nsMin;
267+ mNSigmaRICHMax = nsMax;
268+ }
269+
270+ // / Set RICH nσ range in which a track should be conditionally accepted if combined with TOF.
271+ void setRangeNSigmaRICHCondTOF (float nsMin, float nsMax)
272+ {
273+ mNSigmaRICHMinCondTOF = nsMin;
274+ mNSigmaRICHMaxCondTOF = nsMax;
275+ }
276+
277+ // / Checks if track is OK for RICH PID.
278+ // / \param track track
279+ // / \return true if track is OK for RICH PID
280+ template <typename T>
281+ bool isValidTrackPIDRICH (const T& track)
282+ {
283+ auto pt = track.pt ();
284+ return mPtRICHMin <= pt && pt <= mPtRICHMax ;
285+ }
286+
287+ // / Checks if track is compatible with given particle species hypothesis within given RICH nσ range.
255288 // / \param track track
256- // / \return combined-selection status (see TrackSelectorPID::Status)
289+ // / \param conditionalTOF variable to store the result of selection with looser cuts for conditional accepting of track if combined with TOF
290+ // / \return true if track satisfies RICH PID hypothesis for given RICH nσ range
291+ template <typename T>
292+ bool isSelectedTrackPIDRICH (const T& track, bool & conditionalTOF)
293+ {
294+ // Accept if selection is disabled via large values.
295+ if (mNSigmaRICHMin < -999 . && mNSigmaRICHMax > 999 .) {
296+ return true ;
297+ }
298+
299+ // Get nσ for a given particle hypothesis.
300+ double nSigma = 100 .;
301+ switch (mPdg ) {
302+ case kElectron : {
303+ nSigma = track.rich ().richNsigmaEl ();
304+ break ;
305+ }
306+ case kMuonMinus : {
307+ nSigma = track.rich ().richNsigmaMu ();
308+ break ;
309+ }
310+ case kPiPlus : {
311+ nSigma = track.rich ().richNsigmaPi ();
312+ break ;
313+ }
314+ case kKPlus : {
315+ nSigma = track.rich ().richNsigmaKa ();
316+ break ;
317+ }
318+ case kProton : {
319+ nSigma = track.rich ().richNsigmaPr ();
320+ break ;
321+ }
322+ default : {
323+ LOGF (error, " ERROR: RICH PID not implemented for PDG %d" , mPdg );
324+ assert (false );
325+ }
326+ }
327+
328+ if (mNSigmaRICHMinCondTOF < -999 . && mNSigmaRICHMaxCondTOF > 999 .) {
329+ conditionalTOF = true ;
330+ } else {
331+ conditionalTOF = mNSigmaRICHMinCondTOF <= nSigma && nSigma <= mNSigmaRICHMaxCondTOF ;
332+ }
333+ return mNSigmaRICHMin <= nSigma && nSigma <= mNSigmaRICHMax ;
334+ }
335+
336+ // / Returns status of RICH PID selection for a given track.
337+ // / \param track track
338+ // / \return RICH selection status (see TrackSelectorPID::Status)
339+ template <typename T>
340+ int getStatusTrackPIDRICH (const T& track)
341+ {
342+ if (isValidTrackPIDRICH (track)) {
343+ bool condTOF = false ;
344+ if (isSelectedTrackPIDRICH (track, condTOF)) {
345+ return Status::PIDAccepted; // accepted
346+ } else if (condTOF) {
347+ return Status::PIDConditional; // potential to be accepted if combined with TOF
348+ } else {
349+ return Status::PIDRejected; // rejected
350+ }
351+ } else {
352+ return Status::PIDNotApplicable; // PID not applicable
353+ }
354+ }
355+
356+ // MID
357+
358+ // / Checks if track is compatible with muon hypothesis in the MID detector.
359+ // / \param track track
360+ // / \return true if track has been identified as muon by the MID detector
361+ template <typename T>
362+ bool isSelectedTrackPIDMID (const T& track)
363+ {
364+ if (mPdg != kMuonMinus ) {
365+ // LOGF(info, "isSelectedTrackPIDMID: Not a muon hypothesis");
366+ return false ;
367+ }
368+ // LOGF(info, "isSelectedTrackPIDMID: Getting muon response");
369+ // LOGF(info, "isSelectedTrackPIDMID: Got: %d", track.mid().midIsMuon());
370+ // LOGF(info, "isSelectedTrackPIDMID: Return: %d", track.mid().midIsMuon() == 1);
371+ return track.mid ().midIsMuon () == 1 ; // FIXME: change to return track.midIsMuon() once the column is bool.
372+ }
373+
374+ // / Returns status of MID PID selection for a given track.
375+ // / \param track track
376+ // / \return MID selection status (see TrackSelectorPID::Status)
377+ template <typename T>
378+ int getStatusTrackPIDMID (const T& track)
379+ {
380+ // LOGF(info, "getStatusTrackPIDMID: Start");
381+ if (mPdg != kMuonMinus ) {
382+ // LOGF(info, "getStatusTrackPIDMID: Not a muon hypothesis");
383+ return Status::PIDRejected;
384+ }
385+ if (isSelectedTrackPIDMID (track)) {
386+ // LOGF(info, "getStatusTrackPIDMID: Accepted");
387+ return Status::PIDAccepted; // accepted
388+ } else {
389+ // LOGF(info, "getStatusTrackPIDMID: Rejected");
390+ return Status::PIDRejected; // rejected
391+ }
392+ }
393+
394+ // Combined selection (TPC + TOF)
395+
396+ // / Returns status of combined PID (TPC + TOF) selection for a given track.
397+ // / \param track track
398+ // / \return status of combined PID (TPC + TOF) (see TrackSelectorPID::Status)
257399 template <typename T>
258400 int getStatusTrackPIDAll (const T& track)
259401 {
@@ -290,6 +432,14 @@ class TrackSelectorPID
290432 float mNSigmaTOFMax = 3 .; // /< maximum number of TOF σ
291433 float mNSigmaTOFMinCondTPC = -1000 .; // /< minimum number of TOF σ if combined with TPC
292434 float mNSigmaTOFMaxCondTPC = 1000 .; // /< maximum number of TOF σ if combined with TPC
435+
436+ // RICH
437+ float mPtRICHMin = 0 .; // /< minimum pT for RICH PID [GeV/c]
438+ float mPtRICHMax = 100 .; // /< maximum pT for RICH PID [GeV/c]
439+ float mNSigmaRICHMin = -3 .; // /< minimum number of RICH σ
440+ float mNSigmaRICHMax = 3 .; // /< maximum number of RICH σ
441+ float mNSigmaRICHMinCondTOF = -1000 .; // /< minimum number of RICH σ if combined with TOF
442+ float mNSigmaRICHMaxCondTOF = 1000 .; // /< maximum number of RICH σ if combined with TOF
293443};
294444
295445#endif // O2_ANALYSIS_TRACKSELECTORPID_H_
0 commit comments