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 : trackManager_(stm), 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");
40 <<
" MaxTrackTime = " <<
maxTrackTime / CLHEP::ns <<
" ns;" 57 <<
"SteppingAction: Number of DeadRegions where all trackes are killed " <<
ndeadRegions;
89 G4Track* theTrack = aStep->GetTrack();
92 if (theTrack->GetKineticEnergy() < 0.0) {
96 <<
"SteppingAction::UserSteppingAction: Track #" << theTrack->GetTrackID() <<
" " 97 << theTrack->GetDefinition()->GetParticleName() <<
" Ekin(MeV)= " << theTrack->GetKineticEnergy() / MeV;
99 theTrack->SetKineticEnergy(0.0);
102 const G4StepPoint* preStep = aStep->GetPreStepPoint();
103 const G4StepPoint* postStep = aStep->GetPostStepPoint();
118 <<
"Track #" << theTrack->GetTrackID() <<
" " << theTrack->GetDefinition()->GetParticleName()
119 <<
" E(MeV)= " << preStep->GetKineticEnergy() / MeV <<
" Nstep= " << theTrack->GetCurrentStepNumber()
120 <<
" is killed due to limit on number of steps;/n PV: " << preStep->GetPhysicalVolume()->GetName() <<
" at " 121 << theTrack->GetPosition() <<
" StepLen(mm)= " << aStep->GetStepLength();
124 const double time = theTrack->GetGlobalTime();
134 const G4LogicalVolume* lv = postStep->GetPhysicalVolume()->GetLogicalVolume();
135 const G4Region* theRegion = lv->GetRegion();
156 theTrack->GetDefinition()->GetPDGCharge() != 0.0 && lv->GetMaterial()->GetDensity() <=
theCriticalDensity) {
162 bool isKilled =
false;
164 if (preStep->GetPhysicalVolume() ==
tracker && postStep->GetPhysicalVolume() ==
calo) {
165 math::XYZVectorD pos((postStep->GetPosition()).
x(), (postStep->GetPosition()).
y(), (postStep->GetPosition()).
z());
168 (postStep->GetMomentum()).
y(),
169 (postStep->GetMomentum()).
z(),
170 postStep->GetTotalEnergy());
173 uint32_t
id = theTrack->GetTrackID();
174 std::pair<math::XYZVectorD, math::XYZTLorentzVectorD>
p(
pos, mom);
178 theTrack->SetTrackStatus(fStopAndKill);
190 const double ekin = theTrack->GetKineticEnergy();
191 int pCode = theTrack->GetDefinition()->GetPDGEncoding();
207 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
208 for (
auto const& pvcite : *
pvs) {
209 const G4String& pvname = pvcite->GetName();
210 if (pvname ==
"Tracker" || pvname ==
"tracker:Tracker_1") {
212 }
else if (pvname ==
"CALO" || pvname ==
"caloBase:CALO_1") {
219 <<
"SteppingAction: pointer for Tracker " <<
tracker <<
" and for Calo " <<
calo;
221 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
224 for (
auto const& lvcite : *lvs) {
225 const G4String& lvname = lvcite->GetName();
239 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
246 <<
" and KE cut off " <<
ekinMins[
i] / MeV <<
" MeV";
250 const G4RegionStore* rs = G4RegionStore::GetInstance();
253 for (
auto const& rcite : *rs) {
254 const G4String&
rname = rcite->GetName();
265 for (
auto const& rcite : *rs) {
266 const G4String&
rname = rcite->GetName();
284 typ =
" in dead region ";
287 typ =
" out of time window ";
290 typ =
" low energy limit ";
293 typ =
" low energy limit in vacuum ";
296 typ =
" energy deposition is NaN ";
299 typ =
" very forward track ";
302 typ =
" too many steps ";
307 G4VPhysicalVolume*
pv = aTrack->GetNextVolume();
308 vname =
pv->GetLogicalVolume()->GetName();
309 rname =
pv->GetLogicalVolume()->GetRegion()->GetName();
311 const double ekin = aTrack->GetKineticEnergy();
312 if (ekin < 2 * CLHEP::MeV) {
316 <<
"Track #" << aTrack->GetTrackID() <<
" StepN= " << aTrack->GetCurrentStepNumber() <<
" " 317 << aTrack->GetDefinition()->GetParticleName() <<
" E(MeV)=" << ekin / CLHEP::MeV
318 <<
" T(ns)=" << aTrack->GetGlobalTime() / CLHEP::ns <<
" is killed due to " << typ <<
"\n LV: " << vname <<
" (" 319 <<
rname <<
") at " << aTrack->GetPosition() <<
" step(cm)=" << aTrack->GetStep()->GetStepLength() / CLHEP::cm;
Log< level::Info, true > LogVerbatim
void UserSteppingAction(const G4Step *aStep) final
const G4VPhysicalVolume * tracker
std::vector< int > ekinPDG
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::vector< const G4Region * > deadRegions
double theCriticalDensity
SteppingAction(SimTrackManager *, const CMSSteppingVerbose *, const edm::ParameterSet &, bool hasW)
SimActivityRegistry::G4StepSignal m_g4StepSignal
bool isOutOfTimeWindow(const G4Region *reg, const double &time) const
const CMSSteppingVerbose * steppingVerbose
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
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
void PrintKilledTrack(const G4Track *, const TrackStatus &) const
std::vector< std::string > deadRegionNames
Abs< T >::type abs(const T &t)
bool isLowEnergy(const G4LogicalVolume *, const G4Track *) const
std::vector< double > maxTrackTimes
bool isInsideDeadRegion(const G4Region *reg) const
std::vector< G4LogicalVolume * > ekinVolumes
const G4VPhysicalVolume * calo
double theCriticalEnergyForVacuum
std::vector< double > ekinMins
std::vector< std::string > maxTimeNames
std::vector< std::string > ekinNames
double maxTrackTimeForward
const G4String rname[NREG]
void nextStep(const G4Step *, const G4SteppingManager *ptr, bool isKilled) const
Log< level::Warning, false > LogWarning
unsigned int ndeadRegions
std::vector< std::string > ekinParticles
SimTrackManager * trackManager_
std::vector< const G4Region * > maxTimeRegions