fOutList->Add(listTmp);
}
- fRsnEventBuffer = new AliRsnEventBuffer(1000);
+ fRsnEventBuffer = new AliRsnEventBuffer(fNumOfEventsInBuffer);
// fRsnEventBuffer = new AliRsnEventBuffer ( 10000 ,kFALSE );
AliDebug(AliLog::kDebug, "->");
if (!fMC[index]) return (AliRsnEvent *) 0x0;
- Bool_t success = fReader.FillFromESD(fRSN[index], fESD[index], fMC[index]);
- if (!success)
+ if (!fReader.Fill(fRSN[index], (AliVEvent*) fESD[index],fMC[index]))
{
- AliInfo("Failed filling");
return (AliRsnEvent*) 0x0;
};
if (!fRsnMC[index]) return (AliRsnEvent *) 0x0;
if (!fReader.FillFromMC(fRSN[index], fRsnMC[index])) return (AliRsnEvent*) 0x0;
//if (!fReader.FillFromESD(fRSN[index], fRsnESD[index], fRsnMC[index])) return (AliRsnEvent*) 0x0;
- fPID.Process(fRSN[index], 3000);
+ fPID.Process(fRSN[index]);
+ fRSN[index]->FillPIDArrays(3000);
return fRSN[index];
}
Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnEvent * ev1, AliRsnEvent * ev2)
{
AliDebug(AliLog::kDebug, "<-");
+
+ // check type
+ if (type != kMixEvent)
+ {
+ AliWarning(Form("Mismatch: type = %d (expected %d)", type, kMixEvent));
+ return kTRUE;
+ }
- Double_t valueD;
+ Double_t valueD, mult1, mult2;
Int_t valueI;
switch (fType)
case kMultiplicityDifference:
valueI = TMath::Abs(ev1->GetMultiplicity() - ev2->GetMultiplicity());
return IsBetween((Int_t)valueI);
+ case kMultiplicityRatio:
+ mult1 = (Double_t)ev1->GetMultiplicity();
+ mult2 = (Double_t)ev2->GetMultiplicity();
+ if (mult1 == 0.0 && mult2 == 0.0) return kTRUE;
+ valueD = 100.0 * TMath::Abs(mult1 - mult2) / TMath::Max(mult1, mult2); // in %
+ return IsBetween((Double_t)valueD);
case kVzDifference:
valueD = TMath::Abs(ev1->GetVz() - ev2->GetVz());
return IsBetween((Double_t)valueD);
kPIDProb,
kMultiplicity,
kMultiplicityDifference,
+ kMultiplicityRatio,
kPhiMeanDifference,
kVzDifference,
kLastCutType
fP[1] = s*xx + c*fP[1];
}
+//_____________________________________________________________________________
+Double_t AliRsnDaughter::AngleTo(AliRsnDaughter *d)
+{
+//
+// Compute angle in DEGREES between the vector momentum of (this)
+// and the one of argument.
+//
+
+ Double_t arg, dot, ptot2 = P2() * d->P2();
+
+ if(ptot2 <= 0) {
+ return 0.0;
+ }
+ else {
+ dot = Px()*d->Px() + Py()*d->Py() + Pz()*d->Pz();
+ arg = dot / TMath::Sqrt(ptot2);
+ if (arg > 1.0) arg = 1.0;
+ if (arg < -1.0) arg = -1.0;
+ return TMath::ACos(arg) * TMath::RadToDeg();
+ }
+}
+
//_____________________________________________________________________________
void AliRsnDaughter::SetPIDWeight(Int_t i, Double_t value)
{
fCharge = (Short_t)esdTrack->Charge();
// calculate N sigma to vertex
- SetNSigmaToVertex(fESDTrackCuts.GetSigmaToVertex(esdTrack));
-
+ AliESDtrackCuts trkCut;
+ SetNSigmaToVertex(trkCut.GetSigmaToVertex(esdTrack));
return kTRUE;
}
void SetM(Double_t m) {fMass = m;}
void SetChi2(Double_t chi2) {fChi2 = chi2;}
void RotateP(Double_t angle);
+ Double_t AngleTo(AliRsnDaughter *d);
// DCA vertex
virtual Double_t Xv() const {return fV[0];}
Double_t fPIDProb[AliRsnPID::kSpecies]; // PID probabilities (Bayesian comp.)
Double_t fPIDWeight[AliRsnPID::kSpecies]; // PID weights
- AliRsnMCInfo *fMCInfo; // reference to particle object (if any)
-
- AliESDtrackCuts fESDTrackCuts; //! tmp object of AliESDtrackCuts for fNSigmaToVertex
-
+ AliRsnMCInfo *fMCInfo; // reference to particle object (if any)
static EPIDMethod fgPIDMethod; // flag to define how the PID is computed for this object
ClassDef(AliRsnDaughter, 4)
//
#include <Riostream.h>
+#include <TH1.h>
#include "AliLog.h"
fPVx(0.0),
fPVy(0.0),
fPVz(0.0),
+ fPhiMean(0.0),
+ fMult(0),
fTracks(0x0),
fNoPID(0x0),
fPerfectPID(0x0),
- fRealisticPID(0x0)
+ fRealisticPID(0x0),
+ fSelPIDType(AliRsnPID::kUnknown),
+ fSelCharge('0'),
+ fSelPIDMethod(AliRsnDaughter::kRealistic),
+ fSelCuts(0x0)
{
//
// Default constructor
fPVx(event.fPVx),
fPVy(event.fPVy),
fPVz(event.fPVz),
+ fPhiMean(event.fPhiMean),
+ fMult(event.fMult),
fTracks(0x0),
fNoPID(0x0),
fPerfectPID(0x0),
- fRealisticPID(0x0)
+ fRealisticPID(0x0),
+ fSelPIDType(AliRsnPID::kUnknown),
+ fSelCharge('0'),
+ fSelPIDMethod(AliRsnDaughter::kRealistic),
+ fSelCuts(0x0)
{
//
// Copy constructor.
fPVx = event.fPVx;
fPVy = event.fPVy;
fPVz = event.fPVz;
+
+ // other data
+ fPhiMean = event.fPhiMean;
+ fMult = event.fMult;
// add tracks from array of argument
Int_t errors = Fill(event.fTracks);
return (AliRsnDaughter*) fTracks->UncheckedAt(index);
}
-//_____________________________________________________________________________
-AliRsnDaughter* AliRsnEvent::GetLeadingParticle
-(Double_t ptMin, AliRsnPID::EType type, Bool_t realistic)
-{
-//
-// Returns the particle in this event with largest transverse momentum,
-// provided that this momentum is larger than the first argument
-// and that the PID type correspond to the second argument.
-// If one specifies "AliRsnPID::kUnknown" as second arguments, the PID check is not done.
-//
-
- Double_t prob;
- AliRsnPID::EType trackType;
- AliRsnDaughter *track, *leading = 0x0;
- TObjArrayIter iter(fTracks);
- while ((track = (AliRsnDaughter*) iter.Next()))
- {
- if (track->Pt() < ptMin) continue;
- if (realistic)
- {
- AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic);
- }
- else
- {
- AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kPerfect);
- }
- trackType = track->PIDType(prob);
- if (type != AliRsnPID::kUnknown && trackType != type) continue;
- ptMin = track->Pt();
- leading = track;
- }
-
- return leading;
-}
-
-//_____________________________________________________________________________
-Int_t AliRsnEvent::GetLastFastTrack
-(Double_t ptMin, AliRsnPID::EType type, Bool_t realistic)
-{
-//
-// Loops on the list of tracks (eventually skipping the ones which do not match
-// the given PID type with the specified PID method) and returns the index of the last
-// one whose transverse momentum is still larger than a specified value.
-// When no tracks are found this way, the value "-1" is returned.
-//
-
- if (realistic)
- {
- AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic);
- }
- else
- {
- AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kPerfect);
- }
-
- Double_t prob;
- Int_t i, nTracks = fTracks->GetEntries(), lastIndex = -1;
- for (i = 0; i < nTracks; i++)
- {
- AliRsnDaughter *d = (AliRsnDaughter*) fTracks->At(i);
- AliRsnPID::EType trackType = d->PIDType(prob);
- if (type != AliRsnPID::kUnknown && trackType != type) continue;
- if (d->Pt() >= ptMin) lastIndex = i;
- }
-
- return lastIndex;
-}
-
//_____________________________________________________________________________
TArrayI* AliRsnEvent::GetCharged(Char_t sign)
{
return -1;
}
}
+//_____________________________________________________________________________
+inline void AliRsnEvent::SetSelection
+(AliRsnPID::EType pid, Char_t charge, AliRsnDaughter::EPIDMethod meth, AliRsnCutSet *cuts)
+{
+//
+// Set all selection parameters at once
+//
+
+ SetSelectionPIDType(pid);
+ SetSelectionCharge(charge);
+ SetSelectionPIDMethod(meth);
+ SetSelectionTrackCuts(cuts);
+}
+
+//_____________________________________________________________________________
+AliRsnDaughter* AliRsnEvent::GetLeadingParticle(Double_t ptMin)
+{
+//
+// Searches the collection of all particles with given PID type and charge,
+// and returns the one with largest momentum, provided that it is greater than 1st argument.
+// If one specifies AliRsnPID::kUnknown as type or AliRsnDaughter::kNoPID as method,
+// the check is done over all particles irrespectively of their PID.
+// If the sign argument is '+' or '-', the check is done over the particles of that charge,
+// otherwise it is done irrespectively of the charge.
+//
+
+ Int_t i;
+ TArrayI *array = 0x0;
+ AliRsnDaughter *track1 = 0x0, *track2 = 0x0, *leading = 0x0;
+
+ if (fSelCharge == '+' || fSelCharge == '-') {
+ // if the charge '+' or '-' does simply the search
+ array = GetTracksArray(fSelPIDMethod, fSelCharge, fSelPIDType);
+ for (i = 0; i < array->GetSize(); i++) {
+ track1 = (AliRsnDaughter *) fTracks->At(array->At(i));
+ if (!track1) continue;
+ if (track1->Pt() < ptMin) continue;
+ if (!CutPass(track1)) continue;
+ ptMin = track1->Pt();
+ leading = track1;
+ }
+ }
+ else {
+ track1 = GetLeadingParticle(ptMin);
+ track2 = GetLeadingParticle(ptMin);
+ if (track1 && track2) {
+ if (track1->Pt() > track2->Pt()) leading = track1;
+ else leading = track2;
+ }
+ else if (track1) leading = track1;
+ else if (track2) leading = track2;
+ else leading = 0x0;
+ }
+
+ return leading;
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnEvent::GetAverageMomentum(Int_t &count)
+{
+//
+// Loops on the list of tracks and computes average total momentum.
+//
+
+ Int_t i;
+ Double_t pmean = 0.0;
+ TArrayI *array = 0x0;
+ AliRsnDaughter *d = 0x0;
+
+ if (fSelCharge == '+' || fSelCharge == '-') {
+ // if the charge '+' or '-' does simply the search
+ count = 0;
+ array = GetTracksArray(fSelPIDMethod, fSelCharge, fSelPIDType);
+ for (i = 0; i < array->GetSize(); i++) {
+ d = (AliRsnDaughter *) fTracks->At(array->At(i));
+ if (!d) continue;
+ if (!CutPass(d)) continue;
+ pmean += d->P();
+ count++;
+ }
+ if (count > 0) pmean /= (Double_t)count;
+ else pmean = 0.0;
+ }
+ else {
+ Int_t countP, countM;
+ Double_t pmeanP = GetAverageMomentum(countP);
+ Double_t pmeanM = GetAverageMomentum(countM);
+ if (countP && countM) {
+ pmean = (pmeanP * (Double_t)countP + pmeanM * (Double_t)countM) / (countP + countM);
+ count = countP + countM;
+ }
+ else if (countP) {
+ pmean = pmeanP;
+ count = countP;
+ }
+ else if (countM) {
+ pmean = pmeanM;
+ count = countM;
+ }
+ else {
+ count = 0;
+ pmean = 0.0;
+ }
+ }
+
+ return pmean;
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnEvent::GetAngleDistrWRLeading
+(Double_t &angleMean, Double_t &angleRMS, Double_t ptMin)
+{
+//
+// Takes the leading particle and computes the mean and RMS
+// of the distribution of directions of all other tracks
+// with respect to the direction of leading particle.
+//
+
+ AliRsnDaughter *leading = GetLeadingParticle(ptMin);
+ if (!leading) return kFALSE;
+
+ Int_t count = 0;
+ Double_t angle, angle2Mean;
+ AliRsnDaughter *trk = 0x0;
+ TObjArrayIter next(fTracks);
+
+ angleMean = angle2Mean = 0.0;
+
+ while ( (trk = (AliRsnDaughter*)next()) )
+ {
+ if (trk == leading) continue;
+
+ angle = leading->AngleTo(trk);
+
+ angleMean += angle;
+ angle2Mean += angle * angle;
+ count++;
+ }
+
+ if (!count) return kFALSE;
+
+ angleMean /= (Double_t)count;
+ angle2Mean /= (Double_t)count;
+ angleRMS = TMath::Sqrt(angle2Mean - angleMean*angleMean);
+
+ return kTRUE;
+}
#include "AliRsnPID.h"
#include "AliRsnPIDIndex.h"
#include "AliRsnDaughter.h"
+#include "AliRsnCutSet.h"
+
+class TH1D;
class AliRsnEvent : public TNamed
{
void Clear(Option_t *option = "");
AliRsnDaughter* AddTrack(AliRsnDaughter track);
AliRsnDaughter* GetTrack(Int_t index);
- AliRsnDaughter* GetLeadingParticle(Double_t ptMin = 0.0, AliRsnPID::EType type = AliRsnPID::kUnknown, Bool_t realistic = kTRUE);
- Int_t GetLastFastTrack(Double_t ptMin, AliRsnPID::EType type = AliRsnPID::kUnknown, Bool_t realistic = kTRUE);
TClonesArray* GetTracks() {return fTracks;}
TArrayI* GetCharged(Char_t sign);
TArrayI* GetTracksArray(AliRsnDaughter::EPIDMethod method, Char_t sign, AliRsnPID::EType type);
// Mean phi
Double_t GetPhiMean() const {return fPhiMean;}
+
+ // functions for event selection and computation (require on-fly setting of sel parameters)
+ void SetSelectionPIDType(AliRsnPID::EType type) {fSelPIDType = type;}
+ void SetSelectionCharge(Char_t charge) {fSelCharge = charge;}
+ void SetSelectionPIDMethod(AliRsnDaughter::EPIDMethod method) {fSelPIDMethod = method;}
+ void SetSelectionTrackCuts(AliRsnCutSet *cuts) {fSelCuts = cuts;}
+ void SetSelection(AliRsnPID::EType pid, Char_t charge, AliRsnDaughter::EPIDMethod meth, AliRsnCutSet *cuts = 0x0);
+
+ Bool_t CutPass(AliRsnDaughter *d)
+ {if (!fSelCuts) return kTRUE; else return fSelCuts->IsSelected(AliRsnCut::kParticle, d);}
+
+ AliRsnDaughter* GetLeadingParticle(Double_t ptMin = 0.0);
+ Double_t GetAverageMomentum(Int_t &count);
+ Bool_t GetAngleDistrWRLeading(Double_t &angleMean, Double_t &angleRMS, Double_t ptMin = 0.0);
private:
AliRsnPIDIndex *fNoPID; // array index only for charged tracks
AliRsnPIDIndex *fPerfectPID; // array index for perfect PID
AliRsnPIDIndex *fRealisticPID; // array index for realistic PID (largest prob)
+
+ AliRsnPID::EType fSelPIDType; //! (for selection/cut functions) particle type
+ Char_t fSelCharge; //! (for selection/cut functions) particle charge ('0' = both)
+ AliRsnDaughter::EPIDMethod fSelPIDMethod; //! (for selection/cut functions) PID method used
+ AliRsnCutSet *fSelCuts; //! (for selection/cut functions) track cuts used
ClassDef(AliRsnEvent, 2);
};
--- /dev/null
+//
+// Class AliRsnEventFunction
+//
+// This class defines a base classe to implement a function
+// which uses the internal RSN package event format (AliRsnEvent).
+// It contains some default flags which turn out to be useful:
+// - a flag to select only the "true" pairs (tracks from same resonance)
+// - a flag to know if the computation is done over two events (mixing)
+//
+// Any kind of analysis object should be implemented as inheriting from this
+// because the AliRsnAnalyzer which executes the analysis will accept a collection
+// of such objects, in order to have a unique format of processing method
+//
+// The user who implements a kind of computation type should inherit from
+// this class and override the virtual functions defined in it, which
+// initialize the final output histogram and define how to process data.
+//
+//
+// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+//
+
+#include <Riostream.h>
+
+#include <TH1.h>
+#include <TList.h>
+#include <TString.h>
+
+#include "AliLog.h"
+
+#include "AliRsnMCInfo.h"
+#include "AliRsnDaughter.h"
+#include "AliRsnEvent.h"
+#include "AliRsnPairDef.h"
+#include "AliRsnCut.h"
+#include "AliRsnCutSet.h"
+
+#include "AliRsnEventFunction.h"
+
+ClassImp(AliRsnEventFunction)
+
+//________________________________________________________________________________________
+AliRsnEventFunction::AliRsnEventFunction() :
+ fType(kTypes),
+ fPIDMethod(AliRsnDaughter::kNoPID),
+ fPIDType(AliRsnPID::kUnknown),
+ fCharge('0'),
+ fLeadPtMin(0.0),
+ fAccept(kFALSE),
+ fUseBins(kFALSE),
+ fBins(0),
+ fBinningCut(),
+ fBinningCutType(AliRsnCut::kLastCutType),
+ fEventCuts(0x0),
+ fTrackCuts(0x0),
+ fHistoDef(0x0)
+{
+ //
+ // Constructor.
+ // The histogram data member cannot be passed externally,
+ // its initialization MUST be defined inside the Init() method,
+ // which must be overridden in any derivate implementation.
+ //
+
+ Int_t i;
+ for (i = 0; i < 100; i++)
+ {
+ fHisto[i] = 0x0;
+ }
+}
+
+//________________________________________________________________________________________
+AliRsnEventFunction::AliRsnEventFunction
+(EType type, AliRsnHistoDef *hd, AliRsnDaughter::EPIDMethod pidMethod,
+ AliRsnPID::EType pidType, Char_t sign) :
+ fType(type),
+ fPIDMethod(pidMethod),
+ fPIDType(pidType),
+ fCharge(sign),
+ fLeadPtMin(0.0),
+ fAccept(kFALSE),
+ fUseBins(kFALSE),
+ fBins(0),
+ fBinningCut(),
+ fBinningCutType(AliRsnCut::kLastCutType),
+ fEventCuts(0x0),
+ fTrackCuts(0x0),
+ fHistoDef(hd)
+{
+ //
+ // Constructor.
+ // The histogram data member cannot be passed externally,
+ // its initialization MUST be defined inside the Init() method,
+ // which must be overridden in any derivate implementation.
+ //
+
+ Int_t i;
+ for (i = 0; i < 100; i++)
+ {
+ fHisto[i] = 0x0;
+ }
+}
+
+//________________________________________________________________________________________
+AliRsnEventFunction::AliRsnEventFunction(const AliRsnEventFunction ©) :
+ TObject(copy),
+ fType(copy.fType),
+ fPIDMethod(copy.fPIDMethod),
+ fPIDType(copy.fPIDType),
+ fCharge(copy.fCharge),
+ fLeadPtMin(copy.fLeadPtMin),
+ fAccept(kFALSE),
+ fUseBins(copy.fUseBins),
+ fBins(0),
+ fBinningCut(),
+ fBinningCutType(AliRsnCut::kLastCutType),
+ fEventCuts(copy.fEventCuts),
+ fTrackCuts(copy.fTrackCuts),
+ fHistoDef(copy.fHistoDef)
+{
+ //
+ // Constructor.
+ // The histogram data member cannot be passed externally,
+ // its initialization MUST be defined inside the Init() method,
+ // which must be overridden in any derivate implementation.
+ //
+
+ Int_t i, n = 100;
+ for (i = 0; i < n; i++)
+ {
+ fHisto[i] = 0x0;
+ }
+
+ if (fUseBins)
+ {
+ n = copy.fBins.GetSize();
+ Double_t *array = new Double_t[n];
+ for (i = 0; i < n; i++) array[i] = copy.fBins[i];
+ SetBinningCut(copy.fBinningCutType, copy.fBins.GetSize(), array);
+ delete [] array;
+ }
+}
+
+//________________________________________________________________________________________
+void AliRsnEventFunction::Clear(Option_t* /*option*/)
+{
+ //
+ // Clear arrays and histogram.
+ // For the sake of security, all pointers are also set explicitly to NULL.
+ //
+
+ Int_t i;
+ for (i = 0; i < 100; i++)
+ {
+ delete fHisto[i];
+ fHisto[i] = 0x0;
+ }
+}
+
+//________________________________________________________________________________________
+void AliRsnEventFunction::Init(TList *histos)
+{
+ //
+ // Initialization function.
+ // By default, it initializes the owned histogram using the method
+ // from AliRsnHistoDef class, giving the same name and title of this.
+ // A user can override this behaviour, if necessary.
+ // Before creating, the HistoDef is checked for proper initialization.
+ //
+
+ Clear();
+
+ Int_t i, ibin, nbins = fHistoDef->GetNBins();
+ Double_t min = fHistoDef->GetMin(), max = fHistoDef->GetMax();
+
+ // list is created and named after the general
+ // settings used for the contained histograms
+ if (!histos)
+ {
+ AliError("NULL target list!");
+ return;
+ }
+
+ // a general histogram is always added,
+ // which overrides the binning and collects everything
+ fHisto[0] = new TH1D(GetFcnName(), "", nbins, min, max);
+ histos->AddLast(fHisto[0]);
+
+ // if requested a binning w.r. to some cut variable, histograms are added
+ // for that in this part of the method (one per each bin)
+ Char_t hName[255];
+ if (fUseBins)
+ {
+ for (ibin = 0, i = 1; ibin < fBins.GetSize() - 1; ibin++, i++)
+ {
+ sprintf(hName, "%s[%.2f-%.2f]", GetFcnName().Data(), fBins[ibin], fBins[ibin+1]);
+ fHisto[i] = new TH1D(hName, "", nbins, min, max);
+ histos->AddLast(fHisto[i]);
+ }
+ }
+}
+
+//________________________________________________________________________________________
+void AliRsnEventFunction::SetBinningCut
+(AliRsnCut::EType type, Double_t min, Double_t max, Double_t step)
+{
+ //
+ // Set fixed bins
+ //
+
+ fUseBins = kTRUE;
+
+ Int_t i, nBins = (Int_t)((max - min) / step) + 1;
+ fBinningCutType = type;
+ fBins.Set(nBins);
+ for (i = 0; i < nBins; i++)
+ {
+ fBins[i] = min + (Double_t)i * step;
+ }
+}
+
+//________________________________________________________________________________________
+void AliRsnEventFunction::SetBinningCut
+(AliRsnCut::EType type, Int_t nbins, Double_t *bins)
+{
+ //
+ // Set variable bins
+ //
+
+ fUseBins = kTRUE;
+
+ Int_t i;
+ fBinningCutType = type;
+ fBins.Set(nbins);
+ for (i = 0; i < nbins; i++)
+ {
+ fBins[i] = bins[i];
+ }
+}
+
+//________________________________________________________________________________________
+TString AliRsnEventFunction::GetFcnName()
+{
+ //
+ // Return a string which names the function type
+ //
+
+ TString text("Undef");
+
+ switch (fType)
+ {
+ case kMultiplicity:
+ text = "MULT";
+ break;
+ case kLeadingMomentum:
+ text = "PLEAD";
+ break;
+ case kLeadingTheta:
+ text = "LEADTHETA";
+ break;
+ case kAverageMomentum:
+ text = "PAVG";
+ break;
+ case kAngleLeadingMean:
+ text = "ANGLEADMEAN";
+ break;
+ case kAngleLeadingRMS:
+ text = "ANGLEADRMS";
+ break;
+ default:
+ AliError("Type not defined");
+ }
+
+ switch (fPIDMethod)
+ {
+ case AliRsnDaughter::kNoPID:
+ text += "_NOPID_";
+ break;
+ case AliRsnDaughter::kPerfect:
+ text += "_PERFECT_";
+ break;
+ case AliRsnDaughter::kRealistic:
+ text += "_REALISTIC_";
+ break;
+ default:
+ AliError("PID method not defined");
+ }
+
+ text += AliRsnPID::ParticleName(fPIDType);
+ text += fCharge;
+
+ if (fEventCuts) {
+ text += '_';
+ text += fEventCuts->GetName();
+ }
+ if (fTrackCuts) {
+ text += '_';
+ text += fTrackCuts->GetName();
+ }
+
+ return text;
+}
+
+//________________________________________________________________________________________
+Bool_t AliRsnEventFunction::Fill(AliRsnEvent *event)
+{
+ //
+ // Fillse the histogram with data contained in a defined pair.
+ // This method must be overidden by an appropriate definition in each inheriting class.
+ //
+
+ if (fEventCuts) if (!fEventCuts->IsSelected(AliRsnCut::kEvent, event)) return kFALSE;
+
+ // first of all, set all selection definitions, using the ones in this object
+ event->SetSelectionPIDType(fPIDType);
+ event->SetSelectionCharge(fCharge);
+ event->SetSelectionPIDMethod(fPIDMethod);
+ event->SetSelectionTrackCuts(fTrackCuts);
+
+ Double_t value = FcnValue(event);
+ if (!fAccept) return kFALSE;
+
+ // fill global histogram
+ fHisto[0]->Fill(value);
+
+ // if bins are allocated, find right one and fill it
+ if (fUseBins)
+ {
+ Int_t i, ibin;
+ for (ibin = 0, i = 1; ibin < fBins.GetSize() - 1; ibin++, i++)
+ {
+ if (!fHisto[i]) continue;
+ fBinningCut.SetCutValues(fBinningCutType, (Double_t)fBins[ibin], (Double_t)fBins[ibin+1]);
+ fBinningCut.SetCutValues(fBinningCutType, (Int_t)fBins[ibin], (Int_t)fBins[ibin+1]);
+ if (fBinningCut.IsSelected(AliRsnCut::kEvent, event))
+ {
+ fHisto[i]->Fill(value);
+ break;
+ }
+ }
+ }
+
+ return kTRUE;
+}
+
+//________________________________________________________________________________________
+Double_t AliRsnEventFunction::FcnValue(AliRsnEvent *event)
+{
+ //
+ // This method must be overridden in all inheritin functions.
+ // It computes the value which must be used to fill the histogram.
+ //
+
+ Int_t count;
+ Double_t output, mean = 0.0, rms = 0.0;
+ AliRsnDaughter *trk = 0x0;
+
+ switch (fType)
+ {
+ case kMultiplicity:
+ fAccept = kTRUE;
+ output = (Double_t)event->GetMultiplicity();
+ break;
+ case kLeadingMomentum:
+ trk = event->GetLeadingParticle(fLeadPtMin);
+ if (trk) {
+ fAccept = kTRUE;
+ output = trk->P();
+ }
+ else {
+ fAccept = kFALSE;
+ output = 0.0;
+ }
+ break;
+ case kLeadingTheta:
+ trk = event->GetLeadingParticle(fLeadPtMin);
+ if (trk) {
+ fAccept = kTRUE;
+ output = trk->Theta();
+ }
+ else {
+ fAccept = kFALSE;
+ output = 0.0;
+ }
+ break;
+ case kAverageMomentum:
+ output = event->GetAverageMomentum(count);
+ fAccept = (count > 0);
+ break;
+ case kAngleLeadingMean:
+ case kAngleLeadingRMS:
+ fAccept = event->GetAngleDistrWRLeading(mean, rms, fLeadPtMin);
+ if (fType == kAngleLeadingMean) output = mean; else output = rms;
+ break;
+ default:
+ AliError(Form("Type '%d' not supported for EVENT functions", fType));
+ fAccept = kFALSE;
+ output = 0.0;
+ }
+
+ return output;
+}
+
--- /dev/null
+//
+// Class AliRsn Fcn
+//
+// This class defines a base classe to implement a typical computation
+// which uses the internal RSN package event format (AliRsnEvent).
+// It contains some default flags which turn out to be useful:
+// - a flag to select only the "true" pairs (tracks from same resonance)
+// - a flag to know if the computation is done over two events (mixing)
+//
+// Any kind of analysis object should be implemented as inheriting from this
+// because the AliRsnAnalyzer which executes the analysis will accept a collection
+// of such objects, in order to have a unique format of processing method
+//
+// The user who implements a kind of computation type should inherit from
+// this class and override the virtual functions defined in it, which
+// initialize the final output histogram and define how to process data.
+//
+//
+// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
+//
+
+#ifndef ALIRsnEventFunction_H
+#define ALIRsnEventFunction_H
+
+#include <TArrayD.h>
+#include <TString.h>
+
+#include "AliRsnCut.h"
+#include "AliRsnCutSet.h"
+#include "AliRsnHistoDef.h"
+#include "AliRsnPairParticle.h"
+
+class TH1D;
+class TH2D;
+class AliRsnEvent;
+
+class AliRsnEventFunction : public TObject
+{
+
+ public:
+
+ enum EType
+ {
+ kMultiplicity,
+ kLeadingMomentum,
+ kLeadingTheta,
+ kAverageMomentum,
+ kAngleLeadingMean,
+ kAngleLeadingRMS,
+
+ kTypes
+ };
+
+ AliRsnEventFunction();
+ AliRsnEventFunction(EType type, AliRsnHistoDef *hd,
+ AliRsnDaughter::EPIDMethod pidMethod = AliRsnDaughter::kNoPID,
+ AliRsnPID::EType pidType = AliRsnPID::kUnknown,
+ Char_t sign = '0');
+ AliRsnEventFunction(const AliRsnEventFunction ©);
+ virtual ~AliRsnEventFunction() {Clear();}
+ virtual void Clear(Option_t *option = "");
+
+ Bool_t UseBins() {return fUseBins;}
+ AliRsnHistoDef* GetHistoDef() {return fHistoDef;}
+ TString GetFcnName();
+
+ void SetBinningCut(AliRsnCut::EType type, Double_t min, Double_t max, Double_t step);
+ void SetBinningCut(AliRsnCut::EType type, Int_t nbins, Double_t *bins);
+ void SetHistoDef(AliRsnHistoDef *def) {fHistoDef = def;}
+ void SetEventCuts(AliRsnCutSet *cuts) {fEventCuts = cuts;}
+ void SetTrackCuts(AliRsnCutSet *cuts) {fTrackCuts = cuts;}
+ void SetLeadingPtMin(Double_t value) {fLeadPtMin = value;}
+
+ // working routines
+ void Init(TList *tgt);
+ Bool_t Fill(AliRsnEvent *event);
+ Double_t FcnValue(AliRsnEvent *event);
+
+ private:
+
+ const AliRsnEventFunction& operator=(const AliRsnEventFunction& /*copy*/) { return *this; }
+
+ EType fType; // function type
+
+ AliRsnDaughter::EPIDMethod fPIDMethod; // PID method to be used
+ AliRsnPID::EType fPIDType; // PID species to be used
+ Char_t fCharge; // charge sign
+ Double_t fLeadPtMin; // smallest acceptable momentum of leading particle
+
+ Bool_t fAccept; // internal flag to check a computed value
+ Bool_t fUseBins; // flag to choose if binning is used
+
+ TArrayD fBins; // low edge of each bin (upper is the low edge of next bin)
+ AliRsnCut fBinningCut; // binning cut
+ AliRsnCut::EType fBinningCutType; // binning cut type
+
+ AliRsnCutSet *fEventCuts; // selection cuts for events
+ AliRsnCutSet *fTrackCuts; // selection cuts for tracks in each event
+
+ AliRsnHistoDef *fHistoDef; // definitions for histogram
+ TH1D *fHisto[100]; // binned histograms
+
+ // ROOT dictionary
+ ClassDef(AliRsnEventFunction, 1)
+};
+
+#endif
--- /dev/null
+//
+// Class AliRsnEventTaskSE
+//
+// TODO
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#include <TList.h>
+
+#include "AliLog.h"
+
+#include "AliAnalysisManager.h"
+
+#include "AliRsnEvent.h"
+#include "AliRsnEventFunction.h"
+#include "AliRsnEventTaskSE.h"
+
+ClassImp(AliRsnEventTaskSE)
+
+//________________________________________________________________________
+AliRsnEventTaskSE::AliRsnEventTaskSE(const char * name) :
+ AliRsnAnalysisTaskSEBase(name),
+ fEventFunctions("AliRsnEventFunction", 0),
+ fOutList(0x0)
+{
+//
+// Default constructor
+//
+
+ InitIOVars();
+ DefineOutput(1, TList::Class());
+}
+
+//________________________________________________________________________
+AliRsnEventTaskSE::~AliRsnEventTaskSE()
+{
+//
+// Destructor
+//
+}
+
+//________________________________________________________________________
+void AliRsnEventTaskSE::InitIOVars()
+{
+//
+// Init input output values
+//
+
+ AliRsnAnalysisTaskSEBase::InitIOVars();
+ fOutList = 0;
+}
+
+//________________________________________________________________________
+void AliRsnEventTaskSE::UserCreateOutputObjects()
+{
+//
+// UserCreateOutputObjects() of AliAnalysisTaskSE
+//
+
+ OpenFile(0);
+ fOutList = new TList();
+ fOutList->SetOwner();
+ fOutList->SetName("EventFunctions");
+
+ AliRsnEventFunction *fcn = 0;
+ TObjArrayIter next(&fEventFunctions);
+
+ while ( (fcn = (AliRsnEventFunction*)next()) )
+ {
+ fcn->Init(fOutList);
+ }
+
+ AliInfo("List");
+ fOutList->Print();
+ AliInfo("End List");
+}
+
+//________________________________________________________________________
+void AliRsnEventTaskSE::UserExec(Option_t *)
+{
+//
+// UserExec() of AliAnalysisTaskSE
+//
+
+ if (fEntry++ % 1000 == 0) AliInfo(Form("Event %d", fEntry-1));
+
+ AliRsnEvent *curEvent = GetRsnEventFromInputType();return;
+ if (!curEvent) return;
+
+ AliRsnEventFunction *fcn = 0;
+ TObjArrayIter next(&fEventFunctions);
+
+ while ( (fcn = (AliRsnEventFunction*)next()) )
+ {
+ fcn->Fill(curEvent);
+ }
+
+ PostData(1, fOutList);
+}
+
+//________________________________________________________________________
+void AliRsnEventTaskSE::Terminate(Option_t *)
+{
+//
+// Terminate() of AliAnalysisTask
+//
+
+ fOutList = dynamic_cast<TList*>(GetOutputData(1));
+ if (!fOutList) { AliError("*** Output list not available ***"); return; }
+ fOutList->Print();
+}
+
+//________________________________________________________________________
+void AliRsnEventTaskSE::AddEventFunction(AliRsnEventFunction *fcn)
+{
+ Int_t size = fEventFunctions.GetEntries();
+ new (fEventFunctions[size]) AliRsnEventFunction(*fcn);
+ AliInfo(Form("Function name: %s", fcn->GetFcnName().Data()));
+}
--- /dev/null
+//
+// Class AliRsnEventTaskSE
+//
+// TODO
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#ifndef ALIRSNEVENTTASK_H
+#define ALIRSNEVENTTASK_H
+
+#include <TClonesArray.h>
+#include "AliRsnAnalysisTaskSEBase.h"
+
+class TList;
+class AliRsnEvent;
+class AliRsnEventFunction;
+
+
+class AliRsnEventTaskSE : public AliRsnAnalysisTaskSEBase
+{
+ public:
+ AliRsnEventTaskSE(const char *name = "AliRsnEventTaskSE");
+ AliRsnEventTaskSE(const AliRsnEventTaskSE& copy): AliRsnAnalysisTaskSEBase(copy),
+ fEventFunctions("AliRsnEventFunction", 0),fOutList(0x0) {}
+ AliRsnEventTaskSE& operator= (const AliRsnEventTaskSE&) {return *this;}
+ ~AliRsnEventTaskSE();
+
+ virtual void InitIOVars();
+ virtual void UserCreateOutputObjects();
+ virtual void UserExec(Option_t *option);
+ virtual void Terminate(Option_t *);
+
+ void AddEventFunction(AliRsnEventFunction *fcn);
+
+ private:
+
+ TClonesArray fEventFunctions;
+ TList *fOutList; // List of output
+
+ void ProcessEventAnalysis(AliRsnEvent *curEvent);
+ void PostEventProcess(const Short_t &index=0);
+
+ ClassDef(AliRsnEventTaskSE, 1)
+};
+
+#endif
case kEtaSpectrum:
text = "ETA";
break;
- case kAngleSpectrum:
- text = "ANGLE";
default:
AliError("Type not defined");
}
case kEtaSpectrum:
text = "#eta distribution";
break;
- case kAngleSpectrum:
- text = "angle distribution";
- break;
default:
AliError("Type not defined");
}
return pair->GetPt();
case kEtaSpectrum:
return pair->GetEta();
- case kAngleSpectrum:
- return pair->GetAngle();
default:
AliError("Type not defined");
}
kResolution,
kPtSpectrum,
kEtaSpectrum,
- kAngleSpectrum,
kFcnTypes
};
}
//_____________________________________________________________________________
-Bool_t AliRsnPID::Process(AliRsnEvent *event, Int_t pidArraySizeDefault)
+Bool_t AliRsnPID::Process(AliRsnEvent *event)
{
//
// Performs identification for all tracks in a given event.
{
check = check && ComputeProbs(daughter);
}
- event->FillPIDArrays(pidArraySizeDefault);
+ event->FillPIDArrays();
return check;
}
static Double_t ParticleMass(EType pid);
// identification routines
- Bool_t Process(AliRsnEvent *e, Int_t pidArraySizeDefault = 1000);
+ Bool_t Process(AliRsnEvent *e);
Bool_t ComputeProbs(AliRsnDaughter *d);
Bool_t IdentifiedAs(AliRsnDaughter *d, EType type, Short_t charge = 0);
EType TrackType(AliRsnDaughter *d);
//_____________________________________________________________________________
AliRsnPair::AliRsnPair
-(EPairType type, AliRsnPairDef *def, Int_t mixNum, Double_t mixVzCut, Int_t mixMultCut) :
+(EPairType type, AliRsnPairDef *def, Int_t mixNum) :
TObject(),
fIsMixed(kFALSE),
fUseMC(kFALSE),
}
//_____________________________________________________________________________
-void AliRsnPair::Print()
+void AliRsnPair::Print(Option_t* /*option*/) const
{
//
// Prints info about pair
AliRsnEvent *e2 = 0;
e2 = FindEventByEventCut(buf, lastOkEvent);
if (!e2) return;
- //if (fIsMixed) {
- //AliInfo(Form("ev1 = #%d -- ev2 = #%d -- nMixed = %d/%d", buf->IndexOf(e1), buf->IndexOf(e2), i, fMixNum));
+ if (fIsMixed) {
+ AliInfo(Form("ev1 = #%d -- ev2 = #%d -- nMixed = %d/%d", buf->IndexOf(e1), buf->IndexOf(e2), i, fMixNum));
//AliInfo(Form("Diff Mult = %d", TMath::Abs(e1->GetMultiplicity() - e2->GetMultiplicity())));
//AliInfo(Form("Diff Vz = %f", TMath::Abs(e1->GetVz() - e2->GetVz())));
//AliInfo(Form("Diff Phi = %f", TMath::Abs(e1->GetPhiMean() - e2->GetPhiMean())));
- //}
+ }
// if (e2->GetMultiplicity() < 1) continue;
array2 = e2->GetTracksArray(fTypePID, fPairDef->GetCharge(1), fPairDef->GetType(1));
LoopPair(e1, array1, e2, array2);
}
//_____________________________________________________________________________
-TString AliRsnPair::GetPairTypeName(EPairType type)
+TString AliRsnPair::GetPairTypeName(EPairType type) const
{
//
// Returns type name, made with particle names ant chosen PID
}
//_____________________________________________________________________________
-TString AliRsnPair::GetPairName()
+TString AliRsnPair::GetPairName() const
{
//
// Retruns pair name
}
//_____________________________________________________________________________
-TString AliRsnPair::GetPairHistName(AliRsnFunction *fcn, TString text)
+TString AliRsnPair::GetPairHistName(AliRsnFunction *fcn, TString text) const
{
//
// Returns eff. mass histogram name
}
//_____________________________________________________________________________
-TString AliRsnPair::GetPairHistTitle(AliRsnFunction *fcn, TString text)
+TString AliRsnPair::GetPairHistTitle(AliRsnFunction *fcn, TString text) const
{
//
// Returns eff. mass histogram title
kPairTypes
};
- AliRsnPair(EPairType type = kRealisticPID, AliRsnPairDef *def = 0,
- Int_t mixNum = 1, Double_t mixVzCut = 1.0, Int_t mixMultCut = 10);
+ AliRsnPair(EPairType type = kRealisticPID, AliRsnPairDef *def = 0, Int_t mixNum = 1);
~AliRsnPair();
void Init();
- void Print();
+ void Print(Option_t *option = "") const;
void ProcessPair(AliRsnEventBuffer *buf);
void SetCutMgr(AliRsnCutMgr* theValue) { fCutMgr = theValue; }
void SetMixingCut(AliRsnCutSet* theValue) { fMixingCut = theValue; }
TList* GenerateHistograms(TString prefix = "");
void GenerateHistograms(TString prefix, TList *tgt);
- TString GetPairTypeName(EPairType type);
- TString GetPairName();
- TString GetPairHistName(AliRsnFunction *fcn, TString text = "");
- TString GetPairHistTitle(AliRsnFunction *fcn, TString text="");
+ TString GetPairTypeName(EPairType type) const;
+ TString GetPairName() const;
+ TString GetPairHistName(AliRsnFunction *fcn, TString text = "") const;
+ TString GetPairHistTitle(AliRsnFunction *fcn, TString text = "") const;
private:
Double_t dotProd = 0.0;
dotProd += fDaughter[0]->Px() * fDaughter[1]->Px();
- dotProd += fDaughter[0]->Py() * fDaughter[1]->Py();
+ dotProd += fDaughter[0]->Py() * fDaughter[1]->Pz();
dotProd += fDaughter[0]->Pz() * fDaughter[1]->Pz();
Double_t cosAngle = dotProd / (fDaughter[0]->P() * fDaughter[1]->P());
- Double_t angle = TMath::ACos(cosAngle) * TMath::RadToDeg();
- if (angle < 0) angle += 360.0;
- return angle;
+ return TMath::ACos(cosAngle) * TMath::RadToDeg();
}
//_____________________________________________________________________________
// dummy copy methods
AliRsnReader(const AliRsnReader ©) : TNamed(copy),
fCheckSplit(0),fRejectFakes(0),fWeightsMgr(0x0),fCurrentPIDtype(AliRsnDaughter::kEsd),
- fPIDDivValue(0.),fITSClusters(0),fTPCClusters(0),fTRDClusters(0) { /*nothing*/ }
+ fPIDDivValue(0.),fITSClusters(0),fTPCClusters(0),fTRDClusters(0),
+ fTrackRefs(0),fTrackRefsITS(0),fTrackRefsTPC(0) { /*nothing*/ }
AliRsnReader& operator=(const AliRsnReader&) {return (*this);}
Bool_t fCheckSplit; // flag to check and remove split tracks
// step 1: conversion
- Int_t arraySize = 1000;
Bool_t ok = kFALSE;
switch (fInputType[0])
{
case kMC:
AliDebug(5, "Reading MC only event...");
ok = fReader.FillFromMC(fRsnEvent, fMCEvent);
- arraySize = 3000;
AliDebug(5, "...done");
break;
default:
if (!ok) AliWarning("Failed reading");
// step 2: PID probability computation
- if (!fPID.Process(fRsnEvent, arraySize)) AliWarning("Failed PID");
+ if (!fPID.Process(fRsnEvent)) AliWarning("Failed PID");
AliInfo(Form("Collected %d tracks", fRsnEvent->GetMultiplicity()));
}