]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnCutMomentumComparison.cxx
Corrected assignment operator
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutMomentumComparison.cxx
CommitLineData
cb0f5af6 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
24ClassImp(AliRsnCutMomentumComparison)
25
26//_________________________________________________________________________________________________
27AliRsnCutMomentumComparison::AliRsnCutMomentumComparison(const char *name, EMode mode) :
28 AliRsnCut(name, AliRsnCut::kMother),
29 fMode(mode)
30{
31//
32// Default constructor.
33//
34}
35
36//_________________________________________________________________________________________________
37AliRsnCutMomentumComparison::AliRsnCutMomentumComparison(const AliRsnCutMomentumComparison& copy) :
38 AliRsnCut(copy),
39 fMode(copy.fMode)
40{
41//
42// Copy constructor
43//
44}
45
46//_________________________________________________________________________________________________
47AliRsnCutMomentumComparison& AliRsnCutMomentumComparison::operator=(const AliRsnCutMomentumComparison& copy)
48{
49//
50// Assignment operator
51//
52
53 AliRsnCut::operator=(copy);
54 fMode = copy.fMode;
bfe5cdb3 55
56 return (*this);
cb0f5af6 57}
58
59//_________________________________________________________________________________________________
60Bool_t AliRsnCutMomentumComparison::IsSelected(TObject *object)
61{
62//
63// Cut checker.
64//
65
66 // convert the object into the unique correct type
67 if (!TargetOK(object)) {
68 AliError(Form("[%s]: this cut works only with AliRsnMother objects", GetName()));
69 return kTRUE;
70 }
71
72 // compare momenta
73 AliRsnMother *mother = dynamic_cast<AliRsnMother*>(object);
74 Double_t p1 = mother->GetDaughter(0)->GetRef()->P();
75 Double_t p2 = mother->GetDaughter(1)->GetRef()->P();
76 Double_t pt1 = mother->GetDaughter(0)->GetRef()->Pt();
77 Double_t pt2 = mother->GetDaughter(1)->GetRef()->Pt();
78
79 switch (fMode)
80 {
81 case kFirstLargerP : return (p1 > p2);
82 case kFirstSmallerP : return (p1 < p2);
83 case kFirstLargerPt : return (pt1 > pt2);
84 case kFirstSmallerPt: return (pt1 < pt2);
85 default:
86 AliError("Invalid mode selected. Cut is skipped");
87 return kTRUE;
88 }
89}