Fixing a little bug
[u/mrichter/AliRoot.git] / TFluka / bxdraw.cxx
CommitLineData
fa3d1cc7 1#include <Riostream.h>
a7bb59a2 2
fa3d1cc7 3#include "TFluka.h"
d566901f 4#include "TFlukaCodes.h"
5#include "TFlukaMCGeometry.h"
a1f42b9c 6#include "Fdimpar.h" //(DIMPAR) fluka include
7#include "Ftrackr.h" //(TRACKR) fluka common
d566901f 8#include "Fltclcm.h" //(LTCLCM) fluka common
fa3d1cc7 9#ifndef WIN32
10# define bxdraw bxdraw_
11#else
12# define bxdraw BXDRAW
13#endif
14extern "C" {
15void bxdraw(Int_t& icode, Int_t& mreg, Int_t& newreg,
16 Double_t& xsco, Double_t& ysco, Double_t& zsco)
17{
a1f42b9c 18 TFluka* fluka = (TFluka*) gMC;
d566901f 19 Int_t oldlttc = LTCLCM.mlatm1;
20 Int_t newlttc = LTCLCM.newlat;
21 fluka->SetIcode((FlukaProcessCode_t)icode);
22 fluka->SetNewreg(newreg,newlttc);
a1f42b9c 23 fluka->SetXsco(xsco);
24 fluka->SetYsco(ysco);
25 fluka->SetZsco(zsco);
2bc4c610 26 Int_t verbosityLevel = fluka->GetVerbosityLevel();
27 Bool_t debug = (verbosityLevel>=3)?kTRUE:kFALSE;
a1f42b9c 28//
29// Double step for boundary crossing
30//
4d286778 31 fluka->SetTrackIsNew(kFALSE); // has to be called BEFORE Stepping()
d566901f 32 if (mreg != fluka->GetDummyRegion()) {
33 if (debug) printf("bxdraw (ex) \n");
34 fluka->SetTrackIsExiting();
35 fluka->SetCaller(kBXExiting);
36 fluka->SetMreg(mreg,oldlttc);
18e0cabb 37 TVirtualMCStack* cppstack = fluka->GetStack();
38 cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
39 (TVirtualMCApplication::Instance())->Stepping();
d566901f 40 }
41 if (newreg != fluka->GetDummyRegion()) {
42 if (debug) printf("bxdraw (en) \n");
43 fluka->SetCaller(kBXEntering);
44 fluka->SetTrackIsEntering();
45 if (fluka->GetDummyBoundary() == 1) fluka->SetDummyBoundary(2);
46 fluka->SetMreg(newreg,newlttc);
18e0cabb 47 TVirtualMCStack* cppstack = fluka->GetStack();
48 cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
d566901f 49 (TVirtualMCApplication::Instance())->Stepping();
18e0cabb 50 }
4d286778 51
fa3d1cc7 52} // end of bxdraw
53} // end of extern "C"
54