]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/mgdraw.cxx
Flag interrupted track in EMSTK instead of TRACKR.
[u/mrichter/AliRoot.git] / TFluka / mgdraw.cxx
1 #include <Riostream.h>
2 #include "TVirtualMCApplication.h"
3 #include "TVirtualMCStack.h"
4
5 #include "TFluka.h"
6
7 // Fluka include
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
14 #ifndef WIN32
15 # define mgdraw mgdraw_
16 #else
17 # define mgdraw MGDRAW
18 #endif
19
20 extern "C" {
21 void mgdraw(Int_t& icode, Int_t& mreg)
22 {
23     TFluka* fluka =  (TFluka*) gMC;
24     Int_t verbosityLevel = fluka->GetVerbosityLevel();
25 //
26 //  Make sure that stack has currrent track Id
27 //
28     Int_t trackId = -1;
29     TVirtualMCStack* cppstack = fluka->GetStack();
30     
31     if (TRACKR.jtrack == -1) {
32         trackId = OPPHST.louopp[OPPHST.lstopp];
33         if (trackId == 0) {
34             trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
35         }
36     } else {
37         trackId = TRACKR.ispusr[mkbmx2-1];
38     }
39     
40     cppstack->SetCurrentTrack(trackId);
41 //
42 //    
43     fluka->SetMreg(mreg);
44     fluka->SetNewreg(mreg);
45     fluka->SetIcode(icode);
46     fluka->SetCaller(4);
47
48     if (!TRACKR.ispusr[mkbmx2 - 2]) {
49         //
50         // Single step
51         if (TRACKR.jtrack == -1 && trackId == 109340) {
52             cout << endl << " !!! I am in mgdraw - calling Stepping(): " << icode << endl;
53             cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
54             printf("Stepsize %13.5e \n", fluka->TrackStep());
55         }
56
57
58
59       
60         (TVirtualMCApplication::Instance())->Stepping();
61         fluka->SetTrackIsNew(kFALSE);
62     } else {
63         //
64         // Tracking is being resumed after secondary tracking
65         //
66         if (verbosityLevel >= 3) {
67             cout << endl << " !!! I am in mgdraw - resuming Stepping(): " << trackId << endl;
68         }
69         
70         fluka->SetTrackIsNew(kTRUE);
71         fluka->SetCaller(40);
72         (TVirtualMCApplication::Instance())->Stepping();
73
74         // Reset flag and stored values
75         TRACKR.ispusr[mkbmx2 - 2] = 0;
76         for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
77
78
79         if (verbosityLevel >= 3) {
80             cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
81             cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
82         }
83
84         fluka->SetTrackIsNew(kFALSE);
85         fluka->SetCaller(4);
86         (TVirtualMCApplication::Instance())->Stepping();
87     }
88     
89     
90 } // end of mgdraw
91 } // end of extern "C"
92