// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // /// \file runAndEvent/RE02/RE02.cc /// \brief Main program of the runAndEvent/RE02 example // // // // #include "RE02DetectorConstruction.hh" #include "QGS_BIC.hh" #include "RE02ActionInitialization.hh" #include "G4RunManagerFactory.hh" #include "G4UImanager.hh" #include "G4SystemOfUnits.hh" #include "G4UIExecutive.hh" #include "G4VisExecutive.hh" // Timing definitionss typedef std::chrono::high_resolution_clock Time; typedef std::chrono::duration fsec; int main(int argc,char** argv) { // Instantiate G4UIExecutive if there are no arguments (interactive mode) G4UIExecutive* ui = nullptr; if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); } auto* runManager = G4RunManagerFactory::CreateRunManager(); // UserInitialization classes (mandatory) // Create Detector RE02DetectorConstruction* detector = new RE02DetectorConstruction; detector->SetPhantomSize(G4ThreeVector(142.5 * mm, 142.5 * mm, 0.45 * mm)); //Default detector->SetNumberOfSegmentsInPhantom(950, 1075, 3); //Default // detector->SetLeadSegment(false); // Default (Water and Lead) // Water and Lead segments are placed alternately, by defult., // If you want to simulation homogeneous water phantom, please set it FALSE. //detector->SetLeadSegment(FALSE); // Homogeneous water phantom // runManager->SetUserInitialization(detector); // runManager->SetUserInitialization(new QGS_BIC()); // Visualization, if you choose to have it! G4VisManager* visManager = new G4VisExecutive; visManager->Initialize(); // UserAction classes runManager->SetUserInitialization(new RE02ActionInitialization); //Initialize G4 kernel runManager->Initialize(); //get the pointer to the User Interface manager G4UImanager * UImanager = G4UImanager::GetUIpointer(); // Plotting if (false) { UImanager->ApplyCommand("/vis/open OGL 600x600-0+0"); UImanager->ApplyCommand("/vis/drawVolume"); UImanager->ApplyCommand("/vis/viewer/set/viewpointThetaPhi 0. 0."); UImanager->ApplyCommand("/vis/scene/add/gps"); // Section for adding trajectories and hits UImanager->ApplyCommand("/vis/scene/add/trajectories smooth"); UImanager->ApplyCommand("/vis/modeling/trajectories/create/drawByCharge"); UImanager->ApplyCommand("/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true"); UImanager->ApplyCommand("/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2"); UImanager->ApplyCommand("/vis/scene/endOfEventAction accumulate 1000"); // UImanager->ApplyCommand("/run/beamOn 1"); UImanager->ApplyCommand("/vis/enable"); UImanager->ApplyCommand("/vis/viewer/rebuild"); ui->SessionStart(); delete ui; } // Scoring if (false) { G4int Photons = 1000000; auto t0_score = Time::now(); UImanager->ApplyCommand("/vis/disable"); UImanager->ApplyCommand("/score/create/boxMesh DetectorGrid"); UImanager->ApplyCommand("/score/mesh/boxSize 71.25 80.625 0.225 mm"); UImanager->ApplyCommand("/score/mesh/nBin 950 1075 3"); UImanager->ApplyCommand("/score/quantity/doseDeposit dose"); UImanager->ApplyCommand("/run/beamOn " + std::to_string(Photons)); UImanager->ApplyCommand("/score/close"); UImanager->ApplyCommand("/score/dumpQuantityToFile DetectorGrid dose C:/Users/jpol0001/calculations/ScoreTest.hdf5 1"); fsec TimetilNow = Time::now() - t0_score; G4cout << "Test speed was " << Photons / TimetilNow.count() << " Photons/sec" << G4endl; G4cout << "Time taken was " << TimetilNow.count() << " seconds" << G4endl; ui->SessionStart(); delete ui; } // Individual runs if (true) { G4int Photons = 10000000; auto t0_test = Time::now(); UImanager->ApplyCommand("geometry/navigator/check_mode true"); UImanager->ApplyCommand("/run/beamOn " + std::to_string(Photons)); fsec TimetilNow = Time::now() - t0_test; G4cout << "Test speed was " << (G4double)Photons / TimetilNow.count() << " Photons/sec" << G4endl; G4cout << "Time taken was " << TimetilNow.count() << " seconds" << G4endl; ui->SessionStart(); delete ui; } // delete memory allocations delete visManager; delete runManager; return 0; } //