]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TFluka/mgdraw.cxx
Warning corrected.
[u/mrichter/AliRoot.git] / TFluka / mgdraw.cxx
index f0f25565105ed23e6ca1e2ffa9d3f56a55eb94cf..221596b56640dfc8378e1a80662ba82b227473ff 100644 (file)
@@ -1,11 +1,17 @@
 #include <Riostream.h>
 #include "TVirtualMCApplication.h"
 #include "TVirtualMCStack.h"
+
 #include "TFluka.h"
+#include "TFlukaCodes.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 "Fflkstk.h"  //(FLKSTK) fluka common
+#include "Fltclcm.h"  //(LTCLCM) fluka common
+#include "Fpaprop.h"  //(PAPROP) fluka common
 
 #ifndef WIN32
 # define mgdraw mgdraw_
@@ -17,47 +23,64 @@ extern "C" {
 void mgdraw(Int_t& icode, Int_t& mreg)
 {
     TFluka* fluka =  (TFluka*) gMC;
+    if (mreg == fluka->GetDummyRegion()) return;
     Int_t verbosityLevel = fluka->GetVerbosityLevel();
 //
 //  Make sure that stack has currrent track Id
-    Int_t trackId = TRACKR.ispusr[mkbmx2-1];
-    TVirtualMCStack* cppstack = fluka->GetStack();
-    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);
+    Int_t trackId = -1;
+    TVirtualMCStack* cppstack = fluka->GetStack();
+    
+    if (TRACKR.jtrack == -1) {
+       trackId = OPPHST.louopp[OPPHST.lstopp];
+       if (trackId == 0) {
+           trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
+       }
     } else {
-       fluka->SetMreg(mreg);
-       fluka->SetNewreg(mreg);
-       if (verbosityLevel >= 3)
-           printf("Normal step %d %d \n", oldreg, mreg);
+       trackId = TRACKR.ispusr[mkbmx2-1];
     }
-    fluka->SetIcode(icode);
-
-    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
+    cppstack->SetCurrentTrack(trackId);
 //
-       fluka->SetTrackIsExiting();
-       (TVirtualMCApplication::Instance())->Stepping();
-       fluka->SetMreg(mreg);
-       fluka->SetTrackIsEntering();
+//    
+    Int_t mlttc = LTCLCM.mlatm1;
+    fluka->SetMreg(mreg, mlttc);
+    fluka->SetNewreg(mreg, mlttc);
+    fluka->SetIcode((FlukaProcessCode_t) icode);
+    fluka->SetCaller(kMGDRAW);
+
+    if (!TRACKR.ispusr[mkbmx2 - 2]) {
+       //
+       // Single step
+       if (verbosityLevel >= 3) {
+           cout << endl << "mgdraw: energy deposition for:" << trackId << endl;
+       }
        (TVirtualMCApplication::Instance())->Stepping();
-       fluka->SetTrackIsInside();
+       fluka->SetTrackIsNew(kFALSE);
     } else {
+       //
+       // Tracking is being resumed after secondary tracking
+       //
+       if (verbosityLevel >= 3) {
+           cout << endl << "mgdraw: resuming Stepping(): " << trackId << endl;
+       }
+
+       fluka->SetTrackIsNew(kTRUE);
+       fluka->SetCaller(kMGResumedTrack);
+       (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(kMGDRAW);
        (TVirtualMCApplication::Instance())->Stepping();
     }
 } // end of mgdraw