]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenPythia.cxx
Have to create Digits trees and branches by hand in the case of multiple event files.
[u/mrichter/AliRoot.git] / EVGEN / AliGenPythia.cxx
index 919d090861fe23a6404004cd7871ecca4d1a9e8b..83b4e18d316998223f06c044d8fa5e2fba59f9eb 100644 (file)
 
 /*
 $Log$
+Revision 1.32  2001/01/26 19:55:51  hristov
+Major upgrade of AliRoot code
+
+Revision 1.31  2001/01/17 10:54:31  hristov
+Better protection against FPE
+
+Revision 1.30  2000/12/18 08:55:35  morsch
+Make AliPythia dependent generartors work with new scheme of random number generation
+
+Revision 1.29  2000/12/04 11:22:03  morsch
+Init of sRandom as in 1.15
+
+Revision 1.28  2000/12/02 11:41:39  morsch
+Use SetRandom() to initialize random number generator in constructor.
+
+Revision 1.27  2000/11/30 20:29:02  morsch
+Initialise static variable sRandom in constructor: sRandom = fRandom;
+
+Revision 1.26  2000/11/30 07:12:50  alibrary
+Introducing new Rndm and QA classes
+
+Revision 1.25  2000/10/18 19:11:27  hristov
+Division by zero fixed
+
+Revision 1.24  2000/09/18 10:41:35  morsch
+Add possibility to use nuclear structure functions from PDF library V8.
+
+Revision 1.23  2000/09/14 14:05:40  morsch
+dito
+
+Revision 1.22  2000/09/14 14:02:22  morsch
+- Correct conversion from mm to cm when passing particle vertex to MC.
+- Correct handling of fForceDecay == all.
+
+Revision 1.21  2000/09/12 14:14:55  morsch
+Call fDecayer->ForceDecay() at the beginning of Generate().
+
+Revision 1.20  2000/09/06 14:29:33  morsch
+Use AliPythia for event generation an AliDecayPythia for decays.
+Correct handling of "nodecay" option
+
 Revision 1.19  2000/07/11 18:24:56  fca
 Coding convention corrections + few minor bug fixes
 
@@ -72,6 +113,8 @@ AliGenPythia::AliGenPythia(Int_t npart)
 // structure function GRVHO
 //
     fXsection  = 0.;
+    fNucA1=0;
+    fNucA2=0;
     fParentSelect.Set(5);
     fChildSelect.Set(5);
     for (Int_t i=0; i<5; i++) fParentSelect[i]=fChildSelect[i]=0;
@@ -81,6 +124,8 @@ AliGenPythia::AliGenPythia(Int_t npart)
     SetPtHard();
     SetEnergyCMS();
     fDecayer = new AliDecayerPythia();
+    // Set random number generator 
+    sRandom=fRandom;
 }
 
 AliGenPythia::AliGenPythia(const AliGenPythia & Pythia)
@@ -105,12 +150,14 @@ void AliGenPythia::Init()
     //    gSystem->Exec("ln -s $ALICE_ROOT/data/Decay.table fort.1");
     //    fPythia->Pyupda(2,1);    
     //    gSystem->Exec("rm fort.1");
-    
+
+    fDecayer->SetForceDecay(fForceDecay);    
     fDecayer->Init();
-    fDecayer->ForceDecay(fForceDecay);
+
 
     fPythia->SetCKIN(3,fPtHardMin);
     fPythia->SetCKIN(4,fPtHardMax);    
+    if (fNucA1 > 0 && fNucA2 > 0) fPythia->SetNuclei(fNucA1, fNucA2);  
     fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc);
 
     //    fPythia->Pylist(0);
@@ -181,7 +228,7 @@ void AliGenPythia::Init()
 void AliGenPythia::Generate()
 {
 // Generate one event
-  fDecayer->ForceDecay(fForceDecay);
+    fDecayer->ForceDecay();
 
     Float_t polar[3] =   {0,0,0};
     Float_t origin[3]=   {0,0,0};
@@ -250,7 +297,8 @@ void AliGenPythia::Generate()
                            pP[3] = massP;
                            gAlice->SetTrack(0,-1,-1,
                                             pP,originP,polar,
-                                            0,"Hard Scat.",ntP,fParentWeight);
+                                            0,kPPrimary,ntP,fParentWeight);
+//                                          0,"Hard Scat.",ntP,fParentWeight);
                            gAlice->KeepTrack(ntP);
                        }
                        nc++;
@@ -259,9 +307,9 @@ void AliGenPythia::Generate()
                        p[0]=iparticle->Px();
                        p[1]=iparticle->Py();
                        p[2]=iparticle->Pz();
-                       origin[0]=origin0[0]+iparticle->Vx()*10.;
-                       origin[1]=origin0[1]+iparticle->Vy()*10.;
-                       origin[2]=origin0[2]+iparticle->Vz()*10.;
+                       origin[0]=origin0[0]+iparticle->Vx()/10.;
+                       origin[1]=origin0[1]+iparticle->Vy()/10.;
+                       origin[2]=origin0[2]+iparticle->Vz()/10.;
 
                        Int_t ifch=iparticle->GetFirstDaughter();
                        Int_t ilch=iparticle->GetLastDaughter();        
@@ -271,7 +319,7 @@ void AliGenPythia::Generate()
                          if (fForceDecay == nodecay) trackit = 1;
                            gAlice->SetTrack(trackit,ntP,kf,
                                             p,origin,polar,
-                                            0,"Primary",nt,fParentWeight);
+                                            0,kPPrimary,nt,fParentWeight);
                            gAlice->KeepTrack(nt);
                            Int_t iparent = nt;
 //
@@ -285,16 +333,16 @@ void AliGenPythia::Generate()
 //
 // 
                                  if (ChildSelected(TMath::Abs(kf))) {
-                                   origin[0]=origin0[0]+ichild->Vx()*10.;
-                                   origin[1]=origin0[1]+ichild->Vy()*10.;
-                                   origin[2]=origin0[2]+ichild->Vz()*10.;              
+                                   origin[0]=origin0[0]+ichild->Vx()/10.;
+                                   origin[1]=origin0[1]+ichild->Vy()/10.;
+                                   origin[2]=origin0[2]+ichild->Vz()/10.;              
                                    p[0]=ichild->Px();
                                    p[1]=ichild->Py();
                                    p[2]=ichild->Pz();
                                    Float_t tof=kconv*ichild->T();
                                    gAlice->SetTrack(fTrackIt, iparent, kf,
                                                     p,origin,polar,
-                                                    tof,"Decay",nt,fChildWeight);
+                                                    tof,kPDecay,nt,fChildWeight);
                                    gAlice->KeepTrack(nt);
                                  } // select child
                                } // child loop
@@ -316,12 +364,12 @@ void AliGenPythia::Generate()
                        p[0]=iparticle->Px();
                        p[1]=iparticle->Py();
                        p[2]=iparticle->Pz();
-                       origin[0]=origin0[0]+iparticle->Vx()*10;
-                       origin[1]=origin0[1]+iparticle->Vy()*10;
-                       origin[2]=origin0[2]+iparticle->Vz()*10;
+                       origin[0]=origin0[0]+iparticle->Vx()/10.;
+                       origin[1]=origin0[1]+iparticle->Vy()/10.;
+                       origin[2]=origin0[2]+iparticle->Vz()/10.;
                        Float_t tof=kconv*iparticle->T();
                        gAlice->SetTrack(fTrackIt,-1,kf,p,origin,polar,
-                                        tof,"Primary",nt);
+                                        tof,kPPrimary,nt);
                        gAlice->KeepTrack(nt);
                } // select particle
            } // particle loop 
@@ -332,6 +380,8 @@ void AliGenPythia::Generate()
            if (jev >= fNpart || fNpart == -1) {
                fKineBias=Float_t(fNpart)/Float_t(fTrials);
                printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
+// Print x-section summary
+               fPythia->Pystat(1);
                break;
            }
        }
@@ -355,6 +405,8 @@ Bool_t AliGenPythia::ParentSelected(Int_t ip)
 Bool_t AliGenPythia::ChildSelected(Int_t ip)
 {
 // True if particle is in list of decay products to be selected
+    if (fForceDecay == all) return kTRUE;
+    
     for (Int_t i=0; i<5; i++)
     {
        if (fChildSelect[i]==ip) return kTRUE;
@@ -398,11 +450,16 @@ Bool_t AliGenPythia::KinematicSelection(TParticle *particle)
 
 //
 // rapidity cut
-    Float_t y = 0.5*TMath::Log((e+pz)/(e-pz));
-    if (y > fYMax || y < fYMin)
-    {
+    if ( (e-pz)<=0 || (e+pz)<=0 ) {
+      return kFALSE;
+    }
+    else {
+      Float_t y = 0.5*TMath::Log((e+pz)/(e-pz));
+      if (y > fYMax || y < fYMin)
+        {
 //     printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
-       return kFALSE;
+          return kFALSE;
+        }
     }
 
 //
@@ -420,11 +477,10 @@ void AliGenPythia::AdjustWeights()
 {
 // Adjust the weights after generation of all events
 //
-    TClonesArray *partArray = gAlice->Particles();
     TParticle *part;
     Int_t ntrack=gAlice->GetNtrack();
     for (Int_t i=0; i<ntrack; i++) {
-       part= (TParticle*) partArray->UncheckedAt(i);
+       part= gAlice->Particle(i);
        part->SetWeight(part->GetWeight()*fKineBias);
     }
 }
@@ -461,7 +517,16 @@ Int_t AliGenPythia::CheckPDGCode(Int_t pdgcode)
   //non diffractive state -- return code unchanged
   return pdgcode;
 }
-                 
+
+    
+void AliGenPythia::SetNuclei(Int_t a1, Int_t a2)
+{
+// Treat protons as inside nuclei with mass numbers a1 and a2  
+    fNucA1 = a1;
+    fNucA2 = a2;
+}
+       
+         
 AliGenPythia& AliGenPythia::operator=(const  AliGenPythia& rhs)
 {
 // Assignment operator
@@ -469,6 +534,8 @@ AliGenPythia& AliGenPythia::operator=(const  AliGenPythia& rhs)
 }
 
 
+
+#ifdef never
 void AliGenPythia::Streamer(TBuffer &R__b)
 {
    // Stream an object of class AliGenPythia.
@@ -507,11 +574,5 @@ void AliGenPythia::Streamer(TBuffer &R__b)
       //     fDecayer->Streamer(R__b);
    }
 }
-
-
-
-
-
-
-
+#endif