]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/usdraw.cxx
No debug message.
[u/mrichter/AliRoot.git] / TFluka / usdraw.cxx
1 #include <Riostream.h>
2 #include "TVirtualMCApplication.h"
3 #include "TFluka.h"
4 #include "TFlukaCodes.h"
5 #include <TLorentzVector.h>
6 #include "Fdimpar.h"  //(DIMPAR) fluka include
7 #include "Ftrackr.h"  //(TRACKR) fluka common
8 #include "Fltclcm.h"  //(LTCLCM) fluka common
9 #include "Femfstk.h"  //(EMFSTK) fluka common
10 #include "Fflkstk.h"  //(FLKSTK) fluka common
11 #ifndef WIN32
12 # define usdraw usdraw_
13 #else
14 # define usdraw USDRAW
15 #endif
16
17 #include "TGeoManager.h" // <- delete
18
19 extern "C" {
20 void usdraw(Int_t& icode, Int_t& mreg, 
21             Double_t& xsco, Double_t& ysco, Double_t& zsco)
22 {
23   TFluka *fluka = (TFluka*)gMC;
24   // nothing to do if particle inside dummy region
25   if (mreg == fluka->GetDummyRegion()) return;
26   Int_t verbosityLevel = fluka->GetVerbosityLevel();
27   Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
28   fluka->SetCaller(kUSDRAW);
29   fluka->SetIcode((FlukaProcessCode_t) icode);
30
31 //
32 // Catch paused tracks
33 //
34   if (icode/100 == kEMFSCO) {
35       for (Int_t npnw = EMFSTK.npstrt-1; npnw <= EMFSTK.npemf-1; npnw++) {
36           if (EMFSTK.iespak[npnw][mkbmx2-1] ==  TRACKR.ispusr[mkbmx2 - 1] ) {
37               EMFSTK.iespak[npnw][mkbmx2 - 2] = 1;
38 // Save properties at point where particle disappears in case this is only an interruption
39               TLorentzVector p;
40               gMC->TrackMomentum(p);
41               EMFSTK.espark[npnw][0] = xsco;               // x
42               EMFSTK.espark[npnw][1] = ysco;               // y
43               EMFSTK.espark[npnw][2] = zsco;               // z
44               EMFSTK.espark[npnw][3] = gMC->TrackTime();   // t
45               EMFSTK.espark[npnw][4] = p[0];               // px
46               EMFSTK.espark[npnw][5] = p[1];               // py
47               EMFSTK.espark[npnw][6] = p[2];               // pz
48               EMFSTK.espark[npnw][7] = p[3];               // e
49               EMFSTK.espark[npnw][8] = gMC->TrackLength(); // Length
50           } // Track found in stack
51       } // Loop over emf stack 
52   } // Electromagnetic process
53
54   if (icode == kKASKADdray || icode == kKASKADpair || icode == kKASKADbrems) {
55         TRACKR.ispusr[mkbmx2-2] = 1;
56         TLorentzVector p;
57         gMC->TrackMomentum(p);
58         TRACKR.spausr[0] = xsco;               // x
59         TRACKR.spausr[1] = ysco;               // y
60         TRACKR.spausr[2] = zsco;               // z
61         TRACKR.spausr[3] = gMC->TrackTime();   // t
62         TRACKR.spausr[4] = p[0];               // px
63         TRACKR.spausr[5] = p[1];               // py
64         TRACKR.spausr[6] = p[2];               // pz
65         TRACKR.spausr[7] = p[3];               // e
66         TRACKR.spausr[8] = gMC->TrackLength(); // Length
67   }
68   
69   //
70   //
71   Int_t mlttc = TRACKR.lt1trk; //LTCLCM.mlatm1;
72   fluka->SetMreg(mreg, mlttc);
73   fluka->SetXsco(xsco);
74   fluka->SetYsco(ysco);
75   fluka->SetZsco(zsco);
76
77     // check region lattice consistency (debug Ernesto)
78     // *****************************************************
79     Int_t nodeId;
80     Int_t volId = fluka->CurrentVolID(nodeId);
81     Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
82     if(verbosityLevel>=3 && mreg != volId  && !gGeoManager->IsOutside() ) {
83        cout << "  usdraw:   track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
84             << " icode=" << icode << " gNstep=" << fluka->GetNstep() << endl
85             << "               fluka   mreg=" << mreg << " mlttc=" << mlttc << endl
86             << "               TGeo   volId=" << volId << " crtlttc=" << crtlttc << endl
87             << "     common TRACKR   lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl
88             << "     common LTCLCM   newlat=" << LTCLCM.newlat << " mlatld=" <<  LTCLCM.mlatld << endl
89             << "                     mlatm1=" << LTCLCM.mlatm1 << " mltsen=" <<  LTCLCM.mltsen << endl
90             << "                     mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl;
91         if( mlttc == crtlttc ) cout << "   *************************************************************" << endl;
92     }
93     // *****************************************************
94
95   if (debug) printf("USDRAW: Number of track segments:%6d %6d icode=%d tof=%10.3e track=%d pdg=%d mreg=%d\n",
96   TRACKR.ntrack, TRACKR.mtrack, icode, TRACKR.atrack, TRACKR.ispusr[mkbmx2-1], fluka->PDGFromId(TRACKR.jtrack), mreg );
97
98   TVirtualMCStack* cppstack = fluka->GetStack();
99   cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
100
101   (TVirtualMCApplication::Instance())->Stepping();
102   fluka->SetTrackIsNew(kFALSE);
103
104  
105 } // end of usdraw
106 } // end of extern "C"
107