Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

lcdg4.cc File Reference

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "LHEP.hh"
#include "QGSP.hh"
#include "LCDXML2G4DetConst.hh"
#include "LCDG4_SIOglobal.hh"
#include "LCDG4readStdFile.hh"
#include "LCDG4PrimaryGeneratorAction.hh"
#include "LCDG4RunAction.hh"
#include "LCDG4EventAction.hh"
#include "LCDG4SteppingAction.hh"
#include "LCDG4TrackingAction.hh"
#include "LCDG4McPartManager.hh"
#include "FTFP.hh"
#include "LHEP_BERT.hh"
#include "LHEP_BIC.hh"
#include "LHEP_GN.hh"
#include "LHEP_HP.hh"
#include "QGSC.hh"
#include "QGSP_BERT.hh"
#include "QGSP_BIC.hh"
#include <iostream>
#include <fstream>

Include dependency graph for lcdg4.cc:

Include dependency graph

Go to the source code of this file.

Functions

int main (int argc, char *argv[])


Function Documentation

int main int  argc,
char *  argv[]
 

Definition at line 43 of file lcdg4.cc.

References SIO_stream::close(), LCDXML2G4DetConst::GetDetTypeMap(), LCDG4_SIOglobal::getStream(), and LCDG4EventAction::SetupOutputLcio().

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   // command line arguments
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"; // default
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   // Open and initialize output SIO file
00079   LCDG4_SIOglobal sio(sio_file, det_id);
00080   SIO_stream* stream = sio.getStream();
00081 
00082   //*** Geant4 stuff ***
00083 
00084   // run manager
00085   G4RunManager* runManager = new G4RunManager;
00086 
00087   // detector construction
00088   LCDXML2G4DetConst* xmldet = new LCDXML2G4DetConst(xml_file);
00089   runManager->SetUserInitialization(xmldet);
00090 
00091   //*** LOOK HERE *** CHOOSE THE PHYSICS LIST ***
00092   /*-- SELECT YOUR G4 PHYSICS LIST -------------------
00093    * LHEP - parameterized (Gheisha)
00094    * LHEP-BERT - Gheisha + Bertini cascade (E<3GeV)
00095    * LHEP-BIC  - Gheisha + Binary cascade (E<3GeV)
00096    * LHEP-GN   - Gheisha + gamma-Nucleon processes
00097    * LHEP-HP   - Gheisha + evaluated x-sec data (for neutrons w/E<20MeV)
00098    * QGSP      - Gheisha + quark-gluon string model (E>25GeV): theory-driven
00099    * QGSP-BERT - Gheisha + Bertini (E<3GeV) + qg string model (E>25GeV)
00100    * QGSP-BIC  - Gheisha + Binary (E<3GeV)  + qg string model (E>25GeV)
00101    * FTFP      - Gheisha + qg string model (E>25GeV) with Fritjof fragmentation
00102    * QGSC      - Gheisha + quark-gluon string model (E>25GeV): theory-driven
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   //***endLOOKHERE***
00116 
00117   // LCDG4 specific stuff
00118   int debflg=0x0; //  Check LCDG4McPartManager.cc for details
00119   LCDG4McPartManager* mcmgr = new LCDG4McPartManager(xmldet->GetDetTypeMap(),debflg);
00120 
00121   // Visualization system
00122 #ifdef G4VIS_USE
00123   G4VisManager* visManager = new LCDG4VisManager;
00124   visManager->Initialize();
00125 #endif
00126 
00127   //=========================
00128 
00129 //   //*** set run with single particles ***
00130 //   double energy=0;
00131 //   G4String partType = "";
00132 //   ifstream singfile("singfile");
00133 //   singfile >> partType >> energy;
00134 //   singfile.close();
00135 //   energy *= GeV;
00136 
00137 //   LCDG4PrimaryGeneratorAction* pgen = new LCDG4PrimaryGeneratorAction();
00138 //   pgen->SetHEPEvtGenerator(false);  // false forces use of particle gun
00139 //   pgen->SetConeRadius(0.15);  // false forces use of particle gun
00140 //   pgen->SetPartGunEnergy(energy);
00141 //   pgen->SetPartGunType(partType);
00142 
00143   //=======
00144 
00145   // StdHEP and event generation
00146   LCDG4readStdFile* stdfile = new LCDG4readStdFile(stdhep_file,mcmgr);
00147   LCDG4PrimaryGeneratorAction* pgen =
00148     new LCDG4PrimaryGeneratorAction(stdfile);
00149 //   pgen->SetHEPEvtGenerator(false);  // false forces use of G4ParticleGun
00150 
00151   //========
00152 
00153   runManager->SetUserAction( pgen );
00154 
00155   // run action
00156   runManager->SetUserAction( new LCDG4RunAction(det_id) );
00157 
00158   // event action
00159   LCDG4EventAction* pEventAction = new LCDG4EventAction(stream,mcmgr);
00160   runManager->SetUserAction(pEventAction);
00161 
00162   // tracking and stepping
00163   runManager->SetUserAction(new LCDG4TrackingAction(mcmgr));
00164   runManager->SetUserAction(new LCDG4SteppingAction(mcmgr));
00165 
00166   // This sets up ASCII output format (NICADD studies)
00167   // The filename is set from TXTFILEPATH environment variable
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 }


Generated on Thu Oct 7 18:44:49 2004 for LCDG4 by doxygen 1.3.4