EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eASTInitialization.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file eASTInitialization.cc
1 // ********************************************************************
2 //
3 // eASTInitialization.cc
4 // Defines the initialization procedure of Geant4 and eAST
5 //
6 // History
7 // April 28, 2021 - first implementation (M.Asai/SLAC)
8 //
9 // ********************************************************************
10 
11 #include "eASTInitialization.hh"
12 
14 #include "eASTPhysicsList.hh"
15 #include "eASTMagneticField.hh"
16 //#include "FTFP_BERT.hh"
18 #include "G4GenericMessenger.hh"
19 
20 #include "G4RunManager.hh"
21 #include "G4ScoringManager.hh"
22 #include "G4UIdirectory.hh"
23 #include "G4UnitsTable.hh"
24 #include <CLHEP/Units/SystemOfUnits.h>
25 
26 #include "eASTBeamPipe.hh"
27 #include "eASTSupportStructure.hh"
29 
31 : verboseLevel(verboseLvl)
32 {
33  // adding units
34  new G4UnitDefinition("milligray","mGy","Dose",1.e-3*CLHEP::gray);
35  new G4UnitDefinition("microgray","muGy","Dose",1.e-6*CLHEP::gray);
36  new G4UnitDefinition("nanogray","nGy","Dose",1.e-9*CLHEP::gray);
37 
38  //G4ScoringManager::GetScoringManager()->SetScoreWriter(new eASTScoreWriter());
39 
40  messenger = new G4GenericMessenger(this,"/eAST/","eAST commands");
41  auto& initCmd = messenger->DeclareMethod("initialize",
42  &eASTInitialization::Initialize,"Initialize G4RunManager and eAST");
43  initCmd.SetToBeBroadcasted(false);
44  initCmd.SetStates(G4State_PreInit);
45 
46  auto compDir = new G4UIdirectory("/eAST/component/");
47  compDir->SetGuidance("Activate a component of EIC detector");
48 
50  physics = new eASTPhysicsList();
51  field = new eASTMagneticField();
52 
54 
56 
57  // EIC Detector Components
58  new eASTBeamPipe("beampipe");
59  new eASTSupportStructure("DIRC_support");
60  new eASTSupportStructure("EM_CAL_support");
61 
62  new eASTDetectorComponentGDML("GenericGDML1");
63  new eASTDetectorComponentGDML("GenericGDML2");
64  new eASTDetectorComponentGDML("GenericGDML3");
65  new eASTDetectorComponentGDML("GenericGDML4");
66  new eASTDetectorComponentGDML("GenericGDML5");
67 
68 
69 }
70 
72 {
73  delete messenger;
74 }
75 
77 {
78  auto runManager = G4RunManager::GetRunManager();
79  runManager->SetUserInitialization(detector);
80  runManager->SetUserInitialization(physics);
81  runManager->SetUserInitialization(actionInitialization);
82  if(verboseLevel>0) G4cout << "initializing eAST .........." << G4endl;
83  runManager->Initialize();
84 }
85 
86 #include "G4UIExecutive.hh"
87 #ifdef G4UI_USE_QT
88 #include "G4UIQt.hh"
89 #endif
90 
91 void eASTInitialization::SetWindowText(G4UIExecutive* ui)
92 {
93  // If the current GUI is not G4UIQt, do nothing and return.
94  if(!(ui->IsGUI())) return;
95 
96 #ifdef G4UI_USE_QT
97  G4UIQt* qt = dynamic_cast<G4UIQt*>(ui->GetSession());
98  if(!qt) return;
99 
100  qt->SetStartPage(std::string("<table width='100%'><tr><td width='50%'></td><td><div ")+
101  "style='color: rgb(140, 31, 31); font-size: xx-large; font-family: Garamond, serif; "+
102  "padding-bottom: 0px; font-weight: normal'>eAST "+
103  "</div></td></td></tr></table>"+
104  "<p>&nbsp;</p>"+
105  "<div><dl>"+
106  "<dd><b>eAST (eA Simulation Tool) is meant to be "+
107  "a common tool for detector simulation studies for Electron-Ion Collider experiments "+
108  "built on top of Geant4."+
109  "</dd></dl></div>"+
110  "<p>&nbsp;</p>"+
111  "<div style='background:#EEEEEE;'><b>Tooltips :</b><ul>"+
112  "<li><b>Start an interactive run :</b><br />"+
113  "/control/execute <i>run.mac</i><br />"+
114  "/run/beamOn <i>number_of_events</i></li></ul></div>"+
115  "<div style='background:#EEEEEE;'><b>Documentation :</b><ul>"+
116  "<li><i>"+
117  "<b>eAST manual</b> is "+
118  "<a href='https://eic.github.io/east/content/manual.html'>"+
119  "here"+
120  "</a>.</i></li>"+
121  "</ul></div>"
122  );
123 #endif
124 }
125