#include #include // for atoi #include "G4RunManager.hh" #include "G4UImanager.hh" #include "G4ios.hh" #include "FCALDetectorConstruction.hh" #include "FCALPhysicsList.hh" #include "FCALPhysicsListMessenger.hh" #include "FCALPrimaryGeneratorAction.hh" #include "FCALEventAction.hh" #include "FCALRunAction.hh" #include "FCALSteppingAction.hh" #include "FCALStackingAction.hh" #include "FCALTrackingAction.hh" #include "FCALTrackingMessenger.hh" #include "TFile.h" #include "TTree.h" #include "Randomize.hh" int main(int argc, char** argv) { G4int n_Rows, n_Columns; // number of rows and number of columns G4double particle_Energy; // the energy of an incident particle G4double gun_Azimuthal; // the azimuthal angle of the particle gun G4int n_Events; // number of events G4String output_FileName; // the name of output file for 'ROOT' if (argc >= 7) { n_Rows = atoi(argv[1]); n_Columns = atoi(argv[2]); particle_Energy = atof(argv[3]); gun_Azimuthal = atof(argv[4]); n_Events = atoi(argv[5]); output_FileName = argv[6]; } else { G4cout << "You must input the following information." << G4endl; G4cout << "Usage: " << G4endl; return 1; } // ---------------------------------------------------------------------- // -------- 0. Seed the random number generator manually // ---------------------------------------------------------------------- unsigned long my_Seed = time(NULL); CLHEP::HepRandom::setTheSeed(my_Seed); // ---------------------------------------------------------------------- // -------- 1. Construction of the default run manager // ---------------------------------------------------------------------- G4RunManager* run_Manager = new G4RunManager; // ---------------------------------------------------------------------- // -------- 2. Mandatory initialization class set-up // ------------------------------------- G4cout << "End of the Geometry Construction" << G4endl;--------------------------------- FCALDetectorConstruction* detector_Construction = new FCALDetectorConstruction(n_Rows, n_Columns); run_Manager->SetUserInitialization(detector_Construction); run_Manager->SetUserInitialization(new FCALPhysicsList); // ---------------------------------------------------------------------- // -------- 3. User action class set-up and creation of a tree // ---------------------------------------------------------------------- FCALPrimaryGeneratorAction* generator_Action = new FCALPrimaryGeneratorAction(particle_Energy, gun_Azimuthal); run_Manager->SetUserAction(generator_Action); TFile* f = new TFile(output_FileName, "RECREATE"); TTree* FCAL_Tree = new TTree("FCALTree", "FCALTree"); // create a tree FCALEventAction* event_Action = new FCALEventAction(detector_Construction, generator_Action, FCAL_Tree); run_Manager->SetUserAction(event_Action); run_Manager->SetUserAction(new FCALRunAction(detector_Construction, event_Action)); run_Manager->SetUserAction(new FCALSteppingAction(event_Action)); run_Manager->SetUserAction(new FCALStackingAction(event_Action)); run_Manager->SetUserAction(new FCALTrackingAction); // ---------------------------------------------------------------------- // -------- 4. Initialization of G4 kernel // ---------------------------------------------------------------------- run_Manager->Initialize(); // ---------------------------------------------------------------------- // -------- 5. UI Session // ---------------------------------------------------------------------- G4UImanager* UI = G4UImanager::GetUIpointer(); // Getting the pointer to UI manager UI->ApplyCommand("/event/verbose 0"); UI->ApplyCommand("/tracking/verbose 0"); UI->ApplyCommand("/phys/verbose 0"); UI->ApplyCommand("/control/verbose 0"); UI->ApplyCommand("/run/verbose 2"); // ---------------------------------------------------------------------- // -------- 6. Job Start // ---------------------------------------------------------------------- run_Manager->BeamOn(n_Events); // ---------------------------------------------------------------------- // -------- 7. Job Termination // ---------------------------------------------------------------------- delete run_Manager; FCAL_Tree->Write(); f->Close(); G4cout << "Success!" << G4endl; return 0; }