ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SteppingAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SteppingAction.cc
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 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "SteppingAction.hh"
34 #include "Run.hh"
35 
36 #include "G4RunManager.hh"
37 #include "G4SteppingManager.hh"
38 #include "G4VProcess.hh"
39 #include "G4ParticleTypes.hh"
40 #include "G4UnitsTable.hh"
41 #include "HistoManager.hh"
42 #include "G4EmProcessSubType.hh"
43 #include "G4SystemOfUnits.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
49 { }
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 { }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 {
60  Run* run = static_cast<Run*>(
62 
63  const G4VProcess* process = aStep->GetPostStepPoint()->GetProcessDefinedStep();
64  if (process == 0) { return; }
65 
66  static G4int iCalled=0;
67  const G4int nprint=0; // set to 10 to get debug print for first 10 calls
68 
69  if (fSynchrotronRadiation == process->GetProcessSubType())
70  {
71  ++iCalled;
72  const G4StepPoint* PrePoint = aStep->GetPreStepPoint();
73  const G4TrackVector* secondary = fpSteppingManager->GetSecondary();
74 
75  //(*secondary)[lp-1] points to the last photon generated
76  //
77  size_t lp=(*secondary).size();
78  if (lp)
79  {
80  G4double Egamma = (*secondary)[lp-1]->GetTotalEnergy();
81  run->f_n_gam_sync++;
82  run->f_e_gam_sync += Egamma;
83  run->f_e_gam_sync2 += Egamma*Egamma;
84  if (Egamma > run->f_e_gam_sync_max)
85  {
86  run->f_e_gam_sync_max = Egamma;
87  }
88  run->f_lam_gam_sync += aStep->GetStepLength();
89  if (iCalled<nprint)
90  {
91  G4double Eelec = PrePoint->GetTotalEnergy();
92  G4ThreeVector Pelec = PrePoint->GetMomentum();
93  G4ThreeVector PGamma = (*secondary)[lp-1]->GetMomentum();
94  G4bool IsGamma =
95  ((*secondary)[lp-1]->GetDefinition() == G4Gamma::Gamma());
96 
97  G4cout << "UserSteppingAction processName="
98  << process->GetProcessName()
99  << " Step Length=" << std::setw(6)
100  << G4BestUnit(aStep->GetStepLength(),"Length")
101  << " Eelec=" << G4BestUnit(Eelec,"Energy")
102  << " Pelec=" << G4BestUnit(Pelec,"Energy")
103  << " IsGamma=" << IsGamma
104  << " Egamma=" << G4BestUnit(Egamma,"Energy")
105  << " PGamma=" << G4BestUnit(PGamma,"Energy")
106  << " #secondaries lp=" << lp
107  << '\n';
108  }
109 
110  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
111  analysisManager->FillH1(1,Egamma);
112 
113  // power spectrum : gamma weighted with its energy
114  analysisManager->FillH1(2,Egamma,Egamma/keV);
115 
116  analysisManager->FillH1(3,aStep->GetStepLength());
117  }
118  }
119 }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......