00001
00002
00003
00004
00005
00006 #include "G4RunManager.hh"
00007 #include "G4UImanager.hh"
00008 #include "LHEP.hh"
00009 #include "QGSP.hh"
00010
00011 #include "LCDXML2G4DetConst.hh"
00012 #include "LCDG4_SIOglobal.hh"
00013 #include "LCDG4readStdFile.hh"
00014 #include "LCDG4PrimaryGeneratorAction.hh"
00015 #include "LCDG4RunAction.hh"
00016 #include "LCDG4EventAction.hh"
00017 #include "LCDG4SteppingAction.hh"
00018 #include "LCDG4TrackingAction.hh"
00019 #include "LCDG4McPartManager.hh"
00020
00021
00022 #include "FTFP.hh"
00023 #include "LHEP.hh"
00024 #include "LHEP_BERT.hh"
00025 #include "LHEP_BIC.hh"
00026 #include "LHEP_GN.hh"
00027 #include "LHEP_HP.hh"
00028 #include "QGSC.hh"
00029 #include "QGSP.hh"
00030 #include "QGSP_BERT.hh"
00031 #include "QGSP_BIC.hh"
00032
00033 #include <iostream>
00034 #include <fstream>
00035 using std::cout;
00036 using std::endl;
00037 using std::ifstream;
00038
00039 #ifdef G4VIS_USE
00040 #include "LCDG4VisManager.hh"
00041 #endif
00042
00043 int main(int argc,char *argv[])
00044 {
00045 const char* env = getenv("PEGS4PATH");
00046 if(env == NULL) {
00047 cout << "Error! The PEGS4PATH environment variable is not set.\n";
00048 exit(0);
00049 }
00050
00051 if(argc < 6) {
00052 cout << "Error! Not enough command line arguments. Usage is:\n";
00053 cout << "lcdg4 input_file.xml output_file.sio Detector_ID input_file.stdhep macro_file output_file.slcio\n\n";
00054 cout << "For example:\n";
00055 cout << "lcdg4 SDMar01.xml output.sio SDMar01 events.stdhep macro_file output.slcio\n";
00056 exit(0);
00057 }
00058
00059
00060 char* xml_file = argv[1];
00061 char* sio_file = argv[2];
00062 char* det_id = argv[3];
00063 char* stdhep_file = argv[4];
00064 char* macro_file = argv[5];
00065 char* lcio_file = argv[6];
00066 char* hadphys = (char*)"LHEP";
00067 if(argc==8) hadphys = argv[7];
00068
00069 cout << "The following inputs have been selected:"<< endl;
00070 cout << "XML File input: " << xml_file << endl;
00071 cout << "SIO File output: " << sio_file << endl;
00072 cout << "Detector ID: " << det_id << endl;
00073 cout << "StdHEP file: " << stdhep_file << endl;
00074 cout << "Macro file: " << macro_file << endl;
00075 cout << "LCIO File output: " << lcio_file << endl;
00076 cout << "PEGS4PATH = " << env << endl;
00077
00078
00079 LCDG4_SIOglobal sio(sio_file, det_id);
00080 SIO_stream* stream = sio.getStream();
00081
00082
00083
00084
00085 G4RunManager* runManager = new G4RunManager;
00086
00087
00088 LCDXML2G4DetConst* xmldet = new LCDXML2G4DetConst(xml_file);
00089 runManager->SetUserInitialization(xmldet);
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 G4cout << "Hadronic physics selected: "<< hadphys << G4endl;
00105 if(!strcmp(hadphys,"LHEP")) runManager->SetUserInitialization(new LHEP);
00106 if(!strcmp(hadphys,"LHEP-BERT")) runManager->SetUserInitialization(new LHEP_BERT);
00107 if(!strcmp(hadphys,"LHEP-BIC")) runManager->SetUserInitialization(new LHEP_BIC);
00108 if(!strcmp(hadphys,"LHEP-GN")) runManager->SetUserInitialization(new LHEP_GN);
00109 if(!strcmp(hadphys,"LHEP-HP")) runManager->SetUserInitialization(new LHEP_HP);
00110 if(!strcmp(hadphys,"QGSP")) runManager->SetUserInitialization(new QGSP);
00111 if(!strcmp(hadphys,"QGSP-BERT")) runManager->SetUserInitialization(new QGSP_BERT);
00112 if(!strcmp(hadphys,"QGSP-BIC")) runManager->SetUserInitialization(new QGSP_BIC);
00113 if(!strcmp(hadphys,"QGSC")) runManager->SetUserInitialization(new QGSC);
00114 if(!strcmp(hadphys,"FTFP")) runManager->SetUserInitialization(new FTFP);
00115
00116
00117
00118 int debflg=0x0;
00119 LCDG4McPartManager* mcmgr = new LCDG4McPartManager(xmldet->GetDetTypeMap(),debflg);
00120
00121
00122 #ifdef G4VIS_USE
00123 G4VisManager* visManager = new LCDG4VisManager;
00124 visManager->Initialize();
00125 #endif
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 LCDG4readStdFile* stdfile = new LCDG4readStdFile(stdhep_file,mcmgr);
00147 LCDG4PrimaryGeneratorAction* pgen =
00148 new LCDG4PrimaryGeneratorAction(stdfile);
00149
00150
00151
00152
00153 runManager->SetUserAction( pgen );
00154
00155
00156 runManager->SetUserAction( new LCDG4RunAction(det_id) );
00157
00158
00159 LCDG4EventAction* pEventAction = new LCDG4EventAction(stream,mcmgr);
00160 runManager->SetUserAction(pEventAction);
00161
00162
00163 runManager->SetUserAction(new LCDG4TrackingAction(mcmgr));
00164 runManager->SetUserAction(new LCDG4SteppingAction(mcmgr));
00165
00166
00167
00168 #ifdef TXT_MODE
00169 pEventAction->SetupOutputTextFile();
00170 #endif
00171 pEventAction->SetupOutputLcio(lcio_file);
00172
00173 runManager->Initialize();
00174
00175 G4UImanager* UI = G4UImanager::GetUIpointer();
00176 G4String command = "/control/execute ";
00177 G4String fileName = macro_file;
00178 UI->ApplyCommand(command+fileName);
00179
00180 stream->close();
00181
00182 #ifdef G4VIS_USE
00183 delete visManager;
00184 #endif
00185
00186 delete runManager;
00187 exit(0);
00188 }