Parent id and current track id handling corrected.
[u/mrichter/AliRoot.git] / TFluka / mgdraw.cxx
CommitLineData
fa3d1cc7 1#include <Riostream.h>
8fd1d27e 2#include "TVirtualMCApplication.h"
fa3d1cc7 3#include "TFluka.h"
4#ifndef WIN32
5# define mgdraw mgdraw_
6#else
7# define mgdraw MGDRAW
8#endif
9
10extern "C" {
11void mgdraw(Int_t& icode, Int_t& mreg)
12{
8fd1d27e 13 Int_t oldreg = ((TFluka*) gMC)->GetMreg();
14 if (oldreg != mreg) {
15//
16// Boundary Crossing
17//
18 ((TFluka*) gMC)->SetNewreg(mreg);
19 if (oldreg == -1)
20 ((TFluka*) gMC)->SetMreg(mreg);
21 printf("Boundary Crossing %d %d \n", oldreg, mreg);
22 } else {
23 ((TFluka*) gMC)->SetMreg(mreg);
24 ((TFluka*) gMC)->SetNewreg(mreg);
25 printf("Normal step %d %d \n", oldreg, mreg);
26 }
27 ((TFluka*) gMC)->SetIcode(icode);
28 cout << endl << " !!! I am in mgdraw - calling Stepping()" << endl;
29 ((TFluka*) gMC)->FutoTest();
30
31 if (oldreg != mreg) {
32//
33// Double step for boundary crossing
34//
35 ((TFluka*) gMC)->SetTrackIsExiting();
36 (TVirtualMCApplication::Instance())->Stepping();
37 ((TFluka*) gMC)->SetMreg(mreg);
38 ((TFluka*) gMC)->SetTrackIsEntering();
39 (TVirtualMCApplication::Instance())->Stepping();
40 ((TFluka*) gMC)->SetTrackIsInside();
41 } else {
42 (TVirtualMCApplication::Instance())->Stepping();
43 }
fa3d1cc7 44} // end of mgdraw
45} // end of extern "C"
46