]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New methods for more effective access of particles from TreeK (J.Chudoba)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 22 Oct 2002 15:21:39 +0000 (15:21 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 22 Oct 2002 15:21:39 +0000 (15:21 +0000)
STEER/AliStack.cxx
STEER/AliStack.h

index 85b130305489b1027734ff2088ca1af1315c5896..3a5449b47eb4444616b64eb93940f73a1ab14d84 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.24  2002/10/22 15:02:15  alibrary
+Introducing Riostream.h
+
 Revision 1.23  2002/10/14 14:57:32  hristov
 Merging the VirtualMC branch to the main development branch (HEAD)
 
@@ -660,11 +663,7 @@ TParticle* AliStack::Particle(Int_t i)
     Int_t nentries = fParticles->GetEntriesFast();
     // algorithmic way of getting entry index
     // (primary particles are filled after secondaries)
-    Int_t entry;
-    if (i<fNprimary)
-       entry = i+fNtrack-fNprimary;
-    else 
-       entry = i-fNprimary;
+    Int_t entry = TreeKEntry(i);
     // check whether algorithmic way and 
     // and the fParticleFileMap[i] give the same;
     // give the fatal error if not
@@ -682,6 +681,33 @@ TParticle* AliStack::Particle(Int_t i)
   return (TParticle *) fParticleMap->At(i);
 }
 
+//_____________________________________________________________________________
+TParticle* AliStack::ParticleFromTreeK(Int_t id) const
+{
+// 
+// return pointer to TParticle with label id
+//
+  Int_t entry;
+  if ((entry = TreeKEntry(id)) < 0) return 0;
+  if (fTreeK->GetEntry(entry)<=0) return 0;
+  return fParticleBuffer;
+}
+
+//_____________________________________________________________________________
+Int_t AliStack::TreeKEntry(Int_t id) const 
+{
+//
+// return entry number in the TreeK for particle with label id
+// return negative number if label>fNtrack
+//
+  Int_t entry;
+  if (id<fNprimary)
+    entry = id+fNtrack-fNprimary;
+  else 
+    entry = id-fNprimary;
+  return entry;
+}
+
 //_____________________________________________________________________________
 Int_t AliStack::GetPrimary(Int_t id)
 {
index d0bdc6ad59f1033fa5f44b6fd7ed65b403424c92..21b6c6405c4fcdb3d6c0beb8132820bd5f883759 100644 (file)
@@ -67,6 +67,8 @@ class AliStack : public TVirtualMCStack
     TParticle*  Particle(Int_t id);
     Int_t       GetPrimary(Int_t id);
     TTree*      TreeK() const {return fTreeK;}
+    TParticle*  ParticleFromTreeK(Int_t id) const;
+    Int_t       TreeKEntry(Int_t id) const;
     
   protected:
     // methods