Geant4  10.03
CompositeCalorimeter.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 //
27 // File: CompositeCalorimeter.cc
28 // Description: Main function for Geant4 application HCAL Test-BEAM H2-96
30 
32 #include "CCalEndOfEventAction.hh"
33 #include "CCalRunAction.hh"
34 
36 #include "G4PhysListFactory.hh"
37 
38 #include "G4RunManager.hh"
39 #include "G4UImanager.hh"
40 
41 #ifdef G4VIS_USE
42  #include "G4VisExecutive.hh"
43 #endif
44 
45 #ifdef G4UI_USE
46  #include "G4UIExecutive.hh"
47 #endif
48 
49 
50 int main(int argc,char** argv) {
51 
52 #ifdef G4VIS_USE
53  G4VisManager *visManager = new G4VisExecutive;
54  visManager->Initialize();
55 #endif
56 
57  G4RunManager * runManager = new G4RunManager;
59 
60  G4PhysListFactory factory;
61  runManager->SetUserInitialization(factory.ReferencePhysList());
62 
64  // User action classes. //
65  // -------------------- //
67 
69  // PRIMARY PARTICLEs GENERATION //
71 
73  runManager->SetUserAction(primaryGenerator);
74 
76  // RUN //
78 
79  runManager->SetUserAction(new CCalRunAction);
80 
82  // EVENT //
84 
85  runManager->SetUserAction(new CCalEndOfEventAction(primaryGenerator));
86 
87  G4UImanager * UImanager = G4UImanager::GetUIpointer();
88  UImanager->ApplyCommand("/CCal/generator/verbose 2");
89  UImanager->ApplyCommand("/gun/position -1380. 0. 0. mm");
90  UImanager->ApplyCommand("/gun/direction 1. 0. 0.");
91  UImanager->ApplyCommand("/gun/energy 100 GeV");
92 
93  // Define (G)UI terminal for interactive mode
94  if (argc==1) { // No arguments - interactive assumed.
95 
96 #ifdef G4UI_USE
97  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
98  if (ui->IsGUI())
99  // Customize the menubar with a macro file :
100  UImanager->ApplyCommand("/control/execute gui.mac");
101  G4cout <<" Run initializing ..."<<G4endl;
102  UImanager->ApplyCommand("/process/verbose 0");
103  UImanager->ApplyCommand("/run/verbose 2");
104  UImanager->ApplyCommand("/run/initialize");
105 #ifdef G4VIS_USE
106  // Create empty scene
107  G4String visCommand = "/vis/scene/create";
108  UImanager->ApplyCommand(visCommand);
109 
110  // Choose one default viewer
111  // (the user can always change it later on)
112  // visCommand = "/vis/open DAWNFILE";
113  // visCommand = "/vis/open VRML2FILE";
114  visCommand = "/vis/open OGL";
115  UImanager->ApplyCommand(visCommand);
116 
117  visCommand = "/vis/viewer/flush";
118  UImanager->ApplyCommand(visCommand);
119  visCommand = "/tracking/storeTrajectory 1";
120  UImanager->ApplyCommand(visCommand);
121 #endif
122  G4cout <<"Now, please, apply beamOn command..."<<G4endl;
123  ui->SessionStart();
124  delete ui;
125 #endif
126 
127  } else {
128 
129  // Batch mode
130  G4String command = "/control/execute ";
131  G4String fileName = argv[1];
132  UImanager->ApplyCommand(command+fileName);
133 
134  }
135 
136 delete runManager;
137 
138 #ifdef G4VIS_USE
139  delete visManager;
140 #endif
141 
142  return 0;
143 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
void Initialize()
#define G4endl
Definition: G4ios.hh:61
G4VModularPhysicsList * ReferencePhysList()
G4bool IsGUI() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
int main(int argc, char **argv)
virtual void SetUserAction(G4UserRunAction *userAction)