Coding Rule violations corrected.
[u/mrichter/AliRoot.git] / EVGEN / AliGenCocktailAfterBurner.cxx
index abf0d6c..8127ab0 100644 (file)
@@ -13,6 +13,8 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+/* $Id$ */
+
 // 
 // Container class for AliGenerator and AfterBurners 
 // (which are AliGenerators as well) through recursion.
 //             debug -> gDebug,
 //             fNEvents replaced with gAlice->GetEventsPerRun()
 //
-#include "AliGenCocktailAfterBurner.h"
-#include "AliGenCocktailEntry.h"
 
-#include "AliStack.h"
-#include <TObjArray.h>
+
+#include <Riostream.h>
+
 #include <TList.h>
+#include <TObjArray.h>
 #include <TParticle.h>
-#include <iostream.h>
+
+#include "AliGenCocktailAfterBurner.h"
+#include "AliGenCocktailEntry.h"
+#include "AliStack.h"
+#include "AliMC.h"
 
 
 ClassImp(AliGenCocktailAfterBurner)
@@ -45,18 +51,29 @@ AliGenCocktailAfterBurner::AliGenCocktailAfterBurner()
 {
 // Constructor
     if (gDebug > 0) 
-       cout<<"AliGenCocktailAfterBurner::AliGenCocktailAfterBurner()"<<endl;
+       cout<<"AliGenCocktailAfterBurner::AliGenCocktailAfterBurner()"<<endl;
     SetName("AliGenCocktailAfterBurner");
     SetTitle("AliGenCocktailAfterBurner");
     fInternalStacks =0;
+    fActiveStack = 0;
+    fCurrentGenerator = 0;
     fCurrentEvent =0;
     fAfterBurnerEntries = new TList();
     fNAfterBurners = 0;
     fGenerationDone = kFALSE;
     
     fActiveEvent = -1;  
+    fNBgEvents = 0;
 }
 /*********************************************************************/ 
+AliGenCocktailAfterBurner::AliGenCocktailAfterBurner(const AliGenCocktailAfterBurner& cocktail):
+    AliGenCocktail(cocktail)
+
+{
+ //Copy constructor
+    cocktail.Copy(*this);
+}
+
 /*********************************************************************/ 
 
 AliGenCocktailAfterBurner::~AliGenCocktailAfterBurner()
@@ -87,14 +104,10 @@ AddAfterBurner(AliGenerator *AfterBurner, char* Name, Float_t RateExp)
        AfterBurner->SetMomentumRange(fPMin,fPMax);
     
     AfterBurner->SetYRange(fYMin,fYMax);
-    AfterBurner->
-       SetPhiRange(fPhiMin*180/TMath::Pi(),fPhiMax*180/TMath::Pi());
-    AfterBurner->
-       SetThetaRange(fThetaMin*180/TMath::Pi(),fThetaMax*180/TMath::Pi());
-    AfterBurner->
-       SetOrigin(fOrigin[0], fOrigin[1], fOrigin[2]);
-    AfterBurner->
-       SetSigma(fOsigma[0], fOsigma[1], fOsigma[2]);
+    AfterBurner->SetPhiRange(fPhiMin*180/TMath::Pi(),fPhiMax*180/TMath::Pi());
+    AfterBurner->SetThetaRange(fThetaMin*180/TMath::Pi(),fThetaMax*180/TMath::Pi());
+    AfterBurner->SetOrigin(fOrigin[0], fOrigin[1], fOrigin[2]);
+    AfterBurner->SetSigma(fOsigma[0], fOsigma[1], fOsigma[2]);
     AfterBurner->SetVertexSmear(fVertexSmear);
     AfterBurner->SetTrackingFlag(fTrackIt);    
 //
@@ -114,6 +127,12 @@ void AliGenCocktailAfterBurner::Init()
 {
 // Initialisation
     fGenerationDone = kFALSE;
+    if (fInternalStacks) //delete stacks
+     { 
+       fInternalStacks->SetOwner();
+       fInternalStacks->Delete(); //clean after previous generation cycle
+     }
+
     this->AliGenCocktail::Init(); 
     
     if (gDebug>0) cout<<"AliGenCocktailAfterBurner::Init"<<endl;
@@ -160,8 +179,8 @@ void AliGenCocktailAfterBurner::Generate()
       fCurrentEvent=0;
       Int_t numberOfEvents = gAlice->GetEventsPerRun();
       //Create stacks
-      fInternalStacks = new TObjArray(numberOfEvents); //Create array of internal stacks
-      for(i=0;i<numberOfEvents;i++) 
+      fInternalStacks = new TObjArray(numberOfEvents + fNBgEvents); //Create array of internal stacks
+      for(i=0;i<numberOfEvents + fNBgEvents;i++) 
        {       
         stack = new AliStack(10000);
         stack->Reset();
@@ -182,7 +201,7 @@ void AliGenCocktailAfterBurner::Generate()
         cout<<"Generator "<<igen<<"  : "<<entry->GetName()<<endl;
 /***********************************************/
 //First generator for all evenets, than second for all events, etc...
-        for(i=0;i<numberOfEvents;i++) 
+        for(i=0;i<numberOfEvents + fNBgEvents;i++) 
           {  
             cout<<"                  EVENT "<<i<<endl;
             stack = GetStack(i);
@@ -252,12 +271,13 @@ void AliGenCocktailAfterBurner::Generate()
 AliGenCocktailAfterBurner& AliGenCocktailAfterBurner::operator=(const  AliGenCocktailAfterBurner& rhs)
 {
 // Assignment operator
-    return *this;
+    rhs.Copy(*this);
+    return (*this);
 }
 /*********************************************************************/
 /*********************************************************************/ 
 
-AliStack* AliGenCocktailAfterBurner::GetStack(Int_t n)
+AliStack* AliGenCocktailAfterBurner::GetStack(Int_t n) const
 {
 //Returns the pointer to the N'th stack (event)
   if( ( n<0 ) || ( n>=GetNumberOfEvents() ) )
@@ -291,19 +311,19 @@ void AliGenCocktailAfterBurner::SetTracks(Int_t stackno)
     Int_t parent; 
     Int_t pdg;
     Double_t px, py, pz, e, vx, vy, vz, tof, polx, poly, polz;
-    AliMCProcess mech;
+    TMCProcess mech;
     Int_t ntr;
     Float_t weight;
     TVector3 pol;
     
     TParticle * p;
-    Int_t N = instack->GetNtrack();
+    Int_t n = instack->GetNtrack();
     if (gDebug) 
     {
-      cout<<"AliGenCocktailAfterBurner::SetTracks("<<stackno<<"). Number of particles is: "<<N<<"\n";
+      cout<<"AliGenCocktailAfterBurner::SetTracks("<<stackno<<"). Number of particles is: "<<n<<"\n";
     }
     
-    for(Int_t i = 0; i < N; i++)
+    for(Int_t i = 0; i < n; i++)
     {
        
       p = instack->Particle(i);
@@ -325,17 +345,17 @@ void AliGenCocktailAfterBurner::SetTracks(Int_t stackno)
       mech = AliGenCocktailAfterBurner::IntToMCProcess(p->GetUniqueID());
       weight = p->GetWeight();
 
-      gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+      gAlice->GetMCApp()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
                        polx, poly, polz, mech, ntr, weight);
     }
 }
 /*********************************************************************/ 
 /*********************************************************************/ 
 
-AliMCProcess AliGenCocktailAfterBurner::IntToMCProcess(Int_t no)
+TMCProcess AliGenCocktailAfterBurner::IntToMCProcess(Int_t no)
 {
- //Mothod used to convert uniqueID (integer) to AliMCProcess type
-    const AliMCProcess MCprocesses[kMaxMCProcess] = 
+ //Mothod used to convert uniqueID (integer) to TMCProcess type
+    const TMCProcess kMCprocesses[kMaxMCProcess] = 
     {
      kPNoProcess, kPMultipleScattering, kPEnergyLoss, kPMagneticFieldL, 
      kPDecay, kPPair, kPCompton, kPPhotoelectric, kPBrem, kPDeltaRay,
@@ -347,11 +367,15 @@ AliMCProcess AliGenCocktailAfterBurner::IntToMCProcess(Int_t no)
     
     for (Int_t i = 0;i<kMaxMCProcess;i++)
     {
-      if (MCprocesses[i] == no)
+      if (kMCprocesses[i] == no)
         {
-          //if (debug) cout<<"IntToMCProcess("<<no<<") returned AliMCProcess Named \""<<AliMCProcessName[MCprocesses[i]]<<"\""<<endl;
-          return MCprocesses[i];
+          return kMCprocesses[i];
         }
     } 
     return kPNoProcess;
 }
+
+void AliGenCocktailAfterBurner::Copy(AliGenCocktailAfterBurner &) const
+{
+    Fatal("Copy","Not implemented!\n");
+}