6 #include "G4LogicalVolumeStore.hh" 7 #include "G4ParticleTable.hh" 8 #include "G4PhysicalVolumeStore.hh" 9 #include "G4RegionStore.hh" 10 #include "G4UnitsTable.hh" 11 #include "G4SystemOfUnits.hh" 19 : steppingVerbose(
sv), hasWatcher(hasW) {
26 maxTrackTime =
p.getParameter<
double>(
"MaxTrackTime") * CLHEP::ns;
28 maxTrackTimes =
p.getParameter<std::vector<double> >(
"MaxTrackTimes");
29 maxTimeNames =
p.getParameter<std::vector<std::string> >(
"MaxTimeNames");
32 ekinMins =
p.getParameter<std::vector<double> >(
"EkinThresholds");
33 ekinNames =
p.getParameter<std::vector<std::string> >(
"EkinNames");
34 ekinParticles =
p.getParameter<std::vector<std::string> >(
"EkinParticles");
37 <<
"Phase2SteppingAction:: KillBeamPipe = " <<
killBeamPipe 40 <<
" MaxTrackTime = " <<
maxTrackTime / CLHEP::ns <<
" ns;" 57 <<
"Phase2SteppingAction: Number of DeadRegions where all trackes are killed " <<
ndeadRegions;
71 <<
"Phase2SteppingAction::Kill following " <<
numberPart <<
" particles in " <<
numberEkins <<
" volumes";
74 <<
" Threshold = " <<
ekinMins[
i] <<
" MeV";
90 G4Track* theTrack = aStep->GetTrack();
93 if (theTrack->GetKineticEnergy() < 0.0) {
97 <<
"Phase2SteppingAction::UserPhase2SteppingAction: Track #" << theTrack->GetTrackID() <<
" " 98 << theTrack->GetDefinition()->GetParticleName() <<
" Ekin(MeV)= " << theTrack->GetKineticEnergy() / MeV;
100 theTrack->SetKineticEnergy(0.0);
103 const G4StepPoint* preStep = aStep->GetPreStepPoint();
104 const G4StepPoint* postStep = aStep->GetPostStepPoint();
119 <<
"Track #" << theTrack->GetTrackID() <<
" " << theTrack->GetDefinition()->GetParticleName()
120 <<
" E(MeV)= " << preStep->GetKineticEnergy() / MeV <<
" Nstep= " << theTrack->GetCurrentStepNumber()
121 <<
" is killed due to limit on number of steps;/n PV: " << preStep->GetPhysicalVolume()->GetName() <<
" at " 122 << theTrack->GetPosition() <<
" StepLen(mm)= " << aStep->GetStepLength();
125 const double time = theTrack->GetGlobalTime();
135 const G4LogicalVolume* lv = postStep->GetPhysicalVolume()->GetLogicalVolume();
136 const G4Region* theRegion = lv->GetRegion();
157 theTrack->GetDefinition()->GetPDGCharge() != 0.0 && lv->GetMaterial()->GetDensity() <=
theCriticalDensity) {
163 bool isKilled =
false;
166 if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
btl) {
173 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for Tracker -> BTL " << trkinfo->
isFromTtoBTL()
180 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL looper " << trkinfo->
isBTLlooper();
184 }
else if (preStep->GetPhysicalVolume() ==
btl && postStep->GetPhysicalVolume() ==
tracker) {
190 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL -> Tracker " << trkinfo->
isFromBTLtoT();
193 }
else if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
calo) {
201 theTrack->SetTrackStatus(fStopAndKill);
213 const double ekin = theTrack->GetKineticEnergy();
214 int pCode = theTrack->GetDefinition()->GetPDGEncoding();
230 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
231 for (
auto const& pvcite : *
pvs) {
232 const G4String& pvname = pvcite->GetName();
233 if (pvname ==
"Tracker" || pvname ==
"tracker:Tracker_1") {
235 }
else if (pvname ==
"CALO" || pvname ==
"caloBase:CALO_1") {
237 }
else if (pvname ==
"BarrelTimingLayer" || pvname ==
"btl:BarrelTimingLayer_1") {
244 <<
"Phase2SteppingAction: pointer for Tracker " <<
tracker <<
" and for Calo " <<
calo <<
" and for BTL " <<
btl;
246 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
249 for (
auto const& lvcite : *lvs) {
250 const G4String& lvname = lvcite->GetName();
264 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
271 <<
" and KE cut off " <<
ekinMins[
i] / MeV <<
" MeV";
275 const G4RegionStore* rs = G4RegionStore::GetInstance();
278 for (
auto const& rcite : *rs) {
279 const G4String&
rname = rcite->GetName();
290 for (
auto const& rcite : *rs) {
291 const G4String&
rname = rcite->GetName();
309 typ =
" in dead region ";
312 typ =
" out of time window ";
315 typ =
" low energy limit ";
318 typ =
" low energy limit in vacuum ";
321 typ =
" energy deposition is NaN ";
324 typ =
" very forward track ";
327 typ =
" too many steps ";
332 G4VPhysicalVolume*
pv = aTrack->GetNextVolume();
333 vname =
pv->GetLogicalVolume()->GetName();
334 rname =
pv->GetLogicalVolume()->GetRegion()->GetName();
336 const double ekin = aTrack->GetKineticEnergy();
337 if (ekin < 2 * CLHEP::MeV) {
341 <<
"Track #" << aTrack->GetTrackID() <<
" StepN= " << aTrack->GetCurrentStepNumber() <<
" " 342 << aTrack->GetDefinition()->GetParticleName() <<
" E(MeV)=" << ekin / CLHEP::MeV
343 <<
" T(ns)=" << aTrack->GetGlobalTime() / CLHEP::ns <<
" is killed due to " << typ <<
"\n LV: " << vname <<
" (" 344 <<
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
std::vector< double > maxTrackTimes
void UserSteppingAction(const G4Step *aStep) final