// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // $Id: clGeometry.cc,v 1.7 2006/06/29 17:20:00 gunter Exp $ // GEANT4 tag $Name: geant4-09-03-cand-01 $ // // // controls whether drawing is to be Done or not #include #include #include "G4ios.hh" // package includes #include "G3toG4DetectorConstruction.hh" #include "G3toG4RunAction.hh" #include "G3toG4PrimaryGeneratorAction.hh" #include "G3toG4PhysicsList.hh" #include "G3toG4EventAction.hh" #include "G4LogicalVolume.hh" #include "G3VolTable.hh" // geant4 includes #include "G4RunManager.hh" #include "G4UImanager.hh" #include "G4UIterminal.hh" // visualization #ifdef G4VIS_USE #include "G4VisExecutive.hh" #endif int main(int argc, char** argv) { G4String inFile; G4String macroFile = ""; if (argc < 2) { G4cerr << "clGeometry: Correct syntax: clGeometry [ ]" << G4endl; G4cerr << "If only one argument is specified, interactive mode will be " << "entered." << G4endl << "The second argument, if specified, is " << "the name of the macro file (batch mode)." << G4endl; return EXIT_FAILURE; } if (argc >= 2) { // Process the command line inFile = argv[1]; std::ifstream in(inFile); if (!in) { G4cerr << "Cannot open input file \"" << inFile << "\"" << G4endl; return EXIT_FAILURE; } } if (argc >= 3) { macroFile = argv[2]; std::ifstream mac(macroFile); if (!mac) { G4cout << "Cannot open macro file """ << macroFile << """" << G4endl; return 2; } } if (argc >= 4) { G4cerr << "Too many command line arguments (" << argc <<")" << G4endl; return EXIT_FAILURE; } // Construct the default run manager G4RunManager* RunManager = new G4RunManager; // set mandatory initialization classes RunManager->SetUserInitialization(new G3toG4DetectorConstruction(inFile)); G3toG4PhysicsList* thePhysicsList = new G3toG4PhysicsList; // set verbosity of PhysicsList thePhysicsList->SetVerboseLevel(2); RunManager->SetUserInitialization(thePhysicsList); //---------------- // Visualization: //---------------- #ifdef G4VIS_USE G4VisManager* VisManager = new G4VisExecutive; VisManager -> Initialize(); #endif // set user action classes RunManager->SetUserAction(new G3toG4RunAction); G3toG4EventAction* theEventAction = new G3toG4EventAction; theEventAction->SetDrawFlag("all"); RunManager->SetUserAction(theEventAction); RunManager->SetUserAction(new G3toG4PrimaryGeneratorAction); // the pointer to the User Interface manager G4UImanager* UI = G4UImanager::GetUIpointer(); // set some additional defaults and initial actions UI->ApplyCommand("/control/verbose 1"); UI->ApplyCommand("/run/verbose 1"); UI->ApplyCommand("/tracking/verbose 1"); UI->ApplyCommand("/tracking/storeTrajectory 1"); UI->ApplyCommand("/run/initialize"); G4bool batch_mode = macroFile != ""; if(!batch_mode) { G4UIsession * session = new G4UIterminal; if (session != 0) { session->SessionStart(); delete session; // G4cout << "deleted G4UITerminal..." << G4endl; } } else { // Batch mode G4String command = "/control/execute "; UI->ApplyCommand(command+macroFile); } #ifdef G4VIS_USE if (VisManager !=0) delete VisManager; #endif delete RunManager; return EXIT_SUCCESS; }