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)
22 #include <Riostream.h>
27 #include "AliRsnDaughter.h"
28 #include "AliRsnEvent.h"
29 #include "AliRsnPairDef.h"
30 #include "AliRsnCut.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()) )
102 if (name.Length() > 1) name += '_';
103 name += axis->GetName();
109 //________________________________________________________________________________________
110 void AliRsnFunction::AddAxis(AliRsnFunctionAxis *axis)
112 Int_t size = fAxisList.GetEntries();
113 new (fAxisList[size]) AliRsnFunctionAxis(*axis);
116 //________________________________________________________________________________________
117 THnSparseD* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTitle)
120 // Creates and returns the histogram defined using
121 // arguments fo name and title, and the first histoDef for binning.
122 // Variable-sized histogram binning is always called, due to use of histoDef,
123 // even if the bins are equal, since they are defined in this class.
124 // Eventually present histoDef's in other slots of array (1, 2) are ignored.
127 Int_t size = fAxisList.GetEntries();
129 AliError("No axes defined");
133 static Int_t *nbins = new Int_t[size];
134 static Double_t *min = new Double_t[size];
135 static Double_t *max = new Double_t[size];
137 // retrieve binnings for main and secondary axes
138 AliRsnFunctionAxis *fcnAxis = 0;
139 for (Int_t i = 0; i < size; i++)
141 fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(i);
146 AliError("Empty axis");
149 nbins[i] = fcnAxis->GetNBins();
150 min[i] = fcnAxis->GetMin();
151 max[i] = fcnAxis->GetMax();
155 fHistogram = new THnSparseD(histoName, histoTitle, size, nbins, min, max);
161 //________________________________________________________________________________________
162 Bool_t AliRsnFunction::Fill()
165 // Fill function histogram with values computed from given input object.
168 AliDebug(AliLog::kDebug +2,"->");
170 Int_t i, nAxes = fAxisList.GetEntries();
171 static Double_t *values = new Double_t[nAxes];
173 AliRsnFunctionAxis *fcnAxis = 0;
174 for (i = 0; i < nAxes; i++)
176 fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(i);
181 switch (fcnAxis->GetAxisObject())
183 case AliRsnFunctionAxis::kParticle:
184 values[i] = fcnAxis->Eval(fTrack);
186 case AliRsnFunctionAxis::kPair:
187 values[i] = fcnAxis->Eval(fPair, fPairDef);
189 case AliRsnFunctionAxis::kEvent:
190 values[i] = fcnAxis->Eval(fEvent);
197 // check presence of output histogram
199 AliError("Histogram is not yet initialized");
202 fHistogram->Fill(values);
204 AliDebug(AliLog::kDebug +2,"->");