LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 
31 #include "CCalDetectorConstruction.hh"
32 #include "CCalActionInitializer.hh"
33 #include "CCalAnalysis.hh"
34 
35 #include "G4PhysListFactory.hh"
36 
37 #include "G4RunManager.hh"
38 #include "G4UImanager.hh"
39 
40 #include "G4VisExecutive.hh"
41 
42 #include "G4UIExecutive.hh"
43 
44 int main(int argc,char** argv) {
45 
46  G4VisManager *visManager = nullptr;
47 
48  G4RunManager * runManager = new G4RunManager;
49  runManager->SetUserInitialization(new CCalDetectorConstruction);
50 
51  G4PhysListFactory factory;
52  runManager->SetUserInitialization(factory.ReferencePhysList());
53 
54  runManager->SetUserInitialization(new CCalActionInitializer());
55 
56  G4UImanager * UImanager = G4UImanager::GetUIpointer();
57  UImanager->ApplyCommand("/CCal/generator/verbose 2");
58  UImanager->ApplyCommand("/gun/position -1380. 0. 0. mm");
59  UImanager->ApplyCommand("/gun/direction 1. 0. 0.");
60  UImanager->ApplyCommand("/gun/energy 100 GeV");
61 
62  // Define (G)UI terminal for interactive mode
63  if (argc==1) { // No arguments - interactive assumed.
64 
65  visManager = new G4VisExecutive;
66  visManager->Initialize();
67 
68  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
69  if (ui->IsGUI()) {
70  // Customize the menubar with a macro file :
71  UImanager->ApplyCommand("/control/execute gui.mac");
72  }
73  G4cout <<" Run initializing ..."<<G4endl;
74  UImanager->ApplyCommand("/process/verbose 0");
75  UImanager->ApplyCommand("/run/verbose 2");
76  UImanager->ApplyCommand("/run/initialize");
77 
78  // Create empty scene
79  G4String visCommand = "/vis/scene/create";
80  UImanager->ApplyCommand(visCommand);
81 
82  // Choose one default viewer
83  // (the user can always change it later on)
84  // visCommand = "/vis/open DAWNFILE";
85  // visCommand = "/vis/open VRML2FILE";
86  visCommand = "/vis/open OGL";
87  UImanager->ApplyCommand(visCommand);
88 
89  visCommand = "/vis/viewer/flush";
90  UImanager->ApplyCommand(visCommand);
91  visCommand = "/tracking/storeTrajectory 1";
92  UImanager->ApplyCommand(visCommand);
93 
94  G4cout <<"Now, please, apply beamOn command..."<<G4endl;
95  ui->SessionStart();
96  delete ui;
97 
98  } else {
99 
100  // Batch mode
101  G4String command = "/control/execute ";
102  G4String fileName = argv[1];
103  UImanager->ApplyCommand(command+fileName);
104  }
105 
106  //Close-out analysis:
107  // Save histograms
108  G4AnalysisManager* man = G4AnalysisManager::Instance();
109  man->Write();
110  man->CloseFile();
111  // Complete clean-up
112  delete G4AnalysisManager::Instance();
113  delete runManager;
114  delete visManager;
115  return 0;
116 }
int main(int argc, char **argv)