+++ /dev/null
-//__________________________________________________________
-///////////////////////////////////////////////////////////////////
-//
-// class AliHBTEvent
-//
-// This class is container for paticles coming from one event
-//
-// Piotr.Skowronski@cern.ch
-//
-///////////////////////////////////////////////////////////////////
-
-
-#include "AliHBTEvent.h"
-#include "AliHBTParticle.h"
-
-ClassImp(AliHBTEvent)
-
-const UInt_t AliHBTEvent::fgkInitEventSize = 100;
-
-/**************************************************************************/
-
-AliHBTEvent::AliHBTEvent():
- fSize(fgkInitEventSize),
- fParticles(new AliHBTParticle* [fSize]),
- fNParticles(0),
- fOwner(kTRUE),
- fRandomized(kFALSE)
- {
-//default constructor
- if(fgkInitEventSize<1)
- {
- Fatal("AliHBTEvent::AliHBTEvent()",
- "fgkInitEventSize has a stiupid value (%d). Change it to positive number and recompile",
- fgkInitEventSize);
-
- }
- }
-/**************************************************************************/
-
-AliHBTEvent::AliHBTEvent(const AliHBTEvent& source):
- TObject(source),
- fSize(source.fSize),
- fParticles(new AliHBTParticle* [fSize]),
- fNParticles(source.fNParticles),
- fOwner(source.fNParticles),
- fRandomized(source.fRandomized)
-{
-//copy constructor
- for(Int_t i =0; i<fNParticles; i++)
- {
- fParticles[i] = new AliHBTParticle( *(source.fParticles[i]) );
- }
-
-}
-/**************************************************************************/
-
-AliHBTEvent& AliHBTEvent::operator=(const AliHBTEvent& source)
-{
- // assigment operator
- Reset();
- if (fParticles) delete [] fParticles;
- fSize = source.fSize;
- fParticles = new AliHBTParticle* [fSize];
- fNParticles = source.fNParticles;
- fOwner = source.fNParticles;
- fRandomized = source.fRandomized;
-
- for(Int_t i =0; i<fNParticles; i++)
- {
- fParticles[i] = new AliHBTParticle( *(source.fParticles[i]) );
- }
- return *this;
-}
-/**************************************************************************/
-AliHBTEvent::~AliHBTEvent()
- {
-//destructor
- this->Reset();//delete all particles
- if(fParticles)
- {
- delete [] fParticles; //and delete array itself
- }
- fParticles = 0x0;
- }
-/**************************************************************************/
-void AliHBTEvent::Reset()
-{
- //deletes all particles from the event
- if(fParticles && fOwner)
- {
- for(Int_t i =0; i<fNParticles; i++)
- {
- for (Int_t j = i+1; j<fNParticles; j++)
- if (fParticles[j] == fParticles[i]) fParticles[j] = 0x0;
- delete fParticles[i];
- }
- }
- fNParticles = 0;
- fRandomized = kFALSE;
-}
-/**************************************************************************/
-
-AliHBTParticle* AliHBTEvent::GetParticleSafely(Int_t n)
-{
- //returns nth particle with range check
- if( (n<0) || (fNParticles<=n) ) return 0x0;
- else return fParticles[n];
-}
-/**************************************************************************/
-
-void AliHBTEvent:: AddParticle(AliHBTParticle* hbtpart)
-{
- //Adds new perticle to the event
- if ( fNParticles+1 >= fSize) Expand(); //if there is no space in array, expand it
- fParticles[fNParticles++] = hbtpart; //add a pointer
-}
-/**************************************************************************/
-
-void AliHBTEvent::AddParticle(TParticle* part, Int_t idx)
-{
- //Adds TParticle to event
- AddParticle( new AliHBTParticle(*part,idx) );
-}
-/**************************************************************************/
-void AliHBTEvent::AddParticle(Int_t pdg, Int_t idx,
- Double_t px, Double_t py, Double_t pz, Double_t etot,
- Double_t vx, Double_t vy, Double_t vz, Double_t time)
-{
- //adds particle to event
- AddParticle(new AliHBTParticle(pdg,idx,px,py,pz,etot,vx,vy,vz,time) );
-}
-/**************************************************************************/
-
-void AliHBTEvent::Expand()
-{
-//expands the array with pointers to particles
-//about the size defined in fgkInitEventSize
-
- fSize+=fgkInitEventSize;
- AliHBTParticle** tmpParticles = new AliHBTParticle* [fSize]; //create new array of pointers
- //check if we got memory / if not Abort
- if (!tmpParticles) Fatal("AliHBTEvent::Expand()","No more space in memory");
-
-
- for(Int_t i = 0; i<fNParticles ;i++)
- //copy pointers to the new array
- {
- tmpParticles[i] = fParticles[i];
- }
- delete [] fParticles; //delete old array
- fParticles = tmpParticles; //copy new pointer to the array of pointers to particles
-}
-/**************************************************************************/
-
-void AliHBTEvent::SwapParticles(Int_t i, Int_t j)
-{
-//swaps particles positions; used by AliHBTEvent::Blend
- if ( (i<0) || (i>=fNParticles)) return;
- if ( (j<0) || (j>=fNParticles)) return;
-
- AliHBTParticle* tmp = fParticles[i];
- fParticles[i] = fParticles[j];
- fParticles[j] = tmp;
-}
+++ /dev/null
-#ifndef ALIHBTEVENT_H
-#define ALIHBTEVENT_H
-//__________________________________________________________
-///////////////////////////////////////////////////////////////////
-//
-// class AliHBTEvent
-//
-// This class is container for paticles coming from one event
-// -----------------------------------------------------------------
-// -----------------------------------------------------------------
-// more info: http://aliweb.cern.ch/people/skowron/analyzer/index.html
-//
-// Piotr.Skowronski@cern.ch
-//
-///////////////////////////////////////////////////////////////////
-
-#include <TObject.h>
-
-class AliHBTParticle;
-class TParticle;
-class AliHBTEvent: public TObject
- {
- public:
- AliHBTEvent();
- AliHBTEvent(const AliHBTEvent& source);
- virtual ~AliHBTEvent();
-
- AliHBTEvent& operator=(const AliHBTEvent& source);
-
- static const UInt_t fgkInitEventSize; //initial number of the array
- //if expanded, this size is used also
- AliHBTParticle* GetParticle(Int_t n); //gets particle
- AliHBTParticle* GetParticleSafely(Int_t n); //gets particle with index check
-
- void AddParticle(AliHBTParticle* hbtpart); //adds particle to the event
- void AddParticle(TParticle* part, Int_t idx); //adds particle to the event
- void AddParticle(Int_t pdg, Int_t idx, Double_t px, Double_t py, Double_t pz, Double_t etot,
- Double_t vx, Double_t vy, Double_t vz, Double_t time);
-
- Int_t GetNumberOfParticles() const;
- void Reset(); //deletes all entries
- void SetOwner(Bool_t owns = kTRUE){ fOwner = owns; }
- Bool_t IsOwner() const {return fOwner;}
- void SetRandomized(Bool_t rd = kTRUE){fRandomized = rd;}
- Bool_t IsRandomized()const {return fRandomized;}
- void SwapParticles(Int_t i, Int_t j);//swaps particles positions; used by AliHBTEvent::Blend
-
- protected:
- Int_t fSize; //!current size of the array
- AliHBTParticle ** fParticles; //!array of pointers to the particles
- Int_t fNParticles; //!number of particles in Event
- Bool_t fOwner; //flag if that event owns the
- Bool_t fRandomized; //!flag indicating if particles positions has been already randomizd
- void Expand(); //expands the array if necessary
-
- private:
- ClassDef(AliHBTEvent,1)
- };
-/**************************************************************************/
-
-inline
-AliHBTParticle* AliHBTEvent::GetParticle(Int_t n)
- {
- //Gets particle without boundary check
- return fParticles[n];
- }
-
-/**************************************************************************/
-
-inline
-Int_t AliHBTEvent::GetNumberOfParticles() const
- {
- //reurns number of particles in this event
- return fNParticles;
- }
-
-#endif
+++ /dev/null
-#include "AliHBTEventBuffer.h"
-
-ClassImp(AliHBTEventBuffer)
-
-//______________________________________________________
-////////////////////////////////////////////////////////
-//
-// class AliHBTEventBuffer
-//
-// FIFO type event buffer
-//
-// Piotr.Skowronski@cern.ch
-//
-////////////////////////////////////////////////////////
-
-AliHBTEventBuffer::AliHBTEventBuffer():
- fSize(-1),fEvents(),fIter(&fEvents)
-{
- //ctor
-}
-/***********************************************************/
-
-AliHBTEventBuffer::AliHBTEventBuffer(Int_t size):
- fSize(size),fEvents(),fIter(&fEvents)
-{
- //ctor
-}
-/***********************************************************/
-
-AliHBTEventBuffer::~AliHBTEventBuffer()
-{
- //dtor -- TList::IsOwner(1) does not work - Valgrind says that there is mem leak
- //take care owerseves
- if (fEvents.IsOwner())
- {
- AliHBTEvent* e=0x0;
- while (( e=RemoveLast() )) delete e;
- }
-}
-/***********************************************************/
-
-AliHBTEvent* AliHBTEventBuffer::Push(AliHBTEvent* event)
-{
- //adds a new event, and returns old of do not fit in size
- if (fSize == 0) return event;
-
- AliHBTEvent* ret = 0x0;
-
- if (fSize == fEvents.GetSize())
- ret = dynamic_cast<AliHBTEvent*>(fEvents.Remove(fEvents.Last()));
- if (event) fEvents.AddFirst(event);
- return ret;
-}
-
+++ /dev/null
-#ifndef ALIHBTEVENTBUFFER_H
-#define ALIHBTEVENTBUFFER_H
-//______________________________________________________
-////////////////////////////////////////////////////////
-//
-// class AliHBTEventBuffer
-//
-// FIFO type event buffer
-//
-// Piotr.Skowronski@cern.ch
-//
-////////////////////////////////////////////////////////
-
-#include <TObject.h>
-#include <TList.h>
-#include "AliHBTEvent.h"
-
-class AliHBTEventBuffer: public TObject
-{
- public:
- AliHBTEventBuffer();
- AliHBTEventBuffer(Int_t size);
- virtual ~AliHBTEventBuffer();
-
- AliHBTEvent* Push(AliHBTEvent* event);//adds a new event, and returns old of do not fit in size
- AliHBTEvent* RemoveLast(){return dynamic_cast<AliHBTEvent*>(fEvents.Remove(fEvents.Last()));}
- void ResetIter(){fIter.Reset();}
- AliHBTEvent* Next(){return dynamic_cast<AliHBTEvent*>( fIter.Next() );}
- void SetSize(Int_t size){fSize = size;}
- Int_t GetSize() const {return fSize;}
- void SetOwner(Bool_t flag) {fEvents.SetOwner(flag);}
- protected:
- private:
- Int_t fSize;//size of buffer; if 0 infinite size
- TList fEvents;//list with arrays
- TIter fIter;//iterator
- ClassDef(AliHBTEventBuffer,1)
-};
-
-
-#endif