// M Hentz, 2016 #include "StepMax.hh" #include "StepMaxMessenger.hh" StepMax::StepMax( const G4String& processName ) :G4VDiscreteProcess(processName), fMaxChargedStep(DBL_MAX), fMessenger(0) { fMessenger = new StepMaxMessenger(this); } StepMax::~StepMax() { delete fMessenger; } G4bool StepMax::IsApplicable( const G4ParticleDefinition& particle ) { return ( particle.GetPDGCharge() != 0. && !particle.IsShortLived() ); } void StepMax::SetMaxStep( G4double step ) { fMaxChargedStep = step; } G4double StepMax::PostStepGetPhysicalInteractionLength( const G4Track& aTrack, G4double, G4ForceCondition* condition ) { // condition is set to "Not Forced" *condition = NotForced; G4double proposedStep = DBL_MAX; G4String volName = aTrack.GetVolume()->GetName(); // Remove last character from volume name G4String shortenedVolName = volName.remove( volName.length() - 1 ); // Set the maximum step length depending on the volume if ( fMaxChargedStep > 0. && aTrack.GetVolume() != NULL && volName != "World" ) { proposedStep = fMaxChargedStep; } // Set the max step length to be no bigger than 5% of the volume's thickness if ( fMaxChargedStep > 0. && aTrack.GetVolume() != NULL ) { // Thickness of scatter foils: 25 um if (volName == "ScatterFoil") { proposedStep = 0.05 * 0.025*CLHEP::mm; } // Thickness of mylar layer: 5 um if (volName == "MonitorMylar") { proposedStep = 0.05 * 0.005*CLHEP::mm; } // Thicnkess of aluminium foil: 1 um if (volName == "MonitorAl") { proposedStep = (0.05)*(0.001*CLHEP::mm); } } return proposedStep; } G4VParticleChange* StepMax::PostStepDoIt( const G4Track& aTrack, const G4Step& ) { // do nothing aParticleChange.Initialize(aTrack); return &aParticleChange; }