2 #include "TVirtualMCApplication.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
11 # define usdraw usdraw_
13 # define usdraw USDRAW
16 #include "TGeoManager.h" // <- delete
19 void usdraw(Int_t& icode, Int_t& mreg,
20 Double_t& xsco, Double_t& ysco, Double_t& zsco)
22 TFluka *fluka = (TFluka*)gMC;
23 // nothing to do if particle inside dummy region
24 if (mreg == fluka->GetDummyRegion()) return;
25 Int_t verbosityLevel = fluka->GetVerbosityLevel();
26 Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
27 fluka->SetCaller(kUSDRAW);
28 fluka->SetIcode((FlukaProcessCode_t) icode);
30 if (icode/100 == kEMFSCO) {
31 for (Int_t npnw = EMFSTK.npstrt-1; npnw <= EMFSTK.npemf-1; npnw++) {
32 if (EMFSTK.iespak[npnw][mkbmx2-1] == TRACKR.ispusr[mkbmx2 - 1] ) {
33 EMFSTK.iespak[npnw][mkbmx2 - 2] = 1;
34 // Save properties at point where particle disappears in case this is only an interruption
36 gMC->TrackMomentum(p);
37 EMFSTK.espark[npnw][0] = xsco; // x
38 EMFSTK.espark[npnw][1] = ysco; // y
39 EMFSTK.espark[npnw][2] = zsco; // z
40 EMFSTK.espark[npnw][3] = gMC->TrackTime(); // t
41 EMFSTK.espark[npnw][4] = p[0]; // px
42 EMFSTK.espark[npnw][5] = p[1]; // py
43 EMFSTK.espark[npnw][6] = p[2]; // pz
44 EMFSTK.espark[npnw][7] = p[3]; // e
45 EMFSTK.espark[npnw][8] = gMC->TrackLength(); // Length
46 } // Track found in stack
47 } // Loop over emf stack
48 } // Electromagnetic process
50 Int_t mlttc = TRACKR.lt1trk; //LTCLCM.mlatm1;
51 fluka->SetMreg(mreg, mlttc);
56 // check region lattice consistency (debug Ernesto)
57 // *****************************************************
59 Int_t volId = fluka->CurrentVolID(nodeId);
60 Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
61 if(verbosityLevel>=3 && mreg != volId && !gGeoManager->IsOutside() ) {
62 cout << " usdraw: track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
63 << " icode=" << icode << " gNstep=" << fluka->GetNstep() << endl
64 << " fluka mreg=" << mreg << " mlttc=" << mlttc << endl
65 << " TGeo volId=" << volId << " crtlttc=" << crtlttc << endl
66 << " common TRACKR lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl
67 << " common LTCLCM newlat=" << LTCLCM.newlat << " mlatld=" << LTCLCM.mlatld << endl
68 << " mlatm1=" << LTCLCM.mlatm1 << " mltsen=" << LTCLCM.mltsen << endl
69 << " mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl;
70 if( mlttc == crtlttc ) cout << " *************************************************************" << endl;
72 // *****************************************************
74 if (debug) printf("USDRAW: Number of track segments:%6d %6d icode=%d tof=%10.3e track=%d pdg=%d mreg=%d\n",
75 TRACKR.ntrack, TRACKR.mtrack, icode, TRACKR.atrack, TRACKR.ispusr[mkbmx2-1], fluka->PDGFromId(TRACKR.jtrack), mreg );
77 TVirtualMCStack* cppstack = fluka->GetStack();
78 cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
80 (TVirtualMCApplication::Instance())->Stepping();
81 fluka->SetTrackIsNew(kFALSE);
85 } // end of extern "C"