/*
$Log$
+Revision 1.20 2002/04/30 11:47:30 morsch
+KeepPhysics method called by PurifyKine added (N. Carrer, A.M.)
+
+Revision 1.19 2002/03/12 11:06:03 morsch
+Add particle status code to argument list of SetTrack(..).
+
+Revision 1.18 2002/02/20 16:14:41 hristov
+fParticleBuffer points to object which doesn't belong to AliStack, do not delete it (J.Chudoba)
+
+Revision 1.17 2001/12/05 08:51:56 hristov
+The default constructor now creates no objects (thanks to r.Brun). Some corrections required by the previous changes.
+
+Revision 1.16 2001/11/20 09:27:55 hristov
+Possibility to investigate a primary of not yet loaded particle (I.Hrivnacova)
+
+Revision 1.15 2001/09/04 15:10:37 hristov
+Additional protection is included to avoid some problems using Hijing
+
+Revision 1.14 2001/08/30 09:44:06 hristov
+VertexSource_t added to avoid the warnings
+
+Revision 1.13 2001/08/29 13:31:42 morsch
+Protection against (fTreeK == 0) in destructor.
+
+Revision 1.12 2001/07/27 13:03:13 hristov
+Default Branch split level set to 99
+
+Revision 1.11 2001/07/27 12:34:20 jchudoba
+remove the dummy argument in GetEvent method
+
+Revision 1.10 2001/07/20 10:13:54 morsch
+In Particle(Int_t) use GetEntriesFast to speed up the procedure.
+
Revision 1.9 2001/07/03 08:10:57 hristov
J.Chudoba's changes merged correctly with the HEAD
#include "AliRun.h"
#include "AliModule.h"
#include "AliHit.h"
-//#include "ETrackBits.h"
ClassImp(AliStack)
//
// Create the particles arrays
- fParticles = new TClonesArray("TParticle",1000);
- fParticleMap = new TObjArray(10000);
+ fParticles = 0;
+ fParticleMap = 0;
fParticleBuffer = 0;
fNtrack = 0;
fCurrent = -1;
// Destructor
//
- delete fParticleBuffer;
if (fParticles) {
fParticles->Delete();
delete fParticles;
}
delete fParticleMap;
- delete fTreeK;
+ if (fTreeK) delete fTreeK;
}
//
//_____________________________________________________________________________
void AliStack::SetTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom,
Float_t *vpos, Float_t *polar, Float_t tof,
- AliMCProcess mech, Int_t &ntr, Float_t weight)
+ AliMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
{
//
// Load a track on the stack
Float_t mass;
const Int_t kfirstdaughter=-1;
const Int_t klastdaughter=-1;
- const Int_t kS=0;
// const Float_t tlife=0;
//
TClonesArray &particles = *fParticles;
TParticle* particle
= new(particles[fLoadPoint++])
- TParticle(pdg, kS, parent, -1, kfirstdaughter, klastdaughter,
+ TParticle(pdg, is, parent, -1, kfirstdaughter, klastdaughter,
pmom[0], pmom[1], pmom[2], e, vpos[0], vpos[1], vpos[2], tof);
particle->SetPolarisation(TVector3(polar[0],polar[1],polar[2]));
particle->SetWeight(weight);
if(parent>=0) {
particle = (TParticle*) fParticleMap->At(parent);
- particle->SetLastDaughter(fNtrack);
- if(particle->GetFirstDaughter()<0) particle->SetFirstDaughter(fNtrack);
+ if (particle) {
+ particle->SetLastDaughter(fNtrack);
+ if(particle->GetFirstDaughter()<0) particle->SetFirstDaughter(fNtrack);
+ }
+ else {
+ printf("Error in AliStack::SetTrack: Parent %d does not exist\n",parent);
+ }
}
else {
//
Double_t px, Double_t py, Double_t pz, Double_t e,
Double_t vx, Double_t vy, Double_t vz, Double_t tof,
Double_t polx, Double_t poly, Double_t polz,
- AliMCProcess mech, Int_t &ntr, Float_t weight)
+ AliMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
{
//
// Load a track on the stack
// it is passed by argument e.
- const Int_t kS=0;
const Int_t kFirstDaughter=-1;
const Int_t kLastDaughter=-1;
TClonesArray &particles = *fParticles;
TParticle* particle
= new(particles[fLoadPoint++])
- TParticle(pdg, kS, parent, -1, kFirstDaughter, kLastDaughter,
+ TParticle(pdg, is, parent, -1, kFirstDaughter, kLastDaughter,
px, py, pz, e, vx, vy, vz, tof);
particle->SetPolarisation(polx, poly, polz);
if(parent>=0) {
particle = (TParticle*) fParticleMap->At(parent);
- particle->SetLastDaughter(fNtrack);
- if(particle->GetFirstDaughter()<0) particle->SetFirstDaughter(fNtrack);
+ if (particle) {
+ particle->SetLastDaughter(fNtrack);
+ if(particle->GetFirstDaughter()<0) particle->SetFirstDaughter(fNtrack);
+ }
+ else {
+ printf("Error in AliStack::SetTrack: Parent %d does not exist\n",parent);
+ }
}
else {
//
if(i<=fHgwmk) map[i]=i ;
else {
map[i] = -99;
- if((part=(TParticle*) particles.At(i))) {
+ if((part=(TParticle*) particles.At(i))) {
+//
+// Check of this track should be kept for physics reasons
+ if (KeepPhysics(part)) KeepTrack(i);
+//
part->ResetBit(kDaughtersBit);
part->SetFirstDaughter(-1);
part->SetLastDaughter(-1);
// delete [] map;
}
+Bool_t AliStack::KeepPhysics(TParticle* part)
+{
+ //
+ // Some particles have to kept on the stack for reasons motivated
+ // by physics analysis. Decision is put here.
+ //
+ Bool_t keep = kFALSE;
+ //
+ // Keep first-generation daughter from primaries with heavy flavor
+ //
+ Int_t parent = part->GetFirstMother();
+ if (parent >= 0 && parent <= fHgwmk) {
+ TParticle* father = (TParticle*) Particles()->At(parent);
+ Int_t kf = father->GetPdgCode();
+ kf = TMath::Abs(kf);
+ Int_t kfl = kf;
+ // meson ?
+ if (kfl > 10) kfl/=100;
+ // baryon
+ if (kfl > 10) kfl/=10;
+ if (kfl > 10) kfl/=10;
+ if (kfl >= 4) {
+ keep = kTRUE;
+ }
+ }
+ return keep;
+}
+
//_____________________________________________________________________________
void AliStack::FinishEvent()
{
fParticleBuffer = (TParticle*) part;
fParticleFileMap[i]= (Int_t) fTreeK->GetEntries();
fTreeK->Fill();
- (*fParticleMap)[i]=fParticleBuffer=0;
+ //PH (*fParticleMap)[i]=fParticleBuffer=0;
+ fParticleBuffer=0;
+ fParticleMap->AddAt(0,i);
// When all primaries were filled no particle!=0
// should be left => to be removed later.
// Resets stack arrays
//
- fParticles->Clear();
- fParticleMap->Clear();
- if (size>0) fParticleMap->Expand(size);
+ if (fParticles)
+ fParticles->Clear();
+ else
+ fParticles = new TClonesArray("TParticle",1000);
+ if (fParticleMap) {
+ fParticleMap->Clear();
+ if (size>0) fParticleMap->Expand(size);}
+ else
+ fParticleMap = new TObjArray(size);
}
//_____________________________________________________________________________
//
// Return particle with specified ID
- if(!(*fParticleMap)[i]) {
+ //PH if(!(*fParticleMap)[i]) {
+ if(!fParticleMap->At(i)) {
Int_t nentries = fParticles->GetEntriesFast();
// algorithmic way of getting entry index
// (primary particles are filled after secondaries)
new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
fParticleMap->AddAt((*fParticles)[nentries],i);
}
- return (TParticle *) (*fParticleMap)[i];
+ //PH return (TParticle *) (*fParticleMap)[i];
+ return (TParticle *) fParticleMap->At(i);
}
//_____________________________________________________________________________
-Int_t AliStack::GetPrimary(Int_t id) const
+Int_t AliStack::GetPrimary(Int_t id)
{
//
// Return number of primary that has generated track
//
int current, parent;
- TParticle *part;
//
parent=id;
while (1) {
current=parent;
- part = (TParticle *)fParticleMap->At(current);
- parent=part->GetFirstMother();
+ parent=Particle(current)->GetFirstMother();
if(parent<0) return current;
}
}
// Dumps particle i in the stack
//
- ((TParticle*) (*fParticleMap)[i])->Print();
+ //PH ((TParticle*) (*fParticleMap)[i])->Print();
+ ((TParticle*) fParticleMap->At(i))->Print();
}
//_____________________________________________________________________________
TBranch *branch=0;
// Make Kinematics Tree
char hname[30];
-// printf("\n MakeTree called %d", event);
if (!fTreeK) {
sprintf(hname,"TreeK%d",event);
fTreeK = new TTree(hname,"Kinematics");
// Create a branch for particles
- branch = fTreeK->Branch("Particles", "TParticle", &fParticleBuffer, 4000, 1);
+ branch = fTreeK->Branch("Particles", "TParticle", &fParticleBuffer, 4000);
fTreeK->Write(0,TObject::kOverwrite);
}
}
}
}
-//_____________________________________________________________________________
-Bool_t AliStack::GetEvent(Int_t event, Int_t dummy)
+Bool_t AliStack::GetEvent(Int_t event)
{
//
// Get new event from TreeK
if (fTreeK)
fTreeK->SetBranchAddress("Particles", &fParticleBuffer);
else {
- Error("GetEvent","cannot find Kine Tree for event:%d\n",event);
+ // Error("GetEvent","cannot find Kine Tree for event:%d\n",event);
+ Warning("GetEvent","cannot find Kine Tree for event:%d\n",event);
return kFALSE;
}
// printf("\n primaries %d", fNprimary);
ResetArrays(size);
return kTRUE;
}
-
-//----------------------------------------------------------------------