Splitted multiplicity computation
authorpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 9 Nov 2006 16:02:32 +0000 (16:02 +0000)
committerpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 9 Nov 2006 16:02:32 +0000 (16:02 +0000)
PWG2/RESONANCES/AliRsnEvent.cxx
PWG2/RESONANCES/AliRsnEvent.h

index 9badd160675d0fa51ee89b040fd51ce9bf8e3064..a2b0a18d9e04389d21175409a462416ec623cee6 100644 (file)
@@ -37,8 +37,6 @@ ClassImp(AliRsnEvent)
 
 //--------------------------------------------------------------------------------------------------------
 AliRsnEvent::AliRsnEvent() :
- fIsESD(kTRUE),
- fPath(""),
  fPVx(0.0),
  fPVy(0.0),
  fPVz(0.0),
@@ -52,12 +50,12 @@ AliRsnEvent::AliRsnEvent() :
                fPos[i] = NULL;
                fNeg[i] = NULL;
        }
+       fPosNoPID = NULL;
+       fNegNoPID = NULL;
 }
 //--------------------------------------------------------------------------------------------------------
 AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) :
  TObject((TObject)event),
- fIsESD(event.fIsESD),
- fPath(event.fPath),
  fPVx(event.fPVx), 
  fPVy(event.fPVy), 
  fPVz(event.fPVz),
@@ -75,15 +73,16 @@ AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) :
                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.
 //
-       fIsESD = event.fIsESD;
-       fPath = event.fPath;
        fPVx = event.fPVx; 
        fPVy = event.fPVy; 
        fPVz = event.fPVz;
@@ -97,6 +96,8 @@ AliRsnEvent& AliRsnEvent::operator=(const AliRsnEvent &event)
                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);
 }
@@ -106,38 +107,24 @@ 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();
+       Int_t sign = (Int_t)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);
        }
 }
 //--------------------------------------------------------------------------------------------------------
@@ -163,42 +150,29 @@ void AliRsnEvent::Clear(Option_t *option)
                        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() const
+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)
@@ -228,6 +202,10 @@ void AliRsnEvent::Init()
                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)
index 1495a51c0ddffdcd5d7af669da93826acd4686d1..b9abc79adbefbec4c87418eac5ef12b05b540d3e 100644 (file)
@@ -28,8 +28,8 @@ public:
        
        void           AddTrack(AliRsnDaughter track);
        void           Clear(Option_t *option = "");
-       Int_t          GetMultiplicity(Bool_t recalc = kFALSE);
-       const char*    GetOriginFileName() const;
+       void           ComputeMultiplicity();
+       Int_t          GetMultiplicity() const {return fMultiplicity;}
        Double_t       GetPrimaryVertexX() const {return fPVx;}
        Double_t       GetPrimaryVertexY() const {return fPVy;}
        Double_t       GetPrimaryVertexZ() const {return fPVz;}
@@ -38,15 +38,10 @@ public:
        void           Init();
        Int_t          PDG2Enum(Int_t pdgcode);
        void           PrintTracks();
-       void           SetESD(Bool_t yesno = kTRUE) {fIsESD=yesno;}
-       void           SetPath(TString path) {fPath=path;}
        void           SetPrimaryVertex(Double_t x, Double_t y, Double_t z) {fPVx=x;fPVy=y;fPVz=z;}
 
 private:
 
-       Bool_t         fIsESD;                    // if true, it is ESD event, otherwise it comes from Kine
-       TString        fPath;                     // complete path where input event file is stored
-       
        Double_t       fPVx;                              // position of
        Double_t       fPVy;                              // primary
        Double_t       fPVz;                              // vertex
@@ -55,6 +50,8 @@ private:
 
        TClonesArray  *fPos[AliPID::kSPECIES];    // collections of positive particles
        TClonesArray  *fNeg[AliPID::kSPECIES];    // collections of negative particles
+       TClonesArray  *fPosNoPID;                 // collection of unidentified positive particles
+       TClonesArray  *fNegNoPID;                 // collection of unidentified positive particles
        
        ClassDef(AliRsnEvent,1);
 };