Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:47

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 /// \file biasing/ReverseMC01/exampleRMC01.cc
0027 /// \brief Main program of the biasing/ReverseMC01 example
0028 //
0029 //
0030 //
0031 //
0032 // --------------------------------------------------------------
0033 //      GEANT 4 - exampleRMC01
0034 //
0035 // --------------------------------------------------------------
0036 // Comments
0037 //
0038 // This example intends to show how to use the adjoint/reverse simulation mode.
0039 //
0040 // --------------------------------------------------------------
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0044 
0045 #include "RMC01AdjointEventAction.hh"
0046 #include "RMC01DetectorConstruction.hh"
0047 #include "RMC01EventAction.hh"
0048 #include "RMC01PrimaryGeneratorAction.hh"
0049 #include "RMC01RunAction.hh"
0050 
0051 #include "G4AdjointPhysicsList.hh"
0052 #include "G4AdjointSimManager.hh"
0053 #include "G4RunManagerFactory.hh"
0054 #include "G4Types.hh"
0055 #include "G4UIExecutive.hh"
0056 #include "G4UImanager.hh"
0057 #include "G4VisExecutive.hh"
0058 #include "Randomize.hh"
0059 
0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0061 
0062 int main(int argc, char** argv)
0063 {
0064   // Instantiate G4UIExecutive if interactive mode
0065   G4UIExecutive* ui = nullptr;
0066   if (argc == 1) {
0067     ui = new G4UIExecutive(argc, argv);
0068   }
0069 
0070   // Construct a serial run manager
0071   auto* theRunManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly);
0072 
0073   RMC01DetectorConstruction* detector = new RMC01DetectorConstruction();
0074 
0075   // Physics and geometry are declared as in a normal G4 application
0076   //--------------------------------------------
0077   theRunManager->SetUserInitialization(detector);
0078   theRunManager->SetUserInitialization(new G4AdjointPhysicsList);
0079 
0080   theRunManager->SetUserAction(new RMC01PrimaryGeneratorAction);
0081   theRunManager->SetUserAction(new RMC01EventAction);
0082   RMC01RunAction* theRunAction = new RMC01RunAction;
0083   theRunManager->SetUserAction(theRunAction);
0084 
0085   // The adjoint simulation manager will control the Reverse MC mode
0086   //---------------------------------------------------------------
0087 
0088   G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();
0089 
0090   // It is possible to define action that will be used during
0091   //                                         the adjoint tracking phase
0092 
0093   theAdjointSimManager->SetAdjointRunAction(theRunAction);
0094   // theAdjointSimManager->SetAdjointEventAction(new RMC01AdjointEventAction);
0095   theAdjointSimManager->SetAdjointEventAction(new RMC01EventAction);
0096 
0097   // visualization manager
0098   G4VisManager* visManager = new G4VisExecutive;
0099   visManager->Initialize();
0100 
0101   // get the pointer to the User Interface manager
0102   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0103 
0104   if (!ui)  // batch mode
0105   {
0106     G4String command = "/control/execute ";
0107     G4String fileName = argv[1];
0108     UImanager->ApplyCommand(command + fileName);
0109   }
0110   else {  // interactive mode : define UI session
0111     ui->SessionStart();
0112     delete ui;
0113   }
0114 
0115   // job termination
0116   delete visManager;
0117   delete theRunManager;
0118 
0119   return 0;
0120 }
0121 
0122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......