#include "AASteppingAction.hh" #ifndef __CLING__ #include "G4PhysicalConstants.hh" #include "G4PrimaryVertex.hh" #include "G4Event.hh" #include "G4RunManager.hh" #include "G4Step.hh" #endif #include "Sim.hh" #include "TrackSegment.hh" #include "generate_photons.hh" #include #include "stringutil.hh" using namespace std; AASteppingAction:: AASteppingAction() { simulate_photons = true; total_length = 0; } void AASteppingAction::UserSteppingAction(const G4Step* step) { TIMESCOPE G4Track* track = step->GetTrack(); const double charge = track -> GetParticleDefinition ()-> GetPDGCharge () ; // ----------------------------------------------------------- // Do not process tracks that do not produce Cherenkov light // ----------------------------------------------------------- if ( charge == 0 ) return; g_sim -> n_track_seg++; G4StepPoint* point1 = step->GetPreStepPoint(); G4StepPoint* point2 = step->GetPostStepPoint(); const double beta1 = point1 -> GetVelocity () / c_light; const double beta2 = point2 -> GetVelocity () / c_light; double beta = ( beta1 + beta2 ) / 2 ; // The following should be refined, somewhat. // it *may* be the case that a slow-heavy particle e.g. decays and // can still produce cherenkov. if ( beta < 0.7 ) { step->GetTrack()->SetTrackStatus(fStopAndKill); return; } // ------------------------------------------------ // Make a TrackSegment // ------------------------------------------------ static TrackSegment trkseg; G4ThreeVector pos1 = step->GetPreStepPoint()->GetPosition(); G4ThreeVector pos2 = step->GetPostStepPoint()->GetPosition(); trkseg.pos.set( pos1.x() / m , pos1.y() / m, pos1.z() / m ); trkseg.dir.set( pos2.x() / m , pos2.y() / m, pos2.z() / m ); trkseg.dir -= trkseg.pos; trkseg.len = trkseg.dir.len(); if ( trkseg.len > 0 ) trkseg.dir /= trkseg.len; trkseg.len_effective = step->GetStepLength() / m; trkseg.beta = beta; trkseg.energy = point1-> GetTotalEnergy() / GeV; trkseg.t = step -> GetPreStepPoint()->GetGlobalTime(); trkseg.id = track -> GetTrackID (); trkseg.type = track -> GetParticleDefinition ()-> GetPDGEncoding (); //trkseg.nphot will be set in generate_photons. if ( trkseg.energy < 1e-4 ) { dbg( beta1, beta2, beta ); dbg( trkseg.type, charge ); fatal("found a particle with too low energy"); } // ------------------------------------------------ // simulate the photons // ------------------------------------------------ if ( simulate_photons ) generate_photons( *g_sim, trkseg ); // if (g_sim -> verbose_tracks ) // { // get_track_pool().add_track_segment( trkseg.id, trkseg ); // } }