]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/mgdraw.cxx
Adding MUON HLT code to the repository.
[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
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 "Fstack.h"   //(STACK)  fluka common
13
14 #ifndef WIN32
15 # define mgdraw mgdraw_
16 #else
17 # define mgdraw MGDRAW
18 #endif
19
20 extern "C" {
21 void mgdraw(Int_t& icode, Int_t& mreg)
22 {
23     TFluka* fluka =  (TFluka*) gMC;
24     Int_t verbosityLevel = fluka->GetVerbosityLevel();
25 //
26 //  Make sure that stack has currrent track Id
27 //
28     Int_t trackId = -1;
29     TVirtualMCStack* cppstack = fluka->GetStack();
30     
31     if (TRACKR.jtrack == -1) {
32         trackId = OPPHST.louopp[OPPHST.lstopp];
33         if (trackId == 0) {
34             trackId = STACK.ispark[STACK.lstack][mkbmx2-1];
35         }
36     } else {
37         trackId = TRACKR.ispusr[mkbmx2-1];
38     }
39     
40     cppstack->SetCurrentTrack(trackId);
41 //
42 //    
43     fluka->SetMreg(mreg);
44     fluka->SetNewreg(mreg);
45     fluka->SetIcode(icode);
46     fluka->SetCaller(4);
47
48     if (!TRACKR.ispusr[mkbmx2 - 2]) {
49         //
50         // Single step
51         if (verbosityLevel >= 3) {
52             cout << endl << " !!! I am in mgdraw - calling Stepping(): " << icode << endl;
53             cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
54         }
55       
56         (TVirtualMCApplication::Instance())->Stepping();
57         fluka->SetTrackIsNew(kFALSE);
58     } else {
59         //
60         // Tracking is being resumed after secondary tracking
61         //
62         if (verbosityLevel >= 3) {
63             cout << endl << " !!! I am in mgdraw - resuming Stepping(): " << trackId << endl;
64         }
65         
66         fluka->SetTrackIsNew(kTRUE);
67         fluka->SetCaller(40);
68         (TVirtualMCApplication::Instance())->Stepping();
69
70         // Reset flag and stored values
71         TRACKR.ispusr[mkbmx2 - 2] = 0;
72         for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
73
74
75         if (verbosityLevel >= 3) {
76             cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
77             cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
78         }
79
80         fluka->SetTrackIsNew(kFALSE);
81         fluka->SetCaller(4);
82         (TVirtualMCApplication::Instance())->Stepping();
83     }
84     
85     
86 } // end of mgdraw
87 } // end of extern "C"
88