|
|
|||
File indexing completed on 2025-11-07 09:22:33
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0032 0033 #include "F01ActionInitialization.hh" 0034 #include "F01DetectorConstruction.hh" 0035 #include "F01RunAction.hh" 0036 #include "F01SteppingVerbose.hh" 0037 0038 #include "G4RunManagerFactory.hh" 0039 #include "G4Types.hh" 0040 #include "G4UImanager.hh" 0041 0042 #include "FTFP_BERT.hh" 0043 0044 #include "G4EmParameters.hh" 0045 #include "G4HadronicParameters.hh" 0046 #include "G4PhysicsListHelper.hh" 0047 #include "G4StepLimiterPhysics.hh" 0048 #include "G4UIExecutive.hh" 0049 #include "G4VisExecutive.hh" 0050 #include "Randomize.hh" 0051 0052 // For Printing statistic from Transporation process(es) 0053 #include "G4CoupledTransportation.hh" 0054 #include "G4Electron.hh" 0055 #include "G4Transportation.hh" 0056 #include "G4TransportationParameters.hh" 0057 0058 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0059 0060 int main(int argc, char** argv) 0061 { 0062 // Instantiate G4UIExecutive if there are no arguments (interactive mode) 0063 // 0064 G4UIExecutive* ui = nullptr; 0065 if (argc == 1) { 0066 ui = new G4UIExecutive(argc, argv); 0067 } 0068 0069 // Setting the application-specific SteppingVerbose 0070 // 0071 auto verbosity = new F01SteppingVerbose; 0072 0073 // Construct the default run manager 0074 auto runManager = G4RunManagerFactory::CreateRunManager(); 0075 0076 // G4TransportationWithMscType: fDisabled, fEnabled, fMultipleSteps 0077 // G4EmParameters::Instance()->SetTransportationWithMsc(G4TransportationWithMscType::fEnabled); 0078 0079 // Set mandatory initialization classes 0080 // 0081 // Detector construction 0082 auto detector = new F01DetectorConstruction(); 0083 // detector->SetUseFSALstepper(); // Uncomment to use FSAL steppers 0084 0085 runManager->SetUserInitialization(detector); 0086 0087 // Configure the use of low thresholds for looping particles 0088 // ( appropriate for typical applications using low-energy physics. ) 0089 // auto plHelper = G4PhysicsListHelper::GetPhysicsListHelper(); 0090 // plHelper->UseLowLooperThresholds(); 0091 // plHelper->UseHighLooperThresholds(); 0092 // Request a set of pre-selected values of the parameters for looping 0093 // particles: 0094 // - High for collider HEP applications, 0095 // - Low for 'low-E' applications, medical, .. 0096 // Note: If helper is used select low or high thresholds , it will overwrite 0097 // values from TransportationParameters! 0098 0099 // They are currently applied in the following order: 0100 // 1. Transportation Parameters - fine grained control in Transportation construction 0101 // 2. Physics List Helper - impose a fixed set of new values in Transport classes 0102 // 3. Run Action (F01RunAction) - revise values at Start of Run 0103 // 4. Tracking Action - could revise value at start of each track (not shown) 0104 // Note that this also could customise by particle type, e.g. giving different values 0105 // to mu-/mu+ , e-/e+ vs others) 0106 // If multiple are present, later methods overwrite previous ones in this list. 0107 0108 // Physics list 0109 G4VModularPhysicsList* physicsList = new FTFP_BERT; 0110 physicsList->RegisterPhysics(new G4StepLimiterPhysics()); 0111 runManager->SetUserInitialization(physicsList); 0112 0113 // User action initialization 0114 runManager->SetUserInitialization(new F01ActionInitialization(detector)); 0115 0116 G4double warningE = 10.0 * CLHEP::keV; 0117 G4double importantE = 0.1 * CLHEP::MeV; 0118 G4int numTrials = 30; 0119 0120 G4bool useTransportParams = true; // Use the new way - Nov 2022 0121 0122 if (useTransportParams) { 0123 auto transportParams = G4TransportationParameters::Instance(); 0124 transportParams->SetWarningEnergy(warningE); 0125 transportParams->SetImportantEnergy(importantE); 0126 transportParams->SetNumberOfTrials(numTrials); 0127 G4cout << "field01: Using G4TransportationParameters to set looper parameters." << G4endl; 0128 } 0129 else { 0130 // Fine grained control of thresholds for looping particles 0131 auto runAction = new F01RunAction(); 0132 runAction->SetWarningEnergy(warningE); 0133 // Looping particles with E < 10 keV will be killed after 1 step 0134 // with warning. 0135 // Looping particles with E > 10 keV will generate a warning. 0136 runAction->SetImportantEnergy(importantE); 0137 runAction->SetNumberOfTrials(numTrials); 0138 // Looping particles with E > 0.1 MeV will survive for up to 0139 // 30 'tracking' steps, and only be killed if they still loop. 0140 0141 G4cout << "field01: Using F01RunAction to set looper parameters." << G4endl; 0142 runManager->SetUserAction(runAction); 0143 } 0144 0145 // Note: this mechanism overwrites the thresholds established by 0146 // the call to UseLowLooperThresholds() above. 0147 0148 // Suppress large verbosity from EM & hadronic processes 0149 G4EmParameters::Instance()->SetVerbose(0); 0150 G4HadronicParameters::Instance()->SetVerboseLevel(0); 0151 0152 // Initialize G4 kernel 0153 // 0154 runManager->Initialize(); 0155 0156 // Initialize visualization 0157 // 0158 // G4VisExecutive can take a verbosity argument - see /vis/verbose 0159 G4VisManager* visManager = new G4VisExecutive("Quiet"); 0160 visManager->Initialize(); 0161 0162 // Get the pointer to the User Interface manager 0163 // 0164 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0165 0166 if (!ui) // batch mode 0167 { 0168 G4String command = "/control/execute "; 0169 G4String fileName = argv[1]; 0170 UImanager->ApplyCommand(command + fileName); 0171 } 0172 else { // interactive mode : define UI session 0173 UImanager->ApplyCommand("/control/execute init_vis.mac"); 0174 if (ui->IsGUI()) UImanager->ApplyCommand("/control/execute gui.mac"); 0175 ui->SessionStart(); 0176 delete ui; 0177 } 0178 0179 // Statistics of tracks killed by G4Transportation are currently 0180 // printed in the RunAction's EndOfEvent action. 0181 // ( Eventually a summary could be provided here instead or as well. ) 0182 0183 delete verbosity; 0184 delete visManager; 0185 delete runManager; 0186 0187 return 0; 0188 } 0189 0190 //....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 |
|