#include "BeHit.hh" #include "BeDetectorSD.hh" #include "BeEventAction.hh" #include "G4HCofThisEvent.hh" #include "G4Step.hh" #include "G4ThreeVector.hh" #include "G4SDManager.hh" #include "G4ios.hh" #include "G4TouchableHistory.hh" #include "G4Track.hh" #include "G4SystemOfUnits.hh" #include "BeAnalysis.hh" #include "BeRunAction.hh" //using CHLEP::MeV; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4double noOfcells = 25; BeDetectorSD::BeDetectorSD(const G4String& name, const G4String& hitsCollectionName) : G4VSensitiveDetector(name), fHitsCollection(NULL) { collectionName.insert(hitsCollectionName); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... BeDetectorSD::~BeDetectorSD() { } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void BeDetectorSD::Initialize(G4HCofThisEvent* hce) { // Create hits collection fHitsCollection = new BeHitsCollection(SensitiveDetectorName, collectionName[0]); // Add this collection in hce hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); hce->AddHitsCollection( hcID, fHitsCollection ); //fill detector with zero energy deposition for (G4int i=0;iinsert(new BeHit()); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4bool BeDetectorSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) { // energy deposit auto edep = aStep->GetTotalEnergyDeposit(); if (edep==0.) return true; BeHit* newHit = new BeHit(); newHit->SetHitID(aStep->GetPreStepPoint()->GetTouchableHandle() ->GetCopyNumber()); newHit->SetEdep(edep); newHit->SetPos(aStep->GetPostStepPoint()->GetPosition()); fHitsCollection->insert( newHit ); // newHit->Print(); // Get hit for total accounting // BeHit* hitTotal = (*fHitsCollection)[fHitsCollection->entries()-1]; // Add values // newHit->Add(edep); // hitTotal->Add(edep); return true; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void BeDetectorSD::EndOfEvent(G4HCofThisEvent*) { G4int NbHits = fHitsCollection->entries(); G4double TotalEdep = 0; G4double cell = 0; for (int i=0;iGetEdep(); } for (int i=NbHits-1;iGetHitID(); } // G4ThreeVector IntPos = (*fHitsCollection)[0]->GetPos(); // G4double cell = (*fHitsCollection)[0]->GetHitID(); G4cout << TotalEdep << " " << cell << G4endl; G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); //fill histograms analysisManager->FillH1(1, TotalEdep); // m_energyHistogram->Fill(TotalEdep); // analysisManager->FillNtupleDColumn(0, TotalEdep); // analysisManager->FillNtupleDColumn(1, cell); // analysisManager->FillNtupleDColumn(2, IntPos); // << "-------->Hits Collection: in this event they are " << NbHits // << " hits in the detector 1: " << G4endl; // for ( G4int i=0; iPrint(); }