Geant4  10.03
DMX.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 //
27 // --------------------------------------------------------------
28 // GEANT 4 - Underground Dark Matter Detector Advanced Example
29 //
30 // For information related to this code contact: Alex Howard
31 // e-mail: alexander.howard@cern.ch
32 // --------------------------------------------------------------
33 // Comments
34 //
35 // Underground Advanced example main program
36 // by A. Howard and H. Araujo
37 // (27th November 2001)
38 //
39 // main program
40 // --------------------------------------------------------------
41 
42 #ifdef G4MULTITHREADED
43 #include "G4MTRunManager.hh"
44 #else
45 #include "G4RunManager.hh"
46 #endif
47 
48 #include "G4UImanager.hh"
49 #include "Randomize.hh"
50 
51 #ifdef G4VIS_USE
52 #include "G4VisExecutive.hh"
53 #endif
54 
55 #ifdef G4UI_USE
56 #include "G4UIExecutive.hh"
57 #endif
58 
59 #include "DMXAnalysisManager.hh"
61 #include "DMXPhysicsList.hh"
62 #include "DMXActionInitializer.hh"
63 
64 int main(int argc,char** argv) {
65 
66  // choose the Random engine
67  G4Random::setTheEngine(new CLHEP::RanecuEngine);
68 
69  // Construct the default run manager
70 #ifdef G4MULTITHREADED
71  G4MTRunManager* runManager = new G4MTRunManager;
72  //runManager->SetNumberOfThreads(2);
73 #else
74  G4RunManager* runManager = new G4RunManager;
75 #endif
76 
77  // set mandatory initialization classes
79  runManager->SetUserInitialization(new DMXPhysicsList);
81 
82 #ifdef G4VIS_USE
83  // visualization manager
84  G4VisManager* visManager = new G4VisExecutive;
85  visManager->Initialize();
86 #endif
87 
88 
89 #ifdef DMXENV_GPS_USE
90  G4cout << " Using GPS and not DMX gun " << G4endl;
91 #else
92  G4cout << " Using the DMX gun " << G4endl;
93 #endif
94 
95 
96  //Initialize G4 kernel
97  runManager->Initialize();
98 
99  // get the pointer to the User Interface manager
100  G4UImanager* UImanager = G4UImanager::GetUIpointer();
101 
102  // Define UI session for interactive mode.
103  if(argc == 1)
104  {
105 #ifdef G4UI_USE
106  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
107 #ifdef G4VIS_USE
108  UImanager->ApplyCommand("/control/execute initInter.mac");
109 #endif
110  ui->SessionStart();
111  delete ui;
112 #endif
113  }
114  // Batch mode
115  else
116  {
117  G4String command = "/control/execute ";
118  G4String fileName = argv[1];
119  UImanager->ApplyCommand(command+fileName);
120  }
121 
122  //Close-out analysis:
123  // Save histograms
124  G4AnalysisManager* man = G4AnalysisManager::Instance();
125  man->Write();
126  man->CloseFile();
127  // Complete clean-up
128  delete G4AnalysisManager::Instance();
129 
130 #ifdef G4VIS_USE
131  if(visManager) delete visManager;
132 #endif
133  delete runManager;
134 
135  return 0;
136 }
137 
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int main(int argc, char **argv)
Definition: DMX.cc:64
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
void Initialize()
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446