6 #include "G4LogicalVolumeStore.hh" 7 #include "G4ParticleTable.hh" 8 #include "G4PhysicalVolumeStore.hh" 9 #include "G4RegionStore.hh" 10 #include "G4UnitsTable.hh" 11 #include "G4SystemOfUnits.hh" 17 : steppingVerbose(
sv), hasWatcher(hasW) {
24 maxTrackTime =
p.getParameter<
double>(
"MaxTrackTime") * CLHEP::ns;
26 maxTrackTimes =
p.getParameter<std::vector<double> >(
"MaxTrackTimes");
27 maxTimeNames =
p.getParameter<std::vector<std::string> >(
"MaxTimeNames");
30 ekinMins =
p.getParameter<std::vector<double> >(
"EkinThresholds");
31 ekinNames =
p.getParameter<std::vector<std::string> >(
"EkinNames");
32 ekinParticles =
p.getParameter<std::vector<std::string> >(
"EkinParticles");
35 <<
"Phase2SteppingAction:: KillBeamPipe = " <<
killBeamPipe 38 <<
" MaxTrackTime = " <<
maxTrackTime / CLHEP::ns <<
" ns;" 55 <<
"Phase2SteppingAction: Number of DeadRegions where all trackes are killed " <<
ndeadRegions;
69 <<
"Phase2SteppingAction::Kill following " <<
numberPart <<
" particles in " <<
numberEkins <<
" volumes";
72 <<
" Threshold = " <<
ekinMins[
i] <<
" MeV";
88 G4Track* theTrack = aStep->GetTrack();
91 if (theTrack->GetKineticEnergy() < 0.0) {
95 <<
"Phase2SteppingAction::UserPhase2SteppingAction: Track #" << theTrack->GetTrackID() <<
" " 96 << theTrack->GetDefinition()->GetParticleName() <<
" Ekin(MeV)= " << theTrack->GetKineticEnergy() / MeV;
98 theTrack->SetKineticEnergy(0.0);
101 const G4StepPoint* preStep = aStep->GetPreStepPoint();
102 const G4StepPoint* postStep = aStep->GetPostStepPoint();
117 <<
"Track #" << theTrack->GetTrackID() <<
" " << theTrack->GetDefinition()->GetParticleName()
118 <<
" E(MeV)= " << preStep->GetKineticEnergy() / MeV <<
" Nstep= " << theTrack->GetCurrentStepNumber()
119 <<
" is killed due to limit on number of steps;/n PV: " << preStep->GetPhysicalVolume()->GetName() <<
" at " 120 << theTrack->GetPosition() <<
" StepLen(mm)= " << aStep->GetStepLength();
123 const double time = theTrack->GetGlobalTime();
133 const G4LogicalVolume* lv = postStep->GetPhysicalVolume()->GetLogicalVolume();
134 const G4Region* theRegion = lv->GetRegion();
155 theTrack->GetDefinition()->GetPDGCharge() != 0.0 && lv->GetMaterial()->GetDensity() <=
theCriticalDensity) {
161 bool isKilled =
false;
164 if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
btl) {
170 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for Tracker -> BTL " << trkinfo->
isFromTtoBTL()
171 <<
" IdAtBTLentrance = " << trkinfo->
mcTruthID();
176 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL looper " << trkinfo->
isBTLlooper();
179 }
else if (preStep->GetPhysicalVolume() ==
btl && postStep->GetPhysicalVolume() ==
tracker) {
185 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL -> Tracker " << trkinfo->
isFromBTLtoT();
188 }
else if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
calo) {
194 }
else if (preStep->GetPhysicalVolume() ==
calo && postStep->GetPhysicalVolume() !=
calo) {
195 bool backscattering(
false);
196 if (postStep->GetPhysicalVolume() ==
tracker) {
197 backscattering =
true;
198 }
else if (postStep->GetPhysicalVolume() ==
cmse) {
201 if (preStep->GetPosition().mag2() > postStep->GetPosition().mag2()) {
202 backscattering =
true;
206 if (backscattering) {
218 theTrack->SetTrackStatus(fStopAndKill);
230 const double ekin = theTrack->GetKineticEnergy();
231 int pCode = theTrack->GetDefinition()->GetPDGEncoding();
247 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
248 for (
auto const& pvcite : *
pvs) {
249 const G4String& pvname = pvcite->GetName();
250 if (pvname ==
"Tracker" || pvname ==
"tracker:Tracker_1") {
252 }
else if (pvname ==
"CALO" || pvname ==
"caloBase:CALO_1") {
254 }
else if (pvname ==
"BarrelTimingLayer" || pvname ==
"btl:BarrelTimingLayer_1") {
256 }
else if (pvname ==
"CMSE" || pvname ==
"cms:CMSE_1") {
263 <<
"Phase2SteppingAction: pointer for Tracker " <<
tracker <<
" and for Calo " <<
calo <<
" and for BTL " <<
btl;
265 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
268 for (
auto const& lvcite : *lvs) {
269 const G4String& lvname = lvcite->GetName();
283 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
290 <<
" and KE cut off " <<
ekinMins[
i] / MeV <<
" MeV";
294 const G4RegionStore* rs = G4RegionStore::GetInstance();
297 for (
auto const& rcite : *rs) {
298 const G4String&
rname = rcite->GetName();
309 for (
auto const& rcite : *rs) {
310 const G4String&
rname = rcite->GetName();
328 typ =
" in dead region ";
331 typ =
" out of time window ";
334 typ =
" low energy limit ";
337 typ =
" low energy limit in vacuum ";
340 typ =
" energy deposition is NaN ";
343 typ =
" very forward track ";
346 typ =
" too many steps ";
351 G4VPhysicalVolume*
pv = aTrack->GetNextVolume();
352 vname =
pv->GetLogicalVolume()->GetName();
353 rname =
pv->GetLogicalVolume()->GetRegion()->GetName();
355 const double ekin = aTrack->GetKineticEnergy();
356 if (ekin < 2 * CLHEP::MeV) {
360 <<
"Track #" << aTrack->GetTrackID() <<
" StepN= " << aTrack->GetCurrentStepNumber() <<
" " 361 << aTrack->GetDefinition()->GetParticleName() <<
" E(MeV)=" << ekin / CLHEP::MeV
362 <<
" T(ns)=" << aTrack->GetGlobalTime() / CLHEP::ns <<
" is killed due to " << typ <<
"\n LV: " << vname <<
" (" 363 <<
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 hasW)
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::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
double theCriticalDensity
const G4VPhysicalVolume * cmse
std::vector< double > maxTrackTimes
void UserSteppingAction(const G4Step *aStep) final