]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/mgdraw.cxx
- EffC++ warnings corrected
[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
23 #include "TGeoManager.h" // <- delete
24
25 extern "C" {
26 void mgdraw(Int_t& icode, Int_t& mreg)
27 {
28     TFluka* fluka =  (TFluka*) gMC;
29     if (mreg == fluka->GetDummyRegion()) return;
30 //
31 //  Make sure that stack has currrent track Id
32 //
33     Int_t trackId = -1;
34     TVirtualMCStack* cppstack = fluka->GetStack();
35     
36     if (TRACKR.jtrack == -1) {
37         trackId = OPPHST.louopp[OPPHST.lstopp];
38         if (trackId == 0) {
39             trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
40         }
41     } else {
42         trackId = TRACKR.ispusr[mkbmx2-1];
43     }
44     
45     Int_t verbosityLevel = fluka->GetVerbosityLevel();
46
47     if (TRACKR.jtrack < -6) {
48        // from -7 to -12 = "heavy" fragment
49        // assing parent id
50        // id < -6 was skipped in stuprf =>   if (kpart < -6) return;
51        if (verbosityLevel >= 3) {
52           cout << "mgdraw: (heavy fragment) jtrack < -6 =" << TRACKR.jtrack
53                << " assign parent pdg=" << fluka->PDGFromId(TRACKR.ispusr[mkbmx2 - 3]) << endl;
54        }
55        TRACKR.jtrack = TRACKR.ispusr[mkbmx2 - 3];
56     }
57     
58     cppstack->SetCurrentTrack(trackId);
59 //
60 //    
61     Int_t mlttc = TRACKR.lt1trk; // LTCLCM.mlatm1;
62     fluka->SetMreg(mreg, mlttc);
63 //    fluka->SetNewreg(mreg, mlttc); // dont used!!
64     fluka->SetIcode((FlukaProcessCode_t) icode);
65     fluka->SetCaller(kMGDRAW);
66
67     Int_t nodeId;
68     Int_t volId = fluka->CurrentVolID(nodeId);
69     Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
70
71 //
72 //    if( (fluka->GetNstep() > 43912170 && fluka->GetNstep() < 43912196 ) ||
73 //        (fluka->GetNstep() > 47424560 && fluka->GetNstep() < 47424581 ) ||
74 //        (fluka->GetNstep() > 54388266 && fluka->GetNstep() < 54388319 )
75 //      ) fluka->SetVerbosityLevel(3);
76 //    else fluka->SetVerbosityLevel(0);
77
78     // check region lattice consistency (debug Ernesto)
79     // *****************************************************
80     if( mreg != volId  && !gGeoManager->IsOutside() ) {
81        cout << "  mgdraw:   track=" << trackId << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
82             << " icode=" << icode << " gNstep=" << fluka->GetNstep() << endl
83             << "               fluka   mreg=" << mreg << " mlttc=" << mlttc << endl
84             << "               TGeo   volId=" << volId << " crtlttc=" << crtlttc << endl
85             << "     common TRACKR   lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl
86             << "     common LTCLCM   newlat=" << LTCLCM.newlat << " mlatld=" <<  LTCLCM.mlatld << endl
87             << "                     mlatm1=" << LTCLCM.mlatm1 << " mltsen=" <<  LTCLCM.mltsen << endl
88             << "                     mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl;
89         if( mlttc == crtlttc ) cout << "   *************************************************************" << endl;
90     }
91     // *****************************************************
92
93     if (!TRACKR.ispusr[mkbmx2 - 2]) {
94         //
95         // Single step
96         if (verbosityLevel >= 3) {
97            cout << endl << "mgdraw: energy deposition for:" << trackId
98                  << " icode=" << icode
99                  << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
100                  << " flukaid="<< TRACKR.jtrack
101                  << " mreg=" << mreg << endl;
102         }
103         (TVirtualMCApplication::Instance())->Stepping();
104         fluka->SetTrackIsNew(kFALSE);
105     } else {
106         //
107         // Tracking is being resumed after secondary tracking
108         //
109         if (verbosityLevel >= 3) {
110             cout << endl << "mgdraw: resuming Stepping(): " << trackId << endl;
111         }
112
113         fluka->SetTrackIsNew(kTRUE);
114         fluka->SetCaller(kMGResumedTrack);
115         (TVirtualMCApplication::Instance())->Stepping();
116
117         // Reset flag and stored values
118         TRACKR.ispusr[mkbmx2 - 2] = 0;
119         for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
120
121
122         if (verbosityLevel >= 3) {
123             cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
124             cout << " Track= " << trackId << " region = " << mreg << endl;
125         }
126
127         fluka->SetTrackIsNew(kFALSE);
128         fluka->SetCaller(kMGDRAW);
129         (TVirtualMCApplication::Instance())->Stepping();
130     }
131 } // end of mgdraw
132 } // end of extern "C"
133