]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliGenerator.cxx
Don't write the map-data.
[u/mrichter/AliRoot.git] / STEER / AliGenerator.cxx
index e7f0c81b367c7a2b5f6a59f26836ee10ef1a108a..7fe5e329005e4a260ca8d55707384cfe0e28999a 100644 (file)
 
 /*
 $Log$
+Revision 1.17  2001/11/26 15:46:35  morsch
+Set default value for vertex truncation in constructor.
+
+Revision 1.16  2001/10/16 08:45:37  morsch
+All vertex truncation and event vertex moved here.
+
+Revision 1.15  2001/07/28 10:43:41  hristov
+Default argument initialised once
+
+Revision 1.14  2001/07/27 17:13:12  morsch
+- SetTrack, KeepTrack and SetHighWaterMark methods added to delegate to local
+stack or stack owned by AliRun. (Piotr Skowronski, A.M.)
+- Changes needed for afterburners (Piotr Skowronski)
+
+Revision 1.13  2001/05/16 14:57:22  alibrary
+New files for folders and Stack
+
+Revision 1.12  2001/02/02 11:12:50  morsch
+Add Vertex() method that allows to get vertex from merging manager, if needed.
+
+Revision 1.11  2001/01/26 19:58:48  hristov
+Major upgrade of AliRoot code
+
+Revision 1.10  2000/12/21 15:30:18  fca
+Correcting coding convention violations
+
+Revision 1.9  2000/10/04 10:08:01  fca
+Correction of minor typing mistakes
+
 Revision 1.8  2000/10/02 21:28:14  fca
 Removal of useless dependecies via forward declarations
 
@@ -53,7 +82,11 @@ Introduction of the Copyright and cvs Log
 ///////////////////////////////////////////////////////////////////
 
 #include "AliGenerator.h"
+#include "TGenerator.h"
 #include "AliRun.h"
+#include "AliConfig.h"
+#include "AliStack.h"
+
 
 ClassImp(AliGenerator)
 
@@ -65,9 +98,12 @@ AliGenerator::AliGenerator()
   //
   // Default constructor
   //
-    printf("\n AliGenerator Default Constructor\n\n");
-    
-    gAlice->SetGenerator(this);
+    if (gAlice) {
+       if (gAlice->GetDebug()>0)
+           printf("\n AliGenerator Default Constructor\n\n");
+       gAlice->SetGenerator(this);
+    }
+
     SetThetaRange(); ResetBit(kThetaRange);
     SetPhiRange(); ResetBit(kPhiRange);
     SetMomentumRange(); ResetBit(kMomentumRange);
@@ -75,15 +111,22 @@ AliGenerator::AliGenerator()
     SetYRange(); ResetBit(kYRange);
     SetNumberParticles();
     SetTrackingFlag();
+    SetCutVertexZ();
+
 
     fOrigin.Set(3);
     fOsigma.Set(3);
+    fVertex.Set(3);
+
     fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
     fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
+    fVertex[0]=fVertex[1]=fVertex[2]=0;
+
     fVMin.Set(3);
     fVMin[0]=fVMin[1]=fVMin[2]=0;
     fVMax.Set(3);
     fVMax[0]=fVMax[1]=fVMax[2]=10000;
+    fStack = 0;
 }
 
 //____________________________________________________________
@@ -93,25 +136,37 @@ AliGenerator::AliGenerator(Int_t npart)
   //
   // Standard constructor
   //
-    printf("\n AliGenerator Constructor initializing number of particles \n\n");
-    gAlice->SetGenerator(this);
+    if (gAlice) {
+       if (gAlice->GetDebug()>0)
+           printf("\n AliGenerator Constructor initializing number of particles \n\n");
+       gAlice->SetGenerator(this);
+    }
+    
     SetThetaRange(); ResetBit(kThetaRange);
     SetPhiRange(); ResetBit(kPhiRange);
     SetMomentumRange(); ResetBit(kMomentumRange);
     SetPtRange(); ResetBit(kPtRange);
     SetYRange(); ResetBit(kYRange);
     SetTrackingFlag();
+    SetCutVertexZ();
 
     fOrigin.Set(3);
     fOsigma.Set(3);
+    fVertex.Set(3);
+
     fOrigin[0]=fOrigin[1]=fOrigin[2]=0;
     fOsigma[0]=fOsigma[1]=fOsigma[2]=0;
+    fVertex[0]=fVertex[1]=fVertex[2]=0;
+
     fVMin.Set(3);
     fVMin[0]=fVMin[1]=fVMin[2]=0;
     fVMax.Set(3);
     fVMax[0]=fVMax[1]=fVMax[2]=10000;
 
     SetNumberParticles(npart);
+
+    AliConfig::Instance()->Add(this);
+    fStack = 0;    
 }
 
 //____________________________________________________________
@@ -150,7 +205,10 @@ AliGenerator::~AliGenerator()
   //
   fOrigin.Set(0);
   fOsigma.Set(0);
-  delete fgMCEvGen;
+  if (fgMCEvGen) {
+    delete fgMCEvGen;
+    fgMCEvGen=0;
+  }
 }
 
 void AliGenerator::Init()
@@ -222,7 +280,8 @@ void AliGenerator::SetPhiRange(Float_t phimin, Float_t phimax)
   // Set the Phi range for the generated particles
   //
   fPhiMin = TMath::Pi()*phimin/180;
-  fPhiMax = TMath::Pi()*phimax/180; SetBit(kPhiRange);
+  fPhiMax = TMath::Pi()*phimax/180;
+  SetBit(kPhiRange);
 }
 
 //_______________________________________________________________________
@@ -256,5 +315,90 @@ void AliGenerator::SetThetaRange(Float_t thetamin, Float_t thetamax)
   // Set the theta range for the generated particles
   //
   fThetaMin = TMath::Pi()*thetamin/180;
-  fThetaMax = TMath::Pi()*thetamax/180; SetBit(kThetaRange);
+  fThetaMax = TMath::Pi()*thetamax/180;
+  SetBit(kThetaRange);
+}
+
+void AliGenerator::Vertex()
+{
+  //
+  // Obtain vertex for current event from external source or calculated (internal)
+  //
+    if (fVertexSource == kInternal) {
+       VertexInternal();
+    } else {
+       VertexExternal();
+    }
+}
+
+
+void AliGenerator::VertexExternal()
+{
+    // Dummy !!!!!!
+    // Obtain vertex from external source 
+    //
+    // Should be something like fVertex = gAlice->GetVertex()
+    
+    fVertex[0]=fVertex[1]=fVertex[2]=0;  
+}
+
+void AliGenerator::VertexInternal()
+{
+    // 
+    // Obtain calculated vertex 
+    // Default is gaussian smearing
+    Float_t random[6];
+    Rndm(random,6);
+    for (Int_t j = 0; j<3 ; j++) {
+       fVertex[j]=
+           fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
+           TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
+    }
+}
+
+void  AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
+                               Float_t *pmom, Float_t *vpos, Float_t *polar,
+                               Float_t tof, AliMCProcess mech, Int_t &ntr,
+                               Float_t weight)
+{
+
+  if (fStack)
+    fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
+                     mech, ntr, weight);
+  else 
+    gAlice->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
+                     mech, ntr, weight);
+}
+void  AliGenerator::SetTrack(Int_t done, Int_t parent, Int_t pdg,
+                      Double_t px, Double_t py, Double_t pz, Double_t e,
+                      Double_t vx, Double_t vy, Double_t vz, Double_t tof,
+                      Double_t polx, Double_t poly, Double_t polz,
+                      AliMCProcess mech, Int_t &ntr, Float_t weight)
+{
+  
+  if (fStack)
+     fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+                      polx, poly, polz, mech, ntr, weight);
+  else 
+     gAlice->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+                        polx, poly, polz, mech, ntr, weight);
+}
+
+
+void AliGenerator:: KeepTrack(Int_t itrack)
+{
+  if (fStack)
+     fStack->KeepTrack(itrack);
+  else 
+     gAlice->KeepTrack(itrack);
+   
+}
+
+void AliGenerator:: SetHighWaterMark(Int_t nt)
+{
+  if (fStack)
+     fStack->SetHighWaterMark(nt);
+  else 
+     gAlice->SetHighWaterMark(nt);
+   
 }