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