2 // Class AliRsnFunction
4 // This class defines a base classe to implement a function
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)
26 #include "AliRsnDaughter.h"
27 #include "AliRsnEvent.h"
28 #include "AliRsnPairDef.h"
29 #include "AliRsnPairParticle.h"
30 #include "AliRsnFunctionAxis.h"
32 #include "AliRsnFunction.h"
34 ClassImp(AliRsnFunction)
36 //________________________________________________________________________________________
37 AliRsnFunction::AliRsnFunction() :
40 fAxisList("AliRsnFunctionAxis", 0),
51 //________________________________________________________________________________________
52 AliRsnFunction::AliRsnFunction(const AliRsnFunction ©) :
54 fPairDef(copy.fPairDef),
55 fAxisList(copy.fAxisList),
66 //________________________________________________________________________________________
67 const AliRsnFunction& AliRsnFunction::operator=(const AliRsnFunction& copy)
70 // Assignment operator.
73 SetName(copy.GetName());
74 SetTitle(copy.GetTitle());
76 fPairDef = copy.fPairDef;
81 if (fHistogram) delete fHistogram;
87 //________________________________________________________________________________________
88 const char* AliRsnFunction::GetName() const
91 // Defines the name of this object according to
92 // the function type and binning
97 TObjArrayIter next(&fAxisList);
98 AliRsnFunctionAxis *axis = 0;
100 while ((axis = (AliRsnFunctionAxis*)next())) {
101 if (name.Length() > 1) name += '_';
102 name += axis->GetName();
108 //________________________________________________________________________________________
109 void AliRsnFunction::AddAxis(AliRsnFunctionAxis *const axis)
111 Int_t size = fAxisList.GetEntries();
112 new(fAxisList[size]) AliRsnFunctionAxis(*axis);
115 //________________________________________________________________________________________
116 THnSparseD* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTitle)
119 // Creates and returns the histogram defined using
120 // arguments fo name and title, and the first histoDef for binning.
121 // Variable-sized histogram binning is always called, due to use of histoDef,
122 // even if the bins are equal, since they are defined in this class.
123 // Eventually present histoDef's in other slots of array (1, 2) are ignored.
126 Int_t size = fAxisList.GetEntries();
128 AliError("No axes defined");
132 Int_t *nbins = new Int_t[size];
133 Double_t *min = new Double_t[size];
134 Double_t *max = new Double_t[size];
136 // retrieve binnings for main and secondary axes
137 AliRsnFunctionAxis *fcnAxis = 0;
138 for (Int_t i = 0; i < size; i++) {
139 fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(i);
144 AliError("Empty axis");
147 nbins[i] = fcnAxis->GetNBins();
148 min[i] = fcnAxis->GetMin();
149 max[i] = fcnAxis->GetMax();
153 fHistogram = new THnSparseD(histoName, histoTitle, size, nbins, min, max);
159 //________________________________________________________________________________________
160 Bool_t AliRsnFunction::Fill()
163 // Fill function histogram with values computed from given input object.
166 AliDebug(AliLog::kDebug +2,"->");
168 Int_t i, nAxes = fAxisList.GetEntries();
169 Double_t *values = new Double_t[nAxes];
171 AliRsnFunctionAxis *fcnAxis = 0;
172 for (i = 0; i < nAxes; i++) {
173 fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(i);
178 switch (fcnAxis->GetAxisObject()) {
179 case AliRsnFunctionAxis::kParticle:
180 values[i] = fcnAxis->Eval(fTrack);
182 case AliRsnFunctionAxis::kPair:
183 values[i] = fcnAxis->Eval(fPair, fPairDef);
185 case AliRsnFunctionAxis::kEvent:
186 values[i] = fcnAxis->Eval(fEvent);
193 // check presence of output histogram
195 AliError("Histogram is not yet initialized");
198 //TArrayD val(values); val->Print();
199 fHistogram->Fill(values);
201 AliDebug(AliLog::kDebug +2,"->");