Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 08:30:10

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 radiobiology.cc
0027 /// \brief Main program of the medical/radiobiology example
0028 
0029 // D Chiappara, GAP Cirrone, G Petringa
0030 //
0031 // ** RADIOBIO  example **
0032 // make easy the calculation of the main radiobiology quantities used in
0033 // charged particles radiation therapy: depth dose, Fluence in depth,
0034 // LET (Linear Energy Transfer) and RBE (Relative Bioology Effectiveness)
0035 //
0036 
0037 #include "G4PhysListFactory.hh"
0038 #include "G4RunManagerFactory.hh"
0039 #include "G4ScoringManager.hh"
0040 #include "G4Timer.hh"
0041 #include "G4UImanager.hh"
0042 #include "G4UImessenger.hh"
0043 #include "G4VModularPhysicsList.hh"
0044 #include "Randomize.hh"
0045 #include "globals.hh"
0046 
0047 #include "ActionInitialization.hh"
0048 #include "DetectorConstruction.hh"
0049 #include "Dose.hh"
0050 #include "LET.hh"
0051 #include "Manager.hh"
0052 #include "PhysicsList.hh"
0053 #include "PrimaryGeneratorAction.hh"
0054 #include "RBE.hh"
0055 #include <time.h>
0056 
0057 // #ifdef G4VIS_USE
0058 #include "G4VisExecutive.hh"
0059 // #endif
0060 
0061 // #ifdef G4UI_USE
0062 #include "G4UIExecutive.hh"
0063 // #endif
0064 
0065 using namespace RadioBio;
0066 
0067 ////////////////////////////////////////////////////////////////////////////////
0068 int main(int argc, char** argv)
0069 {
0070   G4UIExecutive* ui = nullptr;
0071   if (argc == 1) {
0072     ui = new G4UIExecutive(argc, argv);
0073   }
0074 
0075   // Instantiate the G4Timer object, to monitor the CPU time spent for
0076   // the entire execution
0077   G4Timer* theTimer = new G4Timer();
0078   // Start the benchmark
0079   theTimer->Start();
0080 
0081   // Set the Random engine
0082   // The following guarantees random generation also for different runs
0083   // in multithread
0084   CLHEP::RanluxEngine defaultEngine(1234567, 4);
0085   G4Random::setTheEngine(&defaultEngine);
0086   G4int seed = time(NULL);
0087   G4Random::setTheSeed(seed);
0088 
0089   // Create the run manager. Uses by default serial or parallel computation.
0090   auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
0091 
0092   // Create Scoring manager
0093   G4ScoringManager* scoringManager = G4ScoringManager::GetScoringManager();
0094   scoringManager->SetVerboseLevel(1);
0095 
0096   // Creating PhysicsList
0097   G4VModularPhysicsList* phys = new PhysicsList();
0098 
0099   // Set mandatory initialization classes
0100   DetectorConstruction* det = new DetectorConstruction();
0101   runManager->SetUserInitialization(det);
0102 
0103   // Creation of Manager
0104   Manager* RBman = Manager::CreateInstance();
0105 
0106   // Create and Register Radiobiological quantities
0107   Dose* dose = new Dose();
0108   RBman->Register(dose, "Dose");
0109 
0110   LET* let = new LET();
0111   RBman->Register(let, "LET");
0112 
0113   RBE* rbe = new RBE();
0114   RBman->Register(rbe, "RBE");
0115 
0116   // Initialisation of physics
0117   runManager->SetUserInitialization(phys);
0118 
0119   // Initialisation of the Actions
0120   runManager->SetUserInitialization(new ActionInitialization(det));
0121 
0122   // Initialize command based scoring
0123   G4ScoringManager::GetScoringManager();
0124 
0125   // Initialise the Visualisation
0126   // #ifdef G4VIS_USE
0127   G4VisManager* visManager = new G4VisExecutive;
0128   visManager->Initialize();
0129   // #endif
0130 
0131   //** Get the pointer to the User Interface manager
0132   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0133 
0134   if (!ui) {
0135     // batch mode
0136     G4String command = "/control/execute ";
0137     G4String fileName = argv[1];
0138     UImanager->ApplyCommand(command + fileName);
0139   }
0140 
0141   else {
0142     // UImanager -> ApplyCommand("/control/execute macro/MacroPablo.mac");
0143     UImanager->ApplyCommand("/control/execute macro/visualize.mac");
0144 
0145     ui->SessionStart();
0146     delete ui;
0147   }
0148 
0149   // Save data in RadioBioManager
0150   RBman->StoreAll();
0151 
0152   // Stop the benchmark here
0153   theTimer->Stop();
0154 
0155   G4cout << "The simulation took: " << theTimer->GetRealElapsed() << " s to run (real time)"
0156          << G4endl;
0157 
0158   delete theTimer;
0159   delete runManager;
0160 }