//-------------------------------------------------------------------------
// Class AliRsnEvent
-// Simple collection of reconstructed tracks, selected from an ESD event
+// -------------------
+// Simple collection of reconstructed tracks
+// selected from an ESD event
+// to be used for analysis.
+// .........................................
//
// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
//-------------------------------------------------------------------------
#include <Riostream.h>
-#include <TTree.h>
#include <TString.h>
-#include <TParticle.h>
#include <TObjArray.h>
-#include <TRefArray.h>
#include <TClonesArray.h>
-#include "AliESD.h"
-#include "AliStack.h"
-#include "AliESDtrack.h"
#include "AliRsnDaughter.h"
#include "AliRsnEvent.h"
//--------------------------------------------------------------------------------------------------------
AliRsnEvent::AliRsnEvent() :
- fIsESD(kTRUE),
- fPath(""),
fPVx(0.0),
fPVy(0.0),
fPVz(0.0),
- fMultiplicity(-1)
+ fMultiplicity(-1),
+ fPosNoPID(0x0),
+ fNegNoPID(0x0)
+{
//
// Default constructor
//
-{
Int_t i;
for (i = 0; i < AliPID::kSPECIES; i++) {
fPos[i] = NULL;
//--------------------------------------------------------------------------------------------------------
AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) :
TObject((TObject)event),
- fIsESD(event.fIsESD),
- fPath(event.fPath),
- fPVx(event.fPVx),
- fPVy(event.fPVy),
+ fPVx(event.fPVx),
+ fPVy(event.fPVy),
fPVz(event.fPVz),
- fMultiplicity(event.fMultiplicity)
+ fMultiplicity(event.fMultiplicity),
+ fPosNoPID(0x0),
+ fNegNoPID(0x0)
+{
//
// Copy constructor.
// Creates new instances of all collections to store a copy of all objects.
//
+ // clone tracks collections
+ Int_t i;
+ for (i = 0; i < AliPID::kSPECIES; i++) {
+ fPos[i] = 0;
+ fNeg[i] = 0;
+ if (event.fPos[i]) fPos[i] = (TClonesArray*)event.fPos[i]->Clone();
+ if (event.fNeg[i]) fNeg[i] = (TClonesArray*)event.fNeg[i]->Clone();
+ }
+ fPosNoPID = (TClonesArray*)event.fPosNoPID->Clone();
+ fNegNoPID = (TClonesArray*)event.fNegNoPID->Clone();
+}
+//--------------------------------------------------------------------------------------------------------
+AliRsnEvent& AliRsnEvent::operator=(const AliRsnEvent &event)
{
+//
+// Assignment operator.
+// Creates new instances of all collections to store a copy of all objects.
+//
+ fPVx = event.fPVx;
+ fPVy = event.fPVy;
+ fPVz = event.fPVz;
+ fMultiplicity = event.fMultiplicity;
+
// clone tracks collections
Int_t i;
for (i = 0; i < AliPID::kSPECIES; i++) {
if (event.fPos[i]) fPos[i] = (TClonesArray*)event.fPos[i]->Clone();
if (event.fNeg[i]) fNeg[i] = (TClonesArray*)event.fNeg[i]->Clone();
}
+ fPosNoPID = (TClonesArray*)event.fPosNoPID->Clone();
+ fNegNoPID = (TClonesArray*)event.fNegNoPID->Clone();
+
+ return (*this);
}
//--------------------------------------------------------------------------------------------------------
void AliRsnEvent::AddTrack(AliRsnDaughter track)
+{
//
// Stores a track into the correct array
//
-{
- Int_t pdg, sign, ifirst, ilast;
-
// if sign is zero, track is not stored
- sign = (Int_t)track.GetSign();
+ Char_t sign = track.GetSign();
if (!sign) return;
// if PDG code is assigned, track is stored in the corresponding collection
- // otherwise, a copy of track is is stored in each collection (undefined track)
- pdg = track.GetPDG();
+ // otherwise, it is stored in the array of unidentified particles with that sign
+ Int_t index, iarray, pdg = track.GetPDG();
if (pdg != 0) {
- ifirst = PDG2Enum(pdg);
- ilast = ifirst;
- if (ifirst < AliPID::kElectron || ifirst > AliPID::kProton) return;
+ iarray = PDG2Enum(pdg);
+ if (iarray < AliPID::kElectron || iarray > AliPID::kProton) return;
+ TClonesArray &array = (sign > 0) ? *fPos[iarray] : *fNeg[iarray];
+ index = array.GetEntries();
+ new(array[index]) AliRsnDaughter(track);
}
else {
- ifirst = AliPID::kElectron;
- ilast = AliPID::kProton;
- }
-
- // track is stored
- Int_t i, index;
- for (i = ifirst; i <= ilast; i++) {
- if (sign > 0) {
- index = fPos[i]->GetEntries();
- TClonesArray &array = *fPos[i];
- new(array[index]) AliRsnDaughter(track);
- }
- else {
- index = fNeg[i]->GetEntries();
- TClonesArray &array = *fNeg[i];
- new(array[index]) AliRsnDaughter(track);
- }
+ TClonesArray &array = (sign > 0) ? *fPosNoPID : *fNegNoPID;
+ index = array.GetEntries();
+ new(array[index]) AliRsnDaughter(track);
}
}
//--------------------------------------------------------------------------------------------------------
void AliRsnEvent::Clear(Option_t *option)
+{
//
// Clears list of tracks and references.
// If the string "DELETE" is specified, the collection classes
// are also cleared from heap.
//
-{
// evaluate option
TString opt(option);
Bool_t deleteCollections = opt.Contains("DELETE", TString::kIgnoreCase);
fNeg[i] = 0;
}
}
-}
-//--------------------------------------------------------------------------------------------------------
-Int_t AliRsnEvent::GetMultiplicity(Bool_t recalc)
-//
-// Computes multiplicity.
-// If it is already computed (fMultiplicity > -1), it returns that value,
-// unless one sets the argument to kTRUE.
-//
-{
- if (fMultiplicity < 0) recalc = kTRUE;
- if (recalc) {
- fMultiplicity = 0;
- Int_t i;
- for (i = 0; i < AliPID::kSPECIES; i++) {
- fMultiplicity += (Int_t)fPos[i]->GetEntries();
- fMultiplicity += (Int_t)fNeg[i]->GetEntries();
- }
+ if (fPosNoPID) fPosNoPID->Delete();
+ if (fNegNoPID) fNegNoPID->Delete();
+ if (deleteCollections) {
+ delete fPosNoPID;
+ delete fNegNoPID;
+ fPosNoPID = 0;
+ fNegNoPID = 0;
}
-
- return fMultiplicity;
}
//--------------------------------------------------------------------------------------------------------
-const char * AliRsnEvent::GetOriginFileName()
+void AliRsnEvent::ComputeMultiplicity()
+{
//
-// Returns the path where input file was stored
+// Computes multiplicity.
//
-{
- TString str(fPath);
- if (fIsESD) {
- str.Append("/AliESDs.root");
- }
- else {
- str.Append("/galice.root");
+ fMultiplicity = 0;
+ Int_t i;
+ for (i = 0; i < AliPID::kSPECIES; i++) {
+ fMultiplicity += (Int_t)fPos[i]->GetEntries();
+ fMultiplicity += (Int_t)fNeg[i]->GetEntries();
}
-
- return str.Data();
+ if (fPosNoPID) fMultiplicity += fPosNoPID->GetEntries();
+ if (fNegNoPID) fMultiplicity += fNegNoPID->GetEntries();
}
//--------------------------------------------------------------------------------------------------------
TClonesArray* AliRsnEvent::GetTracks(Char_t sign, AliPID::EParticleType type)
+{
//
// Returns the particle collection specified in argument
//
-{
Int_t itype = (Int_t)type;
if (itype >= 0 && itype < AliPID::kSPECIES) {
if (sign == '+') return fPos[type]; else return fNeg[type];
}
+ else if (type == AliPID::kUnknown) {
+ if (sign == '+') return fPosNoPID; else return fNegNoPID;
+ }
else {
return NULL;
}
}
//--------------------------------------------------------------------------------------------------------
void AliRsnEvent::Init()
+{
//
// Action 1: define default values for some data members (including pointers).
// Action 2: if 'ntracks' > 0 allocates memory to store tracks.
//
-{
Int_t i;
for (i = 0; i < AliPID::kSPECIES; i++) {
fPos[i] = new TClonesArray("AliRsnDaughter", 0);
fPos[i]->BypassStreamer(kFALSE);
fNeg[i]->BypassStreamer(kFALSE);
}
+ fPosNoPID = new TClonesArray("AliRsnDaughter", 0);
+ fNegNoPID = new TClonesArray("AliRsnDaughter", 0);
+ fPosNoPID->BypassStreamer(kFALSE);
+ fNegNoPID->BypassStreamer(kFALSE);
}
//--------------------------------------------------------------------------------------------------------
Int_t AliRsnEvent::PDG2Enum(Int_t pdgcode)
+{
//
// Converts a PDG code into the correct slot in the EParticleType enumeration in AliPID
//
-{
Int_t i;
for (i = 0; i < AliPID::kSPECIES; i++) {
if (AliPID::ParticleCode((AliPID::EParticleType)i) == TMath::Abs(pdgcode)) {
}
//--------------------------------------------------------------------------------------------------------
void AliRsnEvent::PrintTracks()
+{
//
// Print data for particles stored in this event
//
-{
cout << endl;
AliRsnDaughter *track = 0;