2 // Class AliRsnSimpleFcn
4 // This class defines a base classe to implement a typical computation
5 // which uses the internal RSN package event format (AliRsnEvent).
6 // It contains some default flags which turn out to be useful:
7 // - a flag to select only the "true" pairs (tracks from same resonance)
8 // - a flag to know if the computation is done over two events (mixing)
10 // Any kind of analysis object should be implemented as inheriting from this
11 // because the AliRsnAnalyzer which executes the analysis will accept a collection
12 // of such objects, in order to have a unique format of processing method
14 // The user who implements a kind of computation type should inherit from
15 // this class and override the virtual functions defined in it, which
16 // initialize the final output histogram and define how to process data.
19 // author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
22 #include <Riostream.h>
30 #include "AliRsnMCInfo.h"
31 #include "AliRsnDaughter.h"
32 #include "AliRsnEvent.h"
33 #include "AliRsnCut.h"
35 #include "AliRsnSimpleFunction.h"
37 ClassImp(AliRsnSimpleFunction)
39 //________________________________________________________________________________________
40 AliRsnSimpleFunction::AliRsnSimpleFunction
41 (const char *name, AliRsnPairDef *pd, AliRsnHistoDef *hd,
42 AliRsnCutMgr *cuts, Option_t *option) :
55 // The histogram data member cannot be passed externally,
56 // its initialization MUST be defined inside the Init() method,
57 // which must be overridden in any derivate implementation.
58 // Last argument (option) allows to set in a user-friedly way the flags:
59 // - TRUE (for true pairs)
60 // - MIX (for mixing pairs)
65 fTrueFlag = opt.Contains("TRUE");
66 fMixFlag = opt.Contains("MIX");
68 //________________________________________________________________________________________
69 AliRsnSimpleFunction::AliRsnSimpleFunction(const AliRsnSimpleFunction ©) :
71 fTrueFlag(copy.fTrueFlag),
72 fMixFlag(copy.fMixFlag),
74 fPairDef(copy.fPairDef),
75 fHistoDef(copy.fHistoDef),
82 // Pointer data members are not cloned.
83 // The histogram is not copied, because it is always initialized
84 // by the Init() method.
87 //________________________________________________________________________________________
88 const AliRsnSimpleFunction& AliRsnSimpleFunction::operator=
89 (const AliRsnSimpleFunction ©)
92 // Assignment operator.
93 // Behaves like copy constructor.
94 // Also in this case, the histogram is not copied, and,
95 // if it was present, it is destroyed and will need to be recreated.
99 SetName(copy.GetName());
101 fTrueFlag = copy.fTrueFlag;
102 fMixFlag = copy.fMixFlag;
104 fPairDef = copy.fPairDef;
105 fHistoDef = copy.fHistoDef;
110 //________________________________________________________________________________________
111 void AliRsnSimpleFunction::Clear(Option_t* /*option*/)
114 // Clear arrays and histogram.
115 // For the sake of security, all pointers are also set explicitly to NULL.
117 if (fHisto1D) delete fHisto1D;
119 if (fHisto2D) delete fHisto2D;
123 //________________________________________________________________________________________
124 Bool_t AliRsnSimpleFunction::Init()
127 // Initialization function.
128 // By default, it initializes the owned histogram using the method
129 // from AliRsnHistoDef class, giving the same name and title of this.
130 // A user can override this behaviour, if necessary.
131 // Before creating, the HistoDef is checked for proper initialization.
137 sprintf(name, "h_%s", GetName());
139 fHisto1D = (TH1D*)fHistoDef->CreateHistogram(name, "");
143 //________________________________________________________________________________________
144 Bool_t AliRsnSimpleFunction::ProcessOne(AliRsnEvent* /*event*/)
147 // Process a single event according to the purposes of the derived class.
148 // Here the user must put the code which defines how the internal histogram is filled.
149 // The boolean return value allows to catch a failure in execution.
152 AliWarning("This method must be defined in the derived class");
156 //________________________________________________________________________________________
157 Bool_t AliRsnSimpleFunction::ProcessTwo(AliRsnEvent* /*event1*/, AliRsnEvent* /*event2*/)
160 // Process two events according to relations between them.
161 // This method must be defined whenever the derived object is used in event mixing.
162 // The boolean return value allows to catch a failure in execution.
165 AliWarning("This method must be defined in the derived class");
169 //________________________________________________________________________________________
170 Bool_t AliRsnSimpleFunction::CutPass(AliRsnDaughter *d)
173 // Check if the AliRsnDaughter argument pass its cuts.
174 // If the cut data member is not initialized for it, returns kTRUE.
176 if (!fCuts) return kTRUE;
177 else return fCuts->IsSelected(AliRsnCut::kParticle, d);
180 //________________________________________________________________________________________
181 Bool_t AliRsnSimpleFunction::CutPass(AliRsnPairParticle *p)
184 // Check if the AliRsnPairParticle argument pass its cuts.
185 // If the cut data member is not initialized for it, returns kTRUE.
186 // In this case, another separate check which could be necessary
187 // concerns the possibility that the two tracks are a "true pair" of
188 // daughters of the same resonance. If the corresponding flag is set,
189 // this further check is done, and the method returns kTRUE only
190 // when also this check is passed.
193 Bool_t cutPassed, truePair;
195 cutPassed = fCuts->IsSelected(AliRsnCut::kPair, p);
196 truePair = fPair.IsTruePair(fPairDef->GetMotherPDG());
199 return (cutPassed && truePair);
206 //________________________________________________________________________________________
207 Bool_t AliRsnSimpleFunction::CutPass(AliRsnEvent *e)
210 // Check if the AliRsnEvent argument pass its cuts.
211 // If the cut data member is not initialized for it, returns kTRUE.
213 if (!fCuts) return kTRUE;
214 else return fCuts->IsSelected(AliRsnCut::kEvent, e);