Use fluka routine usrdci to get ion properties.
[u/mrichter/AliRoot.git] / TFluka / usdraw.cxx
CommitLineData
fa3d1cc7 1#include <Riostream.h>
7dac99f1 2#include "TVirtualMCApplication.h"
a7bb59a2 3#include "TFluka.h"
d566901f 4#include "TFlukaCodes.h"
5d80a015 5#include <TLorentzVector.h>
a1f42b9c 6#include "Fdimpar.h" //(DIMPAR) fluka include
7#include "Ftrackr.h" //(TRACKR) fluka common
d566901f 8#include "Fltclcm.h" //(LTCLCM) fluka common
7c1c1ebd 9#include "Femfstk.h" //(EMFSTK) fluka common
367d384b 10#include "Fflkstk.h" //(FLKSTK) fluka common
fa3d1cc7 11#ifndef WIN32
12# define usdraw usdraw_
13#else
14# define usdraw USDRAW
15#endif
4aba9d66 16
17#include "TGeoManager.h" // <- delete
18
fa3d1cc7 19extern "C" {
20void usdraw(Int_t& icode, Int_t& mreg,
21 Double_t& xsco, Double_t& ysco, Double_t& zsco)
22{
fbf08100 23 TFluka *fluka = (TFluka*)gMC;
d566901f 24 // nothing to do if particle inside dummy region
25 if (mreg == fluka->GetDummyRegion()) return;
bcf1cd9c 26 Int_t verbosityLevel = fluka->GetVerbosityLevel();
57dc5a4a 27 Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
d566901f 28 fluka->SetCaller(kUSDRAW);
29 fluka->SetIcode((FlukaProcessCode_t) icode);
57dc5a4a 30
367d384b 31//
32// Catch paused tracks
33//
d566901f 34 if (icode/100 == kEMFSCO) {
7c1c1ebd 35 for (Int_t npnw = EMFSTK.npstrt-1; npnw <= EMFSTK.npemf-1; npnw++) {
4aba9d66 36 if (EMFSTK.iespak[npnw][mkbmx2-1] == TRACKR.ispusr[mkbmx2 - 1] ) {
37 EMFSTK.iespak[npnw][mkbmx2 - 2] = 1;
5d80a015 38// Save properties at point where particle disappears in case this is only an interruption
4aba9d66 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
7c1c1ebd 51 } // Loop over emf stack
52 } // Electromagnetic process
57dc5a4a 53
367d384b 54 if (icode == kKASKADdray || icode == kKASKADpair || icode == kKASKADbrems) {
367d384b 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 //
4aba9d66 71 Int_t mlttc = TRACKR.lt1trk; //LTCLCM.mlatm1;
d566901f 72 fluka->SetMreg(mreg, mlttc);
fbf08100 73 fluka->SetXsco(xsco);
74 fluka->SetYsco(ysco);
75 fluka->SetZsco(zsco);
57dc5a4a 76
4aba9d66 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;
4b1c3976 82 if(verbosityLevel>=3 && mreg != volId && !gGeoManager->IsOutside() ) {
4aba9d66 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 );
18e0cabb 97
98 TVirtualMCStack* cppstack = fluka->GetStack();
99 cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
cad96957 100
a1f42b9c 101 (TVirtualMCApplication::Instance())->Stepping();
fbf08100 102 fluka->SetTrackIsNew(kFALSE);
18e0cabb 103
104
fa3d1cc7 105} // end of usdraw
106} // end of extern "C"
107