#include "G4VSensitiveDetector.hh" #include "SensitiveDetector.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" SensitiveDetector::SensitiveDetector(G4String name) : G4VSensitiveDetector(name) { G4String HCname = "detectorCollection"; collectionName.insert(HCname); } SensitiveDetector::~SensitiveDetector() {;} void SensitiveDetector::Initialize(G4HCofThisEvent* HCE) { detectorCollection = new HitsCollection(SensitiveDetectorName,collectionName[0]); HitID = -1; } G4bool SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist) { G4double edep = aStep->GetTotalEnergyDeposit(); if(aStep->GetTrack()->GetDefinition()->GetParticleName() == "proton"){ ::Hit* newHit = new ::Hit(); newHit->SetEdep(edep); HitID = detectorCollection->insert(newHit); return true; } } void SensitiveDetector::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 SensitiveDetector::clear() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void SensitiveDetector::DrawAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void SensitiveDetector::PrintAll() {}