Geant4  10.00.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 67797 2013-03-08 09:52:18Z maire $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "SteppingAction.hh"
35 #include "RunAction.hh"
36 #include "G4SteppingManager.hh"
37 #include "G4VProcess.hh"
38 #include "G4ParticleTypes.hh"
39 #include "G4UnitsTable.hh"
40 #include "HistoManager.hh"
41 #include "G4EmProcessSubType.hh"
42 #include "G4SystemOfUnits.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47 :G4UserSteppingAction(),fRunAction(RuAct)
48 { }
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53 { }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {
59  const G4VProcess* process = aStep->GetPostStepPoint()->GetProcessDefinedStep();
60  if (process == 0) { return; }
61 
62  static G4int iCalled=0;
63  const G4int nprint=0; // set to 10 to get debug print for first 10 calls
64 
65  if (fSynchrotronRadiation == process->GetProcessSubType())
66  {
67  ++iCalled;
68  const G4StepPoint* PrePoint = aStep->GetPreStepPoint();
69  const G4TrackVector* secondary = fpSteppingManager->GetSecondary();
70 
71  //(*secondary)[lp-1] points to the last photon generated
72  //
73  size_t lp=(*secondary).size();
74  if (lp)
75  {
76  G4double Egamma = (*secondary)[lp-1]->GetTotalEnergy();
78  fRunAction->f_e_gam_sync += Egamma;
79  fRunAction->f_e_gam_sync2 += Egamma*Egamma;
80  if (Egamma > fRunAction->f_e_gam_sync_max)
81  {
82  fRunAction->f_e_gam_sync_max = Egamma;
83  }
85  if (iCalled<nprint)
86  {
87  G4double Eelec = PrePoint->GetTotalEnergy();
88  G4ThreeVector Pelec = PrePoint->GetMomentum();
89  G4ThreeVector PGamma = (*secondary)[lp-1]->GetMomentum();
90  G4bool IsGamma =
91  ((*secondary)[lp-1]->GetDefinition() == G4Gamma::Gamma());
92 
93  G4cout << "UserSteppingAction processName=" << process->GetProcessName()
94  << " Step Length=" << std::setw(6)
95  << G4BestUnit(aStep->GetStepLength(),"Length")
96  << " Eelec=" << G4BestUnit(Eelec,"Energy")
97  << " Pelec=" << G4BestUnit(Pelec,"Energy")
98  << " IsGamma=" << IsGamma
99  << " Egamma=" << G4BestUnit(Egamma,"Energy")
100  << " PGamma=" << G4BestUnit(PGamma,"Energy")
101  << " #secondaries lp=" << lp
102  << '\n';
103  }
104 
105  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
106  analysisManager->FillH1(1,Egamma);
107 
108  // power spectrum : gamma weighted with its energy
109  analysisManager->FillH1(2,Egamma,Egamma/keV);
110 
111  analysisManager->FillH1(3,aStep->GetStepLength());
112  }
113  }
114 }
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double GetTotalEnergy() const
RunAction * fRunAction
CLHEP::Hep3Vector G4ThreeVector
G4double GetStepLength() const
G4double f_e_gam_sync2
Definition: RunAction.hh:58
const G4TrackVector * GetSecondary() const
G4ThreeVector GetMomentum() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4int f_n_gam_sync
Definition: RunAction.hh:57
void UserSteppingAction(const G4Step *)
int G4int
Definition: G4Types.hh:78
G4StepPoint * GetPreStepPoint() const
G4GLOB_DLL std::ostream G4cout
G4SteppingManager * fpSteppingManager
bool G4bool
Definition: G4Types.hh:79
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:46
Definition: G4Step.hh:76
G4double f_e_gam_sync_max
Definition: RunAction.hh:59
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4double f_e_gam_sync
Definition: RunAction.hh:58
const G4VProcess * GetProcessDefinedStep() const
std::vector< G4Track * > G4TrackVector
G4StepPoint * GetPostStepPoint() const
G4double f_lam_gam_sync
Definition: RunAction.hh:60
static const double keV
Definition: G4SIunits.hh:195
double G4double
Definition: G4Types.hh:76
G4int GetProcessSubType() const
Definition: G4VProcess.hh:426