]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/bxdraw.cxx
ALICE_ROOT dependence removed. coreFlukaVmc.inp should be linked to
[u/mrichter/AliRoot.git] / TFluka / bxdraw.cxx
1 #include <Riostream.h>
2
3 #include "TFluka.h"
4 #include "TFlukaCodes.h"
5 #include "TFlukaMCGeometry.h"
6 #include "Fdimpar.h"  //(DIMPAR) fluka include
7 #include "Ftrackr.h"  //(TRACKR) fluka common
8 #include "Fltclcm.h"  //(LTCLCM) fluka common
9 #include "Fopphst.h"  //(OPPHST) fluka common
10
11 #ifndef WIN32
12 # define bxdraw bxdraw_
13 #else
14 # define bxdraw BXDRAW
15 #endif
16
17
18 #include "TGeoManager.h"
19
20
21 extern "C" {
22 void bxdraw(Int_t& icode, Int_t& mreg, Int_t& newreg,
23             Double_t& xsco, Double_t& ysco, Double_t& zsco)
24 {
25     TFluka* fluka = (TFluka*) gMC;
26     Int_t oldlttc = TRACKR.lt1trk; //LTCLCM.mlatm1;
27     Int_t newlttc = LTCLCM.newlat;
28     fluka->SetIcode((FlukaProcessCode_t)icode);
29 //    fluka->SetNewreg(newreg,newlttc);
30     fluka->SetXsco(xsco);
31     fluka->SetYsco(ysco);
32     fluka->SetZsco(zsco);
33     Int_t verbosityLevel = fluka->GetVerbosityLevel();
34     Bool_t debug = (verbosityLevel>=3)?kTRUE:kFALSE;
35     // nothing to do if particle is crossing a dummy region
36     if (mreg   == fluka->GetDummyRegion() ||
37         newreg == fluka->GetDummyRegion() ||
38         oldlttc == TFlukaMCGeometry::kLttcVirtual ||
39         newlttc == TFlukaMCGeometry::kLttcVirtual
40         ) return;
41
42 //
43 // Double step for boundary crossing
44 //
45     fluka->SetTrackIsNew(kFALSE); // has to be called BEFORE Stepping()
46     if (mreg != fluka->GetDummyRegion() && newreg != fluka->GetDummyRegion()) {
47         if (debug) printf("bxdraw (ex) \n");
48         fluka->SetTrackIsExiting();
49         fluka->SetCaller(kBXExiting);
50         fluka->SetMreg(mreg,oldlttc);
51         
52         // check region lattice consistency (debug Ernesto)
53         // *****************************************************
54         Int_t nodeId;
55         Int_t volId = fluka->CurrentVolID(nodeId);
56         Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
57         if(debug && mreg != volId  && !gGeoManager->IsOutside()) {
58             cout << "  bxdraw:   track=" << TRACKR.ispusr[mkbmx2-1]<< " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
59                  << " icode=" << icode << " gNstep=" << fluka->GetNstep() << endl
60                  << "               fluka   mreg=" << mreg << " oldlttc=" << oldlttc << " newreg=" << newreg << " newlttc=" << newlttc << endl
61                  << "               TGeo   volId=" << volId << " crtlttc=" << crtlttc << endl
62                  << "     common TRACKR   lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl
63                  << "     common LTCLCM   newlat=" << LTCLCM.newlat << " mlatld=" <<  LTCLCM.mlatld << endl
64                  << "                     mlatm1=" << LTCLCM.mlatm1 << " mltsen=" <<  LTCLCM.mltsen << endl
65                  << "                     mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl;
66             if( oldlttc == crtlttc ) cout << "   **************************** Exit *********************************" << endl;
67         }
68         // *****************************************************
69         
70         
71         
72         TVirtualMCStack* cppstack = fluka->GetStack();
73         
74         if (TRACKR.jtrack == -1) {
75             cppstack->SetCurrentTrack(OPPHST.louopp[OPPHST.lstopp]);
76         } else {
77             cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
78         }
79         
80         (TVirtualMCApplication::Instance())->Stepping();
81     }
82     if (newreg != fluka->GetDummyRegion()) {
83         if (debug) printf("bxdraw (en) \n");
84         fluka->SetCaller(kBXEntering);
85         fluka->SetTrackIsEntering();
86         if (fluka->GetDummyBoundary() == 1) fluka->SetDummyBoundary(2);
87         fluka->SetMreg(newreg,newlttc);
88         
89         // check region lattice consistency (debug Ernesto)
90         // *****************************************************
91         Int_t nodeId;
92         Int_t volId = fluka->CurrentVolID(nodeId);
93         Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
94         if(debug && newreg != volId  && !gGeoManager->IsOutside()) {
95             cout << "  bxdraw:   track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
96                  << " icode=" << icode << " gNstep=" << fluka->GetNstep() << endl
97                  << "               fluka   mreg=" << mreg << " oldlttc=" << oldlttc << " newreg=" << newreg << " newlttc=" << newlttc << endl
98                  << "               TGeo   volId=" << volId << " crtlttc=" << crtlttc << endl
99                  << "     common TRACKR   lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl
100                  << "     common LTCLCM   newlat=" << LTCLCM.newlat << " mlatld=" <<  LTCLCM.mlatld << endl
101                  << "                     mlatm1=" << LTCLCM.mlatm1 << " mltsen=" <<  LTCLCM.mltsen << endl
102                  << "                     mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl;
103             if( newlttc == crtlttc ) cout << "   ******************************** Enter *****************************" << endl;
104         }
105         // *****************************************************
106         
107         TVirtualMCStack* cppstack = fluka->GetStack();
108         if (TRACKR.jtrack == -1) {
109             cppstack->SetCurrentTrack(OPPHST.louopp[OPPHST.lstopp]);
110         } else {
111             cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
112         }
113         
114         (TVirtualMCApplication::Instance())->Stepping();
115     }
116
117 } // end of bxdraw
118 } // end of extern "C"
119