moller_sim.cc File Reference

#include "MollerDetectorConstruction.hh"
#include "MollerGlobalMagnetField.hh"
#include "MollerPhysicsList.hh"
#include "MollerPrimaryGenAction.hh"
#include "MollerRunAction.hh"
#include "MollerEventAction.hh"
#include "MollerSteppingVerbose.hh"
#include "MollerSteppingAction.hh"
#include "MollerAnalysis.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
Include dependency graph for moller_sim.cc:

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 35 of file moller_sim.cc.

References RootAnalysis::End().

00036 {
00037   // Verbose output class
00038   //
00039   G4VSteppingVerbose* verbosity = new MollerSteppingVerbose();
00040   G4VSteppingVerbose::SetInstance(verbosity);
00041 
00042   // Construct the default Run Manager
00043   //
00044   G4RunManager* runManager = new G4RunManager;
00045 
00046   // Mandatory User Initialization classes
00047   //
00048   MollerDetectorConstruction* detector = new MollerDetectorConstruction;
00049   runManager->SetUserInitialization(detector);
00050   runManager->SetUserInitialization(new MollerPhysicsList);
00051 
00052   // User Action Classes
00053   //
00054   runManager->SetUserAction(new MollerPrimaryGenAction);
00055   runManager->SetUserAction(new MollerRunAction);
00056   runManager->SetUserAction(new MollerEventAction);
00057   runManager->SetUserAction(new MollerSteppingAction);
00058 
00059 
00060   // Determine whether in batch or interactive mode
00061   G4bool interactiveMode = true;
00062   if (argc == 3) interactiveMode = false;
00063 
00064   // Define UI session for interactive mode
00065   //
00066   G4UIsession* session = 0;
00067   if (interactiveMode) {
00068     #if defined(G4UI_USE_QT)
00069       G4cout << "Creating Qt user interface." << G4endl;
00070       session = new G4UIQt(argc,argv);
00071     #elif defined(G4UI_USE_XM)
00072       G4cout << "Creating Xm user interface." << G4endl;
00073       session = new G4UIXm(argc,argv);
00074     #elif defined(G4UI_USE_QT)
00075       G4cout << "Creating Qt user interface." << G4endl;
00076       session = new G4UIQt(argc,argv);
00077     #elif defined(G4UI_USE_WIN32)
00078       G4cout << "Creating win32 user interface." << G4endl;
00079       session = new G4UIWin32();
00080     #elif defined(G4UI_USE_TCSH)
00081       G4cout << "Creating tcsh user interface." << G4endl;
00082       session = new G4UIterminal(new G4UItcsh);
00083     #else
00084       #warning "No user interface supported."
00085     #endif
00086 
00087     if (session == 0)
00088       G4cout << "No user interface created." << G4endl;
00089   }
00090 
00091 
00092   // Visualization, if you choose to have it!
00093   //
00094   #ifdef G4VIS_USE
00095     G4VisManager* visManager = new G4VisExecutive;
00096     // Simple graded message scheme - give first letter or a digit:
00097     //  0) quiet,         // Nothing is printed.
00098     //  1) startup,       // Startup and endup messages are printed...
00099     //  2) errors,        // ...and errors...
00100     //  3) warnings,      // ...and warnings...
00101     //  4) confirmations, // ...and confirming messages...
00102     //  5) parameters,    // ...and parameters of scenes and views...
00103     //  6) all            // ...and everything available.
00104     visManager->SetVerboseLevel(6);
00105     visManager->Initialize();
00106   #endif
00107 
00108 
00109   // Get the pointer to the User Interface manager
00110   //
00111   G4UImanager* UI = G4UImanager::GetUIpointer();
00112 
00113 
00114   // Load prerun macro
00115   //
00116   if (argc > 1) {
00117     G4String command = "/control/execute ";
00118     G4String fileName = argv[1];
00119     UI->ApplyCommand(command + fileName);
00120     G4cout << "Got geometry info from the prerun macro." << G4endl;
00121   } else {
00122     G4cout << G4endl<< G4endl;
00123     G4cout << "==========================================================="<< G4endl;
00124     G4cout << "Please specify the prerun macro, or live with the defaults!"<< G4endl;
00125     G4cout << "==========================================================="<< G4endl;
00126     G4cout << G4endl<< G4endl;
00127   }
00128 
00129 
00130   // Start analysis
00131   //
00132   MollerAnalysis* analysis = new MollerAnalysis(detector);
00133 
00134 
00135   // Initialize G4 kernel
00136   //
00137   runManager->Initialize();
00138 
00139 
00140   // Define UI session for interactive mode
00141   //
00142   if (session) {
00143     // Interactive mode
00144     #if defined(G4UI_USE_XM) || defined(G4UI_USE_WIN32) || defined(G4UI_USE_QT)
00145       // Customize the user interface
00146       UI->ApplyCommand("/control/execute gui.mac");
00147     #endif
00148     // Start interactive session
00149     session->SessionStart();
00150     delete session;
00151   } else {
00152     // Batch mode
00153     if (argc > 2) {
00154       G4String command = "/control/execute ";
00155       G4String fileName = argv[2];
00156       UI->ApplyCommand(command + fileName);
00157     } else {
00158       G4cout << "Only prerun macro specified but still in batch mode." << G4endl;
00159     }
00160   }
00161 
00162 
00163   // End analysis
00164   //
00165   analysis->End();
00166   delete analysis;
00167 
00168 
00169   #ifdef G4VIS_USE
00170   delete visManager;
00171   #endif
00172 
00173   delete verbosity;
00174   delete runManager;
00175 
00176   return 0;
00177 }

Here is the call graph for this function:


Generated on 16 Jun 2013 for mollersim by  doxygen 1.6.1