ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F01RunAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file F01RunAction.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 //
26 #include "F01RunAction.hh"
27 #include "globals.hh"
28 #include "G4SystemOfUnits.hh"
29 #include "G4Run.hh"
30 
31 #include "G4ParticleDefinition.hh"
32 #include "G4Electron.hh"
33 #include "G4ProcessManager.hh"
34 #include "G4Transportation.hh"
36 
38  theWarningEnergy = 1.0 * CLHEP::kiloelectronvolt; // Arbitrary
39  theImportantEnergy = 10.0 * CLHEP::kiloelectronvolt; // Arbitrary
40  theNumberOfTrials = 15; // Arbitrary
41  // Applications should determine these thresholds according to
42  // - physics requirements, and
43  // - the computing cost of continuing integration for looping tracks
44 }
45 
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
49 
51  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
52 
53  G4cout << " Calling F01RunAction::ChangeLooperParameters() " << G4endl;
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
58 
59 void F01RunAction::
61 {
62  if( particleDef == nullptr )
63  particleDef = G4Electron::Definition();
64  auto transportPair= findTransportation( particleDef );
65  auto transport = transportPair.first;
66  auto coupledTransport = transportPair.second;
67 
68  if( transport != nullptr )
69  {
70  // Change the values of the looping particle parameters of Transportation
71  if( theWarningEnergy >= 0.0 )
72  transport->SetThresholdWarningEnergy( theWarningEnergy );
73  if( theImportantEnergy >= 0.0 )
74  transport->SetThresholdImportantEnergy( theImportantEnergy );
75  if( theNumberOfTrials > 0 )
76  transport->SetThresholdTrials( theNumberOfTrials );
77  }
78  else if( coupledTransport != nullptr )
79  {
80  // Change the values for Coupled Transport
81  if( theWarningEnergy >= 0.0 )
82  coupledTransport->SetThresholdWarningEnergy( theWarningEnergy );
83  if( theImportantEnergy >= 0.0 )
84  coupledTransport->SetThresholdImportantEnergy( theImportantEnergy );
85  if( theNumberOfTrials > 0 )
86  coupledTransport->SetThresholdTrials( theNumberOfTrials );
87  }
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
91 
93  if( theVerboseLevel > 1 )
94  G4cout << G4endl << G4endl
95  << " ########### Track Statistics for Transportation process(es) "
96  << " ########### " << G4endl
97  << " ############################################## "
98  << " ####################### " << G4endl << G4endl;
99 
100  auto transportPair= findTransportation( G4Electron::Definition() );
101  auto transport = transportPair.first;
102  auto coupledTransport = transportPair.second;
103  if( transport) { transport->PrintStatistics(G4cout); }
104  else if( coupledTransport) { coupledTransport->PrintStatistics(G4cout); }
105 }
106 
107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 
109 std::pair<G4Transportation*, G4CoupledTransportation*>
111  bool reportError )
112 {
113  const auto *partPM= particleDef->GetProcessManager();
114 
115  G4VProcess* partTransport = partPM->GetProcess("Transportation");
116  auto transport= dynamic_cast<G4Transportation*>(partTransport);
117 
118  partTransport = partPM->GetProcess("CoupledTransportation");
119  auto coupledTransport=
120  dynamic_cast<G4CoupledTransportation*>(partTransport);
121 
122  if( reportError && !transport && !coupledTransport )
123  {
124  G4cerr << "Unable to find Transportation process for particle type "
125  << particleDef->GetParticleName()
126  << " ( PDG code = " << particleDef->GetPDGEncoding() << " ) "
127  << G4endl;
128  }
129 
130  return
131  std::make_pair( transport, coupledTransport );
132  // <G4Transportation*, G4CoupledTransportation*>
133 }