2 // Class AliRsnEventFunction
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>
30 #include "AliRsnMCInfo.h"
31 #include "AliRsnDaughter.h"
32 #include "AliRsnEvent.h"
33 #include "AliRsnPairDef.h"
34 #include "AliRsnCut.h"
35 #include "AliRsnCutSet.h"
37 #include "AliRsnEventFunction.h"
39 ClassImp(AliRsnEventFunction)
41 //________________________________________________________________________________________
42 AliRsnEventFunction::AliRsnEventFunction() :
44 fPIDMethod(AliRsnDaughter::kNoPID),
45 fPIDType(AliRsnPID::kUnknown),
52 fBinningCutType(AliRsnCut::kLastCutType),
59 // The histogram data member cannot be passed externally,
60 // its initialization MUST be defined inside the Init() method,
61 // which must be overridden in any derivate implementation.
65 for (i = 0; i < 100; i++)
71 //________________________________________________________________________________________
72 AliRsnEventFunction::AliRsnEventFunction
73 (EType type, AliRsnHistoDef *hd, AliRsnDaughter::EPIDMethod pidMethod,
74 AliRsnPID::EType pidType, Char_t sign) :
76 fPIDMethod(pidMethod),
84 fBinningCutType(AliRsnCut::kLastCutType),
91 // The histogram data member cannot be passed externally,
92 // its initialization MUST be defined inside the Init() method,
93 // which must be overridden in any derivate implementation.
97 for (i = 0; i < 100; i++)
103 //________________________________________________________________________________________
104 AliRsnEventFunction::AliRsnEventFunction(const AliRsnEventFunction ©) :
107 fPIDMethod(copy.fPIDMethod),
108 fPIDType(copy.fPIDType),
109 fCharge(copy.fCharge),
110 fLeadPtMin(copy.fLeadPtMin),
112 fUseBins(copy.fUseBins),
115 fBinningCutType(AliRsnCut::kLastCutType),
116 fEventCuts(copy.fEventCuts),
117 fTrackCuts(copy.fTrackCuts),
118 fHistoDef(copy.fHistoDef)
122 // The histogram data member cannot be passed externally,
123 // its initialization MUST be defined inside the Init() method,
124 // which must be overridden in any derivate implementation.
128 for (i = 0; i < n; i++)
135 n = copy.fBins.GetSize();
136 Double_t *array = new Double_t[n];
137 for (i = 0; i < n; i++) array[i] = copy.fBins[i];
138 SetBinningCut(copy.fBinningCutType, copy.fBins.GetSize(), array);
143 //________________________________________________________________________________________
144 void AliRsnEventFunction::Clear(Option_t* /*option*/)
147 // Clear arrays and histogram.
148 // For the sake of security, all pointers are also set explicitly to NULL.
152 for (i = 0; i < 100; i++)
159 //________________________________________________________________________________________
160 void AliRsnEventFunction::Init(TList *histos)
163 // Initialization function.
164 // By default, it initializes the owned histogram using the method
165 // from AliRsnHistoDef class, giving the same name and title of this.
166 // A user can override this behaviour, if necessary.
167 // Before creating, the HistoDef is checked for proper initialization.
172 Int_t i, ibin, nbins = fHistoDef->GetNBins();
173 Double_t min = fHistoDef->GetMin(), max = fHistoDef->GetMax();
175 // list is created and named after the general
176 // settings used for the contained histograms
179 AliError("NULL target list!");
183 // a general histogram is always added,
184 // which overrides the binning and collects everything
185 fHisto[0] = new TH1D(GetFcnName(), "", nbins, min, max);
186 histos->AddLast(fHisto[0]);
188 // if requested a binning w.r. to some cut variable, histograms are added
189 // for that in this part of the method (one per each bin)
193 for (ibin = 0, i = 1; ibin < fBins.GetSize() - 1; ibin++, i++)
195 sprintf(hName, "%s[%.2f-%.2f]", GetFcnName().Data(), fBins[ibin], fBins[ibin+1]);
196 fHisto[i] = new TH1D(hName, "", nbins, min, max);
197 histos->AddLast(fHisto[i]);
202 //________________________________________________________________________________________
203 void AliRsnEventFunction::SetBinningCut
204 (AliRsnCut::EType type, Double_t min, Double_t max, Double_t step)
212 Int_t i, nBins = (Int_t)((max - min) / step) + 1;
213 fBinningCutType = type;
215 for (i = 0; i < nBins; i++)
217 fBins[i] = min + (Double_t)i * step;
221 //________________________________________________________________________________________
222 void AliRsnEventFunction::SetBinningCut
223 (AliRsnCut::EType type, Int_t nbins, Double_t *bins)
232 fBinningCutType = type;
234 for (i = 0; i < nbins; i++)
240 //________________________________________________________________________________________
241 TString AliRsnEventFunction::GetFcnName()
244 // Return a string which names the function type
247 TString text("Undef");
254 case kLeadingMomentum:
260 case kAverageMomentum:
263 case kAngleLeadingMean:
264 text = "ANGLEADMEAN";
266 case kAngleLeadingRMS:
276 AliError("Type not defined");
281 case AliRsnDaughter::kNoPID:
284 case AliRsnDaughter::kPerfect:
287 case AliRsnDaughter::kRealistic:
288 text += "_REALISTIC_";
291 AliError("PID method not defined");
294 text += AliRsnPID::ParticleName(fPIDType);
299 text += fEventCuts->GetName();
303 text += fTrackCuts->GetName();
309 //________________________________________________________________________________________
310 Bool_t AliRsnEventFunction::Fill(AliRsnEvent *event)
313 // Fillse the histogram with data contained in a defined pair.
314 // This method must be overidden by an appropriate definition in each inheriting class.
317 if (fEventCuts) if (!fEventCuts->IsSelected(AliRsnCut::kEvent, event)) return kFALSE;
319 // first of all, set all selection definitions, using the ones in this object
320 event->SetSelectionPIDType(fPIDType);
321 event->SetSelectionCharge(fCharge);
322 event->SetSelectionPIDMethod(fPIDMethod);
323 event->SetSelectionTrackCuts(fTrackCuts);
325 Double_t value = FcnValue(event);
326 if (!fAccept) return kFALSE;
328 // fill global histogram
329 fHisto[0]->Fill(value);
331 // if bins are allocated, find right one and fill it
335 for (ibin = 0, i = 1; ibin < fBins.GetSize() - 1; ibin++, i++)
337 if (!fHisto[i]) continue;
338 fBinningCut.SetCutValues(fBinningCutType, (Double_t)fBins[ibin], (Double_t)fBins[ibin+1]);
339 fBinningCut.SetCutValues(fBinningCutType, (Int_t)fBins[ibin], (Int_t)fBins[ibin+1]);
340 if (fBinningCut.IsSelected(AliRsnCut::kEvent, event))
342 fHisto[i]->Fill(value);
351 //________________________________________________________________________________________
352 Double_t AliRsnEventFunction::FcnValue(AliRsnEvent *event)
355 // This method must be overridden in all inheritin functions.
356 // It computes the value which must be used to fill the histogram.
360 Double_t output, v[3], vMC[3], vt, vtMC, mean = 0.0, rms = 0.0;
361 AliRsnDaughter *trk = 0x0;
367 output = (Double_t)event->GetMultiplicity();
369 case kLeadingMomentum:
370 trk = event->GetLeadingParticle(fLeadPtMin);
381 trk = event->GetLeadingParticle(fLeadPtMin);
384 output = trk->Theta();
391 case kAverageMomentum:
392 output = event->GetAverageMomentum(count);
393 fAccept = (count > 0);
395 case kAngleLeadingMean:
396 case kAngleLeadingRMS:
397 fAccept = event->GetAngleDistrWRLeading(mean, rms, fLeadPtMin);
398 if (fType == kAngleLeadingMean) output = mean; else output = rms;
403 v[0] = event->GetPrimaryVertexX();
404 v[1] = event->GetPrimaryVertexY();
405 v[2] = event->GetPrimaryVertexZ();
406 vMC[0] = event->GetPrimaryVertexXMC();
407 vMC[1] = event->GetPrimaryVertexYMC();
408 vMC[2] = event->GetPrimaryVertexZMC();
409 vt = TMath::Sqrt(v[0]*v[0] + v[1]*v[1]);
410 vtMC = TMath::Sqrt(vMC[0]*vMC[0] + vMC[1]*vMC[1]);
411 if (fType == kVtResolution) return (vt - vtMC); else return (v[2] - vMC[2]);
414 AliError(Form("Type '%d' not supported for EVENT functions", fType));