Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /// \file electromagnetic/TestEm2/src/RunActio 27 /// \brief Implementation of the RunAction cla 28 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 33 #include "RunAction.hh" 34 35 #include "DetectorConstruction.hh" 36 #include "EmAcceptance.hh" 37 #include "PrimaryGeneratorAction.hh" 38 #include "Run.hh" 39 #include "RunActionMessenger.hh" 40 41 #include "G4Run.hh" 42 #include "G4RunManager.hh" 43 #include "G4SystemOfUnits.hh" 44 #include "Randomize.hh" 45 46 //....oooOO0OOooo........oooOO0OOooo........oo 47 48 RunAction::RunAction(DetectorConstruction* det 49 { 50 fRunMessenger = new RunActionMessenger(this) 51 52 // Create analysis manager 53 // The choice of analysis technology is done 54 fAnalysisManager = G4AnalysisManager::Instan 55 fAnalysisManager->SetDefaultFileType("root") 56 57 // Set the default file name "testem2" 58 // which can be then redefine in a macro via 59 fAnalysisManager->SetFileName("testem2"); 60 } 61 62 //....oooOO0OOooo........oooOO0OOooo........oo 63 64 RunAction::~RunAction() 65 { 66 delete fRunMessenger; 67 } 68 69 //....oooOO0OOooo........oooOO0OOooo........oo 70 71 void RunAction::BookHisto() 72 { 73 // Get analysis manager 74 fAnalysisManager = G4AnalysisManager::Instan 75 76 // Open an output file 77 fAnalysisManager->OpenFile(); 78 fAnalysisManager->SetVerboseLevel(1); 79 80 // Creating histograms 81 // 82 G4double Ekin = fKin->GetParticleGun()->GetP 83 G4int nLbin = fDet->GetnLtot(); 84 G4int nRbin = fDet->GetnRtot(); 85 G4double dLradl = fDet->GetdLradl(); 86 G4double dRradl = fDet->GetdRradl(); 87 88 fAnalysisManager->SetFirstHistoId(1); 89 fAnalysisManager->CreateH1("h1", "total ener 90 91 fAnalysisManager->CreateH1("h2", "total char 92 93 fAnalysisManager->CreateH1("h3", "total neut 94 95 fAnalysisManager->CreateH1("h4", "longit ene 96 97 fAnalysisManager->CreateP1("p4", "longit ene 98 0., 1000.); 99 100 fAnalysisManager->CreateH1("h5", "rms on lon 101 102 G4double Zmin = 0.5 * dLradl, Zmax = Zmin + 103 fAnalysisManager->CreateH1("h6", "cumul long 104 105 fAnalysisManager->CreateH1("h7", "rms on cum 106 107 fAnalysisManager->CreateH1("h8", "radial ene 108 109 fAnalysisManager->CreateP1("p8", "radial ene 110 0., 1000.); 111 112 fAnalysisManager->CreateH1("h9", "rms on rad 113 114 G4double Rmin = 0.5 * dRradl, Rmax = Rmin + 115 fAnalysisManager->CreateH1("h10", "cumul rad 116 117 fAnalysisManager->CreateH1("h11", "rms on cu 118 119 G4String fileName = fAnalysisManager->GetFil 120 G4String extension = fAnalysisManager->GetFi 121 G4String fullFileName = fileName + "." + ext 122 G4cout << "\n----> Histogram file is opened 123 } 124 125 //....oooOO0OOooo........oooOO0OOooo........oo 126 127 G4Run* RunAction::GenerateRun() 128 { 129 fRun = new Run(fDet, fKin); 130 fRun->SetVerbose(fVerbose); 131 return fRun; 132 } 133 134 //....oooOO0OOooo........oooOO0OOooo........oo 135 136 void RunAction::BeginOfRunAction(const G4Run*) 137 { 138 // show Rndm status 139 if (isMaster) G4Random::showEngineStatus(); 140 141 // histograms 142 // 143 BookHisto(); 144 } 145 146 //....oooOO0OOooo........oooOO0OOooo........oo 147 148 void RunAction::EndOfRunAction(const G4Run*) 149 { 150 // compute and print statistic 151 // 152 if (isMaster) fRun->EndOfRun(fEdeptrue, fRms 153 154 // show Rndm status 155 if (isMaster) G4Random::showEngineStatus(); 156 157 // save histos and close analysis 158 fAnalysisManager->Write(); 159 fAnalysisManager->CloseFile(); 160 fAnalysisManager->Clear(); 161 } 162 163 //....oooOO0OOooo........oooOO0OOooo........oo 164 165 void RunAction::SetEdepAndRMS(G4ThreeVector Va 166 { 167 fEdeptrue = Value(0); 168 fRmstrue = Value(1); 169 fLimittrue = Value(2); 170 } 171 //....oooOO0OOooo........oooOO0OOooo........oo 172 173 void RunAction::SetVerbose(G4int val) 174 { 175 fVerbose = val; 176 if (fRun) fRun->SetVerbose(val); 177 } 178 179 //....oooOO0OOooo........oooOO0OOooo........oo 180