Update to new vmc.
[u/mrichter/AliRoot.git] / TFluka / source.cxx
index bd3793a7895f14e69a5d039caea58b8db9762b0c..ccb3dc73f6e6f165531c3ee9c7701143ee57cf5a 100644 (file)
@@ -88,7 +88,12 @@ extern "C" {
       lfirst = false;
       EPISOR.lussrc = true;
       /*|  *** User initialization ***/
+    } else {
+           TVirtualMCApplication::Instance()->PostTrack();
+           TVirtualMCApplication::Instance()->FinishPrimary();
     }
+
+    
     /*  |
      *  +-------------------------------------------------------------------*
      *  Push one source particle to the stack. Note that you could as well
@@ -101,12 +106,8 @@ extern "C" {
     // Get the stack produced from the generator
     TVirtualMCStack* cppstack = fluka->GetStack();
     //Get next particle
-    if (STACK.lstack != 1) {
-       TVirtualMCApplication::Instance()->PostTrack();
-       TVirtualMCApplication::Instance()->FinishPrimary();
-    }
     Int_t itrack = -1;
-    TParticle* particle = cppstack->GetNextTrack(itrack);
+    TParticle* particle = cppstack->PopNextTrack(itrack);
 
     //Exit if itrack is negative (-1). Set lsouit to false to mark last track for
     //this event
@@ -258,6 +259,7 @@ extern "C" {
     geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
     STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
     soevsv();
+    TVirtualMCApplication::Instance()->BeginPrimary();
     TVirtualMCApplication::Instance()->PreTrack();
 #ifdef METHODDEBUG
     cout << "<== source(" << nomore << ")" << endl;