]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TFluka/source.cxx
Update to new vmc.
[u/mrichter/AliRoot.git] / TFluka / source.cxx
index 7c0038d9dc2f324c50f0fefe0bac8bc84a456904..ccb3dc73f6e6f165531c3ee9c7701143ee57cf5a 100644 (file)
@@ -17,6 +17,7 @@
 //Virutal MC
 #include "TFluka.h"
 #include "TVirtualMCStack.h"
+#include "TVirtualMCApplication.h"
 #include "TParticle.h"
 #include "TVector3.h"
 
@@ -37,7 +38,6 @@
 # define soevsv SOEVSV
 #endif
 
-
 extern "C" {
   //
   // Prototypes for FLUKA functions
@@ -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
@@ -102,7 +107,7 @@ extern "C" {
     TVirtualMCStack* cppstack = fluka->GetStack();
     //Get next particle
     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
@@ -124,29 +129,18 @@ extern "C" {
     cout << "\t\t+ Name = " << particle->GetName() << endl;
     cout << "\t\t+ PDG/Fluka code = " << particle->GetPdgCode() 
         << " / " << fluka->IdFromPDG(particle->GetPdgCode()) << endl;
-    cout << "\t\t+ E = " << particle->Energy() << " GeV" << endl;
     cout << "\t\t+ P = (" 
         << particle->Px() << " , "
         << particle->Py() << " , "
         << particle->Pz() << " ) --> "
         << particle->P() << " GeV" << endl;
-    cout << "\t\t+ M = " << particle->GetMass() << " GeV" << endl;
-    cout << "\t\t+ Initial point = ( " 
-        << particle->Vx() << " , "
-        << particle->Vy() << " , "
-        << particle->Vz() << " )"
-        << endl;    
-    cout << "\t\t+ Polarisation = ( " 
-        << polarisation.Px() << " , "
-        << polarisation.Py() << " , "
-        << polarisation.Pz() << " )"
-        << endl;    
     /* Lstack is the stack counter: of course any time source is called it
      * must be =0
      */
+    
     STACK.lstack++;
-    cout << "\t* Storing particle parameters in the stack, lstack = " 
-        << STACK.lstack << endl;
+    //cout << "\t* Storing particle parameters in the stack, lstack = " 
+    //  << STACK.lstack << endl;
     /* Wt is the weight of the particle*/
     STACK.wt[STACK.lstack] = oneone;
     STARS.weipri += STACK.wt[STACK.lstack];
@@ -169,7 +163,7 @@ extern "C" {
     for (ispr = 0; ispr < mkbmx2; ispr++)
        STACK.ispark[STACK.lstack][ispr] = 0;
     /* Save the track number of the stack particle:*/
-    STACK.ispark[STACK.lstack][mkbmx2-1] = STACK.lstack;
+    STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
     STACK.nparma++;
     STACK.numpar[STACK.lstack] = STACK.nparma;
     STACK.nevent[STACK.lstack] = 0;
@@ -201,7 +195,8 @@ extern "C" {
     //STACK.tz [STACK.lstack] = BEAM.tinz;
     Double_t cosx = particle->Px()/particle->P();
     Double_t cosy = particle->Py()/particle->P();
-    Double_t cosz = sqrt(oneone - cosx*cosx - cosy*cosy);
+    Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
+    if (particle->Pz() < 0.) cosz = -cosz;
     STACK.tx [STACK.lstack] = cosx;
     STACK.ty [STACK.lstack] = cosy;
     STACK.tz [STACK.lstack] = cosz;
@@ -234,9 +229,6 @@ extern "C" {
     STACK.ya [STACK.lstack] = particle->Vy();
     STACK.za [STACK.lstack] = particle->Vz();
     
-    // Some printout
-    cout << "\t* Particle information transfered to stack..." << endl;
-    
     /*  Calculate the total kinetic energy of the primaries: don't change*/
     Int_t st_ilo =  STACK.ilo[STACK.lstack];
     if ( st_ilo != 0 )
@@ -267,10 +259,8 @@ extern "C" {
     geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
     STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
     soevsv();
-    
-    cout << "\t* EPISOR.lsouit = " << (EPISOR.lsouit?'T':'F') << endl;
-    cout << "\t* " << STACK.lstack << " particles in the event" << endl;
-      
+    TVirtualMCApplication::Instance()->BeginPrimary();
+    TVirtualMCApplication::Instance()->PreTrack();
 #ifdef METHODDEBUG
     cout << "<== source(" << nomore << ")" << endl;
 #endif