Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file SteppingAction.cc 26 /// \file SteppingAction.cc 27 /// \brief Implementation of the SteppingActio 27 /// \brief Implementation of the SteppingAction class 28 // 28 // 29 // << 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 32 33 #include "SteppingAction.hh" 33 #include "SteppingAction.hh" 34 << 35 #include "HistoManager.hh" << 36 #include "Run.hh" 34 #include "Run.hh" 37 << 35 #include "HistoManager.hh" 38 #include "G4RunManager.hh" 36 #include "G4RunManager.hh" 39 37 40 //....oooOO0OOooo........oooOO0OOooo........oo 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 41 39 >> 40 SteppingAction::SteppingAction() >> 41 :G4UserSteppingAction() >> 42 { } >> 43 >> 44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 45 >> 46 SteppingAction::~SteppingAction() >> 47 { } >> 48 >> 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 50 42 void SteppingAction::UserSteppingAction(const 51 void SteppingAction::UserSteppingAction(const G4Step* aStep) 43 { 52 { 44 const G4StepPoint* endPoint = aStep->GetPost 53 const G4StepPoint* endPoint = aStep->GetPostStepPoint(); 45 G4String procName = endPoint->GetProcessDefi 54 G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName(); 46 << 55 47 Run* run = static_cast<Run*>(G4RunManager::G << 56 Run* run = static_cast<Run*>( 48 << 57 G4RunManager::GetRunManager()->GetNonConstCurrentRun()); 49 G4bool transmit = (endPoint->GetStepStatus() << 58 50 if (transmit) { << 59 G4bool transmit = (endPoint->GetStepStatus() <= fGeomBoundary); 51 run->CountProcesses(procName); << 60 if (transmit) { run->CountProcesses(procName); } 52 } << 61 else { 53 else { << 62 //count real processes and sum track length 54 // count real processes and sum track leng << 55 G4double stepLength = aStep->GetStepLength 63 G4double stepLength = aStep->GetStepLength(); 56 run->CountProcesses(procName); << 64 run->CountProcesses(procName); 57 run->SumTrack(stepLength); 65 run->SumTrack(stepLength); 58 } 66 } 59 << 67 60 // plot final state << 68 //plot final state 61 // 69 // 62 G4AnalysisManager* analysisManager = G4Analy 70 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 63 << 71 64 // scattered primary particle << 72 //scattered primary particle 65 // 73 // 66 G4int id = 1; 74 G4int id = 1; 67 if (aStep->GetTrack()->GetTrackStatus() == f 75 if (aStep->GetTrack()->GetTrackStatus() == fAlive) { 68 G4double energy = endPoint->GetKineticEner << 76 G4double energy = endPoint->GetKineticEnergy(); 69 analysisManager->FillH1(id, energy); << 77 analysisManager->FillH1(id,energy); 70 78 71 id = 2; 79 id = 2; 72 G4ThreeVector direction = endPoint->GetMom 80 G4ThreeVector direction = endPoint->GetMomentumDirection(); 73 G4double costeta = direction.x(); 81 G4double costeta = direction.x(); 74 analysisManager->FillH1(id, costeta); << 82 analysisManager->FillH1(id,costeta); 75 } << 83 } 76 << 84 77 // secondaries << 85 //secondaries 78 // 86 // 79 const std::vector<const G4Track*>* secondary << 87 const std::vector<const G4Track*>* secondary 80 for (size_t lp = 0; lp < (*secondary).size() << 88 = aStep->GetSecondaryInCurrentStep(); >> 89 for (size_t lp=0; lp<(*secondary).size(); lp++) { 81 G4double charge = (*secondary)[lp]->GetDef 90 G4double charge = (*secondary)[lp]->GetDefinition()->GetPDGCharge(); 82 if (charge != 0.) { << 91 if (charge != 0.) { id = 3; } else { id = 5; } 83 id = 3; << 84 } << 85 else { << 86 id = 5; << 87 } << 88 G4double energy = (*secondary)[lp]->GetKin 92 G4double energy = (*secondary)[lp]->GetKineticEnergy(); 89 analysisManager->FillH1(id, energy); << 93 analysisManager->FillH1(id,energy); 90 94 91 ++id; 95 ++id; 92 G4ThreeVector direction = (*secondary)[lp] << 96 G4ThreeVector direction = (*secondary)[lp]->GetMomentumDirection(); 93 G4double costeta = direction.x(); 97 G4double costeta = direction.x(); 94 analysisManager->FillH1(id, costeta); << 98 analysisManager->FillH1(id,costeta); 95 << 99 96 // energy tranferred to charged secondarie << 100 //energy tranferred to charged secondaries 97 if (charge != 0.) { << 101 if (charge != 0.) { run->SumeTransf(energy); } 98 run->SumeTransf(energy); << 99 } << 100 } 102 } 101 << 103 102 // kill event after first interaction 104 // kill event after first interaction 103 // 105 // 104 G4RunManager::GetRunManager()->AbortEvent(); << 106 G4RunManager::GetRunManager()->AbortEvent(); 105 } 107 } 106 108 107 //....oooOO0OOooo........oooOO0OOooo........oo 109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 110 >> 111 108 112