#include "G4VSensitiveDetector.hh" #include "CollSD.hh" #include "Hit.hh" #include "SteppingAction.hh" #include "G4VPhysicalVolume.hh" #include "G4HCofThisEvent.hh" #include "G4Step.hh" #include "G4SDManager.hh" #include "G4RunManager.hh" #include "G4ios.hh" #include "G4TouchableHistory.hh" //User defined sensitive detector - define component to be a detector in DetectorConstruction.cc CollSD::CollSD(G4String name) : G4VSensitiveDetector(name) { G4String HCname = "detectorCollection2"; collectionName.insert(HCname); } CollSD::~CollSD() {;} void CollSD::Initialize(G4HCofThisEvent* HCE) { detectorCollection = new HitsCollection(SensitiveDetectorName,collectionName[0]); HitID = -1; } G4bool CollSD::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist) { G4double edep = aStep->GetTotalEnergyDeposit(); //if particle detected as proton, record energy deposited if(aStep->GetTrack()->GetDefinition()->GetParticleName() == "proton"){ ::Hit* newHit = new ::Hit(); newHit->SetEdep(edep); HitID = detectorCollection->insert(newHit); return true; } } void CollSD::EndOfEvent(G4HCofThisEvent* HCE) { G4String HCname = collectionName[0]; static G4int HCID = -1; if(HCID<0) HCID = G4SDManager::GetSDMpointer()->GetCollectionID(HCname); HCE->AddHitsCollection(HCID,detectorCollection); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void CollSD::clear() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void CollSD::DrawAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void CollSD::PrintAll() {}