Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:20

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