6 #include "G4LogicalVolumeStore.hh" 7 #include "G4ParticleTable.hh" 8 #include "G4PhysicalVolumeStore.hh" 9 #include "G4RegionStore.hh" 10 #include "G4UnitsTable.hh" 11 #include <CLHEP/Units/SystemOfUnits.h> 20 : steppingVerbose(
sv), hasWatcher(hasW), dd4hep_(
dd4hep) {
27 maxTrackTime =
p.getParameter<
double>(
"MaxTrackTime") * CLHEP::ns;
29 maxTrackTimes =
p.getParameter<std::vector<double> >(
"MaxTrackTimes");
30 maxTimeNames =
p.getParameter<std::vector<std::string> >(
"MaxTimeNames");
33 ekinMins =
p.getParameter<std::vector<double> >(
"EkinThresholds");
34 ekinNames =
p.getParameter<std::vector<std::string> >(
"EkinNames");
35 ekinParticles =
p.getParameter<std::vector<std::string> >(
"EkinParticles");
43 <<
"Phase2SteppingAction:: KillBeamPipe = " <<
killBeamPipe 46 <<
" MaxTrackTime = " <<
maxTrackTime / CLHEP::ns <<
" ns;" 65 <<
"Phase2SteppingAction: Number of DeadRegions where all trackes are killed " <<
ndeadRegions;
79 <<
"Phase2SteppingAction::Kill following " <<
numberPart <<
" particles in " <<
numberEkins <<
" volumes";
82 <<
" Threshold = " <<
ekinMins[
i] <<
" MeV";
98 G4Track* theTrack = aStep->GetTrack();
101 if (theTrack->GetKineticEnergy() < 0.0) {
105 <<
"Phase2SteppingAction::UserPhase2SteppingAction: Track #" << theTrack->GetTrackID() <<
" " 106 << theTrack->GetDefinition()->GetParticleName()
107 <<
" Ekin(MeV)= " << theTrack->GetKineticEnergy() / CLHEP::MeV;
109 theTrack->SetKineticEnergy(0.0);
112 const G4StepPoint* preStep = aStep->GetPreStepPoint();
113 const G4StepPoint* postStep = aStep->GetPostStepPoint();
128 <<
"Track #" << theTrack->GetTrackID() <<
" " << theTrack->GetDefinition()->GetParticleName()
129 <<
" E(MeV)= " << preStep->GetKineticEnergy() / CLHEP::MeV <<
" Nstep= " << theTrack->GetCurrentStepNumber()
130 <<
" is killed due to limit on number of steps;/n PV: " << preStep->GetPhysicalVolume()->GetName() <<
" at " 131 << theTrack->GetPosition() <<
" StepLen(mm)= " << aStep->GetStepLength();
134 const double time = theTrack->GetGlobalTime();
144 const G4LogicalVolume* lv = postStep->GetPhysicalVolume()->GetLogicalVolume();
145 const G4Region* theRegion = lv->GetRegion();
166 theTrack->GetDefinition()->GetPDGCharge() != 0.0 && lv->GetMaterial()->GetDensity() <=
theCriticalDensity) {
172 bool isKilled =
false;
175 if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
btl) {
181 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for Tracker -> BTL " << trkinfo->
isFromTtoBTL()
182 <<
" IdAtBTLentrance = " << trkinfo->
mcTruthID();
187 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL looper " << trkinfo->
isBTLlooper();
190 }
else if (preStep->GetPhysicalVolume() ==
btl && postStep->GetPhysicalVolume() ==
tracker) {
196 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL -> Tracker " << trkinfo->
isFromBTLtoT();
199 }
else if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
calo) {
205 }
else if ((preStep->GetPhysicalVolume() ==
calo && postStep->GetPhysicalVolume() ==
tracker) ||
206 (preStep->GetPhysicalVolume() ==
cmse && postStep->GetPhysicalVolume() ==
tracker)) {
211 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for backscattering from CALO " 216 theTrack->SetTrackStatus(fStopAndKill);
228 const double ekin = theTrack->GetKineticEnergy();
229 int pCode = theTrack->GetDefinition()->GetPDGEncoding();
245 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
246 for (
auto const& pvcite : *
pvs) {
261 <<
"Phase2SteppingAction: pointer for Tracker " <<
tracker <<
" and for Calo " <<
calo <<
" and for BTL " <<
btl;
263 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
266 for (
auto const& lvcite : *lvs) {
281 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
288 <<
" and KE cut off " <<
ekinMins[
i] / CLHEP::MeV <<
" MeV";
292 const G4RegionStore* rs = G4RegionStore::GetInstance();
295 for (
auto const& rcite : *rs) {
296 const G4String&
rname = rcite->GetName();
307 for (
auto const& rcite : *rs) {
308 const G4String&
rname = rcite->GetName();
326 typ =
" in dead region ";
329 typ =
" out of time window ";
332 typ =
" low energy limit ";
335 typ =
" low energy limit in vacuum ";
338 typ =
" energy deposition is NaN ";
341 typ =
" very forward track ";
344 typ =
" too many steps ";
349 G4VPhysicalVolume*
pv = aTrack->GetNextVolume();
350 vname =
pv->GetLogicalVolume()->GetName();
351 rname =
pv->GetLogicalVolume()->GetRegion()->GetName();
353 const double ekin = aTrack->GetKineticEnergy();
354 if (ekin < 2 * CLHEP::MeV) {
358 <<
"Track #" << aTrack->GetTrackID() <<
" StepN= " << aTrack->GetCurrentStepNumber() <<
" " 359 << aTrack->GetDefinition()->GetParticleName() <<
" E(MeV)=" << ekin / CLHEP::MeV
360 <<
" T(ns)=" << aTrack->GetGlobalTime() / CLHEP::ns <<
" is killed due to " << typ <<
"\n LV: " << vname <<
" (" 361 <<
rname <<
") at " << aTrack->GetPosition() <<
" step(cm)=" << aTrack->GetStep()->GetStepLength() / CLHEP::cm;
Log< level::Info, true > LogVerbatim
const CMSSteppingVerbose * steppingVerbose
std::vector< std::string > maxTimeNames
bool isOutOfTimeWindow(const G4Region *reg, const double &time) const
double maxTrackTimeForward
SimActivityRegistry::G4StepSignal m_g4StepSignal
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
const G4VPhysicalVolume * calo
Phase2SteppingAction(const CMSSteppingVerbose *, const edm::ParameterSet &, bool, bool)
std::vector< std::string > ekinNames
const G4VPhysicalVolume * tracker
std::vector< int > ekinPDG
Abs< T >::type abs(const T &t)
std::vector< G4LogicalVolume * > ekinVolumes
const G4VPhysicalVolume * btl
std::vector< std::string > ekinParticles
double theCriticalEnergyForVacuum
void PrintKilledTrack(const G4Track *, const TrackStatus &) const
unsigned int ndeadRegions
std::string namePV(const std::string &name, bool dd4hep)
std::vector< double > ekinMins
const G4String rname[NREG]
std::vector< std::string > deadRegionNames
std::vector< const G4Region * > maxTimeRegions
bool isLowEnergy(const G4LogicalVolume *, const G4Track *) const
bool isInsideDeadRegion(const G4Region *reg) const
void nextStep(const G4Step *, const G4SteppingManager *ptr, bool isKilled) const
std::vector< const G4Region * > deadRegions
Log< level::Warning, false > LogWarning
std::string nameMatterLV(const std::string &name, bool dd4hep)
double theCriticalDensity
const G4VPhysicalVolume * cmse
std::vector< double > maxTrackTimes
void UserSteppingAction(const G4Step *aStep) final