Geant4  10.02.p01
SteppingAction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 // $Id: SteppingAction.cc 84365 2014-10-14 12:43:52Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "SteppingAction.hh"
35 #include "Run.hh"
36 
37 #include "G4RunManager.hh"
38 #include "G4SteppingManager.hh"
39 #include "G4VProcess.hh"
40 #include "G4ParticleTypes.hh"
41 #include "G4UnitsTable.hh"
42 #include "HistoManager.hh"
43 #include "G4EmProcessSubType.hh"
44 #include "G4SystemOfUnits.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
50 { }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 { }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {
61  Run* run = static_cast<Run*>(
63 
64  const G4VProcess* process = aStep->GetPostStepPoint()->GetProcessDefinedStep();
65  if (process == 0) { return; }
66 
67  static G4int iCalled=0;
68  const G4int nprint=0; // set to 10 to get debug print for first 10 calls
69 
70  if (fSynchrotronRadiation == process->GetProcessSubType())
71  {
72  ++iCalled;
73  const G4StepPoint* PrePoint = aStep->GetPreStepPoint();
74  const G4TrackVector* secondary = fpSteppingManager->GetSecondary();
75 
76  //(*secondary)[lp-1] points to the last photon generated
77  //
78  size_t lp=(*secondary).size();
79  if (lp)
80  {
81  G4double Egamma = (*secondary)[lp-1]->GetTotalEnergy();
82  run->f_n_gam_sync++;
83  run->f_e_gam_sync += Egamma;
84  run->f_e_gam_sync2 += Egamma*Egamma;
85  if (Egamma > run->f_e_gam_sync_max)
86  {
87  run->f_e_gam_sync_max = Egamma;
88  }
89  run->f_lam_gam_sync += aStep->GetStepLength();
90  if (iCalled<nprint)
91  {
92  G4double Eelec = PrePoint->GetTotalEnergy();
93  G4ThreeVector Pelec = PrePoint->GetMomentum();
94  G4ThreeVector PGamma = (*secondary)[lp-1]->GetMomentum();
95  G4bool IsGamma =
96  ((*secondary)[lp-1]->GetDefinition() == G4Gamma::Gamma());
97 
98  G4cout << "UserSteppingAction processName="
99  << process->GetProcessName()
100  << " Step Length=" << std::setw(6)
101  << G4BestUnit(aStep->GetStepLength(),"Length")
102  << " Eelec=" << G4BestUnit(Eelec,"Energy")
103  << " Pelec=" << G4BestUnit(Pelec,"Energy")
104  << " IsGamma=" << IsGamma
105  << " Egamma=" << G4BestUnit(Egamma,"Energy")
106  << " PGamma=" << G4BestUnit(PGamma,"Energy")
107  << " #secondaries lp=" << lp
108  << '\n';
109  }
110 
111  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
112  analysisManager->FillH1(1,Egamma);
113 
114  // power spectrum : gamma weighted with its energy
115  analysisManager->FillH1(2,Egamma,Egamma/keV);
116 
117  analysisManager->FillH1(3,aStep->GetStepLength());
118  }
119  }
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double GetTotalEnergy() const
CLHEP::Hep3Vector G4ThreeVector
G4double GetStepLength() const
const G4TrackVector * GetSecondary() const
G4ThreeVector GetMomentum() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void UserSteppingAction(const G4Step *)
int G4int
Definition: G4Types.hh:78
G4StepPoint * GetPreStepPoint() const
G4GLOB_DLL std::ostream G4cout
G4double f_e_gam_sync_max
Definition: Run.hh:57
G4SteppingManager * fpSteppingManager
bool G4bool
Definition: G4Types.hh:79
G4double f_e_gam_sync2
Definition: Run.hh:56
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:66
Definition: G4Step.hh:76
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
const G4VProcess * GetProcessDefinedStep() const
std::vector< G4Track * > G4TrackVector
G4StepPoint * GetPostStepPoint() const
static const double keV
Definition: G4SIunits.hh:213
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4double f_e_gam_sync
Definition: Run.hh:56
G4int GetProcessSubType() const
Definition: G4VProcess.hh:426
G4Run * GetNonConstCurrentRun() const
G4int f_n_gam_sync
Definition: Run.hh:55
G4double f_lam_gam_sync
Definition: Run.hh:58