Two Stepping calls at boundary crossing.
[u/mrichter/AliRoot.git] / TFluka / mgdraw.cxx
CommitLineData
fa3d1cc7 1#include <Riostream.h>
8fd1d27e 2#include "TVirtualMCApplication.h"
b1b2005d 3#include "TVirtualMCStack.h"
fa3d1cc7 4#include "TFluka.h"
b1b2005d 5// Fluka include
6#include "Fdimpar.h" //(DIMPAR) fluka include
7#include "Fdblprc.h" //(DBLPRC) fluka common
8#include "Ftrackr.h" //(TRACKR) fluka common
9
fa3d1cc7 10#ifndef WIN32
11# define mgdraw mgdraw_
12#else
13# define mgdraw MGDRAW
14#endif
15
16extern "C" {
17void mgdraw(Int_t& icode, Int_t& mreg)
18{
b1b2005d 19 TFluka* fluka = (TFluka*) gMC;
20 Int_t verbosityLevel = fluka->GetVerbosityLevel();
21//
22// Make sure that stack has currrent track Id
23 Int_t trackId = TRACKR.ispusr[mkbmx2-1];
24 TVirtualMCStack* cppstack = fluka->GetStack();
25 cppstack->SetCurrentTrack(trackId);
26//
27//
8fd1d27e 28 Int_t oldreg = ((TFluka*) gMC)->GetMreg();
29 if (oldreg != mreg) {
30//
31// Boundary Crossing
32//
b1b2005d 33 fluka->SetNewreg(mreg);
34 if (oldreg == -1) fluka->SetMreg(mreg);
35 if (verbosityLevel >= 3)
36 printf("Boundary Crossing %d %d \n", oldreg, mreg);
8fd1d27e 37 } else {
b1b2005d 38 fluka->SetMreg(mreg);
39 fluka->SetNewreg(mreg);
40 if (verbosityLevel >= 3)
41 printf("Normal step %d %d \n", oldreg, mreg);
8fd1d27e 42 }
b1b2005d 43 fluka->SetIcode(icode);
a1f42b9c 44 fluka->SetCaller(4);
45
c31c3638 46 if (verbosityLevel >= 3) {
47 cout << endl << " !!! I am in mgdraw - calling Stepping()" << endl;
48 cout << endl << " Track Id =" << trackId << endl;
49 }
b1b2005d 50
51 fluka->FutoTest();
8fd1d27e 52
53 if (oldreg != mreg) {
54//
55// Double step for boundary crossing
56//
b1b2005d 57 fluka->SetTrackIsExiting();
8fd1d27e 58 (TVirtualMCApplication::Instance())->Stepping();
b1b2005d 59 fluka->SetMreg(mreg);
60 fluka->SetTrackIsEntering();
8fd1d27e 61 (TVirtualMCApplication::Instance())->Stepping();
b1b2005d 62 fluka->SetTrackIsInside();
8fd1d27e 63 } else {
64 (TVirtualMCApplication::Instance())->Stepping();
65 }
fa3d1cc7 66} // end of mgdraw
67} // end of extern "C"
68