Geant4  10.00.p03
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 #include "G4RunManager.hh"
43 #include "G4UImanager.hh"
44 
45 #include "Randomize.hh"
46 
47 #ifdef G4VIS_USE
48 #include "G4VisExecutive.hh"
49 #endif
50 
51 #ifdef G4UI_USE
52 #include "G4UIExecutive.hh"
53 #endif
54 
55 #include "DMXAnalysisManager.hh"
57 #include "DMXPhysicsList.hh"
59 #include "DMXRunAction.hh"
60 #include "DMXEventAction.hh"
61 #include "DMXSteppingAction.hh"
62 #include "DMXStackingAction.hh"
63 
64 #include <vector>
65 
66 int main(int argc,char** argv) {
67 
68  // choose the Random engine
69  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
70 
71  // Construct the default run manager
72  G4RunManager * runManager = new G4RunManager;
73 
74  // set mandatory initialization classes
76  runManager->SetUserInitialization(detector);
77  runManager->SetUserInitialization(new DMXPhysicsList);
78 
79 #ifdef G4VIS_USE
80  // visualization manager
81  G4VisManager* visManager = new G4VisExecutive;
82  visManager->Initialize();
83 #endif
84 
85 
86 #ifdef DMXENV_GPS_USE
87  G4cout << " Using GPS and not DMX gun " << G4endl;
88 #else
89  G4cout << " Using the DMX gun " << G4endl;
90 #endif
91 
92  // set user action classes
94  runManager->SetUserAction(DMXGenerator);
95  // runManager->SetUserAction(new DMXPrimaryGeneratorAction);
96  // RunAction is inherited by EventAction for output filenames - will all
97  // change when implement proper analysis manager?
98  DMXRunAction* DMXRun = new DMXRunAction;
99  runManager->SetUserAction(DMXRun);
100  DMXEventAction* eventAction = new DMXEventAction(DMXRun,DMXGenerator);
101  runManager->SetUserAction(eventAction);
102  // eventAction is inherited by SteppingAction in order to switch colour
103  // flag:
104  runManager->SetUserAction(new DMXSteppingAction(eventAction));
105  runManager->SetUserAction(new DMXStackingAction);
106 
107  //Initialize G4 kernel
108  runManager->Initialize();
109 
110  // get the pointer to the User Interface manager
111  G4UImanager* UImanager = G4UImanager::GetUIpointer();
112 
113  // Define UI session for interactive mode.
114  if(argc == 1)
115  {
116 #ifdef G4UI_USE
117  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
118 #ifdef G4VIS_USE
119  UImanager->ApplyCommand("/control/execute initInter.mac");
120 #endif
121  ui->SessionStart();
122  delete ui;
123 #endif
124  }
125  // Batch mode
126  else
127  {
128  G4String command = "/control/execute ";
129  G4String fileName = argv[1];
130  UImanager->ApplyCommand(command+fileName);
131  }
132 
133  // job termination
134  DMXRun->Finish();
135  G4cout << "Analysis files closed" << G4endl;
136 
137 #ifdef G4VIS_USE
138  if(visManager) delete visManager;
139 #endif
140  delete runManager;
141 
142  return 0;
143 }
144 
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int main(int argc, char **argv)
Definition: DMX.cc:66
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:432
virtual void SetUserAction(G4UserRunAction *userAction)