4 #include "G4LogicalVolumeStore.hh"
5 #include "G4ParticleTable.hh"
6 #include "G4PhysicalVolumeStore.hh"
7 #include "G4RegionStore.hh"
9 #include "G4UnitsTable.hh"
14 : eventAction_(e), initialized(
false),
tracker(0), calo(0) {
27 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction:: KillBeamPipe = "
30 <<
" CriticalEnergyForVacuum = "
36 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction::MaxTrackTime for "
40 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction::Kill following "
46 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction::Particle " <<
i
52 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction::Volume[" <<
i
67 if (aStep->GetPostStepPoint()->GetPhysicalVolume() != 0) {
76 (aStep->GetPreStepPoint()->GetPosition()).
y(),
77 (aStep->GetPreStepPoint()->GetPosition()).
z());
80 (aStep->GetPreStepPoint()->GetMomentum()).
y(),
81 (aStep->GetPreStepPoint()->GetMomentum()).
z(),
82 aStep->GetPreStepPoint()->GetTotalEnergy());
84 uint32_t
id = aStep->GetTrack()->GetTrackID();
86 std::pair<math::XYZVectorD,math::XYZTLorentzVectorD>
p(
pos,mom);
93 G4Track * theTrack = aStep->GetTrack();
94 double theKenergy = theTrack->GetKineticEnergy();
95 if (theTrack->GetVolume()!=0) {
96 double density = theTrack->GetVolume()->GetLogicalVolume()->GetMaterial()->GetDensity();
97 if (theKenergy <= theCriticalEnergyForVacuum && theKenergy > 0.0 &&
98 density <= theCriticalDensity && theTrack->GetDefinition()->GetPDGCharge() != 0 &&
99 theTrack->GetTrackStatus() != fStopAndKill) {
102 <<
" SteppingAction: LoopCatchSteppingAction:catchLowEnergyInVacuumHere: "
103 <<
" Track from " << theTrack->GetDefinition()->GetParticleName()
104 <<
" of kinetic energy " << theKenergy/MeV <<
" MeV "
105 <<
" killed in " << theTrack->GetVolume()->GetLogicalVolume()->GetName()
106 <<
" of density " << density/(
g/cm3) <<
" g/cm3" ;
107 theTrack->SetTrackStatus(fStopAndKill);
113 G4Track * theTrack = aStep->GetTrack();
114 double theKenergy = theTrack->GetKineticEnergy();
115 if (theTrack->GetNextVolume()) {
116 double density = theTrack->GetNextVolume()->GetLogicalVolume()->GetMaterial()->GetDensity();
117 if (theKenergy <= theCriticalEnergyForVacuum && theKenergy > 0.0 &&
118 density <= theCriticalDensity && theTrack->GetDefinition()->GetPDGCharge() != 0 &&
119 theTrack->GetTrackStatus() != fStopAndKill) {
122 <<
" SteppingAction: LoopCatchSteppingAction::catchLowEnergyInVacuumNext: "
123 <<
" Track from " << theTrack->GetDefinition()->GetParticleName()
124 <<
" of kinetic energy " << theKenergy/MeV <<
" MeV "
125 <<
" stopped in " << theTrack->GetVolume()->GetLogicalVolume()->GetName()
126 <<
" before going into "<< theTrack->GetNextVolume()->GetLogicalVolume()->GetName()
127 <<
" of density " << density/(
g/cm3) <<
" g/cm3" ;
128 theTrack->SetTrackStatus(fStopButAlive);
136 double time = (aStep->GetPostStepPoint()->GetGlobalTime())/nanosecond;
139 G4Region* reg = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion();
159 G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
167 G4Track * track = aStep->GetTrack();
168 double ekin = track->GetKineticEnergy();
170 int pCode = track->GetDefinition()->GetPDGEncoding();
171 for (
unsigned int i=0;
i<
ekinPDG.size();
i++) {
189 const G4PhysicalVolumeStore * pvs = G4PhysicalVolumeStore::GetInstance();
191 std::vector<G4VPhysicalVolume*>::const_iterator pvcite;
192 for (pvcite = pvs->begin(); pvcite != pvs->end(); pvcite++) {
193 if ((*pvcite)->GetName() ==
"Tracker")
tracker = (*pvcite);
194 if ((*pvcite)->GetName() ==
"CALO")
calo = (*pvcite);
198 <<
" and for Calo " <<
calo;
201 if (calo)
LogDebug(
"SimG4CoreApplication") <<
"Calorimeter vol name "
207 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
211 std::vector<G4LogicalVolume*>::const_iterator lvcite;
212 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
213 for (
unsigned int i=0;
i<
num;
i++) {
214 if ((*lvcite)->GetName() == (G4String)(
ekinNames[
i])) {
229 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
230 G4String particleName;
232 int pdg = theParticleTable->FindParticle(particleName=
ekinParticles[
i])->GetPDGEncoding();
238 if (!flag)
edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction fails to"
239 <<
" initialize some the "
240 <<
"LV pointers correctly";
242 const G4RegionStore * rs = G4RegionStore::GetInstance();
245 std::vector<double> tofs;
247 std::vector<G4Region*>::const_iterator rcite;
248 for (rcite = rs->begin(); rcite != rs->end(); rcite++) {
249 for (
unsigned int i=0;
i<
num;
i++) {
256 if (tofs.size() ==
num)
break;
259 for (
unsigned int i=0;
i<tofs.size();
i++) {
261 G4String
name =
"Unknown";
263 edm::LogInfo(
"SimG4CoreApplication") << name <<
" with pointer "
267 if (tofs.size() !=
num)
268 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction fails to "
269 <<
"initialize some the region "
270 <<
"pointers correctly";
276 G4VPhysicalVolume* pv) {
278 int level = ((touch->GetHistoryDepth())+1);
279 if (level > 0 && level >= 3) {
280 unsigned int ii = (
unsigned int)(level - 3);
281 return (touch->GetVolume(ii) == pv);
288 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
289 G4TrackVector tv = *(aStep->GetSecondary());
290 for (
unsigned int kk=0; kk<tv.size(); kk++) {
291 if (tv[kk]->
GetVolume() == aStep->GetPreStepPoint()->GetPhysicalVolume())
292 tv[kk]->SetTrackStatus(fStopAndKill);
294 LogDebug(
"SimG4CoreApplication") <<
"SteppingAction: Kills track "
295 << aStep->GetTrack()->GetTrackID() <<
" ("
296 << aStep->GetTrack()->GetDefinition()->GetParticleName()
297 <<
") at " << aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond
298 <<
" ns in " << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName()
299 <<
" from region " << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion()->GetName();
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > ekinPDG
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
double theCriticalDensity
SimActivityRegistry::G4StepSignal m_g4StepSignal
bool catchLongLived(const G4Step *aStep)
bool isThisVolume(const G4VTouchable *touch, G4VPhysicalVolume *pv)
void catchLowEnergyInVacuumHere(const G4Step *aStep)
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 UserSteppingAction(const G4Step *aStep)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
std::vector< double > maxTrackTimes
SteppingAction(EventAction *ea, const edm::ParameterSet &ps)
std::vector< G4LogicalVolume * > ekinVolumes
double theCriticalEnergyForVacuum
static const G4LogicalVolume * GetVolume(const std::string &name)
EventAction * eventAction_
void killTrack(const G4Step *aStep)
std::vector< double > ekinMins
std::vector< std::string > maxTimeNames
std::vector< std::string > ekinNames
bool killLowEnergy(const G4Step *aStep)
void addTkCaloStateInfo(uint32_t t, const std::pair< math::XYZVectorD, math::XYZTLorentzVectorD > &p)
G4VPhysicalVolume * tracker
void catchLowEnergyInVacuumNext(const G4Step *aStep)
std::vector< std::string > ekinParticles
std::vector< G4Region * > maxTimeRegions