]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenCocktail.cxx
Removing warnings (Sun)
[u/mrichter/AliRoot.git] / EVGEN / AliGenCocktail.cxx
index b9edd43873cf5701a7bb04b673466a42038c8056..ce2e5edc743496ea143f27ca4aeccae6d889ad60 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.15  2003/01/07 14:13:22  morsch
-Communication between generators provising and requesting collision
-geometries.
-
-Revision 1.14  2002/02/08 16:50:50  morsch
-Add name and title in constructor.
-
-Revision 1.13  2001/10/21 18:35:56  hristov
-Several pointers were set to zero in the default constructors to avoid memory management problems
-
-Revision 1.12  2001/06/18 13:07:30  morsch
-Forward kinematic ranges to entries only if not set by user.
-
-Revision 1.11  2001/01/30 09:23:12  hristov
-Streamers removed (R.Brun)
-
-Revision 1.10  2001/01/26 19:55:49  hristov
-Major upgrade of AliRoot code
-
-Revision 1.9  2000/12/21 16:24:06  morsch
-Coding convention clean-up
-
-Revision 1.8  2000/10/27 13:53:29  morsch
-AddGenerator: check testbit before setting the pT and momentum range
-(D.Y. Peressounko)
-
-Revision 1.7  2000/10/02 15:15:41  morsch
-Use default streamer for AliGenCocktail
-
-Revision 1.6  2000/09/07 17:04:31  morsch
-In Streamer: TIter() after R__b << fEntries (Dmitri Yurevitch Peressounko)
-
-Revision 1.5  2000/06/09 20:28:51  morsch
-All coding rule violations except RS3 corrected (AM)
-
-Revision 1.4  1999/09/29 09:24:12  fca
-Introduction of the Copyright and cvs Log
-
-*/
+/* $Id$ */
 
 // Container class for AliGenerator through recursion.
 // Container is itself an AliGenerator.
@@ -68,7 +28,9 @@ Introduction of the Copyright and cvs Log
 
 #include "AliGenCocktail.h"
 #include "AliGenCocktailEntry.h"
+#include "AliCollisionGeometry.h"
 #include "AliRun.h"
+#include "AliMC.h"
 
 ClassImp(AliGenCocktail)
 
@@ -78,15 +40,18 @@ AliGenCocktail::AliGenCocktail()
 // Constructor
     fName = "Cocktail";
     fTitle= "Particle Generator using cocktail of generators";
-    fEntries = new TList;
     flnk1 = 0;
     flnk2 = 0;
     fNGenerators=0;
+    fEntries = 0;
+    
 }
 
-AliGenCocktail::AliGenCocktail(const AliGenCocktail & cocktail)
+AliGenCocktail::AliGenCocktail(const AliGenCocktail & cocktail):
+    AliGenerator(cocktail)
 {
-// copy constructor
+// Copy constructor
+    cocktail.Copy(*this);
 }
 
 AliGenCocktail::~AliGenCocktail()
@@ -96,8 +61,13 @@ AliGenCocktail::~AliGenCocktail()
 }
 
 void AliGenCocktail::
-AddGenerator(AliGenerator *Generator, char* Name, Float_t RateExp)
+AddGenerator(AliGenerator *Generator, const char* Name, Float_t RateExp)
 {
+//
+// Add a generator to the list 
+// First check that list exists
+    if (!fEntries) fEntries = new TList();
+
 //
 //  Forward parameters to the new generator
     if(TestBit(kPtRange) && !(Generator->TestBit(kPtRange)) && !(Generator->TestBit(kMomentumRange))) 
@@ -113,15 +83,20 @@ AddGenerator(AliGenerator *Generator, char* Name, Float_t RateExp)
        Generator->SetThetaRange(fThetaMin*180/TMath::Pi(),fThetaMax*180/TMath::Pi());
     if (!(Generator->TestBit(kVertexRange))) 
        Generator->SetOrigin(fOrigin[0], fOrigin[1], fOrigin[2]);
-    Generator->
-       SetSigma(fOsigma[0], fOsigma[1], fOsigma[2]);
+
+    Generator->SetSigma(fOsigma[0], fOsigma[1], fOsigma[2]);
     Generator->SetVertexSmear(fVertexSmear);
-    Generator->SetTrackingFlag(fTrackIt);    
+    Generator->SetVertexSource(kContainer);
+    Generator->SetTrackingFlag(fTrackIt);
 //
 //  Add generator to list   
-    
+    char theName[256];
+    sprintf(theName, "%s_%d",Name, fNGenerators);
+    Generator->SetName(theName);
+
     AliGenCocktailEntry *entry = 
        new AliGenCocktailEntry(Generator, Name, RateExp);
+    
      fEntries->Add(entry);
      fNGenerators++;
  }
@@ -138,6 +113,18 @@ AddGenerator(AliGenerator *Generator, char* Name, Float_t RateExp)
     }  
 }
 
+  void AliGenCocktail::FinishRun()
+{
+// Initialisation
+    TIter next(fEntries);
+    AliGenCocktailEntry *entry;
+    //
+    // Loop over generators and initialize
+    while((entry = (AliGenCocktailEntry*)next())) {
+       entry->Generator()->FinishRun();
+    }  
+}
+
  void AliGenCocktail::Generate()
 {
 //
@@ -146,11 +133,16 @@ AddGenerator(AliGenerator *Generator, char* Name, Float_t RateExp)
     AliGenCocktailEntry *entry = 0;
     AliGenCocktailEntry *preventry = 0;
     AliGenerator* gen = 0;
+
+    TObjArray *partArray = gAlice->GetMCApp()->Particles();
+
+//
+//  Generate the vertex position used by all generators
+//    
+    if(fVertexSmear == kPerEvent) Vertex();
+
     
-//    AliGenCocktailEntry *e1;
-//    AliGenCocktailEntry *e2;
-    TObjArray *partArray = gAlice->Particles();
-    //
+  //
     // Loop over generators and generate events
     Int_t igen=0;
     
@@ -174,31 +166,12 @@ AddGenerator(AliGenerator *Generator, char* Name, Float_t RateExp)
                Fatal("Generate()", "No Collision Geometry Provided");
            }
        }
-       
+       entry->Generator()->SetVertex(fVertex.At(0), fVertex.At(1), fVertex.At(2));
        entry->Generator()->Generate();
        entry->SetLast(partArray->GetEntriesFast());
        preventry = entry;
     }  
     next.Reset();
-/*
-    while((entry = (AliGenCocktailEntry*)next())) {
-       entry->PrintInfo();
-    }
-    for (entry=FirstGenerator();
-        entry;
-        entry=NextGenerator()
-       ) {
-       entry->PrintInfo();
-    }
-    for (FirstGeneratorPair(e1,e2);
-        (e1&&e2);
-        NextGeneratorPair(e1,e2)
-       ){
-       printf("\n -----------------------------");
-       e1->PrintInfo();
-       e2->PrintInfo();
-    }
-*/
 }
 
 AliGenCocktailEntry *  AliGenCocktail::FirstGenerator()
@@ -258,7 +231,14 @@ NextGeneratorPair(AliGenCocktailEntry*& e1, AliGenCocktailEntry*& e2)
 AliGenCocktail& AliGenCocktail::operator=(const  AliGenCocktail& rhs)
 {
 // Assignment operator
-    return *this;
+    rhs.Copy(*this); 
+    return (*this);
 }
 
+void AliGenCocktail::Copy(TObject &) const
+{
+    Fatal("Copy","Not implemented!\n");
+}
+
+