2 #include "TVirtualMCApplication.h"
3 #include "TGeoMaterial.h"
4 #include "TGeoManager.h"
6 #include "TFlukaCerenkov.h"
9 #include "TFlukaCodes.h"
11 #include "Fdimpar.h" //(DIMPAR) fluka include
12 #include "Ftrackr.h" //(TRACKR) fluka common
13 #include "Fltclcm.h" //(LTCLCM) fluka common
14 #include "Fpaprop.h" //(PAPROP) fluka common
17 # define endraw endraw_
19 # define endraw ENDRAW
22 void endraw(Int_t& icode, Int_t& mreg, Double_t& rull, Double_t& xsco, Double_t& ysco, Double_t& zsco)
24 TFluka* fluka = (TFluka*) gMC;
25 // nothing to do if particle in dummy region
26 if (mreg == fluka->GetDummyRegion()) return;
27 Int_t verbosityLevel = fluka->GetVerbosityLevel();
28 Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
29 Int_t mlttc = (icode==kKASKADinelarecoil) ? TRACKR.lt2trk : TRACKR.lt1trk; //LTCLCM.mlatm1;
30 fluka->SetCaller(kENDRAW);
35 fluka->SetMreg(mreg, mlttc);
39 if (TRACKR.jtrack == -1) {
40 // Handle quantum efficiency the G3 way
41 if (debug) printf("endraw: Cerenkov photon depositing energy: %d %e\n", mreg, rull);
42 TGeoMaterial* material = (gGeoManager->GetCurrentVolume())->GetMaterial();
43 TFlukaCerenkov* cerenkov = dynamic_cast<TFlukaCerenkov*> (material->GetCerenkovProperties());
45 Double_t eff = (cerenkov->GetQuantumEfficiency(rull));
46 if (gRandom->Rndm() > eff) {
52 TVirtualMCStack* cppstack = fluka->GetStack();
55 cout << "ENDRAW For icode=" << icode
56 << " track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
57 << " edep="<< edep << " mreg=" << mreg << endl;
60 // check region lattice consistency (debug Ernesto)
61 // *****************************************************
63 Int_t volId = fluka->CurrentVolID(nodeId);
64 Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
65 if( mreg != volId && !gGeoManager->IsOutside() ) {
66 cout << " endraw: track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
67 << " icode=" << icode << " gNstep=" << fluka->GetNstep() << endl
68 << " fluka mreg=" << mreg << " mlttc=" << mlttc << endl
69 << " TGeo volId=" << volId << " crtlttc=" << crtlttc << endl
70 << " common TRACKR lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl
71 << " common LTCLCM newlat=" << LTCLCM.newlat << " mlatld=" << LTCLCM.mlatld << endl
72 << " mlatm1=" << LTCLCM.mlatm1 << " mltsen=" << LTCLCM.mltsen << endl
73 << " mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl;
74 if( mlttc == crtlttc ) cout << " *************************************************************" << endl;
76 // *****************************************************
79 if (icode != kEMFSCOstopping1 && icode != kEMFSCOstopping2) {
80 fluka->SetIcode((FlukaProcessCode_t)icode);
82 if (icode == kKASKADelarecoil && TRACKR.ispusr[mkbmx2-5]) {
83 // Elastic recoil and in stuprf npprmr > 0,
84 // the secondary being loaded is actually still the interacting particle
85 cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-4] );
86 // cout << "endraw elastic recoil track=" << TRACKR.ispusr[mkbmx2-1] << " parent=" << TRACKR.ispusr[mkbmx2-4]
90 cppstack->SetCurrentTrack(TRACKR.ispusr[mkbmx2-1] );
91 (TVirtualMCApplication::Instance())->Stepping();
94 // For icode 21,22 the particle has fallen below thresshold.
95 // This has to be signalled to the StepManager()
97 cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
99 fluka->SetIcode((FlukaProcessCode_t) icode);
100 (TVirtualMCApplication::Instance())->Stepping();
101 fluka->SetTrackIsNew(kFALSE);
102 fluka->SetIcode((FlukaProcessCode_t)icode);
104 (TVirtualMCApplication::Instance())->Stepping();
105 // cppstack->SetCurrentTrack( saveTrackId );
109 } // end of extern "C"