Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:17:11

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 //
0028 // Author: Elena Guardincerri
0029 //
0030 // History:
0031 // -----------
0032 // 28 Nov 2001 Elena Guardincerri     Created
0033 // 24 Ago 2002 Splitted in a separet class  Alfonso Mantero
0034 // 18 Jan 2011 adapted to new deexcitation design
0035 //
0036 // -------------------------------------------------------------------
0037 
0038 #include "G4Types.hh"
0039 #include "G4RunManagerFactory.hh"
0040 #include "G4UImanager.hh"
0041 #include "Randomize.hh"
0042 #include "G4VisExecutive.hh"
0043 #include "G4UIExecutive.hh"
0044 #include "XrayFluoDetectorConstruction.hh"
0045 #include "XrayFluoPlaneDetectorConstruction.hh"
0046 #include "XrayFluoMercuryDetectorConstruction.hh"
0047 #include "XrayFluoPhysicsList.hh"
0048 #include "XrayFluoSimulation.hh"
0049 
0050 #include "XrayFluoActionInitializer.hh"
0051 #include "XrayFluoAnalysisManager.hh"
0052 
0053 void XrayFluoSimulation::RunSimulation(int argc,char* argv[])
0054 {
0055   auto* runManager = G4RunManagerFactory::CreateRunManager();
0056   G4int nThreads = 4;
0057   runManager->SetNumberOfThreads(nThreads);
0058 
0059   // chosing Geometry setup
0060   G4int geometryNumber = 0;
0061 
0062   if (argc == 3){
0063     geometryNumber =  atoi(argv[2]);
0064 
0065   }
0066   while ( (geometryNumber < 1) || (geometryNumber >4)) {
0067     G4cout << "Please Select Simulation Geometrical Set-Up: "<< G4endl;
0068     G4cout << "1 - Test Beam" << G4endl;
0069     G4cout << "2 - Infinite Plane" << G4endl;
0070     G4cout << "3 - Planet and Sun"<< G4endl;
0071     G4cout << "4 - Phase-Space Production"<< G4endl;
0072 
0073     G4cin >> geometryNumber;
0074   }
0075 
0076   // set analysis to have the messenger running...
0077   XrayFluoAnalysisManager* analysis =
0078     XrayFluoAnalysisManager::getInstance();
0079 
0080   // set mandatory initialization
0081 
0082   //Initialize geometry
0083   if (geometryNumber == 1 || geometryNumber == 4) {
0084     XrayFluoDetectorConstruction* testBeamDetector
0085       = XrayFluoDetectorConstruction::GetInstance();
0086     if (geometryNumber == 4) {
0087       testBeamDetector->PhaseSpaceOn();
0088       analysis->PhaseSpaceOn();
0089     }
0090     runManager->SetUserInitialization(testBeamDetector);
0091   }
0092   else if (geometryNumber == 2) {
0093     XrayFluoPlaneDetectorConstruction*
0094       planeDetector = XrayFluoPlaneDetectorConstruction::GetInstance();
0095     runManager->SetUserInitialization(planeDetector);
0096   }
0097   else if (geometryNumber == 3) {
0098     XrayFluoMercuryDetectorConstruction* mercuryDetector =
0099       XrayFluoMercuryDetectorConstruction::GetInstance();
0100     runManager->SetUserInitialization(mercuryDetector);
0101   }
0102 
0103 
0104   //Initialize physics
0105   runManager->SetUserInitialization(new   XrayFluoPhysicsList());
0106 
0107   //Initialize actions
0108   runManager->SetUserInitialization
0109     (new XrayFluoActionInitializer(geometryNumber));
0110 
0111   //visualization manager
0112   G4VisManager* visManager = new G4VisExecutive;
0113   visManager->Initialize();
0114 
0115   // get the pointer to the User Interface manager
0116   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0117 
0118   if (argc == 1)   // Define UI session for interactive mode.
0119     {
0120       UImanager->ApplyCommand("/control/execute initInter.mac");
0121       UImanager->ApplyCommand("/control/execute vis.mac");
0122       G4UIExecutive* ui = new G4UIExecutive(argc, argv);
0123       ui->SessionStart();
0124       delete ui;
0125     }
0126   else           // Batch mode
0127     {
0128       G4String command = "/control/execute ";
0129       G4String fileName = argv[1];
0130       UImanager->ApplyCommand(command+fileName);
0131     }
0132 
0133   // job termination
0134   delete visManager;
0135   G4cout << "visManager deleted"<< G4endl;
0136 
0137   delete runManager;
0138 }