#include "PhaseSpaceSD.hh" #include "PhaseSpaceHit.hh" #include "G4VPhysicalVolume.hh" #include "G4LogicalVolume.hh" #include "G4Track.hh" #include "G4Step.hh" #include "G4ParticleDefinition.hh" #include "G4VTouchable.hh" #include "G4TouchableHistory.hh" #include "G4SystemOfUnits.hh" #include "G4ios.hh" #include "G4SDManager.hh" PhaseSpaceSD::PhaseSpaceSD( G4String name ) :G4VSensitiveDetector(name) { G4cout << "Creating SD with name: " << name << G4endl; collectionName.insert("hitsCollection"); } PhaseSpaceSD::~PhaseSpaceSD() {;} void PhaseSpaceSD::Initialize( G4HCofThisEvent* HCE ) { fHitsCollection = new PhaseSpaceHitsCollection( GetName(), collectionName[0] ); G4int HCID = GetCollectionID(0); HCE->AddHitsCollection( HCID, fHitsCollection ); } G4bool PhaseSpaceSD::ProcessHits( G4Step* step, G4TouchableHistory* ) { // Check if ionising // G4double edep = step->GetTotalEnergyDeposit(); // if( edep <= 0 ) return false; G4StepPoint* preStep = step->GetPreStepPoint(); const G4VTouchable* touchable = step->GetPreStepPoint()->GetTouchable(); // Only score incoming tracks, ie when the starting point of a step is on the boundary if( preStep->GetStepStatus() == fGeomBoundary ){ // Get parameters from track and step G4int parentID = step->GetTrack()->GetParentID(); G4String particleName = step->GetTrack()->GetDefinition()->GetParticleName(); G4ThreeVector pos = preStep->GetPosition(); G4ThreeVector mom = preStep->GetMomentumDirection(); G4double energy = preStep->GetKineticEnergy(); G4int copyNo = touchable->GetVolume()->GetCopyNo(); // Create hit with parameters from track and step PhaseSpaceHit* hit = new PhaseSpaceHit( copyNo, parentID, particleName, pos, mom, energy ); hit->IncrementCount(); // Populate hits collection fHitsCollection->insert(hit); } return true; } void PhaseSpaceSD::EndOfEvent( G4HCofThisEvent* ) {;} void PhaseSpaceSD::clear() {;} void PhaseSpaceSD::DrawAll() {;} void PhaseSpaceSD::PrintAll() {;}