File indexing completed on 2025-01-17 09:57:14
0001
0002 #include "G4RunManager.hh"
0003 #include "G4UImanager.hh"
0004
0005 #include "FTFP_BERT.hh"
0006 #include "G4EmStandardPhysics_option4.hh"
0007 #include "G4OpticalPhysics.hh"
0008
0009 #define _GEANT_SOURCE_CODE_
0010 #include "RunAction.h"
0011 #include "CherenkovEvent.h"
0012 #include "CherenkovSteppingAction.h"
0013 #include "CherenkovStackingAction.h"
0014
0015 #include "G4VisExecutive.hh"
0016 #include "G4UIExecutive.hh"
0017
0018 #include <share.h>
0019
0020
0021
0022 namespace {
0023 void PrintUsage() {
0024 G4cerr << " Usage: " << G4endl;
0025 G4cerr << " pfrich [-m macro ] [-u UIsession] [-r seed] [-s statistics] [-i <input HEPMC3 file>] [-o <output ROOT file>]" << G4endl;
0026 }
0027 }
0028
0029 #include <TFile.h>
0030 #include <TTree.h>
0031
0032 #include <CherenkovDetectorCollection.h>
0033
0034
0035
0036 int main(int argc, char** argv)
0037 {
0038
0039 if ( argc > 9 ) {
0040 PrintUsage();
0041 return 1;
0042 }
0043
0044
0045 G4String macro;
0046 G4String session;
0047
0048
0049 const char *infile = 0;
0050
0051 unsigned stat = _STATISTICS_DEFAULT_;
0052 G4String outfile = "pfrich.root";
0053
0054 G4long myseed = 345354;
0055 for ( G4int i=1; i<argc; i=i+2 ) {
0056 if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
0057 else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
0058 #if defined(HEPMC3)
0059 else if ( G4String(argv[i]) == "-i" ) infile = argv[i+1];
0060 #endif
0061 else if ( G4String(argv[i]) == "-o" ) outfile = argv[i+1];
0062 else if ( G4String(argv[i]) == "-r" ) myseed = atoi(argv[i+1]);
0063 else if ( G4String(argv[i]) == "-s" ) stat = atoi(argv[i+1]);
0064 else {
0065 PrintUsage();
0066 return 1;
0067 }
0068 }
0069
0070 auto outputFile = TFile::Open(outfile, "RECREATE");
0071
0072 auto geometry = new CherenkovDetectorCollection();
0073 auto event = new CherenkovEvent();
0074
0075 auto TT = new TTree("t", "My tree");
0076 TT->Branch("e", "CherenkovEvent", &event, 16000, 2);
0077
0078
0079 G4Random::setTheEngine(new CLHEP::RanecuEngine);
0080
0081
0082 G4RunManager * runManager = new G4RunManager;
0083
0084
0085 G4Random::setTheSeed(myseed);
0086
0087
0088
0089
0090 {
0091 G4VModularPhysicsList* physicsList = new FTFP_BERT;
0092 physicsList->ReplacePhysics(new G4EmStandardPhysics_option4());
0093 G4OpticalPhysics* opticalPhysics = new G4OpticalPhysics();
0094 physicsList->RegisterPhysics(opticalPhysics);
0095 runManager->SetUserInitialization(physicsList);
0096 }
0097
0098
0099 setup(runManager, geometry, infile);
0100
0101 runManager->SetUserAction(new RunAction());
0102 {
0103 auto stepping = new CherenkovSteppingAction(geometry, event);
0104 #ifdef _DISABLE_SECONDARIES_
0105 stepping->DisableSecondaries();
0106 #endif
0107 runManager->SetUserAction(stepping);
0108 }
0109 runManager->SetUserAction(new CherenkovStackingAction(event, TT));
0110
0111
0112 runManager->Initialize();
0113
0114
0115 G4VisManager* visManager = new G4VisExecutive;
0116 visManager->Initialize();
0117
0118
0119
0120 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0121
0122
0123
0124
0125 if ( macro.size() ) {
0126
0127 G4UIExecutive * ui = new G4UIExecutive(argc,argv,session);
0128 G4String command = "/control/execute ";
0129 UImanager->ApplyCommand(command+macro);
0130
0131 #ifdef _GEOMETRY_CHECK_
0132 UImanager->ApplyCommand("/geometry/test/run");
0133 #endif
0134
0135 ui->SessionStart();
0136 delete ui;
0137 } else {
0138
0139 TString cmd; cmd.Form("/run/beamOn %d", stat);
0140 UImanager->ApplyCommand(cmd.Data());
0141 }
0142
0143
0144
0145
0146
0147
0148
0149 delete visManager;
0150 delete runManager;
0151
0152 geometry->Write();
0153 TT->Write();
0154 outputFile->Close();
0155
0156 return 0;
0157 }
0158
0159
0160