#include "mySD.hh" #include "G4Step.hh" #include "G4Track.hh" #include "myHit.hh" #include "G4HCofThisEvent.hh" #include "G4Step.hh" #include "G4ThreeVector.hh" #include "G4SDManager.hh" #include "G4ios.hh" class G4Step; class G4HCofThisEvent; mySD::mySD(G4String name):G4VSensitiveDetector(name),collectionID(-1) { collectionName.insert(hitsCollectionName);} mySD::~mySD() {} void mySD::Initialize(G4HCofThisEvent *HCE) { if(collectionID<0) collectionID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); fHitsCollection = new myHitCollection(SensitiveDetectorName,collectionName[0]); HCE->AddHitsCollection(collectionID,fHitsCollection); } G4bool mySD::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhist) { G4double edep = aStep->GetTotalEnergyDeposit(); if (edep==0.) return false; auto newHit = new myHit(); newHit->SetEdep(edep); newHit->SetPos(aStep->GetPostStepPoint()->GetPosition()); fHitsCollection->insert( newHit ); //newHit->Print(); return true; } void mySD::EndOfEvent(G4HCofThisEvent*) { if ( verboseLevel>1 ) { G4int nofHits = fHitsCollection->entries(); G4cout << G4endl << "-------->Hits Collection: in this event they are " << nofHits << " hits in the tracker chambers: " << G4endl; for ( G4int i=0; iPrint(); } }