Correct adding of headers in case object is part of cocktail.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Aug 2007 16:05:38 +0000 (16:05 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Aug 2007 16:05:38 +0000 (16:05 +0000)
EVGEN/AliGenBox.cxx
EVGEN/AliGenExtFile.cxx
EVGEN/AliGenParam.cxx

index 46c3b97..9c0440b 100644 (file)
@@ -105,7 +105,14 @@ void AliGenBox::Generate()
 
     AliGenEventHeader* header = new AliGenEventHeader("BOX");
     header->SetPrimaryVertex(fVertex);
-    gAlice->SetGenEventHeader(header); 
+    header->SetNProduced(fNpart);
+    
+ // Passes header either to the container or to gAlice
+    if (fContainer) {
+       fContainer->AddHeader(header);
+    } else {
+       gAlice->SetGenEventHeader(header);      
+    }
 }
 
 //_____________________________________________________________________________
index a123e7e..891ebf8 100644 (file)
@@ -133,6 +133,7 @@ void AliGenExtFile::Generate()
     //
     // Stack filling loop
     //
+    fNprimaries = 0;
     for (i = 0; i < nTracks; i++) {
        TParticle* iparticle = fReader->NextParticle();
        Bool_t selected = KinematicSelection(iparticle,0); 
@@ -161,15 +162,15 @@ void AliGenExtFile::Generate()
        
        PushTrack(doTracking,parent,idpart,p,origin,polar,0,kPPrimary,nt);
        KeepTrack(nt);
+       fNprimaries++;
     } // track loop
 
     // Generated event header
     
     AliGenEventHeader * header = new AliGenEventHeader();
-    header->SetNProduced(nt+1);
+    header->SetNProduced(fNprimaries);
     header->SetPrimaryVertex(fVertex);
-    AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(header);
-
+    AddHeader(header);
     break;
     
   } // event loop
index 9c897e9..ab0a0fc 100644 (file)
@@ -38,6 +38,7 @@
 #include "AliGenParam.h"
 #include "AliMC.h"
 #include "AliRun.h"
+#include "AliGenEventHeader.h"
 
 ClassImp(AliGenParam)
 
@@ -283,6 +284,8 @@ void AliGenParam::Generate()
   Int_t ipa=0;
   
 // Generating fNpart particles
+  fNprimaries = 0;
+  
   while (ipa<fNpart) {
       while(1) {
 //
@@ -437,6 +440,8 @@ void AliGenParam::Generate()
                  PushTrack(0, -1, iPart, p, origin0, polar, 0, kPPrimary, nt, wgtp);
                  pParent[0] = nt;
                  KeepTrack(nt); 
+                 fNprimaries++;
+                 
 //
 // Decay Products
 //               
@@ -464,6 +469,7 @@ void AliGenParam::Generate()
                                           0, kPDecay, nt, wgtch);
                          pParent[i] = nt;
                          KeepTrack(nt); 
+                         fNprimaries++;
                      } // Selected
                  } // Particle loop 
              }  // Decays by Lujet
@@ -478,11 +484,18 @@ void AliGenParam::Generate()
            gAlice->GetMCApp()->
                PushTrack(fTrackIt,-1,iPart,p,origin0,polar,0,kPPrimary,nt,wgtp);
             ipa++; 
+           fNprimaries++;
          }
          break;
     } // while
   } // event loop
+  
   SetHighWaterMark(nt);
+
+  AliGenEventHeader* header = new AliGenEventHeader("PARAM");
+  header->SetPrimaryVertex(fVertex);
+  header->SetNProduced(fNprimaries);
+  AddHeader(header);
 }
 //____________________________________________________________________________________
 Float_t AliGenParam::GetRelativeArea(Float_t ptMin, Float_t ptMax, Float_t yMin, Float_t yMax, Float_t phiMin, Float_t phiMax)