]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TFluka/mgdraw.cxx
Changes needed on Sun with Root v4-03-04
[u/mrichter/AliRoot.git] / TFluka / mgdraw.cxx
index ca1070db4473565c957c7e255c297b183259e6bc..3dbe4f36294c8a5e00d95c5d02e98946ded3a598 100644 (file)
@@ -1,11 +1,15 @@
 #include <Riostream.h>
 #include "TVirtualMCApplication.h"
 #include "TVirtualMCStack.h"
+
 #include "TFluka.h"
+
 // Fluka include
 #include "Fdimpar.h"  //(DIMPAR) fluka include
 #include "Fdblprc.h"  //(DBLPRC) fluka common
 #include "Ftrackr.h"  //(TRACKR) fluka common
+#include "Fopphst.h"  //(OPPHST) fluka common
+#include "Fstack.h"   //(STACK)  fluka common
 
 #ifndef WIN32
 # define mgdraw mgdraw_
@@ -20,49 +24,65 @@ void mgdraw(Int_t& icode, Int_t& mreg)
     Int_t verbosityLevel = fluka->GetVerbosityLevel();
 //
 //  Make sure that stack has currrent track Id
-    Int_t trackId = TRACKR.ispusr[mkbmx2-1];
+//
+    Int_t trackId = -1;
     TVirtualMCStack* cppstack = fluka->GetStack();
+    
+    if (TRACKR.jtrack == -1) {
+       trackId = OPPHST.louopp[OPPHST.lstopp];
+       if (trackId == 0) {
+           trackId = STACK.ispark[STACK.lstack][mkbmx2-1];
+       }
+    } else {
+       trackId = TRACKR.ispusr[mkbmx2-1];
+    }
+    
     cppstack->SetCurrentTrack(trackId);
 //
 //    
-    Int_t oldreg = ((TFluka*) gMC)->GetMreg();
-    if (oldreg != mreg) {
-//
-//  Boundary Crossing
-//
-       fluka->SetNewreg(mreg);
-       if (oldreg == -1) fluka->SetMreg(mreg);
-       if (verbosityLevel >= 3)
-           printf("Boundary Crossing %d %d \n", oldreg, mreg);
-    } else {
-       fluka->SetMreg(mreg);
-       fluka->SetNewreg(mreg);
-       if (verbosityLevel >= 3)
-           printf("Normal step %d %d \n", oldreg, mreg);
-    }
+    fluka->SetMreg(mreg);
+    fluka->SetNewreg(mreg);
     fluka->SetIcode(icode);
     fluka->SetCaller(4);
-    
-    if (verbosityLevel >= 3) {
-       cout << endl << " !!! I am in mgdraw - calling Stepping()" << endl;
-       cout << endl << " Track Id =" << trackId << endl;
-    }
-    
-    fluka->FutoTest();
 
-    if (oldreg != mreg) {
-//
-//  Double step for boundary crossing
-//
-       fluka->SetTrackIsExiting();
-       (TVirtualMCApplication::Instance())->Stepping();
-       fluka->SetMreg(mreg);
-       fluka->SetTrackIsEntering();
+    if (!TRACKR.ispusr[mkbmx2 - 2]) {
+       //
+       // Single step
+       if (verbosityLevel >= 3) {
+           cout << endl << " !!! I am in mgdraw - calling Stepping(): " << icode << endl;
+           cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
+       }
+      
        (TVirtualMCApplication::Instance())->Stepping();
-       fluka->SetTrackIsInside();
+       fluka->SetTrackIsNew(kFALSE);
     } else {
+       //
+       // Tracking is being resumed after secondary tracking
+       //
+       if (verbosityLevel >= 3) {
+           cout << endl << " !!! I am in mgdraw - resuming Stepping(): " << trackId << endl;
+       }
+       
+       fluka->SetTrackIsNew(kTRUE);
+       fluka->SetCaller(40);
+       (TVirtualMCApplication::Instance())->Stepping();
+
+       // Reset flag and stored values
+       TRACKR.ispusr[mkbmx2 - 2] = 0;
+       for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
+
+
+       if (verbosityLevel >= 3) {
+           cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
+           cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
+       }
+
+       fluka->SetTrackIsNew(kFALSE);
+       fluka->SetCaller(4);
        (TVirtualMCApplication::Instance())->Stepping();
     }
+    
+    
 } // end of mgdraw
 } // end of extern "C"