]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/usdraw.cxx
Example macros for using AliAODv0 class
[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 #ifndef WIN32
11 # define usdraw usdraw_
12 #else
13 # define usdraw USDRAW
14 #endif
15 extern "C" {
16 void usdraw(Int_t& icode, Int_t& mreg, 
17             Double_t& xsco, Double_t& ysco, Double_t& zsco)
18 {
19   TFluka *fluka = (TFluka*)gMC;
20   // nothing to do if particle inside dummy region
21   if (mreg == fluka->GetDummyRegion()) return;
22   Int_t verbosityLevel = fluka->GetVerbosityLevel();
23   Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
24   fluka->SetCaller(kUSDRAW);
25   fluka->SetIcode((FlukaProcessCode_t) icode);
26
27   if (icode/100 == kEMFSCO) {
28       for (Int_t npnw = EMFSTK.npstrt-1; npnw <= EMFSTK.npemf-1; npnw++) {
29           if (EMFSTK.iespak[npnw][mkbmx2-1] ==  TRACKR.ispusr[mkbmx2 - 1] ) {
30               EMFSTK.iespak[npnw][mkbmx2 - 2] = 1;
31 // Save properties at point where particle disappears in case this is only an interruption
32               TLorentzVector p;
33               gMC->TrackMomentum(p);
34               EMFSTK.espark[npnw][0] = xsco;               // x
35               EMFSTK.espark[npnw][1] = ysco;               // y
36               EMFSTK.espark[npnw][2] = zsco;               // z
37               EMFSTK.espark[npnw][3] = gMC->TrackTime();   // t
38               EMFSTK.espark[npnw][4] = p[0];               // px
39               EMFSTK.espark[npnw][5] = p[1];               // py
40               EMFSTK.espark[npnw][6] = p[2];               // pz
41               EMFSTK.espark[npnw][7] = p[3];               // e
42               EMFSTK.espark[npnw][8] = gMC->TrackLength(); // Length 
43           } // Track found in stack
44       } // Loop over emf stack 
45   } // Electromagnetic process
46
47   Int_t mlttc = LTCLCM.mlatm1;
48   fluka->SetMreg(mreg, mlttc);
49   fluka->SetXsco(xsco);
50   fluka->SetYsco(ysco);
51   fluka->SetZsco(zsco);
52
53   if (debug) printf("USDRAW: Number of track segments:%6d %6d icode=%d tof=%10.3e track=%d pdg=%d\n",
54   TRACKR.ntrack, TRACKR.mtrack, icode, TRACKR.atrack, TRACKR.ispusr[mkbmx2-1], fluka->PDGFromId(TRACKR.jtrack) );
55
56   TVirtualMCStack* cppstack = fluka->GetStack();
57   cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
58
59   (TVirtualMCApplication::Instance())->Stepping();
60   fluka->SetTrackIsNew(kFALSE);
61
62  
63 } // end of usdraw
64 } // end of extern "C"
65