]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutMgr.cxx
Since there are some cuts which require to take informations from the event itself
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutMgr.cxx
1 //
2 // Class AliRsnCutMgr
3 //
4 // The cut manager: contains a complete set of cut definitions
5 // to be applied to all possible targets (one for each target),
6 // in order to ease the set-up procedure of cuts and allow to
7 // pass them at once to each object which must use them
8 //
9 // author: Martin Vala (martin.vala@cern.ch)
10 //
11
12 #include "AliLog.h"
13
14 #include "AliRsnCutSet.h"
15 #include "AliRsnCutMgr.h"
16
17 ClassImp(AliRsnCutMgr)
18
19 //_____________________________________________________________________________
20 AliRsnCutMgr::AliRsnCutMgr() :
21     TNamed("defaultName", "defaultTitle")
22 {
23 //
24 // Constructor without arguments.
25 //
26
27   Int_t i;
28   for (i = 0; i < AliRsnCut::kLastCutTarget; i++) {
29     fCutSets[i] = 0;
30   }
31 }
32
33 //_____________________________________________________________________________
34 AliRsnCutMgr::AliRsnCutMgr(const char *name, const char *title) :
35     TNamed(name, title)
36 {
37 //
38 // Constructor with name and title.
39 //
40
41   Int_t i;
42   for (i = 0; i < AliRsnCut::kLastCutTarget; i++) {
43     fCutSets[i] = 0;
44   }
45 }
46
47 //_____________________________________________________________________________
48 AliRsnCutMgr::~AliRsnCutMgr()
49 {
50 //
51 // Destructor.
52 // Deletes all cut definitions.
53 //
54
55   Int_t i;
56   for (i = 0; i < AliRsnCut::kLastCutTarget; i++) {
57     delete fCutSets[i];
58   }
59 }
60
61 //_____________________________________________________________________________
62 void AliRsnCutMgr::SetCutSet(AliRsnCut::ETarget type, AliRsnCutSet* const cutset)
63 {
64 //
65 // Assign a cut set to a given target
66 //
67
68   if (!fCutSets[type]) fCutSets[type] = (AliRsnCutSet*) cutset->Clone();
69   AliDebug(AliLog::kDebug, Form("DatasetName %s", fCutSets[type]->GetName()));
70 }
71
72 //_____________________________________________________________________________
73 Bool_t AliRsnCutMgr::IsSelected(AliRsnCut::ETarget type, TObject*const obj)
74 {
75 //
76 // Check if a given object passes the cuts defined for it.
77 // The target of the check is here a TObject, in order to allo generality
78 // but then the kind of cut to be used is defined as first argument, and
79 // in the single cut it will be checked if it is appropriate for passed target
80 //
81
82   AliDebug(AliLog::kDebug, "<-");
83   if (!fCutSets[type]) return kTRUE;
84
85   switch (type) {
86   case AliRsnCut::kParticle:
87     return fCutSets[type]->IsSelected(type, (AliRsnDaughter*)obj);
88     break;
89   case AliRsnCut::kPair:
90     return fCutSets[type]->IsSelected(type, (AliRsnPairParticle*)obj);
91     break;
92   case AliRsnCut::kEvent:
93     return fCutSets[type]->IsSelected(type, (AliRsnEvent*)obj);
94     break;
95   default:
96     AliWarning("Wrong target selected.");
97     return kTRUE;
98     break;
99   }
100
101   return kTRUE;
102 }
103
104 //_____________________________________________________________________________
105 void AliRsnCutMgr::SetEvent(AliRsnEvent *event)
106 {
107 //
108 // Sets reference event in all cut sets
109 //
110
111   Int_t i;
112   for (i = 0; i < AliRsnCut::kLastCutTarget; i++)
113   {
114     if (fCutSets[i]) fCutSets[i]->SetEvent(event);
115   }
116 }
117