]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliStack.cxx
Updates for full map (R. Shahoyan)
[u/mrichter/AliRoot.git] / STEER / AliStack.cxx
index c26ccaea7a283cba1ab6e4f791e1da3ab14435fa..19bdf7adf27c94e5fb9ca74309d3087b49eda0b6 100644 (file)
@@ -134,8 +134,8 @@ void AliStack::PushTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom,
   //
   // Load a track on the stack
   //
-  // done     0 if the track has to be transported
-  //          1 if not
+  // done     1 if the track has to be transported
+  //          0 if not
   // parent   identifier of the parent track. -1 for a primary
   // pdg    particle code
   // pmom     momentum GeV/c
@@ -184,8 +184,8 @@ void AliStack::PushTrack(Int_t done, Int_t parent, Int_t pdg,
   //
   // Load a track on the stack
   //
-  // done        0 if the track has to be transported
-  //             1 if not
+  // done        1 if the track has to be transported
+  //             0 if not
   // parent      identifier of the parent track. -1 for a primary
   // pdg         particle code
   // kS          generation status code
@@ -216,7 +216,15 @@ void AliStack::PushTrack(Int_t done, Int_t parent, Int_t pdg,
   particle->SetWeight(weight);
   particle->SetUniqueID(mech);
 
-  if(!done) particle->SetBit(kDoneBit);
+  
+  
+  if(!done) {
+      particle->SetBit(kDoneBit);
+  } else {
+      particle->SetBit(kTransportBit);
+  }
+  
+  
 
   //  Declare that the daughter information is valid
   particle->SetBit(kDaughtersBit);
@@ -284,7 +292,7 @@ TParticle*  AliStack::PopPrimaryForTracking(Int_t i)
 }      
 
 //_____________________________________________________________________________
-void AliStack::PurifyKine()
+Bool_t AliStack::PurifyKine()
 {
   //
   // Compress kinematic tree keeping only flagged particles
@@ -292,13 +300,13 @@ void AliStack::PurifyKine()
   //
 
   TObjArray &particles = *fParticleMap;
-  int nkeep=fHgwmk+1, parent, i;
+  int nkeep = fHgwmk + 1, parent, i;
   TParticle *part, *father;
   fTrackLabelMap.Set(particles.GetLast()+1);
 
   // Save in Header total number of tracks before compression
   // If no tracks generated return now
-  if(fHgwmk+1 == fNtrack) return;
+  if(fHgwmk+1 == fNtrack) return kFALSE;
 
   // First pass, invalid Daughter information
   for(i=0; i<fNtrack; i++) {
@@ -325,19 +333,16 @@ void AliStack::PurifyKine()
   // Second pass, build map between old and new numbering
   for(i=fHgwmk+1; i<fNtrack; i++) {
       if(particles.At(i)->TestBit(kKeepBit)) {
-         
          // This particle has to be kept
          fTrackLabelMap[i]=nkeep;
          // If old and new are different, have to move the pointer
          if(i!=nkeep) particles[nkeep]=particles.At(i);
          part = dynamic_cast<TParticle*>(particles.At(nkeep));
-         
          // as the parent is always *before*, it must be already
          // in place. This is what we are checking anyway!
          if((parent=part->GetFirstMother())>fHgwmk) 
              if(fTrackLabelMap[parent]==-99) Fatal("PurifyKine","fTrackLabelMap[%d] = -99!\n",parent);
              else part->SetFirstMother(fTrackLabelMap[parent]);
-         
          nkeep++;
       }
   }
@@ -370,25 +375,26 @@ void AliStack::PurifyKine()
       particles[i]=fParticleBuffer=0;
   }
   
-  for (i=nkeep; i<fNtrack; ++i) particles[i]=0;
+  for (i = nkeep; i < fNtrack; ++i) particles[i]=0;
   
   Int_t toshrink = fNtrack-fHgwmk-1;
   fLoadPoint-=toshrink;
   
-  
   for(i=fLoadPoint; i<fLoadPoint+toshrink; ++i) fParticles->RemoveAt(i);
   fNtrack=nkeep;
   fHgwmk=nkeep-1;
+  return kTRUE;
 }
 
-void AliStack::ReorderKine()
+
+Bool_t AliStack::ReorderKine()
 {
 //
 // In some transport code children might not come in a continuous sequence.
 // In this case the stack  has  to  be reordered in order to establish the 
 // mother daughter relation using index ranges.
 //    
-  if(fHgwmk+1 == fNtrack) return;
+  if(fHgwmk+1 == fNtrack) return kFALSE;
 
   //
   // Howmany secondaries have been produced ?
@@ -415,7 +421,7 @@ void AliStack::ReorderKine()
       //
       // Reset  LoadPoint 
       // 
-      fLoadPoint = fHgwmk + 1;
+      Int_t loadPoint = fHgwmk + 1;
       //
       // Re-Push particles into stack 
       // The outer loop is over parents, the inner over children.
@@ -449,18 +455,18 @@ void AliStack::ReorderKine()
              Int_t jpa = tmp[j]->GetFirstMother();
               // Check if daughter of current parent
              if (jpa == ipa) {
-                 particles[fLoadPoint] = tmp[j];
+                 particles[loadPoint] = tmp[j];
                  // Re-establish daughter information
-                 parP->SetLastDaughter(fLoadPoint);
-                 if (parP->GetFirstDaughter() == -1) parP->SetFirstDaughter(fLoadPoint);
+                 parP->SetLastDaughter(loadPoint);
+                 if (parP->GetFirstDaughter() == -1) parP->SetFirstDaughter(loadPoint);
                  // Set Mother information
                  if (i != -1) {
                      tmp[j]->SetFirstMother(map1[i]);
                  } 
                  // Build the map
-                 map1[j] = fLoadPoint;
+                 map1[j] = loadPoint;
                  // Increase load point
-                 fLoadPoint++;
+                 loadPoint++;
              }
          } // children
       } // parents
@@ -479,6 +485,8 @@ void AliStack::ReorderKine()
          }
       }
   } // new particles poduced
+  
+  return kTRUE;
 }
 
 Bool_t AliStack::KeepPhysics(TParticle* part)
@@ -590,10 +598,10 @@ void AliStack::KeepTrack(Int_t track)
 }
 
 //_____________________________________________________________________________
-void  AliStack::Reset(Int_t size) 
+void  AliStack::Clean(Int_t size) 
 {
   //
-  // Resets stack
+  // Reset stack data except for fTreeK
   //
   
   fNtrack=0;
@@ -601,10 +609,21 @@ void  AliStack::Reset(Int_t size)
   fHgwmk=0;
   fLoadPoint=0;
   fCurrent = -1;
-  fTreeK = 0x0;
   ResetArrays(size);
 }
 
+//_____________________________________________________________________________
+void  AliStack::Reset(Int_t size) 
+{
+  //
+  // Reset stack data including fTreeK
+  //
+
+  Clean(size);
+  delete fParticleBuffer; fParticleBuffer = 0;
+  fTreeK = 0x0;
+}
+
 //_____________________________________________________________________________
 void  AliStack::ResetArrays(Int_t size) 
 {
@@ -873,7 +892,7 @@ void AliStack::ConnectTree(TTree* tree)
 //
 //  Creates branch for writing particles
 //
-    
+
   fTreeK = tree;
     
   AliDebug(1, "Connecting TreeK");
@@ -918,20 +937,7 @@ void AliStack::ConnectTree(TTree* tree)
   else
     AliWarning("Branch Dir is NOT SET");
 }
-//__________________________________________________________________________________________
-
-
-void AliStack::BeginEvent()
-{
-// start a new event
- Reset();
-}
 
-//_____________________________________________________________________________
-void AliStack::FinishRun()
-{
-// Clean TreeK information
-}
 //_____________________________________________________________________________
 
 Bool_t AliStack::GetEvent()
@@ -1010,10 +1016,16 @@ Bool_t AliStack::IsPhysicalPrimary(Int_t index)
 //
 // Particle produced during transport
 //
-// Check if this is a heavy flavor decay product
+
        Int_t imo =  p->GetFirstMother();
        TParticle* pm  = Particle(imo);
        Int_t mpdg = TMath::Abs(pm->GetPdgCode());
+// Check if it comes from a pi0 decay
+//
+// What about the pi0 Dalitz ??
+//     if ((mpdg == kPi0) && (imo < GetNprimary())) return kTRUE; 
+
+// Check if this is a heavy flavor decay product
        Int_t mfl  = Int_t (mpdg / TMath::Power(10, Int_t(TMath::Log10(mpdg))));
        //
        // Light hadron
@@ -1028,7 +1040,7 @@ Bool_t AliStack::IsPhysicalPrimary(Int_t index)
        // To be sure that heavy flavor has not been produced in a secondary interaction
        // Loop back to the generated mother
        while (imo >=  GetNprimary()) {
-           imo = p->GetFirstMother();
+           imo = pm->GetFirstMother();
            pm  =  Particle(imo);
        }
        mpdg = TMath::Abs(pm->GetPdgCode());
@@ -1041,4 +1053,3 @@ Bool_t AliStack::IsPhysicalPrimary(Int_t index)
        } 
     } // produced by generator ?
 } 
-