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 // $Id: SteppingAction.cc,v 1.4 2006/09/06 09:56:06 maire Exp $ 27 /// \brief Implementation of the SteppingActio << 27 // GEANT4 tag $Name: geant4-08-03-patch-02 $ 28 // << 28 // 29 // << 30 //....oooOO0OOooo........oooOO0OOooo........oo 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 31 33 #include "SteppingAction.hh" 32 #include "SteppingAction.hh" 34 << 33 #include "PrimaryGeneratorAction.hh" >> 34 #include "RunAction.hh" 35 #include "HistoManager.hh" 35 #include "HistoManager.hh" 36 #include "Run.hh" << 36 #include "SteppingMessenger.hh" 37 37 38 #include "G4RunManager.hh" 38 #include "G4RunManager.hh" 39 39 40 //....oooOO0OOooo........oooOO0OOooo........oo 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 41 41 42 void SteppingAction::UserSteppingAction(const << 42 SteppingAction::SteppingAction(PrimaryGeneratorAction* prim, >> 43 RunAction* RuAct, HistoManager* Hist) >> 44 :primary(prim),runAction(RuAct), histoManager(Hist) 43 { 45 { 44 const G4StepPoint* endPoint = aStep->GetPost << 46 stepMessenger = new SteppingMessenger(this); 45 G4String procName = endPoint->GetProcessDefi << 47 fract = 0.1; >> 48 } 46 49 47 Run* run = static_cast<Run*>(G4RunManager::G << 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 48 51 49 G4bool transmit = (endPoint->GetStepStatus() << 52 SteppingAction::~SteppingAction() 50 if (transmit) { << 53 { 51 run->CountProcesses(procName); << 54 delete stepMessenger; 52 } << 55 } 53 else { << 54 // count real processes and sum track leng << 55 G4double stepLength = aStep->GetStepLength << 56 run->CountProcesses(procName); << 57 run->SumTrack(stepLength); << 58 } << 59 56 60 // plot final state << 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 // << 62 G4AnalysisManager* analysisManager = G4Analy << 63 58 64 // scattered primary particle << 59 void SteppingAction::UserSteppingAction(const G4Step* aStep) >> 60 { >> 61 G4StepPoint* endPoint = aStep->GetPostStepPoint(); >> 62 G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName(); >> 63 G4double stepLength = aStep->GetStepLength(); >> 64 >> 65 //count real processes (at least 1 secondary) and sum track length 65 // 66 // 66 G4int id = 1; << 67 G4TrackVector* secondary = fpSteppingManager->GetSecondary(); 67 if (aStep->GetTrack()->GetTrackStatus() == f << 68 G4bool transmit = (endPoint->GetStepStatus() <= fGeomBoundary); 68 G4double energy = endPoint->GetKineticEner << 69 if ((*secondary).size() > 0) { 69 analysisManager->FillH1(id, energy); << 70 runAction->CountProcesses(procName); 70 << 71 runAction->SumTrack(stepLength); 71 id = 2; << 72 G4ThreeVector direction = endPoint->GetMom << 73 G4double costeta = direction.x(); << 74 analysisManager->FillH1(id, costeta); << 75 } 72 } 76 << 73 else if (transmit) runAction->CountProcesses(procName); 77 // secondaries << 74 >> 75 //plot final state (only if continuous energy loss is small enough) 78 // 76 // 79 const std::vector<const G4Track*>* secondary << 77 G4double edep = aStep->GetTotalEnergyDeposit(); 80 for (size_t lp = 0; lp < (*secondary).size() << 78 G4double E0 = primary->GetParticleGun()->GetParticleEnergy(); 81 G4double charge = (*secondary)[lp]->GetDef << 79 if (edep < fract*E0) { 82 if (charge != 0.) { << 80 83 id = 3; << 81 //scattered primary particle 84 } << 82 // 85 else { << 83 G4int id = 1; 86 id = 5; << 84 if (aStep->GetTrack()->GetTrackStatus() == fAlive) { 87 } << 85 G4double energy = endPoint->GetKineticEnergy(); 88 G4double energy = (*secondary)[lp]->GetKin << 86 histoManager->FillHisto(id,energy); 89 analysisManager->FillH1(id, energy); << 87 90 << 88 id = 2; 91 ++id; << 89 G4ThreeVector direction = endPoint->GetMomentumDirection(); 92 G4ThreeVector direction = (*secondary)[lp] << 90 G4double costeta = direction.x(); 93 G4double costeta = direction.x(); << 91 histoManager->FillHisto(id,costeta); 94 analysisManager->FillH1(id, costeta); << 92 } 95 << 93 96 // energy tranferred to charged secondarie << 94 //secondaries 97 if (charge != 0.) { << 95 // 98 run->SumeTransf(energy); << 96 //G4TrackVector* secondary = fpSteppingManager->GetSecondary(); >> 97 for (size_t lp=0; lp<(*secondary).size(); lp++) { >> 98 G4double charge = (*secondary)[lp]->GetDefinition()->GetPDGCharge(); >> 99 if (charge != 0.) id = 3; else id = 5; >> 100 G4double energy = (*secondary)[lp]->GetKineticEnergy(); >> 101 histoManager->FillHisto(id,energy); >> 102 >> 103 id++; >> 104 G4ThreeVector direction = (*secondary)[lp]->GetMomentumDirection(); >> 105 G4double costeta = direction.x(); >> 106 histoManager->FillHisto(id,costeta); >> 107 >> 108 //energy tranferred to charged secondaries >> 109 if (charge != 0.) runAction->SumeTransf(energy); 99 } 110 } 100 } 111 } 101 << 112 102 // kill event after first interaction 113 // kill event after first interaction 103 // 114 // 104 G4RunManager::GetRunManager()->AbortEvent(); << 115 G4RunManager::GetRunManager()->AbortEvent(); 105 } 116 } 106 117 107 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 119 >> 120 108 121