Some protections needed for stand-allone use added.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 18 Nov 2003 10:03:38 +0000 (10:03 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 18 Nov 2003 10:03:38 +0000 (10:03 +0000)
PYTHIA6/AliGenPythia.cxx

index 5c9f412..346e299 100644 (file)
@@ -153,6 +153,8 @@ void AliGenPythia::Init()
     
     SetMC(AliPythia::Instance());
     fPythia=(AliPythia*) fMCEvGen;
+    printf("Pythia Init %p", fPythia);
+    
 //
     fParentWeight=1./Float_t(fNpart);
 //
@@ -313,7 +315,7 @@ void AliGenPythia::Generate()
        if (fQuench) {
            fPythia->SetMSTJ(1, 0);
        }
-
+       printf("Pythia pyevnt %p", fPythia);
        fPythia->Pyevnt();
 
        if (fQuench) {
@@ -322,11 +324,13 @@ void AliGenPythia::Generate()
            fPythia->Pyexec();
        }
        
+       if (gAlice) {
+           if (gAlice->GetEvNumber()>=fDebugEventFirst &&
+               gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(1);
+       }
        
-       if (gAlice->GetEvNumber()>=fDebugEventFirst &&
-           gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(1);
        fTrials++;
-       
+       printf("Pythia import t %p %p ", fPythia, fParticles);
        fPythia->ImportParticles(fParticles,"All");
 
        Boost();
@@ -627,11 +631,13 @@ void AliGenPythia::AdjustWeights()
 {
 // Adjust the weights after generation of all events
 //
-    TParticle *part;
-    Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
-    for (Int_t i=0; i<ntrack; i++) {
-       part= gAlice->GetMCApp()->Particle(i);
-       part->SetWeight(part->GetWeight()*fKineBias);
+    if (gAlice) {
+       TParticle *part;
+       Int_t ntrack=gAlice->GetMCApp()->GetNtrack();
+       for (Int_t i=0; i<ntrack; i++) {
+           part= gAlice->GetMCApp()->Particle(i);
+           part->SetWeight(part->GetWeight()*fKineBias);
+       }
     }
 }
     
@@ -672,7 +678,7 @@ void AliGenPythia::MakeHeader()
                                                        jets[3][i]);
        }
     }
-    gAlice->SetGenEventHeader(fHeader);
+    if (gAlice) gAlice->SetGenEventHeader(fHeader);
 }