X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliMCEvent.cxx;h=fe1775601d4024d6a9a45aedc71f1c1408e74270;hb=ab516493625a1ab57a76ca96091b9f68cbbe88ad;hp=d22440c421b969d6265385541782891c97b365fe;hpb=93df0e9b4b4eea2563722fcdb1692d83ea028c0b;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliMCEvent.cxx b/STEER/AliMCEvent.cxx index d22440c421b..fe1775601d4 100644 --- a/STEER/AliMCEvent.cxx +++ b/STEER/AliMCEvent.cxx @@ -65,7 +65,7 @@ AliMCEvent::AliMCEvent(const AliMCEvent& mcEvnt) : fTmpTreeTR(0), fTmpFileTR(0), fNprimaries(-1), - fNparticles(-1) + fNparticles(-1) { // Copy constructor } @@ -97,16 +97,20 @@ void AliMCEvent::ConnectTreeK (TTree* tree) fStack->GetEvent(); fNparticles = fStack->GetNtrack(); fNprimaries = fStack->GetNprimary(); - AliInfo(Form("AliMCEvent: Number of particles: %5d (all) %5d (primaries)\n", - fNparticles, fNprimaries)); + Int_t iev = fHeader->GetEvent(); + Int_t ievr = fHeader->GetEventNrInRun(); + + AliInfo(Form("AliMCEvent# %5d %5d: Number of particles: %5d (all) %5d (primaries)\n", + iev, ievr, fNparticles, fNprimaries)); // This is a cache for the TParticles converted to MCParticles on user request if (fMCParticleMap) { fMCParticleMap->Clear(); - if (fNparticles>0) fMCParticleMap->Expand(fNparticles);} + fMCParticles->Delete(); + if (fNparticles>0) fMCParticleMap->Expand(fNparticles); + } else fMCParticleMap = new TRefArray(fNparticles); - } void AliMCEvent::ConnectTreeTR (TTree* tree) @@ -151,17 +155,16 @@ Int_t AliMCEvent::GetParticleAndTR(Int_t i, TParticle*& particle, TClonesArray*& void AliMCEvent::Clean() { // Clean-up before new trees are connected - if (fHeader) { delete fHeader; fHeader = 0; } - - delete fStack; + + delete fStack; fStack = 0; // Clear TR if (fTRBuffer) { - fTRBuffer->Clear(); + fTRBuffer->Delete(); delete fTRBuffer; fTRBuffer = 0; } @@ -169,10 +172,14 @@ void AliMCEvent::Clean() void AliMCEvent::FinishEvent() { - // Clean-up after event - fStack->Reset(0); - fMCParticles->Clear(); - fTrackReferences->Clear(); + // Clean-up after event + // + fStack->Reset(0); + fMCParticles->Delete(); + fMCParticleMap->Clear(); + if (fTRBuffer) + fTRBuffer->Delete(); + fTrackReferences->Delete(); } @@ -370,7 +377,7 @@ void AliMCEvent::ReorderAndExpandTreeTR() } // hits } // branches fTmpTreeTR->Fill(); - fTRBuffer->Clear(); + fTRBuffer->Delete(); ifills++; } // daughters } // has hits @@ -407,7 +414,7 @@ void AliMCEvent::ReorderAndExpandTreeTR() } // entries it++; fTmpTreeTR->Fill(); - fTRBuffer->Clear(); + fTRBuffer->Delete(); ifills++; } // tracks // Check @@ -440,7 +447,6 @@ AliMCParticle* AliMCEvent::GetTrack(Int_t i) const TClonesArray *trefs = 0; Int_t ntref = 0; TRefArray *rarray = 0; - // Out of range check if (i < 0 || i >= fNparticles) { AliWarning(Form("AliMCEvent::GetEntry: Index out of range")); @@ -449,7 +455,6 @@ AliMCParticle* AliMCEvent::GetTrack(Int_t i) const } - // // First check of the MC Particle has been already cached if(!fMCParticleMap->At(i)) { @@ -471,15 +476,13 @@ AliMCParticle* AliMCEvent::GetTrack(Int_t i) const nen++; } // loop over track references for entry i } // if TreeTR available - Int_t nentries = fMCParticles->GetEntriesFast(); - new ((*fMCParticles)[nentries]) AliMCParticle(particle, rarray); + new ((*fMCParticles)[nentries]) AliMCParticle(particle, rarray, i); mcParticle = dynamic_cast((*fMCParticles)[nentries]); fMCParticleMap->AddAt(mcParticle, i); } else { mcParticle = dynamic_cast(fMCParticleMap->At(i)); } - return mcParticle; }