Exemple #1
0
int main(int argc, char** argv)   {
  string gdml = argv[1];
  string setup = argv[2];
  const char* args[] = {"cmd"};
  for(int i=1; i<argc;++i)   {
    if ( argv[i][0]=='-' )     {
      string n = argv[i]+1;
      if ( ::strncmp(n.c_str(),"gdml",4) == 0 )
        gdml = get_arg(argc,argv,++i);
      else if ( ::strncmp(n.c_str(),"guisetup",3) == 0 )
        setup = get_arg(argc,argv,++i);
    }
  }
  if ( gdml.empty() || setup.empty() )  {
    cout << " usage: g4gdmlDisplay -gdml <file-name> -guisetup <g4 macro>" << endl;
    return EINVAL;
  }

  G4RunManager * run = new G4RunManager;
  run->SetUserInitialization(new Geant4GDMLDetector(gdml));
  run->SetUserInitialization(new EmptyPhysicsList());
  //
  // Initialize G4 kernel
  run->Initialize();
  //
  // Initialize visualization
  G4VisManager* vis = new G4VisExecutive;
  vis->Initialize();
  //
  // Get the pointer to the User Interface manager
  G4UImanager* uiman = G4UImanager::GetUIpointer();
  G4UIExecutive* ui = new G4UIExecutive(1,(char**)args);
  uiman->ApplyCommand("/control/execute "+setup);
  ui->SessionStart();
  // end ...
  delete ui;
  delete vis;
  delete run;
  return 0;
}
Exemple #2
0
int main(int argc,char** argv)
{

    time_t lt;
    lt = time(NULL);
    ptr = gmtime(&lt);
    printf(asctime(ptr)); // Greenwich Mean time (GMT)
    printf(ctime(&lt)); //local time

    CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
    G4long seed = time(NULL);
    CLHEP::HepRandom::setTheSeed(seed);

    G4RunManager* runManager = new G4RunManager;

    ProDetectorConstruction* detectorCon = new ProDetectorConstruction();
    runManager->SetUserInitialization(detectorCon);

    PhysicsList* physics = new PhysicsList();
    runManager->SetUserInitialization(physics);

    ProAnalysis * anly = new ProAnalysis();

    // UserAction classes - optional
    G4VUserPrimaryGeneratorAction* generator = new ProPrimaryGeneratorAction(detectorCon);
    runManager->SetUserAction(generator);

    ProRunAction* RunAct = new ProRunAction(anly);
    runManager->SetUserAction(RunAct);
    ProEventAction* EvAct = new ProEventAction(RunAct,anly);
    runManager->SetUserAction(EvAct);

    runManager->Initialize();

#ifdef G4VIS_USE
    G4VisManager* visManager = new G4VisExecutive;
    visManager->Initialize();
#endif

    G4UImanager* uiManager = G4UImanager::GetUIpointer();

    if(argc != 1){
        G4String command = "/control/execute ";
        G4String fileName = argv[1];
        uiManager->ApplyCommand(command+fileName);
    }
    else {
#ifdef G4UI_USE
        G4UIExecutive* ui = new G4UIExecutive(argc,argv);
#ifdef G4VIS_USE
        uiManager->ApplyCommand("/control/execute vis.mac");
#endif
        ui->SessionStart();
        delete ui;
#endif
    }

//*******************************************************************

    G4cout<<" This is a Collimator Test which let neutrons having 180MeV "
          <<" pass through collimator, and two collimator detectors are "
          <<" used to record neutrons information" <<G4endl;
//*******************************************************************

#ifdef G4VIS_USE
    delete visManager;
#endif

    delete anly;
    delete runManager;

    return 0;
}