added cdb stuff
[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
fa3d1cc7 10#ifndef WIN32
11# define usdraw usdraw_
12#else
13# define usdraw USDRAW
14#endif
4aba9d66 15
16#include "TGeoManager.h" // <- delete
17
fa3d1cc7 18extern "C" {
19void usdraw(Int_t& icode, Int_t& mreg,
20 Double_t& xsco, Double_t& ysco, Double_t& zsco)
21{
fbf08100 22 TFluka *fluka = (TFluka*)gMC;
d566901f 23 // nothing to do if particle inside dummy region
24 if (mreg == fluka->GetDummyRegion()) return;
bcf1cd9c 25 Int_t verbosityLevel = fluka->GetVerbosityLevel();
57dc5a4a 26 Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
d566901f 27 fluka->SetCaller(kUSDRAW);
28 fluka->SetIcode((FlukaProcessCode_t) icode);
57dc5a4a 29
d566901f 30 if (icode/100 == kEMFSCO) {
7c1c1ebd 31 for (Int_t npnw = EMFSTK.npstrt-1; npnw <= EMFSTK.npemf-1; npnw++) {
4aba9d66 32 if (EMFSTK.iespak[npnw][mkbmx2-1] == TRACKR.ispusr[mkbmx2 - 1] ) {
33 EMFSTK.iespak[npnw][mkbmx2 - 2] = 1;
5d80a015 34// Save properties at point where particle disappears in case this is only an interruption
4aba9d66 35 TLorentzVector p;
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
7c1c1ebd 47 } // Loop over emf stack
48 } // Electromagnetic process
57dc5a4a 49
4aba9d66 50 Int_t mlttc = TRACKR.lt1trk; //LTCLCM.mlatm1;
d566901f 51 fluka->SetMreg(mreg, mlttc);
fbf08100 52 fluka->SetXsco(xsco);
53 fluka->SetYsco(ysco);
54 fluka->SetZsco(zsco);
57dc5a4a 55
4aba9d66 56 // check region lattice consistency (debug Ernesto)
57 // *****************************************************
58 Int_t nodeId;
59 Int_t volId = fluka->CurrentVolID(nodeId);
60 Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
61 if( 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;
71 }
72 // *****************************************************
73
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 );
18e0cabb 76
77 TVirtualMCStack* cppstack = fluka->GetStack();
78 cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
cad96957 79
a1f42b9c 80 (TVirtualMCApplication::Instance())->Stepping();
fbf08100 81 fluka->SetTrackIsNew(kFALSE);
18e0cabb 82
83
fa3d1cc7 84} // end of usdraw
85} // end of extern "C"
86