]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnCutMomentumComparison.cxx
K0s code update (Matt Steinpreis)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutMomentumComparison.cxx
1 //
2 // Class AliRsnCutMomentumComparison
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 #include "TMath.h"
19
20 #include "AliRsnDaughter.h"
21 #include "AliRsnMother.h"
22 #include "AliRsnCutMomentumComparison.h"
23
24 ClassImp(AliRsnCutMomentumComparison)
25
26 //_________________________________________________________________________________________________
27 AliRsnCutMomentumComparison::AliRsnCutMomentumComparison(const char *name, EMode mode) :
28    AliRsnCut(name, AliRsnCut::kMother),
29    fMode(mode)
30 {
31 //
32 // Default constructor.
33 //
34 }
35
36 //_________________________________________________________________________________________________
37 AliRsnCutMomentumComparison::AliRsnCutMomentumComparison(const AliRsnCutMomentumComparison &copy) :
38    AliRsnCut(copy),
39    fMode(copy.fMode)
40 {
41 //
42 // Copy constructor
43 //
44 }
45
46 //_________________________________________________________________________________________________
47 AliRsnCutMomentumComparison &AliRsnCutMomentumComparison::operator=(const AliRsnCutMomentumComparison &copy)
48 {
49 //
50 // Assignment operator
51 //
52
53    AliRsnCut::operator=(copy);
54    if (this == &copy)
55       return *this;
56    fMode = copy.fMode;
57
58    return (*this);
59 }
60
61 //_________________________________________________________________________________________________
62 Bool_t AliRsnCutMomentumComparison::IsSelected(TObject *object)
63 {
64 //
65 // Cut checker.
66 //
67
68    // convert the object into the unique correct type
69    if (!TargetOK(object)) return kFALSE;
70
71    // compare momenta
72    Double_t p1  = fMother->GetDaughter(0)->GetRef()->P();
73    Double_t p2  = fMother->GetDaughter(1)->GetRef()->P();
74    Double_t pt1 = fMother->GetDaughter(0)->GetRef()->Pt();
75    Double_t pt2 = fMother->GetDaughter(1)->GetRef()->Pt();
76
77    switch (fMode)
78    {
79       case kFirstLargerP  : return (p1 > p2);
80       case kFirstSmallerP : return (p1 < p2);
81       case kFirstLargerPt : return (pt1 > pt2);
82       case kFirstSmallerPt: return (pt1 < pt2);
83       default:
84          AliError("Invalid mode selected. Cut is skipped");
85          return kTRUE;
86    }
87 }