ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
monopole.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file monopole.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "G4Types.hh"
34 
35 #ifdef G4MULTITHREADED
36 #include "G4MTRunManager.hh"
37 #else
38 #include "G4RunManager.hh"
39 #endif
40 
41 #include "G4UImanager.hh"
42 #include "Randomize.hh"
43 
44 #include "G4VisExecutive.hh"
45 #include "G4UIExecutive.hh"
46 
47 #include "DetectorConstruction.hh"
48 #include "G4MonopolePhysics.hh"
49 #include "G4PhysListFactory.hh"
50 #include "G4VModularPhysicsList.hh"
51 #include "ActionInitialization.hh"
52 
53 #include "globals.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
57 namespace {
58  void PrintUsage() {
59  G4cerr
60  << " Usage: " << G4endl
61  << " monopole [-m macro ] [-s setupMonopole] [-t nThreads]" << G4endl
62  << " Note: " << G4endl
63  << " -s should be followed by a composed string, eg. \'1 0 100 GeV\'" << G4endl
64  << " -t option is available only for multi-threaded mode." << G4endl
65  << G4endl;
66  }
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
71 int main(int argc,char** argv)
72 {
73  // Evaluate arguments
74  //
75  if ( argc > 7 ) {
76  PrintUsage();
77  return 1;
78  }
79 
80  G4String macro;
81  G4String setupMonopole;
82 #ifdef G4MULTITHREADED
83  G4int nThreads = 1;
84 #endif
85  for ( G4int i=1; i<argc; i=i+2 ) {
86  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
87  else if ( G4String(argv[i]) == "-s" ) setupMonopole = argv[i+1];
88 #ifdef G4MULTITHREADED
89  else if ( G4String(argv[i]) == "-t" ) {
90  nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
91  }
92 #endif
93  else {
94  PrintUsage();
95  return 1;
96  }
97  }
98 
99  // Construct the default run manager
100 #ifdef G4MULTITHREADED
101  G4MTRunManager* runManager = new G4MTRunManager();
102  if ( nThreads > 0 ) {
103  runManager->SetNumberOfThreads(nThreads);
104  }
105  G4cout << "===== Example is started with "
106  << runManager->GetNumberOfThreads() << " threads =====" << G4endl;
107 #else
108  G4RunManager* runManager = new G4RunManager();
109 #endif
110 
111  // Instantiate G4UIExecutive if interactive
112  G4UIExecutive* ui = nullptr;
113  if ( macro.empty() ) {
114  ui = new G4UIExecutive(argc, argv);
115  }
116 
117  //get the pointer to the User Interface manager
118  G4UImanager* UImanager = G4UImanager::GetUIpointer();
119 
120  //create physicsList
121  // Physics List is defined via environment variable PHYSLIST
122  G4PhysListFactory factory;
123  G4VModularPhysicsList* phys = factory.GetReferencePhysList("FTFP_BERT");
124 
125  // monopole physics is added
126  G4MonopolePhysics * theMonopole = new G4MonopolePhysics();
127 
128  // Setup monopole
129  if ( setupMonopole.size() ) {
130  UImanager->ApplyCommand("/control/verbose 1");
131  UImanager->ApplyCommand("/monopole/setup " + setupMonopole);
132  }
133 
134  // regsiter monopole physics
135  phys->RegisterPhysics(theMonopole);
136 
137  runManager->SetUserInitialization(phys);
138 
139  // visualization manager
140  G4VisManager* visManager = nullptr;
141 
142  // set detector construction
144  runManager->SetUserInitialization(det);
145 
146  // set user action classes
147  runManager->SetUserInitialization(new ActionInitialization(det));
148 
149  // Process macro or start UI session
150  //
151  if ( macro.size() ) {
152  // batch mode
153  G4String command = "/control/execute ";
154  UImanager->ApplyCommand(command+macro);
155  }
156  else {
157  // interactive mode : define UI session
158  visManager = new G4VisExecutive();
159  visManager->Initialize();
160  UImanager->ApplyCommand("/control/execute init_vis.mac");
161  ui->SessionStart();
162  delete ui;
163  }
164 
165  delete visManager;
166 
167  // job termination
168  delete runManager;
169 
170  return 0;
171 }
172 
173 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......