// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // /// \file SteppingAction.cc /// \brief Implementation of the SteppingAction class // // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... #include "G4Threading.hh" #include "G4UnitsTable.hh" /* #include "G4BestUnit.hh" */ #include "G4SystemOfUnits.hh" #include "SteppingAction.hh" #include "Run.hh" #include "TrackingAction.hh" /* #include "HistoManager.hh" */ #include "G4AnalysisManager.hh" #include "G4RunManager.hh" #include "G4OpticalPhoton.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... SteppingAction::SteppingAction(TrackingAction* TrAct) : G4UserSteppingAction(),fTrackingAction(TrAct) { } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... SteppingAction::~SteppingAction() { } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void SteppingAction::UserSteppingAction(const G4Step* aStep) { // count processes const G4StepPoint* endPoint = aStep->GetPostStepPoint(); const G4StepPoint* prePoint = aStep->GetPreStepPoint(); const G4VProcess* process = endPoint->GetProcessDefinedStep(); G4int threadID = G4Threading::G4GetThreadId(); if (endPoint && prePoint && process) { G4String process_name = process->GetProcessName(); Run* run = static_cast( G4RunManager::GetRunManager()->GetNonConstCurrentRun()); run->CountProcesses(process); /* if (run) { */ G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); if (aStep->GetTrack()->GetDefinition()== G4OpticalPhoton::Definition() && aStep->GetTrack()->GetCurrentStepNumber()==1) { G4int photon_eventid = G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID(); /* G4ThreeVector photon_finish = track->GetPosition(); */ G4ThreeVector photon_finish = aStep->GetPostStepPoint()->GetPosition(); G4double photon_x = photon_finish.x(); G4double photon_y = photon_finish.y(); G4double photon_z = photon_finish.z(); /* G4double photon_t = aStep->GetPostStepPoint()->GetGlobalTime(); */ G4double photon_t = aStep->GetTrack()->GetGlobalTime(); G4String photon_parent_name = aStep->GetTrack()->GetDynamicParticle()->GetParticleDefinition()->GetParticleName(); G4ThreeVector photonDirection = aStep->GetTrack()->GetMomentumDirection(); G4ThreeVector photonMom = aStep->GetTrack()->GetMomentum(); G4double totalEnergy = aStep->GetTrack()->GetTotalEnergy(); G4double photon_px = photonMom.x(); G4double photon_py = photonMom.y(); G4double photon_pz = photonMom.z(); if (!photon_x) { G4cout<<"PHOTON X PROB"<FillNtupleIColumn(0,0,photon_eventid); */ /* analysisManager->FillNtupleIColun(0,1,trackID); */ analysisManager->FillNtupleDColumn(1,1,photon_finish[0]); analysisManager->FillNtupleDColumn(1,2,photon_finish[1]); analysisManager->FillNtupleDColumn(1,3,photon_finish[2]); analysisManager->FillNtupleDColumn(1,4,photon_t); analysisManager->FillNtupleDColumn(1,5,totalEnergy); analysisManager->FillNtupleDColumn(1,6,photonMom[0]); analysisManager->FillNtupleDColumn(1,7,photonMom[1]); analysisManager->FillNtupleDColumn(1,8,photonMom[2]); /* analysisManager->FillNtupleSColumn(0,10,photon_parent_name); */ analysisManager->AddNtupleRow(0); } //NEUTRON CAPTURES if (!process_name.compare("nCapture")) { G4cout << "!CAPTURE---"<GetPostStepPoint()->GetGlobalTime(); G4ThreeVector position_finish = aStep->GetPostStepPoint()->GetPosition(); G4int runid = run->GetRunID(); G4int eventid = G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID(); G4double ekinpre = prePoint->GetKineticEnergy(); // Get the information about the particles in the current event (since each event only has one primary its easy) const G4Event* nCapEvent = G4RunManager::GetRunManager()->GetCurrentEvent(); const G4PrimaryVertex* nCapPrimaryVertex = nCapEvent->GetPrimaryVertex(); //Now we can retrieve information about the primary that generated the neutron capture G4PrimaryParticle* nCapPrimary = nCapPrimaryVertex->GetPrimary(); G4int nCapPrimaryPDGCode = nCapPrimary->GetPDGcode(); G4double nCapPrimaryEkin = nCapPrimary->GetKineticEnergy(); G4double nCapPrimaryPx = nCapPrimary->GetPx(); G4double nCapPrimaryPy = nCapPrimary->GetPy(); G4double nCapPrimaryPz = nCapPrimary->GetPz(); G4int nCapPrimaryCharge= nCapPrimary->GetCharge(); G4cout << G4BestUnit(t_finish, "Time")<< G4endl; G4cout << "(" << G4BestUnit(position_finish[0],"Length") << "," << G4BestUnit(position_finish[1],"Length") << "," << G4BestUnit(position_finish[2],"Length")<< ")" <FillNtupleIColumn(1,0,runid); //Fill the event column for the run analysisManager->FillNtupleIColumn(1,1,eventid); //Fill the capture time analysisManager->FillNtupleDColumn(1,2,t_finish); //Fill the x position of the Capture analysisManager->FillNtupleDColumn(1,3,position_finish[0]); //Fill the y position of the capture analysisManager->FillNtupleDColumn(1,4,position_finish[1]); //Fill the z position of the capture analysisManager->FillNtupleDColumn(1,5,position_finish[2]); //Fill the energy of the capture analysisManager->FillNtupleDColumn(1,6,ekinpre); analysisManager->AddNtupleRow(1); } /* } */ }} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......