LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Hadr02.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 //
28 //
29 //
30 // -------------------------------------------------------------
31 // GEANT4 Hadr02
32 //
33 // Application demonstrating Geant4 hadronic cross sections
34 //
35 // Author: V.Ivanchenko 20 June 2008
36 //
37 // Modified:
38 //
39 // -------------------------------------------------------------
40 //
41 //
42 #include "G4RunManager.hh"
43 #include "G4UImanager.hh"
44 #include "Randomize.hh"
45 #include "DetectorConstruction.hh"
46 #include "G4PhysListFactory.hh"
47 #include "G4VModularPhysicsList.hh"
49 #include "RunAction.hh"
50 #include "EventAction.hh"
51 #include "StackingAction.hh"
52 #include "HistoManager.hh"
53 #include "G4UIExecutive.hh"
54 #include "G4VisExecutive.hh"
55 #include "UrQMD.hh"
56 #include "CRMC_FTFP_BERT.hh"
57 
58 
59 int main(int argc,char** argv) {
60 
61  //detect interactive mode (if no arguments) and define UI session
62  G4UIExecutive* ui = nullptr;
63  if (argc == 1) ui = new G4UIExecutive(argc,argv);
64 
65  //choose the Random engine
66  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
67 
68  //Construct the default run manager
69  G4RunManager * runManager = new G4RunManager();
70 
71  //set mandatory initialization classes
72  runManager->SetUserInitialization(new DetectorConstruction());
73 
74  G4PhysListFactory factory;
75  G4VModularPhysicsList* phys = 0;
76 
77  // default Physics List for this example
78  G4String physName = "QBBC";
79 
80  // Physics List name defined via 2nd argument
81  if (argc==3) { physName = argv[2]; }
82  else {
83  char* path = std::getenv("PHYSLIST");
84  if (path) { physName = G4String(path); }
85  }
86  if ( physName == "UrQMD" ) {
87  phys = new UrQMD;
88  } else if ( physName == "CRMC_FTFP_BERT" ) {
89  phys = new CRMC_FTFP_BERT;
90  } else {
91  phys = factory.GetReferencePhysList( physName );
92  }
93 
94  // Physics List is defined via environment variable PHYSLIST
95  if(!phys) {
96  G4cout << "Hadr02 FATAL ERROR: Physics List is not defined"
97  << G4endl;
98  return 1;
99  }
100  runManager->SetUserInitialization(phys);
101  HistoManager::GetPointer()->SetPhysicsList(phys);
102 
103  runManager->SetUserAction(new PrimaryGeneratorAction());
104 
105  //set user action classes
106  runManager->SetUserAction(new RunAction());
107  runManager->SetUserAction(new EventAction());
108  runManager->SetUserAction(new StackingAction());
109 
110  //initialize visualization
111  G4VisManager* visManager = new G4VisExecutive;
112  visManager->Initialize();
113 
114  //get the pointer to the User Interface manager
115  G4UImanager* UImanager = G4UImanager::GetUIpointer();
116 
117  if (ui) {
118  //interactive mode
119  ui->SessionStart();
120  delete ui;
121  }
122  else {
123  //batch mode
124  G4String command = "/control/execute ";
125  G4String fileName = argv[1];
126  UImanager->ApplyCommand(command+fileName);
127  }
128 
129  //job termination
130  delete visManager;
131  delete runManager;
132 }
133 
int main(int argc, char **argv)
Definition: Hadr02.cc:59