LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
exampleB3a.cc
Go to the documentation of this file.
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 //
26 //
29 
30 #include "G4Types.hh"
31 
32 #ifdef G4MULTITHREADED
33 #include "G4MTRunManager.hh"
34 #else
35 #include "G4RunManager.hh"
36 #endif
37 
38 #include "G4UImanager.hh"
39 #include "G4VisExecutive.hh"
40 #include "G4UIExecutive.hh"
41 #include "G4TScoreNtupleWriter.hh"
42 
43 #include "Randomize.hh"
44 
45 #include "B3DetectorConstruction.hh"
46 #include "B3PhysicsList.hh"
47 #include "B3aActionInitialization.hh"
48 #include "B3Analysis.hh"
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
52 int main(int argc,char** argv)
53 {
54  // Detect interactive mode (if no arguments) and define UI session
55  //
56  G4UIExecutive* ui = 0;
57  if ( argc == 1 ) {
58  ui = new G4UIExecutive(argc, argv);
59  }
60 
61  // Optionally: choose a different Random engine...
62  //
63  // G4Random::setTheEngine(new CLHEP::MTwistEngine);
64 
65  // Construct the default run manager
66  //
67 #ifdef G4MULTITHREADED
68  G4MTRunManager* runManager = new G4MTRunManager;
69 #else
70  G4RunManager* runManager = new G4RunManager;
71 #endif
72 
73  // Set mandatory initialization classes
74  //
75  runManager->SetUserInitialization(new B3DetectorConstruction);
76  //
77  runManager->SetUserInitialization(new B3PhysicsList);
78 
79  // Set user action initialization
80  //
81  runManager->SetUserInitialization(new B3aActionInitialization());
82 
83  // Initialize visualization
84  //
85  G4VisManager* visManager = new G4VisExecutive;
86  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
87  // G4VisManager* visManager = new G4VisExecutive("Quiet");
88  visManager->Initialize();
89 
90  // Get the pointer to the User Interface manager
91  G4UImanager* UImanager = G4UImanager::GetUIpointer();
92 
93  // Activate score ntuple writer
94  // The Root output type (Root) is selected in B3Analysis.hh.
95  // The verbose level can be also set via UI commands
96  // /score/ntuple/writerVerbose level
97  G4TScoreNtupleWriter<G4AnalysisManager> scoreNtupleWriter;
98  scoreNtupleWriter.SetVerboseLevel(1);
99 
100  // Process macro or start UI session
101  //
102  if ( ! ui ) {
103  // batch mode
104  G4String command = "/control/execute ";
105  G4String fileName = argv[1];
106  UImanager->ApplyCommand(command+fileName);
107  }
108  else {
109  // interactive mode
110  UImanager->ApplyCommand("/control/execute init_vis.mac");
111  ui->SessionStart();
112  delete ui;
113  }
114 
115  // Job termination
116  // Free the store: user actions, physics_list and detector_description are
117  // owned and deleted by the run manager, so they should not be deleted
118  // in the main() program !
119 
120  delete visManager;
121  delete runManager;
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
int main(int argc, char **argv)
Definition: exampleB3a.cc:52