Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:40:13

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 ///////////////////////////////////////////////////////////////////////////////
0027 // File: CompositeCalorimeter.cc
0028 // Description: Main function for Geant4 application HCAL Test-BEAM H2-96
0029 ///////////////////////////////////////////////////////////////////////////////
0030 
0031 #include "CCalDetectorConstruction.hh"
0032 #include "CCalActionInitializer.hh"
0033 
0034 #include "G4AnalysisManager.hh"
0035 
0036 #include "G4PhysListFactory.hh"
0037 
0038 #include "G4RunManagerFactory.hh"
0039 #include "G4UImanager.hh"
0040 
0041 #include "G4VisExecutive.hh"
0042 
0043 #include "G4UIExecutive.hh"
0044 
0045 int main(int argc,char** argv) {
0046 
0047   G4VisManager *visManager = nullptr;
0048 
0049   auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
0050   runManager->SetUserInitialization(new CCalDetectorConstruction);
0051 
0052   G4PhysListFactory factory;
0053   runManager->SetUserInitialization(factory.ReferencePhysList());
0054 
0055   runManager->SetUserInitialization(new CCalActionInitializer());
0056   
0057   G4UImanager * UImanager = G4UImanager::GetUIpointer();
0058   UImanager->ApplyCommand("/CCal/generator/verbose 2");
0059   UImanager->ApplyCommand("/gun/position -1380. 0. 0. mm");
0060   UImanager->ApplyCommand("/gun/direction 1. 0. 0.");
0061   UImanager->ApplyCommand("/gun/energy 100 GeV");
0062 
0063   // Define (G)UI terminal for interactive mode
0064   if (argc==1) {  // No arguments - interactive assumed.
0065 
0066     visManager = new G4VisExecutive;
0067     visManager->Initialize();     
0068 
0069     G4UIExecutive* ui = new G4UIExecutive(argc, argv);
0070     if (ui->IsGUI()) {
0071       // Customize the menubar with a macro file :
0072       UImanager->ApplyCommand("/control/execute gui.mac");
0073     }
0074     G4cout <<" Run initializing ..."<<G4endl;
0075     UImanager->ApplyCommand("/process/verbose 0");
0076     UImanager->ApplyCommand("/run/verbose 2");
0077     UImanager->ApplyCommand("/run/initialize");
0078 
0079     // Create empty scene
0080     G4String visCommand = "/vis/scene/create";
0081     UImanager->ApplyCommand(visCommand);
0082     
0083     // Choose one default viewer 
0084     // (the user can always change it later on) 
0085     // visCommand = "/vis/open DAWNFILE";
0086     // visCommand = "/vis/open VRML2FILE";
0087     visCommand = "/vis/open OGL";
0088     UImanager->ApplyCommand(visCommand);
0089     
0090     visCommand = "/vis/viewer/flush";
0091     UImanager->ApplyCommand(visCommand);
0092     visCommand = "/tracking/storeTrajectory 1";
0093     UImanager->ApplyCommand(visCommand);
0094 
0095     G4cout <<"Now, please, apply beamOn command..."<<G4endl;
0096     ui->SessionStart();
0097     delete ui;
0098 
0099   } else {
0100 
0101     // Batch mode
0102     G4String command = "/control/execute ";
0103     G4String fileName = argv[1];
0104     UImanager->ApplyCommand(command+fileName);
0105   }
0106 
0107   // Complete clean-up
0108   delete runManager;
0109   delete visManager;
0110   return 0;
0111 }