printf("PDGFromId: Error intfluka < 0: %d\n", id);
return -1;
}
- if (fVerbosityLevel >= 3)
- printf("mpdgha called with %d %d \n", id, intfluka);
+// if (fVerbosityLevel >= 3)
+// printf("mpdgha called with %d %d \n", id, intfluka);
return mpdgha(intfluka);
} else {
// ions and optical photons
}
}
+//______________________________________________________________________________
+Int_t TFluka::CorrectFlukaId() const
+{
+ // since we don't put photons and e- created bellow transport cut on the vmc stack
+ // and there is a call to endraw for energy deposition for each of them
+ // and they have the track number of their parent, but different identity (pdg)
+ // so we want to assign also their parent identity also.
+ if( (IsTrackStop() )
+ && TRACKR.ispusr[mkbmx2 - 4] == TRACKR.ispusr[mkbmx2 - 1]
+ && TRACKR.jtrack != TRACKR.ispusr[mkbmx2 - 3] ) {
+ if (fVerbosityLevel >=3)
+ cout << "CorrectFlukaId() for icode=" << GetIcode()
+ << " track=" << TRACKR.ispusr[mkbmx2 - 1]
+ << " current PDG=" << PDGFromId(TRACKR.jtrack)
+ << " assign parent PDG=" << PDGFromId(TRACKR.ispusr[mkbmx2 - 3]) << endl;
+ return TRACKR.ispusr[mkbmx2 - 3]; // assign parent identity
+ }
+ return TRACKR.jtrack;
+}
+
+
//______________________________________________________________________________
Int_t TFluka::TrackPid() const
{
// TRACKR.jtrack = identity number of the particle
FlukaCallerCode_t caller = GetCaller();
if (caller != kEEDRAW) {
- return PDGFromId(TRACKR.jtrack);
+ return PDGFromId( CorrectFlukaId() );
}
else
return -1000;
// TRACKR.jtrack = identity number of the particle
FlukaCallerCode_t caller = GetCaller();
if (caller != kEEDRAW)
- return PAPROP.ichrge[TRACKR.jtrack+6];
+ return PAPROP.ichrge[CorrectFlukaId()+6];
else
return -1000.0;
}
// TRACKR.jtrack = identity number of the particle
FlukaCallerCode_t caller = GetCaller();
if (caller != kEEDRAW)
- return PAPROP.am[TRACKR.jtrack+6];
+ return PAPROP.am[CorrectFlukaId()+6];
else
return -1000.0;
}
// True if the track energy has fallen below the threshold
// means stopped by signal or below energy threshold
FlukaProcessCode_t icode = GetIcode();
- if (icode == kKASKADstopping ||
- icode == kKASKADtimekill ||
- icode == kEMFSCOstopping1 ||
- icode == kEMFSCOstopping2 ||
- icode == kEMFSCOtimekill ||
- icode == kKASNEUstopping ||
- icode == kKASNEUtimekill ||
- icode == kKASHEAtimekill ||
- icode == kKASOPHtimekill) return 1;
+ if (icode == kKASKADstopping || // stopping particle
+ icode == kKASKADtimekill || // time kill
+ icode == kEMFSCOstopping1 || // below user-defined cut-off
+ icode == kEMFSCOstopping2 || // below user cut-off
+ icode == kEMFSCOtimekill || // time kill
+ icode == kKASNEUstopping || // neutron below threshold
+ icode == kKASNEUtimekill || // time kill
+ icode == kKASHEAtimekill || // time kill
+ icode == kKASOPHtimekill) return 1; // time kill
else return 0;
}
virtual Double_t TrackTime() const;
virtual Double_t Edep() const;
// Static properties
+ virtual Int_t CorrectFlukaId() const;
virtual Int_t TrackPid() const;
virtual Double_t TrackCharge() const;
virtual Double_t TrackMass() const;
fluka->SetTrackIsExiting();
fluka->SetCaller(kBXExiting);
fluka->SetMreg(mreg,oldlttc);
- (TVirtualMCApplication::Instance())->Stepping();
+ TVirtualMCStack* cppstack = fluka->GetStack();
+ cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
+ (TVirtualMCApplication::Instance())->Stepping();
}
if (newreg != fluka->GetDummyRegion()) {
if (debug) printf("bxdraw (en) \n");
fluka->SetTrackIsEntering();
if (fluka->GetDummyBoundary() == 1) fluka->SetDummyBoundary(2);
fluka->SetMreg(newreg,newlttc);
+ TVirtualMCStack* cppstack = fluka->GetStack();
+ cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
(TVirtualMCApplication::Instance())->Stepping();
- }
+ }
} // end of bxdraw
} // end of extern "C"
#include "TVirtualMCApplication.h"
#include "TGeoMaterial.h"
#include "TGeoManager.h"
+#include <TParticle.h>
#include "TFlukaCerenkov.h"
#include "TFluka.h"
#include "Ftrackr.h" //(TRACKR) fluka common
#include "Fltclcm.h" //(LTCLCM) fluka common
#include "Fpaprop.h" //(PAPROP) fluka common
+
#ifndef WIN32
# define endraw endraw_
#else
Float_t edep = rull;
- if (icode == kKASKADinelarecoil) {
- if (debug) cout << " For icode=" << icode << " Stepping is NOT called" << endl;
- return;
- }
-
if (TRACKR.jtrack == -1) {
-// Handle quantum efficiency the G3 way
+ // Handle quantum efficiency the G3 way
if (debug) printf("endraw: Cerenkov photon depositing energy: %d %e\n", mreg, rull);
TGeoMaterial* material = (gGeoManager->GetCurrentVolume())->GetMaterial();
TFlukaCerenkov* cerenkov = dynamic_cast<TFlukaCerenkov*> (material->GetCerenkovProperties());
if (cerenkov) {
- Double_t eff = (cerenkov->GetQuantumEfficiency(rull));
- if (gRandom->Rndm() > eff) {
- edep = 0.;
- }
+ Double_t eff = (cerenkov->GetQuantumEfficiency(rull));
+ if (gRandom->Rndm() > eff) {
+ edep = 0.;
+ }
}
}
+ TVirtualMCStack* cppstack = fluka->GetStack();
+ Int_t saveTrackId = cppstack->GetCurrentTrackNumber();
+
+ if (debug) {
+ cout << "ENDRAW For icode=" << icode << " stacktrack=" << saveTrackId
+ << " track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
+ << " edep="<< edep <<endl;
+ }
+
if (icode != kEMFSCOstopping1 && icode != kEMFSCOstopping2) {
fluka->SetIcode((FlukaProcessCode_t)icode);
fluka->SetRull(edep);
+ if (icode == kKASKADelarecoil && TRACKR.ispusr[mkbmx2-5]) {
+ // Elastic recoil and in stuprf npprmr > 0,
+ // the secondary being loaded is actually still the interacting particle
+ cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-4] );
+ // cout << "endraw elastic recoil track=" << TRACKR.ispusr[mkbmx2-1] << " parent=" << TRACKR.ispusr[mkbmx2-4]
+ // << endl;
+ }
+ else
+ cppstack->SetCurrentTrack(TRACKR.ispusr[mkbmx2-1] );
(TVirtualMCApplication::Instance())->Stepping();
+
+// cppstack->SetCurrentTrack( saveTrackId );
} else {
//
// For icode 21,22 the particle has fallen below thresshold.
// This has to be signalled to the StepManager()
//
+ cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
fluka->SetRull(edep);
fluka->SetIcode((FlukaProcessCode_t) icode);
(TVirtualMCApplication::Instance())->Stepping();
fluka->SetIcode((FlukaProcessCode_t)icode);
fluka->SetRull(0.);
(TVirtualMCApplication::Instance())->Stepping();
+// cppstack->SetCurrentTrack( saveTrackId );
+
}
} // end of endraw
} // end of extern "C"
{
TFluka* fluka = (TFluka*) gMC;
if (mreg == fluka->GetDummyRegion()) return;
- Int_t verbosityLevel = fluka->GetVerbosityLevel();
//
// Make sure that stack has currrent track Id
//
TVirtualMCStack* cppstack = fluka->GetStack();
if (TRACKR.jtrack == -1) {
- trackId = OPPHST.louopp[OPPHST.lstopp];
- if (trackId == 0) {
- trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
- }
+ trackId = OPPHST.louopp[OPPHST.lstopp];
+ if (trackId == 0) {
+ trackId = FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1];
+ }
} else {
- trackId = TRACKR.ispusr[mkbmx2-1];
+ trackId = TRACKR.ispusr[mkbmx2-1];
+ }
+
+ Int_t verbosityLevel = fluka->GetVerbosityLevel();
+
+ if (TRACKR.jtrack < -6) {
+ // (Unknow heavy Ion???)
+ // assing parent id ???
+ // id < -6 was skipped in stuprf => if (kpart < -6) return;
+ if (verbosityLevel >= 3) {
+ cout << "mgdraw: jtrack < -6 =" << TRACKR.jtrack
+ << " assign parent pdg=" << fluka->PDGFromId(TRACKR.ispusr[mkbmx2 - 3]) << endl;
+ }
+ TRACKR.jtrack = TRACKR.ispusr[mkbmx2 - 3];
}
cppstack->SetCurrentTrack(trackId);
fluka->SetCaller(kMGDRAW);
if (!TRACKR.ispusr[mkbmx2 - 2]) {
- //
- // Single step
- if (verbosityLevel >= 3) {
- cout << endl << "mgdraw: energy deposition for:" << trackId << endl;
- }
- (TVirtualMCApplication::Instance())->Stepping();
- fluka->SetTrackIsNew(kFALSE);
+ //
+ // Single step
+ if (verbosityLevel >= 3) {
+ cout << endl << "mgdraw: energy deposition for:" << trackId
+ << " icode=" << icode
+ << " pdg=" << fluka->PDGFromId(TRACKR.jtrack) << " flukaid="<< TRACKR.jtrack << endl;
+ }
+ (TVirtualMCApplication::Instance())->Stepping();
+ fluka->SetTrackIsNew(kFALSE);
} else {
- //
- // Tracking is being resumed after secondary tracking
- //
- if (verbosityLevel >= 3) {
- cout << endl << "mgdraw: resuming Stepping(): " << trackId << endl;
- }
+ //
+ // Tracking is being resumed after secondary tracking
+ //
+ if (verbosityLevel >= 3) {
+ cout << endl << "mgdraw: resuming Stepping(): " << trackId << endl;
+ }
- fluka->SetTrackIsNew(kTRUE);
- fluka->SetCaller(kMGResumedTrack);
- (TVirtualMCApplication::Instance())->Stepping();
+ fluka->SetTrackIsNew(kTRUE);
+ fluka->SetCaller(kMGResumedTrack);
+ (TVirtualMCApplication::Instance())->Stepping();
- // Reset flag and stored values
- TRACKR.ispusr[mkbmx2 - 2] = 0;
- for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
+ // Reset flag and stored values
+ TRACKR.ispusr[mkbmx2 - 2] = 0;
+ for (Int_t i = 0; i < 9; i++) TRACKR.spausr[i] = -1.;
- if (verbosityLevel >= 3) {
- cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
- cout << endl << " Track Id = " << trackId << " region = " << mreg << endl;
- }
+ if (verbosityLevel >= 3) {
+ cout << endl << " !!! I am in mgdraw - first Stepping() after resume: " << icode << endl;
+ cout << " Track= " << trackId << " region = " << mreg << endl;
+ }
- fluka->SetTrackIsNew(kFALSE);
- fluka->SetCaller(kMGDRAW);
- (TVirtualMCApplication::Instance())->Stepping();
+ fluka->SetTrackIsNew(kFALSE);
+ fluka->SetCaller(kMGDRAW);
+ (TVirtualMCApplication::Instance())->Stepping();
}
} // end of mgdraw
} // end of extern "C"
{
EMFSTK.iespak[kp][mkbmx2-1] = TRACKR.ispusr[mkbmx2-1];
EMFSTK.iespak[kp][mkbmx2-2] = 0;
+ EMFSTK.iespak[kp][mkbmx2-3] = TRACKR.jtrack;
continue;
}
#include "Ftrackr.h" //(TRACKR) fluka common
#include "Fgenstk.h" //(GENSTK) fluka common
+
//Virtual MC
#include "TFluka.h"
extern "C" {
void stuprf(Int_t& /*ij*/, Int_t& /*mreg*/,
- Double_t& xx, Double_t& yy, Double_t& zz,
- Int_t& numsec, Int_t& npprmr)
+ Double_t& xx, Double_t& yy, Double_t& zz,
+ Int_t& numsec, Int_t& npprmr)
{
//*----------------------------------------------------------------------*
//* *
FLKSTK.ispark[FLKSTK.npflka][ispr] = TRACKR.ispusr[ispr];
}
+ // save parent info
+ FLKSTK.ispark[FLKSTK.npflka][mkbmx2 - 3] = TRACKR.jtrack; // fluka particle id
+ FLKSTK.ispark[FLKSTK.npflka][mkbmx2 - 4] = TRACKR.ispusr[mkbmx2 - 1]; // current track number
+ FLKSTK.ispark[FLKSTK.npflka][mkbmx2 - 5] = npprmr; // flag special case when npprmr>0
+
// Get the pointer to the VMC
TFluka* fluka = (TFluka*) gMC;
Int_t verbosityLevel = fluka->GetVerbosityLevel();
// Increment the track number and put it into the last flag
// was numsec -1
// clarify with Alberto
- if (numsec > npprmr) {
+
+// npprmr > 0, the secondary being loaded is actually still the interacting
+// particle (it can happen in some biasing situations)
+
+ if (numsec > npprmr || npprmr > 0) {
// Now call the PushTrack(...)
Int_t done = 0;
Int_t pdg = fluka->PDGFromId(kpart);
-
Double_t px = GENSTK.plr[numsec-1] * GENSTK.cxr[numsec-1];
Double_t py = GENSTK.plr[numsec-1] * GENSTK.cyr[numsec-1];
Double_t pz = GENSTK.plr[numsec-1] * GENSTK.czr[numsec-1];
Double_t vx = xx;
Double_t vy = yy;
Double_t vz = zz;
-
+
Double_t tof = TRACKR.atrack;
Double_t polx = GENSTK.cxrpol[numsec-1];
Double_t poly = GENSTK.cyrpol[numsec-1];
Double_t polz = GENSTK.czrpol[numsec-1];
-
+
TMCProcess mech = kPHadronic;
-
+
if (EVTFLG.ldecay == 1) {
- mech = kPDecay;
- if (debug) cout << endl << "Decay" << endl;
-
+ mech = kPDecay;
+ if (debug) cout << endl << "Decay" << endl;
} else if (EVTFLG.ldltry == 1) {
- mech = kPDeltaRay;
- if (debug) cout << endl << "Delta Ray" << endl;
-
+ mech = kPDeltaRay;
+ if( fluka->GetIcode() == kKASHEA ) {
+ // For all interactions secondaries are put on GENSTK common (kp=1,np)
+ // but for KASHEA delta ray generation where only the secondary elec-
+ // tron is present and stacked on FLKSTK common for kp=lstack
+ pdg = fluka->PDGFromId( FLKSTK.iloflk[FLKSTK.npflka] );
+ px = FLKSTK.pmoflk[FLKSTK.npflka] * FLKSTK.txflk[FLKSTK.npflka];
+ py = FLKSTK.pmoflk[FLKSTK.npflka] * FLKSTK.tyflk[FLKSTK.npflka];
+ pz = FLKSTK.pmoflk[FLKSTK.npflka] * FLKSTK.tzflk[FLKSTK.npflka];
+ e = FLKSTK.tkeflk[FLKSTK.npflka] + PAPROP.am[FLKSTK.iloflk[FLKSTK.npflka]+6];
+ polx = FLKSTK.txpol[FLKSTK.npflka];
+ poly = FLKSTK.typol[FLKSTK.npflka];
+ polz = FLKSTK.tzpol[FLKSTK.npflka];
+ if (debug) cout << endl << "Delta Ray from KASHEA...." << " pdg from FLKSTK=" << pdg << endl;
+ } else
+ if (debug) cout << endl << "Delta Ray" << endl;
} else if (EVTFLG.lpairp == 1) {
- mech = kPPair;
- if (debug) cout << endl << "Pair Production" << endl;
-
+ mech = kPPair;
+ if (debug) cout << endl << "Pair Production" << endl;
} else if (EVTFLG.lbrmsp == 1) {
- mech = kPBrem;
- if (debug) cout << endl << "Bremsstrahlung" << endl;
-
+ mech = kPBrem;
+ if (debug) cout << endl << "Bremsstrahlung" << endl;
}
-
Double_t weight = GENSTK.wei[numsec-1];
Int_t is = 0;
- Int_t ntr;
+ Int_t ntr;
//
// Save particle in VMC stack
cppstack->PushTrack(done, parent, pdg,
- px, py, pz, e,
- vx, vy, vz, tof,
- polx, poly, polz,
- mech, ntr, weight, is);
- if (debug) cout << endl << " !!! stuprf: ntr=" << ntr << "pdg " << pdg << " parent=" << parent << "numsec "
- << numsec << "npprmr " << npprmr << endl;
+ px, py, pz, e,
+ vx, vy, vz, tof,
+ polx, poly, polz,
+ mech, ntr, weight, is);
+ if (debug)
+ cout << endl << " !!! stuprf: ntr=" << ntr << " pdg " << pdg << " parent=" << parent
+ << " parent_pdg="<< fluka->PDGFromId(TRACKR.jtrack) << " numsec "
+ << numsec << " npprmr " << npprmr << " icode=" << fluka->GetIcode()
+ << endl;
+
//
// Save current track number
FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1] = ntr;
FLKSTK.ispark[FLKSTK.npflka][mkbmx2-2] = 0;
- } // end of if (numsec-1 > npprmr)
+ } // end of if (numsec > npprmr)
+// else {
+// if(debug) {
+// cout << endl << " !!! stuprf: skipping pushtrack track=" << TRACKR.ispusr[mkbmx2-1]
+// << " pdg " << fluka->PDGFromId(TRACKR.jtrack) << " numsec=" << numsec<< " npprmr=" << npprmr
+// << " GENSTK pdg=" << fluka->PDGFromId(GENSTK.kpart[numsec-1]) << endl;
+// }
+// }
} // end of stuprf
} // end of extern "C"
} // Track found in stack
} // Loop over emf stack
} // Electromagnetic process
-
-
Int_t mlttc = LTCLCM.mlatm1;
fluka->SetMreg(mreg, mlttc);
fluka->SetYsco(ysco);
fluka->SetZsco(zsco);
- if (debug) printf("USDRAW: Number of track segments:%6d %6d %6d %10.3e\n", TRACKR.ntrack, TRACKR.mtrack, icode, TRACKR.atrack);
+ if (debug) printf("USDRAW: Number of track segments:%6d %6d icode=%d tof=%10.3e track=%d pdg=%d\n",
+ TRACKR.ntrack, TRACKR.mtrack, icode, TRACKR.atrack, TRACKR.ispusr[mkbmx2-1], fluka->PDGFromId(TRACKR.jtrack) );
+
+ TVirtualMCStack* cppstack = fluka->GetStack();
+ cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
(TVirtualMCApplication::Instance())->Stepping();
fluka->SetTrackIsNew(kFALSE);
-
+
+
} // end of usdraw
} // end of extern "C"