Some fixes in navigation with TGeo and implement the recent
[u/mrichter/AliRoot.git] / TFluka / usdraw.cxx
CommitLineData
fa3d1cc7 1#include <Riostream.h>
7dac99f1 2#include "TVirtualMCApplication.h"
a7bb59a2 3#include "TFluka.h"
5d80a015 4#include <TLorentzVector.h>
a1f42b9c 5#include "Fdimpar.h" //(DIMPAR) fluka include
6#include "Ftrackr.h" //(TRACKR) fluka common
7c1c1ebd 7#include "Femfstk.h" //(EMFSTK) fluka common
fa3d1cc7 8#ifndef WIN32
9# define usdraw usdraw_
10#else
11# define usdraw USDRAW
12#endif
13extern "C" {
14void usdraw(Int_t& icode, Int_t& mreg,
15 Double_t& xsco, Double_t& ysco, Double_t& zsco)
16{
fbf08100 17 TFluka *fluka = (TFluka*)gMC;
bcf1cd9c 18 Int_t verbosityLevel = fluka->GetVerbosityLevel();
57dc5a4a 19 Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
fbf08100 20 fluka->SetCaller(6);
21 fluka->SetIcode(icode);
57dc5a4a 22
7c1c1ebd 23 if (icode/100 == 2) {
24 for (Int_t npnw = EMFSTK.npstrt-1; npnw <= EMFSTK.npemf-1; npnw++) {
25 if (EMFSTK.iespak[npnw][mkbmx2-1] == TRACKR.ispusr[mkbmx2 - 1] ) {
26 EMFSTK.iespak[npnw][mkbmx2 - 2] = 1;
5d80a015 27// Save properties at point where particle disappears in case this is only an interruption
7c1c1ebd 28 TLorentzVector p;
29 gMC->TrackMomentum(p);
30 EMFSTK.espark[npnw][0] = xsco; // x
31 EMFSTK.espark[npnw][1] = ysco; // y
32 EMFSTK.espark[npnw][2] = zsco; // z
33 EMFSTK.espark[npnw][3] = gMC->TrackTime(); // t
34 EMFSTK.espark[npnw][4] = p[0]; // px
35 EMFSTK.espark[npnw][5] = p[1]; // py
36 EMFSTK.espark[npnw][6] = p[2]; // pz
37 EMFSTK.espark[npnw][7] = p[3]; // e
38 EMFSTK.espark[npnw][8] = gMC->TrackLength(); // Length
39 } // Track found in stack
40 } // Loop over emf stack
41 } // Electromagnetic process
42
43
57dc5a4a 44
fbf08100 45 fluka->SetMreg(mreg);
46 fluka->SetXsco(xsco);
47 fluka->SetYsco(ysco);
48 fluka->SetZsco(zsco);
57dc5a4a 49
5d80a015 50 if (debug) printf("USDRAW: Number of track segments:%6d %6d %6d %10.3e\n", TRACKR.ntrack, TRACKR.mtrack, icode, TRACKR.atrack);
cad96957 51
a1f42b9c 52 (TVirtualMCApplication::Instance())->Stepping();
fbf08100 53 fluka->SetTrackIsNew(kFALSE);
54
fa3d1cc7 55} // end of usdraw
56} // end of extern "C"
57