#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 "Fstack.h" //(STACK) 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_
void mgdraw(Int_t& icode, Int_t& mreg)
{
TFluka* fluka = (TFluka*) gMC;
-// Int_t verbosityLevel = fluka->GetVerbosityLevel();
+ if (mreg == fluka->GetDummyRegion()) return;
+ Int_t verbosityLevel = fluka->GetVerbosityLevel();
//
// Make sure that stack has currrent track Id
+//
Int_t trackId = -1;
TVirtualMCStack* cppstack = fluka->GetStack();
if (TRACKR.jtrack == -1) {
- // Optical photons
- //
- // Try first to get the track ID from the FLUKA stack for optical photons
- trackId = OPPHST.LOUOPP[OPPHST.LSTOPP];
+ trackId = OPPHST.louopp[OPPHST.lstopp];
if (trackId == 0) {
- // This might be a feedback photon or similar that was put on the VMC stack first
- trackId = STACK.ispark[STACK.lstack][mkbmx2-1];
+ trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
}
} else {
trackId = TRACKR.ispusr[mkbmx2-1];
cppstack->SetCurrentTrack(trackId);
//
//
- 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;
-// }
-
-
- (TVirtualMCApplication::Instance())->Stepping();
- fluka->SetTrackIsNew(kFALSE);
+ 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->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
} // end of extern "C"