![]() |
|
|||
File indexing completed on 2025-02-23 09:21:16
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // 0027 /// \file field/field01/field01.cc 0028 /// \brief Main program of the field/field01 example 0029 // 0030 // 0031 // 0032 // 0033 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0034 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0035 0036 #include "F01ActionInitialization.hh" 0037 #include "F01DetectorConstruction.hh" 0038 #include "F01RunAction.hh" 0039 #include "F01SteppingVerbose.hh" 0040 0041 #include "G4RunManagerFactory.hh" 0042 #include "G4Types.hh" 0043 #include "G4UImanager.hh" 0044 0045 // To control verbosity 0046 #include "FTFP_BERT.hh" 0047 0048 #include "G4EmParameters.hh" 0049 #include "G4HadronicParameters.hh" 0050 #include "G4PhysicsListHelper.hh" 0051 #include "G4StepLimiterPhysics.hh" 0052 #include "G4UIExecutive.hh" 0053 #include "G4VisExecutive.hh" 0054 #include "Randomize.hh" 0055 0056 // For Printing statistic from Transporation process(es) 0057 #include "G4CoupledTransportation.hh" 0058 #include "G4Electron.hh" 0059 #include "G4Transportation.hh" 0060 #include "G4TransportationParameters.hh" 0061 0062 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0063 0064 int main(int argc, char** argv) 0065 { 0066 // Instantiate G4UIExecutive if there are no arguments (interactive mode) 0067 G4UIExecutive* ui = nullptr; 0068 if (argc == 1) { 0069 ui = new G4UIExecutive(argc, argv); 0070 } 0071 0072 // Choose the Random engine 0073 // 0074 G4Random::setTheEngine(new CLHEP::RanecuEngine); 0075 0076 G4VSteppingVerbose::SetInstance(new F01SteppingVerbose); 0077 0078 // Construct the sequential (or default) run manager 0079 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Serial); 0080 0081 // G4TransportationWithMscType: fDisabled, fEnabled, fMultipleSteps 0082 // G4EmParameters::Instance()->SetTransportationWithMsc(G4TransportationWithMscType::fEnabled); 0083 0084 // Set mandatory initialization classes 0085 // 0086 // Detector construction 0087 auto detector = new F01DetectorConstruction(); 0088 // detector->SetUseFSALstepper(); // Uncomment to use FSAL steppers 0089 0090 runManager->SetUserInitialization(detector); 0091 0092 // Configure the use of low thresholds for looping particles 0093 // ( appropriate for typical applications using low-energy physics. ) 0094 // auto plHelper = G4PhysicsListHelper::GetPhysicsListHelper(); 0095 // plHelper->UseLowLooperThresholds(); 0096 // plHelper->UseHighLooperThresholds(); 0097 // Request a set of pre-selected values of the parameters for looping 0098 // particles: 0099 // - High for collider HEP applications, 0100 // - Low for 'low-E' applications, medical, .. 0101 // Note: If helper is used select low or high thresholds , it will overwrite 0102 // values from TransportationParameters! 0103 0104 // They are currently applied in the following order: 0105 // 1. Transportation Parameters - fine grained control in Transportation construction 0106 // 2. Physics List Helper - impose a fixed set of new values in Transport classes 0107 // 3. Run Action (F01RunAction) - revise values at Start of Run 0108 // 4. Tracking Action - could revise value at start of each track (not shown) 0109 // Note that this also could customise by particle type, e.g. giving different values 0110 // to mu-/mu+ , e-/e+ vs others) 0111 // If multiple are present, later methods overwrite previous ones in this list. 0112 0113 // Physics list 0114 G4VModularPhysicsList* physicsList = new FTFP_BERT; 0115 physicsList->RegisterPhysics(new G4StepLimiterPhysics()); 0116 runManager->SetUserInitialization(physicsList); 0117 0118 // User action initialization 0119 runManager->SetUserInitialization(new F01ActionInitialization(detector)); 0120 0121 G4double warningE = 10.0 * CLHEP::keV; 0122 G4double importantE = 0.1 * CLHEP::MeV; 0123 G4int numTrials = 30; 0124 0125 G4bool useTransportParams = true; // Use the new way - Nov 2022 0126 0127 if (useTransportParams) { 0128 auto transportParams = G4TransportationParameters::Instance(); 0129 transportParams->SetWarningEnergy(warningE); 0130 transportParams->SetImportantEnergy(importantE); 0131 transportParams->SetNumberOfTrials(numTrials); 0132 G4cout << "field01: Using G4TransportationParameters to set looper parameters." << G4endl; 0133 } 0134 else { 0135 // Fine grained control of thresholds for looping particles 0136 auto runAction = new F01RunAction(); 0137 runAction->SetWarningEnergy(warningE); 0138 // Looping particles with E < 10 keV will be killed after 1 step 0139 // with warning. 0140 // Looping particles with E > 10 keV will generate a warning. 0141 runAction->SetImportantEnergy(importantE); 0142 runAction->SetNumberOfTrials(numTrials); 0143 // Looping particles with E > 0.1 MeV will survive for up to 0144 // 30 'tracking' steps, and only be killed if they still loop. 0145 0146 G4cout << "field01: Using F01RunAction to set looper parameters." << G4endl; 0147 runManager->SetUserAction(runAction); 0148 } 0149 0150 // Note: this mechanism overwrites the thresholds established by 0151 // the call to UseLowLooperThresholds() above. 0152 0153 // Suppress large verbosity from EM & hadronic processes 0154 G4EmParameters::Instance()->SetVerbose(0); 0155 G4HadronicParameters::Instance()->SetVerboseLevel(0); 0156 0157 // Initialize G4 kernel 0158 // 0159 runManager->Initialize(); 0160 0161 // Initialize visualization 0162 // 0163 // G4VisExecutive can take a verbosity argument - see /vis/verbose 0164 G4VisManager* visManager = new G4VisExecutive("Quiet"); 0165 visManager->Initialize(); 0166 0167 // Get the pointer to the User Interface manager 0168 // 0169 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0170 0171 if (!ui) // batch mode 0172 { 0173 G4String command = "/control/execute "; 0174 G4String fileName = argv[1]; 0175 UImanager->ApplyCommand(command + fileName); 0176 } 0177 else { // interactive mode : define UI session 0178 UImanager->ApplyCommand("/control/execute init_vis.mac"); 0179 if (ui->IsGUI()) UImanager->ApplyCommand("/control/execute gui.mac"); 0180 ui->SessionStart(); 0181 delete ui; 0182 } 0183 0184 // Statistics of tracks killed by G4Transportation are currently 0185 // printed in the RunAction's EndOfEvent action. 0186 // ( Eventually a summary could be provided here instead or as well. ) 0187 0188 delete visManager; 0189 delete runManager; 0190 0191 return 0; 0192 } 0193 0194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |