Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-25 09:22:34

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 //  Gorad (Geant4 Open-source Radiation Analysis and Design)
0027 //
0028 //  Author : Makoto Asai (SLAC National Accelerator Laboratory)
0029 //
0030 //  Development of Gorad is funded by NASA Johnson Space Center (JSC)
0031 //  under the contract NNJ15HK11B.
0032 //
0033 // ********************************************************************
0034 //
0035 // GRInitialization.hh
0036 //   Defines the initialization procedure of Gorad and Geant4
0037 //
0038 // History
0039 //   September 8th, 2020 : first implementation
0040 //
0041 // ********************************************************************
0042 
0043 #include "GRInitialization.hh"
0044 
0045 #include "GRDetectorConstruction.hh"
0046 #include "GRPhysicsList.hh"
0047 #include "GRActionInitialization.hh"
0048 #include "GRPrimGenActionMessenger.hh"
0049 #include "G4GenericMessenger.hh"
0050 #include "GRGeomBiasMessenger.hh"
0051 #include "GRScoreWriter.hh"
0052 
0053 #include "G4RunManager.hh"
0054 #include "G4ScoringManager.hh"
0055 #include "G4UIdirectory.hh"
0056 #include "G4UnitsTable.hh"
0057 
0058 #include <CLHEP/Units/SystemOfUnits.h>
0059 
0060 GRInitialization::GRInitialization(G4int verboseLvl)
0061 : verboseLevel(verboseLvl)
0062 {
0063   // adding unites
0064   new G4UnitDefinition("milligray","mGy","Dose",1.e-3*CLHEP::gray);
0065   new G4UnitDefinition("microgray","muGy","Dose",1.e-6*CLHEP::gray);
0066   new G4UnitDefinition("nanogray","nGy","Dose",1.e-9*CLHEP::gray);
0067 
0068   G4ScoringManager::GetScoringManager()->SetScoreWriter(new GRScoreWriter());
0069 
0070   messenger = new G4GenericMessenger(this,"/gorad/","GORAD commands");
0071   auto& initCmd = messenger->DeclareMethod("initialize",
0072          &GRInitialization::Initialize,"Initialize Gorad and G4RunManager");
0073   initCmd.SetToBeBroadcasted(false);
0074   initCmd.SetStates(G4State_PreInit);
0075 
0076   detector = new GRDetectorConstruction();
0077   physics = new GRPhysicsList();
0078   actionInitialization = new GRActionInitialization();
0079   sourceMessenger = new GRPrimGenActionMessenger();
0080   geomBiasMessenger = new GRGeomBiasMessenger(detector,physics,verboseLvl);
0081 }
0082 
0083 GRInitialization::~GRInitialization()
0084 {
0085   delete geomBiasMessenger;
0086   delete sourceMessenger;
0087   delete messenger; 
0088 }
0089 
0090 void GRInitialization::Initialize()
0091 {
0092   auto runManager = G4RunManager::GetRunManager();
0093   runManager->SetUserInitialization(detector);
0094   runManager->SetUserInitialization(physics);
0095   runManager->SetUserInitialization(actionInitialization);
0096   if(verboseLevel>0) G4cout << "GORAD is initialized.........." << G4endl;
0097   runManager->Initialize();
0098   sourceMessenger->UpdateParticleList();
0099 }
0100 
0101 #include "G4UIExecutive.hh"
0102 #ifdef G4UI_USE_QT
0103 #include "G4UIQt.hh"
0104 #endif
0105 
0106 void GRInitialization::SetWindowText(G4UIExecutive* ui)
0107 {
0108   // If the current GUI is not G4UIQt, do nothing and return.
0109   if(!(ui->IsGUI())) return;
0110 
0111 #ifdef G4UI_USE_QT
0112   G4UIQt* qt = dynamic_cast<G4UIQt*>(ui->GetSession());
0113   if(!qt) return;
0114 
0115   qt->SetStartPage(std::string("<table width='100%'><tr><td width='50%'></td><td><div ")+
0116        "style='color: rgb(140, 31, 31); font-size: xx-large; font-family: Garamond, serif; "+
0117        "padding-bottom: 0px; font-weight: normal'>GORAD "+
0118        "</div></td></td></tr></table>"+
0119        "<p>&nbsp;</p>"+
0120        "<div><dl>"+
0121          "<dd><b>Gorad (Geant4 Open-source Radiation Analysis and Design) is meant to be "+
0122          "a turn-key application for radiation analysis and spacecraft design "+
0123          "built on top of Geant4. Simulation geometry should be provided in the form of GDML. "+
0124          "Gorad is developed under the NASA JSC contract NNJ15HK11B."+
0125          "</dd></dl></div>"+
0126        "<p>&nbsp;</p>"+
0127        "<div style='background:#EEEEEE;'><b>Tooltips :</b><ul>"+
0128          "<li><b>Start an interactive run :</b><br />"+
0129          "/control/execute <i>run.mac</i><br />"+
0130          "/run/beamOn <i>number_of_events</i></li></ul></div>"+
0131        "<div style='background:#EEEEEE;'><b>Documentation :</b><ul>"+
0132          "<li><i>"+
0133          "<b>GORAD manual</b> and a sample Orion spacecraft shield geometry can be found at<br />"+
0134          "<a href='https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesGorad'>"+
0135          "https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesGorad"+
0136          "</a></i></li>"+
0137          "</ul></div>"
0138        );
0139 #endif
0140 }
0141