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;
28 // Make sure that stack has currrent track Id
31 TVirtualMCStack* cppstack = fluka->GetStack();
33 if (TRACKR.jtrack == -1) {
34 trackId = OPPHST.louopp[OPPHST.lstopp];
36 trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
39 trackId = TRACKR.ispusr[mkbmx2-1];
42 Int_t verbosityLevel = fluka->GetVerbosityLevel();
44 if (TRACKR.jtrack < -6) {
45 // (Unknow heavy Ion???)
46 // assing parent id ???
47 // id < -6 was skipped in stuprf => if (kpart < -6) return;
48 if (verbosityLevel >= 3) {
49 cout << "mgdraw: jtrack < -6 =" << TRACKR.jtrack
50 << " assign parent pdg=" << fluka->PDGFromId(TRACKR.ispusr[mkbmx2 - 3]) << endl;
52 TRACKR.jtrack = TRACKR.ispusr[mkbmx2 - 3];
55 cppstack->SetCurrentTrack(trackId);
58 Int_t mlttc = LTCLCM.mlatm1;
59 fluka->SetMreg(mreg, mlttc);
60 fluka->SetNewreg(mreg, mlttc);
61 fluka->SetIcode((FlukaProcessCode_t) icode);
62 fluka->SetCaller(kMGDRAW);
64 if (!TRACKR.ispusr[mkbmx2 - 2]) {
67 if (verbosityLevel >= 3) {
68 cout << endl << "mgdraw: energy deposition for:" << trackId
70 << " pdg=" << fluka->PDGFromId(TRACKR.jtrack) << " flukaid="<< TRACKR.jtrack << endl;
72 (TVirtualMCApplication::Instance())->Stepping();
73 fluka->SetTrackIsNew(kFALSE);
76 // Tracking is being resumed after secondary tracking
78 if (verbosityLevel >= 3) {
79 cout << endl << "mgdraw: resuming Stepping(): " << trackId << endl;
82 fluka->SetTrackIsNew(kTRUE);
83 fluka->SetCaller(kMGResumedTrack);
84 (TVirtualMCApplication::Instance())->Stepping();
86 // Reset flag and stored values
87 TRACKR.ispusr[mkbmx2 - 2] = 0;
88 for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
91 if (verbosityLevel >= 3) {
92 cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
93 cout << " Track= " << trackId << " region = " << mreg << endl;
96 fluka->SetTrackIsNew(kFALSE);
97 fluka->SetCaller(kMGDRAW);
98 (TVirtualMCApplication::Instance())->Stepping();
101 } // end of extern "C"