6 #include "G4LogicalVolumeStore.hh" 7 #include "G4ParticleTable.hh" 8 #include "G4PhysicalVolumeStore.hh" 9 #include "G4RegionStore.hh" 10 #include "G4UnitsTable.hh" 11 #include "G4SystemOfUnits.hh" 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() <<
" Ekin(MeV)= " << theTrack->GetKineticEnergy() / MeV;
108 theTrack->SetKineticEnergy(0.0);
111 const G4StepPoint* preStep = aStep->GetPreStepPoint();
112 const G4StepPoint* postStep = aStep->GetPostStepPoint();
127 <<
"Track #" << theTrack->GetTrackID() <<
" " << theTrack->GetDefinition()->GetParticleName()
128 <<
" E(MeV)= " << preStep->GetKineticEnergy() / MeV <<
" Nstep= " << theTrack->GetCurrentStepNumber()
129 <<
" is killed due to limit on number of steps;/n PV: " << preStep->GetPhysicalVolume()->GetName() <<
" at " 130 << theTrack->GetPosition() <<
" StepLen(mm)= " << aStep->GetStepLength();
133 const double time = theTrack->GetGlobalTime();
143 const G4LogicalVolume* lv = postStep->GetPhysicalVolume()->GetLogicalVolume();
144 const G4Region* theRegion = lv->GetRegion();
165 theTrack->GetDefinition()->GetPDGCharge() != 0.0 && lv->GetMaterial()->GetDensity() <=
theCriticalDensity) {
171 bool isKilled =
false;
174 if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
btl) {
180 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for Tracker -> BTL " << trkinfo->
isFromTtoBTL()
181 <<
" IdAtBTLentrance = " << trkinfo->
mcTruthID();
186 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL looper " << trkinfo->
isBTLlooper();
189 }
else if (preStep->GetPhysicalVolume() ==
btl && postStep->GetPhysicalVolume() ==
tracker) {
195 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL -> Tracker " << trkinfo->
isFromBTLtoT();
198 }
else if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
calo) {
204 }
else if (preStep->GetPhysicalVolume() ==
calo && postStep->GetPhysicalVolume() !=
calo) {
205 bool backscattering(
false);
206 if (postStep->GetPhysicalVolume() ==
tracker) {
207 backscattering =
true;
208 }
else if (postStep->GetPhysicalVolume() ==
cmse) {
211 if (preStep->GetPosition().mag2() > postStep->GetPosition().mag2()) {
212 backscattering =
true;
216 if (backscattering) {
228 theTrack->SetTrackStatus(fStopAndKill);
240 const double ekin = theTrack->GetKineticEnergy();
241 int pCode = theTrack->GetDefinition()->GetPDGEncoding();
257 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
258 for (
auto const& pvcite : *
pvs) {
273 <<
"Phase2SteppingAction: pointer for Tracker " <<
tracker <<
" and for Calo " <<
calo <<
" and for BTL " <<
btl;
275 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
278 for (
auto const& lvcite : *lvs) {
293 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
300 <<
" and KE cut off " <<
ekinMins[
i] / MeV <<
" MeV";
304 const G4RegionStore* rs = G4RegionStore::GetInstance();
307 for (
auto const& rcite : *rs) {
308 const G4String&
rname = rcite->GetName();
319 for (
auto const& rcite : *rs) {
320 const G4String&
rname = rcite->GetName();
338 typ =
" in dead region ";
341 typ =
" out of time window ";
344 typ =
" low energy limit ";
347 typ =
" low energy limit in vacuum ";
350 typ =
" energy deposition is NaN ";
353 typ =
" very forward track ";
356 typ =
" too many steps ";
361 G4VPhysicalVolume*
pv = aTrack->GetNextVolume();
362 vname =
pv->GetLogicalVolume()->GetName();
363 rname =
pv->GetLogicalVolume()->GetRegion()->GetName();
365 const double ekin = aTrack->GetKineticEnergy();
366 if (ekin < 2 * CLHEP::MeV) {
370 <<
"Track #" << aTrack->GetTrackID() <<
" StepN= " << aTrack->GetCurrentStepNumber() <<
" " 371 << aTrack->GetDefinition()->GetParticleName() <<
" E(MeV)=" << ekin / CLHEP::MeV
372 <<
" T(ns)=" << aTrack->GetGlobalTime() / CLHEP::ns <<
" is killed due to " << typ <<
"\n LV: " << vname <<
" (" 373 <<
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