Ions have to be added to root particle database.
[u/mrichter/AliRoot.git] / TFluka / mgdraw.cxx
CommitLineData
fa3d1cc7 1#include <Riostream.h>
8fd1d27e 2#include "TVirtualMCApplication.h"
b1b2005d 3#include "TVirtualMCStack.h"
a7bb59a2 4
fa3d1cc7 5#include "TFluka.h"
d566901f 6#include "TFlukaCodes.h"
b1b2005d 7// Fluka include
8#include "Fdimpar.h" //(DIMPAR) fluka include
9#include "Fdblprc.h" //(DBLPRC) fluka common
10#include "Ftrackr.h" //(TRACKR) fluka common
3a625972 11#include "Fopphst.h" //(OPPHST) fluka common
81f1d030 12#include "Fflkstk.h" //(FLKSTK) fluka common
d566901f 13#include "Fltclcm.h" //(LTCLCM) fluka common
14#include "Fpaprop.h" //(PAPROP) fluka common
b1b2005d 15
fa3d1cc7 16#ifndef WIN32
17# define mgdraw mgdraw_
18#else
19# define mgdraw MGDRAW
20#endif
21
22extern "C" {
23void mgdraw(Int_t& icode, Int_t& mreg)
24{
b1b2005d 25 TFluka* fluka = (TFluka*) gMC;
d566901f 26 if (mreg == fluka->GetDummyRegion()) return;
57dc5a4a 27 Int_t verbosityLevel = fluka->GetVerbosityLevel();
b1b2005d 28//
29// Make sure that stack has currrent track Id
57dc5a4a 30//
3a625972 31 Int_t trackId = -1;
b1b2005d 32 TVirtualMCStack* cppstack = fluka->GetStack();
3a625972 33
34 if (TRACKR.jtrack == -1) {
e45bbee7 35 trackId = OPPHST.louopp[OPPHST.lstopp];
3ad1c4d5 36 if (trackId == 0) {
81f1d030 37 trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
3ad1c4d5 38 }
3a625972 39 } else {
40 trackId = TRACKR.ispusr[mkbmx2-1];
41 }
42
b1b2005d 43 cppstack->SetCurrentTrack(trackId);
44//
45//
d566901f 46 Int_t mlttc = LTCLCM.mlatm1;
47 fluka->SetMreg(mreg, mlttc);
48 fluka->SetNewreg(mreg, mlttc);
49 fluka->SetIcode((FlukaProcessCode_t) icode);
50 fluka->SetCaller(kMGDRAW);
57dc5a4a 51
52 if (!TRACKR.ispusr[mkbmx2 - 2]) {
53 //
54 // Single step
d566901f 55 if (verbosityLevel >= 3) {
56 cout << endl << "mgdraw: energy deposition for:" << trackId << endl;
57dc5a4a 57 }
58 (TVirtualMCApplication::Instance())->Stepping();
59 fluka->SetTrackIsNew(kFALSE);
60 } else {
61 //
62 // Tracking is being resumed after secondary tracking
63 //
57dc5a4a 64 if (verbosityLevel >= 3) {
d566901f 65 cout << endl << "mgdraw: resuming Stepping(): " << trackId << endl;
57dc5a4a 66 }
d566901f 67
5d80a015 68 fluka->SetTrackIsNew(kTRUE);
d566901f 69 fluka->SetCaller(kMGResumedTrack);
57dc5a4a 70 (TVirtualMCApplication::Instance())->Stepping();
5d80a015 71
72 // Reset flag and stored values
73 TRACKR.ispusr[mkbmx2 - 2] = 0;
74 for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
75
57dc5a4a 76
77 if (verbosityLevel >= 3) {
78 cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
79 cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
80 }
5d80a015 81
82 fluka->SetTrackIsNew(kFALSE);
d566901f 83 fluka->SetCaller(kMGDRAW);
57dc5a4a 84 (TVirtualMCApplication::Instance())->Stepping();
85 }
fa3d1cc7 86} // end of mgdraw
87} // end of extern "C"
88