Precalibrated Ion Beam Identification Detector Simulation 1.0
A pilot study detector simulation, written in C++ with Geant4.
Defines | Functions
PIBIDS.cc File Reference

Main file, starting the simulation. More...

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include <ctime>
#include "MyPhysicsList.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "SteppingAction.hh"
#include "SteppingVerbose.hh"
#include <stdio.h>

Go to the source code of this file.

Defines

#define STDIO
 Inclusion guard.

Functions

int main (int argc, char **argv)
 Main function, starting the program.

Detailed Description

Main file, starting the simulation.

Author:
Rikard Lundmark

Definition in file PIBIDS.cc.


Function Documentation

int main ( int  argc,
char **  argv 
)

Main function, starting the program.

Parameters:
argcNumber of arguments.
argvThe actual arguments.

Definition at line 38 of file PIBIDS.cc.

References PrimaryGeneratorAction::SetParticle().

{
  // Choose the Random engine
  //
  srand(time(0));
  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
  CLHEP::HepRandom::setTheSeed(rand()%10000+1);
  

  // User Verbose output class
  //
  G4VSteppingVerbose::SetInstance(new SteppingVerbose);
     
  // Construct the default run manager
  //
  G4RunManager * runManager = new G4RunManager;

  // Set mandatory initialization classes
  //
  DetectorConstruction* detector = new DetectorConstruction;
  runManager->SetUserInitialization(detector);
  //
  G4VUserPhysicsList* physics = new MyPhysicsList<G4VModularPhysicsList>;   
  runManager->SetUserInitialization(physics);
   
  // Set user action classes
  //

  //
  RunAction* run_action = new RunAction;  
  //


  PrimaryGeneratorAction * myAction = 
    new PrimaryGeneratorAction(detector,run_action);
  
  G4VUserPrimaryGeneratorAction* gen_action = myAction;

  runManager->SetUserAction(gen_action);

  runManager->SetUserAction(run_action);

  EventAction* event_action = new EventAction(run_action, detector);
  runManager->SetUserAction(event_action);
  //
  G4UserSteppingAction* stepping_action =
                    new SteppingAction(detector, event_action);
  runManager->SetUserAction(stepping_action);
  
  // Initialize G4 kernel
  //
  runManager->Initialize();

  myAction->SetParticle(6,17,0.,0.);
  
#ifdef G4VIS_USE
  // Initialize visualization
  //
  G4VisManager* visManager = new G4VisExecutive;
  visManager->Initialize();
#endif

  
  
  // Get the pointer to the User Interface manager
  //
  G4UImanager* UImanager = G4UImanager::GetUIpointer();
  
  if (argc==2)   // batch mode
    {
      G4String command = "/control/execute ";
      G4String fileName = argv[1];
      UImanager->ApplyCommand(command+fileName);    
    }
  else
    {  // interactive mode : define UI session
#ifdef G4UI_USE
      G4UIExecutive* ui = new G4UIExecutive(argc, argv);
#ifdef G4VIS_USE
      if(argc<2)
        UImanager->ApplyCommand("/control/execute vis.mac");     
      else //other init file.
        {
          G4String command = "/control/execute ";
          G4String fileName = argv[1];
          UImanager->ApplyCommand(command+fileName);    
        }
#endif
      if (ui->IsGUI())
        UImanager->ApplyCommand("/control/execute visTutor/gui.mac");     
      ui->SessionStart();
      delete ui;
#endif
    }
  
  // Job termination
  // Free the store: user actions, physics_list and detector_description are
  //                 owned and deleted by the run manager, so they should not
  //                 be deleted in the main() program !
#ifdef G4VIS_USE
  delete visManager;
#endif                
  delete runManager;

  return 0;
}
 All Classes Files Functions Variables Defines

Back to the main page of the Precalibrated Ion Beam Identification Detector project

Created by Rikard Lundmark