]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/mgdraw.cxx
Adding AliVZEROv6
[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 #include "TFlukaCodes.h"
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 "Fflkstk.h"  //(FLKSTK) fluka common
13 #include "Fltclcm.h"  //(LTCLCM) fluka common
14 #include "Fpaprop.h"  //(PAPROP) fluka common
15
16 #ifndef WIN32
17 # define mgdraw mgdraw_
18 #else
19 # define mgdraw MGDRAW
20 #endif
21
22 extern "C" {
23 void mgdraw(Int_t& icode, Int_t& mreg)
24 {
25     TFluka* fluka =  (TFluka*) gMC;
26     if (mreg == fluka->GetDummyRegion()) return;
27     Int_t verbosityLevel = fluka->GetVerbosityLevel();
28 //
29 //  Make sure that stack has currrent track Id
30 //
31     Int_t trackId = -1;
32     TVirtualMCStack* cppstack = fluka->GetStack();
33     
34     if (TRACKR.jtrack == -1) {
35         trackId = OPPHST.louopp[OPPHST.lstopp];
36         if (trackId == 0) {
37             trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
38         }
39     } else {
40         trackId = TRACKR.ispusr[mkbmx2-1];
41     }
42     
43     cppstack->SetCurrentTrack(trackId);
44 //
45 //    
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);
51
52     if (!TRACKR.ispusr[mkbmx2 - 2]) {
53         //
54         // Single step
55         if (verbosityLevel >= 3) {
56             cout << endl << "mgdraw: energy deposition for:" << trackId << endl;
57         }
58         (TVirtualMCApplication::Instance())->Stepping();
59         fluka->SetTrackIsNew(kFALSE);
60     } else {
61         //
62         // Tracking is being resumed after secondary tracking
63         //
64         if (verbosityLevel >= 3) {
65             cout << endl << "mgdraw: resuming Stepping(): " << trackId << endl;
66         }
67
68         fluka->SetTrackIsNew(kTRUE);
69         fluka->SetCaller(kMGResumedTrack);
70         (TVirtualMCApplication::Instance())->Stepping();
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
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         }
81
82         fluka->SetTrackIsNew(kFALSE);
83         fluka->SetCaller(kMGDRAW);
84         (TVirtualMCApplication::Instance())->Stepping();
85     }
86 } // end of mgdraw
87 } // end of extern "C"
88