ROOT logo
//
// Class AliRsnCutPIDITS
//
// General implementation of a single cut strategy, which can be:
// - a value contained in a given interval  [--> IsBetween()   ]
// - a value equal to a given reference     [--> MatchesValue()]
//
// In all cases, the reference value(s) is (are) given as data members
// and each kind of cut requires a given value type (Int, UInt, Double),
// but the cut check procedure is then automatized and chosen thanks to
// an enumeration of the implemented cut types.
// At the end, the user (or any other point which uses this object) has
// to use the method IsSelected() to check if this cut has been passed.
//
// authors: Martin Vala (martin.vala@cern.ch)
//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
//

#include "AliESDtrackCuts.h"
#include "AliAODpidUtil.h"
#include "AliAnalysisManager.h"
#include "AliESDInputHandler.h"

#include "AliRsnDaughter.h"

#include "AliRsnCutPIDITS.h"

ClassImp(AliRsnCutPIDITS)

//_________________________________________________________________________________________________
AliRsnCutPIDITS::AliRsnCutPIDITS
(const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectOutside) :
   AliRsnCut(name, AliRsnCut::kDaughter, min, max),
   fIsMC(kFALSE),
   fRejectOutside(rejectOutside),
   fMomMin(0.0),
   fMomMax(1E+20),
   fRefType(ref),
   fESDpid(),
   fAODpid()
{
//
// Main constructor.
//
}

//_________________________________________________________________________________________________
AliRsnCutPIDITS::AliRsnCutPIDITS
(const AliRsnCutPIDITS &copy) :
   AliRsnCut(copy),
   fIsMC(copy.fIsMC),
   fRejectOutside(copy.fRejectOutside),
   fMomMin(copy.fMomMin),
   fMomMax(copy.fMomMax),
   fRefType(copy.fRefType),
   fESDpid(copy.fESDpid),
   fAODpid(copy.fAODpid)
{
//
// Copy constructor.
//
}

//_________________________________________________________________________________________________
AliRsnCutPIDITS &AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS &copy)
{
//
// Assignment operator
//

   AliRsnCut::operator=(copy);
   if (this == &copy)
      return *this;

   fIsMC          = copy.fIsMC;
   fRejectOutside = copy.fRejectOutside;
   fMomMin        = copy.fMomMin;
   fMomMax        = copy.fMomMax;
   fRefType       = copy.fRefType;
   fESDpid        = copy.fESDpid;
   fAODpid        = copy.fAODpid;

   return (*this);
}

//_________________________________________________________________________________________________
Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
{
//
// Cut checker.
//

   // coherence check
   if (!TargetOK(object)) return kFALSE;

   // reject not ITS tracks
   // status is checked in the same way for all tracks
   AliVTrack *vtrack = fDaughter->Ref2Vtrack();
   if (!vtrack) {
      AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
      return kFALSE;
   }

   // check status, to know it track is an ITS+TPC or ITS standalone
   // and reject it if it is of none of them
   Bool_t isSA = kFALSE;
   if (IsTPC(vtrack)) isSA = kFALSE;
   else if (IsSA(vtrack)) isSA = kTRUE;
   else {
      AliDebug(AliLog::kDebug + 2, "Status flags unmatched");
      return kFALSE;
   }

   // common evaluation variables
   Int_t        k, nITSpidLayers = 0;
   Double_t     mom      = vtrack->P();
   AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
   AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();

   // count number of PID layers...
   if (esdTrack) {
      UChar_t itsCluMap = esdTrack->GetITSClusterMap();
      for (k = 2; k < 6; k++) if (itsCluMap & (1 << k)) ++nITSpidLayers;
   } else if (aodTrack) {
      for (k = 2; k < 6; k++) if (TESTBIT(aodTrack->GetITSClusterMap(), k)) ++nITSpidLayers;
   } else {
      AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
      return kFALSE;
   }
   // ...and reject tracks where it is smaller than 3
   if (nITSpidLayers < 3) {
      AliDebug(AliLog::kDebug + 2, "Rejecting track with too few ITS pid layers");
      return kFALSE;
   }

   // assign PID nsigmas to default cut check value
   // since bad object types are rejected before, here we have an ESD track or AOD track
   if (esdTrack) {
      if (!fESDpid) fESDpid = new AliESDpid(fIsMC);
      fCutValueD = fESDpid->GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
   } else {
      if (!fAODpid) fAODpid = new AliAODpidUtil(fIsMC);
      fCutValueD = fAODpid->NumberOfSigmasITS(aodTrack, fRefType);
   }

   // use AliRsnCut default method to check cut
   Bool_t cutCheck = OkRangeD();

   // now check the momentum:
   // -- if it stays inside the accepted range, track just checked
   //    with respect to the nsigma band
   // -- if it stays outside the accepted range and 'fRejectOutside' is kTRUE,
   //    track is always rejected, while if 'fRejectOutside' is kFALSE,
   //    track is accepted if it stays inside the nsigma band
   if ((mom >= fMomMin && mom <= fMomMax))
      return cutCheck;
   else {
      AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
      return ((!fRejectOutside) && cutCheck);
   }
}

//_________________________________________________________________________________________________
void AliRsnCutPIDITS::Print(const Option_t *) const
{
//
// Print information on this cut
//

   AliInfo(Form("Cut name                    : %s", GetName()));
   AliInfo(Form("--> cut range (nsigma)      : %.3f %.3f", fMinD, fMaxD));
   AliInfo(Form("--> momentum range          : %.3f %.3f", fMomMin, fMomMax));
   AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
}
 AliRsnCutPIDITS.cxx:1
 AliRsnCutPIDITS.cxx:2
 AliRsnCutPIDITS.cxx:3
 AliRsnCutPIDITS.cxx:4
 AliRsnCutPIDITS.cxx:5
 AliRsnCutPIDITS.cxx:6
 AliRsnCutPIDITS.cxx:7
 AliRsnCutPIDITS.cxx:8
 AliRsnCutPIDITS.cxx:9
 AliRsnCutPIDITS.cxx:10
 AliRsnCutPIDITS.cxx:11
 AliRsnCutPIDITS.cxx:12
 AliRsnCutPIDITS.cxx:13
 AliRsnCutPIDITS.cxx:14
 AliRsnCutPIDITS.cxx:15
 AliRsnCutPIDITS.cxx:16
 AliRsnCutPIDITS.cxx:17
 AliRsnCutPIDITS.cxx:18
 AliRsnCutPIDITS.cxx:19
 AliRsnCutPIDITS.cxx:20
 AliRsnCutPIDITS.cxx:21
 AliRsnCutPIDITS.cxx:22
 AliRsnCutPIDITS.cxx:23
 AliRsnCutPIDITS.cxx:24
 AliRsnCutPIDITS.cxx:25
 AliRsnCutPIDITS.cxx:26
 AliRsnCutPIDITS.cxx:27
 AliRsnCutPIDITS.cxx:28
 AliRsnCutPIDITS.cxx:29
 AliRsnCutPIDITS.cxx:30
 AliRsnCutPIDITS.cxx:31
 AliRsnCutPIDITS.cxx:32
 AliRsnCutPIDITS.cxx:33
 AliRsnCutPIDITS.cxx:34
 AliRsnCutPIDITS.cxx:35
 AliRsnCutPIDITS.cxx:36
 AliRsnCutPIDITS.cxx:37
 AliRsnCutPIDITS.cxx:38
 AliRsnCutPIDITS.cxx:39
 AliRsnCutPIDITS.cxx:40
 AliRsnCutPIDITS.cxx:41
 AliRsnCutPIDITS.cxx:42
 AliRsnCutPIDITS.cxx:43
 AliRsnCutPIDITS.cxx:44
 AliRsnCutPIDITS.cxx:45
 AliRsnCutPIDITS.cxx:46
 AliRsnCutPIDITS.cxx:47
 AliRsnCutPIDITS.cxx:48
 AliRsnCutPIDITS.cxx:49
 AliRsnCutPIDITS.cxx:50
 AliRsnCutPIDITS.cxx:51
 AliRsnCutPIDITS.cxx:52
 AliRsnCutPIDITS.cxx:53
 AliRsnCutPIDITS.cxx:54
 AliRsnCutPIDITS.cxx:55
 AliRsnCutPIDITS.cxx:56
 AliRsnCutPIDITS.cxx:57
 AliRsnCutPIDITS.cxx:58
 AliRsnCutPIDITS.cxx:59
 AliRsnCutPIDITS.cxx:60
 AliRsnCutPIDITS.cxx:61
 AliRsnCutPIDITS.cxx:62
 AliRsnCutPIDITS.cxx:63
 AliRsnCutPIDITS.cxx:64
 AliRsnCutPIDITS.cxx:65
 AliRsnCutPIDITS.cxx:66
 AliRsnCutPIDITS.cxx:67
 AliRsnCutPIDITS.cxx:68
 AliRsnCutPIDITS.cxx:69
 AliRsnCutPIDITS.cxx:70
 AliRsnCutPIDITS.cxx:71
 AliRsnCutPIDITS.cxx:72
 AliRsnCutPIDITS.cxx:73
 AliRsnCutPIDITS.cxx:74
 AliRsnCutPIDITS.cxx:75
 AliRsnCutPIDITS.cxx:76
 AliRsnCutPIDITS.cxx:77
 AliRsnCutPIDITS.cxx:78
 AliRsnCutPIDITS.cxx:79
 AliRsnCutPIDITS.cxx:80
 AliRsnCutPIDITS.cxx:81
 AliRsnCutPIDITS.cxx:82
 AliRsnCutPIDITS.cxx:83
 AliRsnCutPIDITS.cxx:84
 AliRsnCutPIDITS.cxx:85
 AliRsnCutPIDITS.cxx:86
 AliRsnCutPIDITS.cxx:87
 AliRsnCutPIDITS.cxx:88
 AliRsnCutPIDITS.cxx:89
 AliRsnCutPIDITS.cxx:90
 AliRsnCutPIDITS.cxx:91
 AliRsnCutPIDITS.cxx:92
 AliRsnCutPIDITS.cxx:93
 AliRsnCutPIDITS.cxx:94
 AliRsnCutPIDITS.cxx:95
 AliRsnCutPIDITS.cxx:96
 AliRsnCutPIDITS.cxx:97
 AliRsnCutPIDITS.cxx:98
 AliRsnCutPIDITS.cxx:99
 AliRsnCutPIDITS.cxx:100
 AliRsnCutPIDITS.cxx:101
 AliRsnCutPIDITS.cxx:102
 AliRsnCutPIDITS.cxx:103
 AliRsnCutPIDITS.cxx:104
 AliRsnCutPIDITS.cxx:105
 AliRsnCutPIDITS.cxx:106
 AliRsnCutPIDITS.cxx:107
 AliRsnCutPIDITS.cxx:108
 AliRsnCutPIDITS.cxx:109
 AliRsnCutPIDITS.cxx:110
 AliRsnCutPIDITS.cxx:111
 AliRsnCutPIDITS.cxx:112
 AliRsnCutPIDITS.cxx:113
 AliRsnCutPIDITS.cxx:114
 AliRsnCutPIDITS.cxx:115
 AliRsnCutPIDITS.cxx:116
 AliRsnCutPIDITS.cxx:117
 AliRsnCutPIDITS.cxx:118
 AliRsnCutPIDITS.cxx:119
 AliRsnCutPIDITS.cxx:120
 AliRsnCutPIDITS.cxx:121
 AliRsnCutPIDITS.cxx:122
 AliRsnCutPIDITS.cxx:123
 AliRsnCutPIDITS.cxx:124
 AliRsnCutPIDITS.cxx:125
 AliRsnCutPIDITS.cxx:126
 AliRsnCutPIDITS.cxx:127
 AliRsnCutPIDITS.cxx:128
 AliRsnCutPIDITS.cxx:129
 AliRsnCutPIDITS.cxx:130
 AliRsnCutPIDITS.cxx:131
 AliRsnCutPIDITS.cxx:132
 AliRsnCutPIDITS.cxx:133
 AliRsnCutPIDITS.cxx:134
 AliRsnCutPIDITS.cxx:135
 AliRsnCutPIDITS.cxx:136
 AliRsnCutPIDITS.cxx:137
 AliRsnCutPIDITS.cxx:138
 AliRsnCutPIDITS.cxx:139
 AliRsnCutPIDITS.cxx:140
 AliRsnCutPIDITS.cxx:141
 AliRsnCutPIDITS.cxx:142
 AliRsnCutPIDITS.cxx:143
 AliRsnCutPIDITS.cxx:144
 AliRsnCutPIDITS.cxx:145
 AliRsnCutPIDITS.cxx:146
 AliRsnCutPIDITS.cxx:147
 AliRsnCutPIDITS.cxx:148
 AliRsnCutPIDITS.cxx:149
 AliRsnCutPIDITS.cxx:150
 AliRsnCutPIDITS.cxx:151
 AliRsnCutPIDITS.cxx:152
 AliRsnCutPIDITS.cxx:153
 AliRsnCutPIDITS.cxx:154
 AliRsnCutPIDITS.cxx:155
 AliRsnCutPIDITS.cxx:156
 AliRsnCutPIDITS.cxx:157
 AliRsnCutPIDITS.cxx:158
 AliRsnCutPIDITS.cxx:159
 AliRsnCutPIDITS.cxx:160
 AliRsnCutPIDITS.cxx:161
 AliRsnCutPIDITS.cxx:162
 AliRsnCutPIDITS.cxx:163
 AliRsnCutPIDITS.cxx:164
 AliRsnCutPIDITS.cxx:165
 AliRsnCutPIDITS.cxx:166
 AliRsnCutPIDITS.cxx:167
 AliRsnCutPIDITS.cxx:168
 AliRsnCutPIDITS.cxx:169
 AliRsnCutPIDITS.cxx:170
 AliRsnCutPIDITS.cxx:171
 AliRsnCutPIDITS.cxx:172
 AliRsnCutPIDITS.cxx:173
 AliRsnCutPIDITS.cxx:174