Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-20 07:40:43

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