]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/mgdraw.cxx
Example macros for using AliAODv0 class
[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 //
28 //  Make sure that stack has currrent track Id
29 //
30     Int_t trackId = -1;
31     TVirtualMCStack* cppstack = fluka->GetStack();
32     
33     if (TRACKR.jtrack == -1) {
34         trackId = OPPHST.louopp[OPPHST.lstopp];
35         if (trackId == 0) {
36             trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
37         }
38     } else {
39         trackId = TRACKR.ispusr[mkbmx2-1];
40     }
41     
42     Int_t verbosityLevel = fluka->GetVerbosityLevel();
43
44     if (TRACKR.jtrack < -6) {
45        // (Unknow heavy Ion???)
46        // assing parent id ???
47        // id < -6 was skipped in stuprf =>   if (kpart < -6) return;
48        if (verbosityLevel >= 3) {
49           cout << "mgdraw: jtrack < -6 =" << TRACKR.jtrack
50                << " assign parent pdg=" << fluka->PDGFromId(TRACKR.ispusr[mkbmx2 - 3]) << endl;
51        }
52        TRACKR.jtrack = TRACKR.ispusr[mkbmx2 - 3];
53     }
54     
55     cppstack->SetCurrentTrack(trackId);
56 //
57 //    
58     Int_t mlttc = LTCLCM.mlatm1;
59     fluka->SetMreg(mreg, mlttc);
60     fluka->SetNewreg(mreg, mlttc);
61     fluka->SetIcode((FlukaProcessCode_t) icode);
62     fluka->SetCaller(kMGDRAW);
63
64     if (!TRACKR.ispusr[mkbmx2 - 2]) {
65         //
66         // Single step
67         if (verbosityLevel >= 3) {
68            cout << endl << "mgdraw: energy deposition for:" << trackId
69                  << " icode=" << icode
70                  << " pdg=" << fluka->PDGFromId(TRACKR.jtrack) << " flukaid="<< TRACKR.jtrack << endl;
71         }
72         (TVirtualMCApplication::Instance())->Stepping();
73         fluka->SetTrackIsNew(kFALSE);
74     } else {
75         //
76         // Tracking is being resumed after secondary tracking
77         //
78         if (verbosityLevel >= 3) {
79             cout << endl << "mgdraw: resuming Stepping(): " << trackId << endl;
80         }
81
82         fluka->SetTrackIsNew(kTRUE);
83         fluka->SetCaller(kMGResumedTrack);
84         (TVirtualMCApplication::Instance())->Stepping();
85
86         // Reset flag and stored values
87         TRACKR.ispusr[mkbmx2 - 2] = 0;
88         for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
89
90
91         if (verbosityLevel >= 3) {
92             cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
93             cout << " Track= " << trackId << " region = " << mreg << endl;
94         }
95
96         fluka->SetTrackIsNew(kFALSE);
97         fluka->SetCaller(kMGDRAW);
98         (TVirtualMCApplication::Instance())->Stepping();
99     }
100 } // end of mgdraw
101 } // end of extern "C"
102