]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenPileup.cxx
Updated DA config following the commit the DA source file.
[u/mrichter/AliRoot.git] / EVGEN / AliGenPileup.cxx
index 1d8336dc799cbeb657b99ebdbc3a982bf821c344..d9c03d1494124e1736b17e79d5600098b2675c60 100644 (file)
@@ -48,6 +48,7 @@
 //-------------------------------------------------------------------------
 
 #include <TParticle.h>
+#include <TFormula.h>
 
 #include "AliGenPileup.h"
 #include "AliLog.h"
@@ -61,7 +62,8 @@ ClassImp(AliGenPileup)
 AliGenPileup::AliGenPileup():
   AliGenCocktail(),
   fBCMask("bcm","3564H"),
-  fGenTrig(kFALSE)
+  fGenTrig(kFALSE),
+  fFlag(kFALSE)
 {
 // Constructor
 // The pileup time window is by default
@@ -77,7 +79,7 @@ AliGenPileup::~AliGenPileup()
 // Destructor
 }
 
-void AliGenPileup::SetGenerator(AliGenerator *generator, Float_t rate)
+void AliGenPileup::SetGenerator(AliGenerator *generator, Float_t rate, Bool_t flag)
 {
   // The method sets the geenrator to be used
   // for pileup simulation.
@@ -91,11 +93,12 @@ void AliGenPileup::SetGenerator(AliGenerator *generator, Float_t rate)
     }
   }
   AddGenerator(generator,"pileup generator",rate);
+  fFlag = flag;
 }
 
 void AliGenPileup::AddGenerator(AliGenerator *Generator,
                                const char* Name,
-                               Float_t RateExp )
+                               Float_t RateExp , TFormula* /*form*/)
 {
   // The method used to add the pileup generator
   // in the cocktail list.
@@ -150,16 +153,24 @@ void AliGenPileup::Generate()
   Int_t *nIntBC = new Int_t[3*AliTriggerBCMask::kNBits];
   Int_t *indexBC = new Int_t[3*AliTriggerBCMask::kNBits];
   Int_t nTotBC = 0;
-  for(Int_t iBC = 0; iBC <  AliTriggerBCMask::kNBits; iBC++) {
+  while (nTotBC == 0) {
+    for(Int_t iBC = 0; iBC <  AliTriggerBCMask::kNBits; iBC++) {
 
-    if (!fBCMask.GetMask(iBC)) continue;
+      if (!fBCMask.GetMask(iBC)) continue;
 
-    Int_t nInteractions = gRandom->Poisson(rate);
-    if (nInteractions == 0) continue;
+      //      Int_t nInteractions = gRandom->Poisson(rate);
+      Int_t nInteractions;
+      if (!fFlag) 
+       nInteractions = gRandom->Poisson(rate);
+      else 
+       nInteractions = TMath::Nint(rate) + 1;
 
-    nIntBC[nTotBC] = nInteractions;
-    indexBC[nTotBC] = iBC;
-    nTotBC++;
+      if (nInteractions == 0) continue;
+
+      nIntBC[nTotBC] = nInteractions;
+      indexBC[nTotBC] = iBC;
+      nTotBC++;
+    }
   }
 
   // Select the bunch crossing for triggered event
@@ -208,7 +219,7 @@ void AliGenPileup::Generate()
 
   // Loop over the generated collision times, call the generator
   // and correct the partcile times in the stack
-  AliStack *stack = AliRunLoader::GetRunLoader()->Stack();
+  AliStack *stack = AliRunLoader::Instance()->Stack();
   Int_t lastpart=0;
   entry->SetFirst(lastpart);
 
@@ -234,6 +245,7 @@ void AliGenPileup::Generate()
 
       // Store the interaction header in the container of the headers
       ((AliGenEventHeader*) fHeader->GetHeaders()->Last())->SetPrimaryVertex(eventVertex);
+      ((AliGenEventHeader*) fHeader->GetHeaders()->Last())->SetInteractionTime(vTime);
     }
   }
   delete [] nIntBC;