]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/mgdraw.cxx
12-jan-2005 NvE Bug fix in AliAttrib::GetSlotIndex() by exiting as soon as matching...
[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 "Fstack.h"   //(STACK)  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 = STACK.ispark[STACK.lstack][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 (verbosityLevel >= 3) {
52             cout << endl << " !!! I am in mgdraw - calling Stepping(): " << icode << endl;
53             cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
54         }
55         (TVirtualMCApplication::Instance())->Stepping();
56         fluka->SetTrackIsNew(kFALSE);
57     } else {
58         //
59         // Tracking is being resumed after secondary tracking
60         //
61         // Reset flag
62         TRACKR.ispusr[mkbmx2 - 2] = 0;
63 //
64         fluka->SetTrackIsNew(kTRUE);
65
66         if (verbosityLevel >= 3) {
67             cout << endl << " !!! I am in mgdraw - resuming Stepping(): " << trackId << endl;
68         }
69
70         (TVirtualMCApplication::Instance())->Stepping();
71         fluka->SetTrackIsNew(kFALSE);
72
73         if (verbosityLevel >= 3) {
74             cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
75             cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
76         }
77         (TVirtualMCApplication::Instance())->Stepping();
78     }
79     
80     
81 } // end of mgdraw
82 } // end of extern "C"
83