Fixing for coverity report
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutDaughterType.cxx
CommitLineData
2dab9030 1//
2// Class AliRsnCutDaughterType
3//
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()]
7//
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.
14//
15// authors: Martin Vala (martin.vala@cern.ch)
16// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
17//
18
19#include "AliRsnDaughter.h"
20#include "AliRsnCutDaughterType.h"
21
22ClassImp(AliRsnCutDaughterType)
23
24//_________________________________________________________________________________________________
25AliRsnCutDaughterType::AliRsnCutDaughterType() :
32992791 26 AliRsnCut(),
2dab9030 27 fRefType(kTypes)
28{
29//
30// Default constructor.
31//
32992791 32
33 SetTargetType(AliRsnTarget::kDaughter);
2dab9030 34}
35
36//_________________________________________________________________________________________________
37AliRsnCutDaughterType::AliRsnCutDaughterType
38(const char *name, EType type) :
39 AliRsnCut(name, AliRsnCut::kDaughter, 0.0, 0.0),
40 fRefType(type)
41{
42//
43// Main constructor.
44//
45}
46
47//_________________________________________________________________________________________________
32992791 48Bool_t AliRsnCutDaughterType::IsSelected(TObject *object)
2dab9030 49{
50//
51// Cut checker.
52//
53
54 // coherence check
32992791 55 if (!TargetOK(object)) return kFALSE;
2dab9030 56
57 // check the daughter according to the selected type
58 // in some cases this means to retrieve the track status
32992791 59 AliRsnDaughter *daughter = dynamic_cast<AliRsnDaughter*>(object);
2dab9030 60 AliVTrack *track = dynamic_cast<AliVTrack*>(daughter->GetRef());
61 AliESDtrack *esdT = dynamic_cast<AliESDtrack*>(daughter->GetRef());
62 ULong_t status = 0x0;
63 if (track) status = (ULong_t)track->GetStatus();
64
65 switch (fRefType)
66 {
67 case kTrackTPC:
68 return ((status & AliESDtrack::kTPCin) != 0);
69 case kTrackITSSA:
96e9d35d 70 if (esdT && track)
2dab9030 71 {
72 UChar_t itsCluMap = track->GetITSClusterMap();
73 Int_t k, nITS = 0;
74 for(k = 2; k < 6; k++) if(itsCluMap & (1 << k)) ++nITS;
75 if (nITS < 3) return kFALSE;
76 }
77 return ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
78 case kV0:
79 return daughter->IsV0();
80 default:
81 AliError("No good reference type is chosen. Cut skipped");
82 return kTRUE;
83 }
84}