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) {
172 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for Tracker -> BTL " << trkinfo->
isFromTtoBTL()
173 <<
" IdAtBTLentrance = " << trkinfo->
mcTruthID();
178 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL looper " << trkinfo->
isBTLlooper();
181 }
else if (preStep->GetPhysicalVolume() ==
btl && postStep->GetPhysicalVolume() ==
tracker) {
187 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for BTL -> Tracker " << trkinfo->
isFromBTLtoT();
190 }
else if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
calo) {
196 }
else if (preStep->GetPhysicalVolume() ==
calo && postStep->GetPhysicalVolume() ==
cmse) {
202 LogDebug(
"SimG4CoreApplication") <<
"Setting flag for backscattering from CALO " 208 theTrack->SetTrackStatus(fStopAndKill);
220 const double ekin = theTrack->GetKineticEnergy();
221 int pCode = theTrack->GetDefinition()->GetPDGEncoding();
237 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
238 for (
auto const& pvcite : *
pvs) {
239 const G4String& pvname = pvcite->GetName();
240 if (pvname ==
"Tracker" || pvname ==
"tracker:Tracker_1") {
242 }
else if (pvname ==
"CALO" || pvname ==
"caloBase:CALO_1") {
244 }
else if (pvname ==
"BarrelTimingLayer" || pvname ==
"btl:BarrelTimingLayer_1") {
246 }
else if (pvname ==
"CMSE" || pvname ==
"cms:CMSE_1") {
253 <<
"Phase2SteppingAction: pointer for Tracker " <<
tracker <<
" and for Calo " <<
calo <<
" and for BTL " <<
btl;
255 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
258 for (
auto const& lvcite : *lvs) {
259 const G4String& lvname = lvcite->GetName();
273 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
280 <<
" and KE cut off " <<
ekinMins[
i] / MeV <<
" MeV";
284 const G4RegionStore* rs = G4RegionStore::GetInstance();
287 for (
auto const& rcite : *rs) {
288 const G4String&
rname = rcite->GetName();
299 for (
auto const& rcite : *rs) {
300 const G4String&
rname = rcite->GetName();
318 typ =
" in dead region ";
321 typ =
" out of time window ";
324 typ =
" low energy limit ";
327 typ =
" low energy limit in vacuum ";
330 typ =
" energy deposition is NaN ";
333 typ =
" very forward track ";
336 typ =
" too many steps ";
341 G4VPhysicalVolume*
pv = aTrack->GetNextVolume();
342 vname =
pv->GetLogicalVolume()->GetName();
343 rname =
pv->GetLogicalVolume()->GetRegion()->GetName();
345 const double ekin = aTrack->GetKineticEnergy();
346 if (ekin < 2 * CLHEP::MeV) {
350 <<
"Track #" << aTrack->GetTrackID() <<
" StepN= " << aTrack->GetCurrentStepNumber() <<
" " 351 << aTrack->GetDefinition()->GetParticleName() <<
" E(MeV)=" << ekin / CLHEP::MeV
352 <<
" T(ns)=" << aTrack->GetGlobalTime() / CLHEP::ns <<
" is killed due to " << typ <<
"\n LV: " << vname <<
" (" 353 <<
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