2 #include "TVirtualMCApplication.h"
3 #include "TVirtualMCStack.h"
6 #include "TFlukaCodes.h"
8 #include "Fdimpar.h" //(DIMPAR) fluka include
9 #include "Fdblprc.h" //(DBLPRC) fluka common
10 #include "Ftrackr.h" //(TRACKR) fluka common
11 #include "Fopphst.h" //(OPPHST) fluka common
12 #include "Fflkstk.h" //(FLKSTK) fluka common
13 #include "Fltclcm.h" //(LTCLCM) fluka common
14 #include "Fpaprop.h" //(PAPROP) fluka common
17 # define mgdraw mgdraw_
19 # define mgdraw MGDRAW
23 void mgdraw(Int_t& icode, Int_t& mreg)
25 TFluka* fluka = (TFluka*) gMC;
26 if (mreg == fluka->GetDummyRegion()) return;
27 Int_t verbosityLevel = fluka->GetVerbosityLevel();
29 // Make sure that stack has currrent track Id
32 TVirtualMCStack* cppstack = fluka->GetStack();
34 if (TRACKR.jtrack == -1) {
35 trackId = OPPHST.louopp[OPPHST.lstopp];
37 trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
40 trackId = TRACKR.ispusr[mkbmx2-1];
43 cppstack->SetCurrentTrack(trackId);
46 Int_t mlttc = LTCLCM.mlatm1;
47 fluka->SetMreg(mreg, mlttc);
48 fluka->SetNewreg(mreg, mlttc);
49 fluka->SetIcode((FlukaProcessCode_t) icode);
50 fluka->SetCaller(kMGDRAW);
52 if (!TRACKR.ispusr[mkbmx2 - 2]) {
55 if (verbosityLevel >= 3) {
56 cout << endl << "mgdraw: energy deposition for:" << trackId << endl;
58 (TVirtualMCApplication::Instance())->Stepping();
59 fluka->SetTrackIsNew(kFALSE);
62 // Tracking is being resumed after secondary tracking
64 if (verbosityLevel >= 3) {
65 cout << endl << "mgdraw: resuming Stepping(): " << trackId << endl;
68 fluka->SetTrackIsNew(kTRUE);
69 fluka->SetCaller(kMGResumedTrack);
70 (TVirtualMCApplication::Instance())->Stepping();
72 // Reset flag and stored values
73 TRACKR.ispusr[mkbmx2 - 2] = 0;
74 for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
77 if (verbosityLevel >= 3) {
78 cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
79 cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
82 fluka->SetTrackIsNew(kFALSE);
83 fluka->SetCaller(kMGDRAW);
84 (TVirtualMCApplication::Instance())->Stepping();
87 } // end of extern "C"