--- PamVMC/src/PamVMCStack.cxx 2007/06/28 07:16:58 1.1 +++ PamVMC/src/PamVMCStack.cxx 2009/06/12 18:39:32 1.5 @@ -1,10 +1,10 @@ // $Id: PamVMCStack.cxx,v 1.0 2007/06/03 -// // Class PamVMCStack -#include +#include #include #include +#include #include #include "PamVMCStack.h" @@ -16,7 +16,7 @@ fCurrentTrack(-1), fNPrimary(0) { - fParticles = new TClonesArray("TParticle", size); + fParticles = new TClonesArray("PamVMCParticle", size); } PamVMCStack::PamVMCStack() @@ -40,22 +40,22 @@ 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, - TMCProcess mech, Int_t& /*ntr*/, Double_t weight, + TMCProcess mech, Int_t& ntr, Double_t weight, Int_t is) { // Creates a new particle with specified properties, // adds it to the particles array (fParticles) and if not done to the // stack (fStack). -// Use TParticle::fMother[1] to store Track ID. +// Use PamVMCParticle::fMother[1] to store Track ID. const Int_t kFirstDaughter=-1; const Int_t kLastDaughter=-1; TClonesArray& particlesRef = *fParticles; Int_t trackId = GetNtrack(); - TParticle* particle + PamVMCParticle* particle = new(particlesRef[trackId]) - TParticle(pdg, is, parent, trackId, kFirstDaughter, kLastDaughter, + PamVMCParticle(pdg, is, parent, trackId, kFirstDaughter, kLastDaughter, px, py, pz, e, vx, vy, vz, tof); particle->SetPolarisation(polx, poly, polz); @@ -65,16 +65,17 @@ if (parent<0) fNPrimary++; if (toBeDone) fStack.push(particle); + ntr=trackId-1; } -TParticle* PamVMCStack::PopNextTrack(Int_t& itrack) +PamVMCParticle* PamVMCStack::PopNextTrack(Int_t& itrack) { // Gets next particle for tracking from the stack. itrack = -1; if (fStack.empty()) return 0; - TParticle* particle = fStack.top(); + PamVMCParticle* particle = fStack.top(); fStack.pop(); if (!particle) return 0; @@ -85,7 +86,7 @@ return particle; } -TParticle* PamVMCStack::PopPrimaryForTracking(Int_t i) +PamVMCParticle* PamVMCStack::PopPrimaryForTracking(Int_t i) { // Returns i-th particle in fParticles. @@ -93,7 +94,7 @@ if (i < 0 || i >= fNPrimary) Fatal("GetPrimaryForTracking", "Index out of range"); - return (TParticle*)fParticles->At(i); + return (PamVMCParticle*)fParticles->At(i); } void PamVMCStack::Print(Option_t* /*option*/) const @@ -104,8 +105,10 @@ cout << "Total number of particles: " << GetNtrack() << endl; cout << "Number of primary particles: " << GetNprimary() << endl; - for (Int_t i=0; iPrint(); + for (Int_t i=0; iPrint(); + + } } void PamVMCStack::Reset() @@ -114,7 +117,8 @@ fCurrentTrack = -1; fNPrimary = 0; - fParticles->Clear(); + fParticles->Clear("C"); + fParticles->Compress(); } void PamVMCStack::SetCurrentTrack(Int_t track) @@ -138,11 +142,11 @@ return fNPrimary; } -TParticle* PamVMCStack::GetCurrentTrack() const +PamVMCParticle* PamVMCStack::GetCurrentTrack() const { // Returns the current track parent ID. - TParticle* current = GetParticle(fCurrentTrack); + PamVMCParticle* current = GetParticle(fCurrentTrack); if (!current) Warning("GetCurrentTrack", "Current track not found in the stack"); @@ -161,7 +165,7 @@ { // Returns the current track parent ID. - TParticle* current = GetCurrentTrack(); + PamVMCParticle* current = GetCurrentTrack(); if (current) return current->GetFirstMother(); @@ -169,14 +173,17 @@ return -1; } -TParticle* PamVMCStack::GetParticle(Int_t id) const +PamVMCParticle* PamVMCStack::GetParticle(Int_t id) const { // Returns id-th particle in fParticles. - if (id < 0 || id >= fParticles->GetEntriesFast()) - Fatal("GetParticle", "Index out of range"); - - return (TParticle*)fParticles->At(id); + if (id < 0 || id >= fParticles->GetEntriesFast()){ + TString e="Index out of range "; + e+=id; + // Fatal("GetParticle", "Index out of range"); + Fatal("GetParticle", e.Data()); + } + return (PamVMCParticle*)fParticles->At(id); }