4 #include "G4LogicalVolumeStore.hh"
5 #include "G4ParticleTable.hh"
6 #include "G4PhysicalVolumeStore.hh"
7 #include "G4RegionStore.hh"
9 #include "G4UnitsTable.hh"
10 #include "G4SystemOfUnits.hh"
15 : eventAction_(e),
tracker(0), calo(0), initialized(
false) {
28 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction:: KillBeamPipe = "
31 <<
" CriticalEnergyForVacuum = "
38 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction::MaxTrackTime for "
50 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction::Kill following "
56 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction::Particle " <<
i
62 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction::Volume[" <<
i
74 G4Track * theTrack = aStep->GetTrack();
75 bool ok = (theTrack->GetTrackStatus() == fAlive);
76 G4double kinEnergy = theTrack->GetKineticEnergy();
79 && theTrack->GetDefinition()->GetPDGCharge() != 0.0 && kinEnergy > 0.0) {
86 if(ok && aStep->GetPostStepPoint()->GetPhysicalVolume() != 0) {
94 G4StepPoint* preStep = aStep->GetPreStepPoint();
99 (preStep->GetPosition()).
y(),
100 (preStep->GetPosition()).
z());
103 (preStep->GetMomentum()).
y(),
104 (preStep->GetMomentum()).
z(),
105 preStep->GetTotalEnergy());
107 uint32_t
id = aStep->GetTrack()->GetTrackID();
109 std::pair<math::XYZVectorD,math::XYZTLorentzVectorD>
p(pos,mom);
119 if (theTrack->GetVolume()!=0) {
120 double density = theTrack->GetVolume()->GetLogicalVolume()->GetMaterial()->GetDensity();
124 <<
" SteppingAction: LoopCatchSteppingAction:catchLowEnergyInVacuumHere: "
125 <<
" Track from " << theTrack->GetDefinition()->GetParticleName()
126 <<
" of kinetic energy " << theKenergy/MeV <<
" MeV "
127 <<
" killed in " << theTrack->GetVolume()->GetLogicalVolume()->GetName()
128 <<
" of density " << density/(
g/cm3) <<
" g/cm3" ;
130 theTrack->SetTrackStatus(fStopAndKill);
134 density = theTrack->GetNextVolume()->GetLogicalVolume()->GetMaterial()->GetDensity();
138 <<
" SteppingAction: LoopCatchSteppingAction::catchLowEnergyInVacuumNext: "
139 <<
" Track from " << theTrack->GetDefinition()->GetParticleName()
140 <<
" of kinetic energy " << theKenergy/MeV <<
" MeV "
141 <<
" stopped in " << theTrack->GetVolume()->GetLogicalVolume()->GetName()
142 <<
" before going into "<< theTrack->GetNextVolume()->GetLogicalVolume()->GetName()
143 <<
" of density " << density/(
g/cm3) <<
" g/cm3" ;
145 theTrack->SetTrackStatus(fStopButAlive);
156 double time = (aStep->GetPostStepPoint()->GetGlobalTime())/nanosecond;
161 aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion();
180 G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
188 G4Track * track = aStep->GetTrack();
189 double ekin = track->GetKineticEnergy();
191 int pCode = track->GetDefinition()->GetPDGEncoding();
192 for (
unsigned int i=0;
i<
ekinPDG.size();
i++) {
209 const G4PhysicalVolumeStore * pvs = G4PhysicalVolumeStore::GetInstance();
211 std::vector<G4VPhysicalVolume*>::const_iterator pvcite;
212 for (pvcite = pvs->begin(); pvcite != pvs->end(); pvcite++) {
213 if ((*pvcite)->GetName() ==
"Tracker")
tracker = (*pvcite);
214 if ((*pvcite)->GetName() ==
"CALO")
calo = (*pvcite);
218 <<
" and for Calo " <<
calo;
221 if (calo)
LogDebug(
"SimG4CoreApplication") <<
"Calorimeter vol name "
227 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
231 std::vector<G4LogicalVolume*>::const_iterator lvcite;
232 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
233 for (
unsigned int i=0;
i<
num;
i++) {
234 if ((*lvcite)->GetName() == (G4String)(
ekinNames[
i])) {
249 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
250 G4String particleName;
252 int pdg = theParticleTable->FindParticle(particleName=
ekinParticles[
i])->GetPDGEncoding();
258 if (!flag)
edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction fails to"
259 <<
" initialize some the "
260 <<
"LV pointers correctly";
262 const G4RegionStore * rs = G4RegionStore::GetInstance();
265 std::vector<double> tofs;
267 std::vector<G4Region*>::const_iterator rcite;
268 for (rcite = rs->begin(); rcite != rs->end(); rcite++) {
269 for (
unsigned int i=0;
i<
num;
i++) {
276 if (tofs.size() ==
num)
break;
279 for (
unsigned int i=0;
i<tofs.size();
i++) {
281 G4String
name =
"Unknown";
283 edm::LogInfo(
"SimG4CoreApplication") << name <<
" with pointer "
287 if (tofs.size() !=
num)
288 edm::LogInfo(
"SimG4CoreApplication") <<
"SteppingAction fails to "
289 <<
"initialize some the region "
290 <<
"pointers correctly";
296 G4VPhysicalVolume* pv)
299 int level = ((touch->GetHistoryDepth())+1);
300 if (level > 0 && level >= 3) {
301 unsigned int ii = (
unsigned int)(level - 3);
302 return (touch->GetVolume(ii) == pv);
310 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
311 G4TrackVector tv = *(aStep->GetSecondary());
312 for (
unsigned int kk=0;
kk<tv.size();
kk++) {
313 if (tv[
kk]->
GetVolume() == aStep->GetPreStepPoint()->GetPhysicalVolume())
314 tv[
kk]->SetTrackStatus(fStopAndKill);
317 <<
"SteppingAction: Kills track "
318 << aStep->GetTrack()->GetTrackID() <<
" ("
319 << aStep->GetTrack()->GetDefinition()->GetParticleName()
320 <<
") at " << aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond <<
" ns in "
321 << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName()
323 << 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)
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
bool catchLowEnergyInVacuum(G4Track *theTrack, double theKenergy)
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
volatile std::atomic< bool > shutdown_flag false
std::vector< std::string > ekinParticles
std::vector< G4Region * > maxTimeRegions