#include #include #include #include // for atoi, At first, you should check if the standard C++ is provided. // If not, you have to change the left header file to #include "G4RunManager.hh" #include "G4UImanager.hh" #include "G4UIterminal.hh" #include "G4UItcsh.hh" #include "G4ios.hh" #ifdef G4UI_USE_XM #include "G4UIXm.hh" #endif #ifdef G4UI_USE_WIN32 #include "G4UIWin32.hh" #endif #include "LGDetectorConstruction.hh" #include "LGPhysicsList.hh" #include "LGPhysicsListMessenger.hh" #include "LGPrimaryGeneratorAction.hh" #include "LGEventAction.hh" #include "LGRunAction.hh" #include "LGSteppingAction.hh" #include "LGStackingAction.hh" #include "LGTrackingAction.hh" #include "LGTrackingMessenger.hh" #include "TFile.h" #include "TTree.h" #include "TH1.h" #include "Randomize.hh" #ifdef G4VIS_USE #include "G4VisExecutive.hh" #endif void Usage(){ G4cout <<"Usage: "; G4cout <<" LGGui [options] "<Initialize(); #endif } //---------------------------------------------------------------------- //-------- 4. User action class set-up //---------------------------------------------------------------------- LGPrimaryGeneratorAction* generator_Action = new LGPrimaryGeneratorAction(RandomDir); run_Manager->SetUserAction(generator_Action); TFile* f = NULL; TTree* LG_Tree = NULL; if (!Interactive){ f = new TFile(output_FileName, "RECREATE"); LG_Tree = new TTree("LGTree", "LGTree"); // create a tree in Bach mode } // setup histogram to record Cerenkov photon wavelength TH1F *spectra[20]; TH2F *spectra2d[6]; makeHistos(spectra, spectra2d, BendFirst); LGEventAction* event_Action = new LGEventAction(detector_Construction, generator_Action, Interactive, LG_Tree); run_Manager->SetUserAction(event_Action); run_Manager->SetUserAction(new LGRunAction(detector_Construction, event_Action)); run_Manager->SetUserAction(new LGSteppingAction(event_Action, zLG, QE, spectra,spectra2d, BendFirst)); run_Manager->SetUserAction(new LGStackingAction(event_Action)); run_Manager->SetUserAction(new LGTrackingAction); // ---------------------------------------------------------------------- // -------- 5. Initialization of G4 kernel // ---------------------------------------------------------------------- run_Manager->Initialize(); // ---------------------------------------------------------------------- // -------- 6. UI Session // ---------------------------------------------------------------------- G4UImanager* UI = G4UImanager::GetUIpointer(); // Getting the pointer to UI manager if (session){ // Define UI session for interactive mode. // G4UIterminal is a (dumb) terminal. UI->ApplyCommand("/control/execute vis.mac"); #if defined(G4UI_USE_XM) || defined(G4UI_USE_WIN32) // Customize the G4UIXm,Win32 menubar with a macro file : UI->ApplyCommand("/control/execute gui.mac"); #endif session->SessionStart(); delete session; } else{ // Batch mode G4cout << "IN BATCH MODE!" << G4endl; UI->ApplyCommand("/control/saveHistory history.txt"); UI->ApplyCommand("/event/verbose 0"); UI->ApplyCommand("/tracking/verbose 0"); UI->ApplyCommand("/phys/verbose 0"); UI->ApplyCommand("/control/verbose 2"); UI->ApplyCommand("/run/verbose 2"); G4String command = "/control/execute "; UI->ApplyCommand(command+file_Name); G4cout<<"Generate "<BeamOn(n_Events); } // ---------------------------------------------------------------------- // -------- 7. Job Termination // ---------------------------------------------------------------------- if(Interactive){ #ifdef G4VIS_USE delete vis_Manager; #endif } delete run_Manager; if (!Interactive){ G4double tin = spectra2d[1]->GetEntries(); G4double tout = spectra2d[2]->GetEntries(); G4double tout1 = spectra2d[3]->GetEntries(); G4double tout2 = spectra2d[4]->GetEntries(); G4double tout3 = spectra2d[5]->GetEntries(); if (BendFirst){ G4cout<<"Loss in bending section: "<< (1.-tout/tin)*100. <<"%"<Write(); for (int i=0;i<6;i++){ spectra2d[i]->Write(); } f->Close(); } G4cout << "END OF PROGRAM: Success!" << G4endl; return 0; } void makeHistos(TH1F** hist1d, TH2F** hist2d, G4int BF){ hist2d[0] = new TH2F("hist2d0","photons hit entrance of light guide", 80,-40.,40.,80,-40.,40.); hist2d[0]->GetXaxis()->SetTitle("Horizontal distance [mm]"); hist2d[0]->GetYaxis()->SetTitle("Vertical distance [mm]"); if (BF){ hist2d[1] = new TH2F("hist2d1","photons hit start bending square section", 80,-40.,40.,80,-40.,40.); } else { hist2d[1] = new TH2F("hist2d1","photons hit start of Tappered section", 80,-40.,40.,80,-40.,40.); } hist2d[1]->GetXaxis()->SetTitle("Horizontal distance [mm]"); hist2d[1]->GetYaxis()->SetTitle("Vertical distance [mm]"); if (BF){ hist2d[2] = new TH2F("hist2d2","photons hit start of tapered section", 80,-40.,40.,80,-40.,40.); } else { hist2d[2] = new TH2F("hist2d2","photons hit start of round bend section", 80,-40.,40.,80,-40.,40.); } hist2d[2]->GetXaxis()->SetTitle("Horizontal distance [mm]"); hist2d[2]->GetYaxis()->SetTitle("Vertical distance [mm]"); hist2d[3] = new TH2F("hist2d3","photons hit start of round strait section", 80,-40.,40.,80,-40.,40.); hist2d[3]->GetXaxis()->SetTitle("Horizontal distance [mm]"); hist2d[3]->GetYaxis()->SetTitle("Vertical distance [mm]"); hist2d[4] = new TH2F("hist2d4","photons hit PMT glass", 80,-40.,40.,80,-40.,40.); hist2d[4]->GetXaxis()->SetTitle("Horizontal distance [mm]"); hist2d[4]->GetYaxis()->SetTitle("Vertical distance [mm]"); hist2d[5] = new TH2F("hist2d5","photons hit PMT cathode", 80,-40.,40.,80,-40.,40.); hist2d[5]->GetXaxis()->SetTitle("Horizontal distance [mm]"); hist2d[5]->GetYaxis()->SetTitle("Vertical distance [mm]"); }