Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file hadronic/Hadr01/src/HistoManager.cc 26 /// \file hadronic/Hadr01/src/HistoManager.cc 27 /// \brief Implementation of the HistoManager 27 /// \brief Implementation of the HistoManager class 28 // 28 // 29 //-------------------------------------------- 29 //--------------------------------------------------------------------------- 30 // 30 // 31 // ClassName: HistoManager 31 // ClassName: HistoManager 32 // 32 // 33 // 33 // 34 // Author: V.Ivanchenko 30/01/01 34 // Author: V.Ivanchenko 30/01/01 35 // 35 // 36 // Modified: 36 // Modified: 37 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchen 37 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko) 38 // 16.11.2006 Add beamFlag (V.Ivanchenko) 38 // 16.11.2006 Add beamFlag (V.Ivanchenko) 39 // 39 // 40 //-------------------------------------------- 40 //---------------------------------------------------------------------------- 41 // 41 // 42 42 43 //....oooOO0OOooo........oooOO0OOooo........oo 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 44 //....oooOO0OOooo........oooOO0OOooo........oo 44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 45 45 46 #include "HistoManager.hh" 46 #include "HistoManager.hh" 47 << 47 #include "G4Track.hh" 48 #include "Histo.hh" << 48 #include "G4Step.hh" 49 << 49 #include "G4UnitsTable.hh" 50 #include "G4Alpha.hh" << 50 #include "G4Neutron.hh" >> 51 #include "G4Proton.hh" 51 #include "G4AntiProton.hh" 52 #include "G4AntiProton.hh" 52 #include "G4Deuteron.hh" << 53 #include "G4Electron.hh" << 54 #include "G4Gamma.hh" 53 #include "G4Gamma.hh" 55 #include "G4He3.hh" << 54 #include "G4Electron.hh" 56 #include "G4KaonMinus.hh" << 55 #include "G4Positron.hh" 57 #include "G4KaonPlus.hh" << 58 #include "G4KaonZeroLong.hh" << 59 #include "G4KaonZeroShort.hh" << 60 #include "G4MuonMinus.hh" << 61 #include "G4MuonPlus.hh" 56 #include "G4MuonPlus.hh" 62 #include "G4Neutron.hh" << 57 #include "G4MuonMinus.hh" 63 #include "G4PhysicalConstants.hh" << 64 #include "G4PionMinus.hh" << 65 #include "G4PionPlus.hh" 58 #include "G4PionPlus.hh" >> 59 #include "G4PionMinus.hh" 66 #include "G4PionZero.hh" 60 #include "G4PionZero.hh" 67 #include "G4Positron.hh" << 61 #include "G4KaonPlus.hh" 68 #include "G4Proton.hh" << 62 #include "G4KaonMinus.hh" 69 #include "G4Step.hh" << 63 #include "G4KaonZeroShort.hh" 70 #include "G4SystemOfUnits.hh" << 64 #include "G4KaonZeroLong.hh" 71 #include "G4Track.hh" << 65 #include "G4Deuteron.hh" 72 #include "G4Triton.hh" 66 #include "G4Triton.hh" 73 #include "G4UnitsTable.hh" << 67 #include "G4He3.hh" >> 68 #include "G4Alpha.hh" >> 69 #include "Histo.hh" 74 #include "globals.hh" 70 #include "globals.hh" >> 71 #include "G4SystemOfUnits.hh" >> 72 #include "G4PhysicalConstants.hh" 75 73 76 //....oooOO0OOooo........oooOO0OOooo........oo 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 77 75 78 HistoManager* HistoManager::fManager = nullptr 76 HistoManager* HistoManager::fManager = nullptr; 79 77 80 //....oooOO0OOooo........oooOO0OOooo........oo 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 81 79 82 HistoManager* HistoManager::GetPointer() 80 HistoManager* HistoManager::GetPointer() 83 { 81 { 84 if (nullptr == fManager) { 82 if (nullptr == fManager) { 85 static HistoManager manager; 83 static HistoManager manager; 86 fManager = &manager; 84 fManager = &manager; 87 } 85 } 88 return fManager; 86 return fManager; 89 } 87 } 90 88 91 //....oooOO0OOooo........oooOO0OOooo........oo 89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 92 90 93 HistoManager::HistoManager() 91 HistoManager::HistoManager() 94 : fPrimaryDef(nullptr), << 92 : fPrimaryDef(nullptr), 95 fRadius(10 * CLHEP::cm), << 93 fRadius(10*CLHEP::cm), 96 fLength(300. * CLHEP::mm), << 94 fLength(300.*CLHEP::mm), 97 fEdepMax(1.0 * CLHEP::GeV) << 95 fEdepMax(1.0*CLHEP::GeV) 98 { 96 { 99 fHisto = new Histo(); 97 fHisto = new Histo(); 100 fHisto->SetVerbose(fVerbose); 98 fHisto->SetVerbose(fVerbose); 101 fNeutron = G4Neutron::Neutron(); 99 fNeutron = G4Neutron::Neutron(); 102 } 100 } 103 101 104 //....oooOO0OOooo........oooOO0OOooo........oo 102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 105 103 106 HistoManager::~HistoManager() 104 HistoManager::~HistoManager() 107 { 105 { 108 delete fHisto; 106 delete fHisto; 109 } 107 } 110 108 111 //....oooOO0OOooo........oooOO0OOooo........oo 109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 112 110 113 void HistoManager::BookHisto() 111 void HistoManager::BookHisto() 114 { 112 { 115 fHistoBooked = true; 113 fHistoBooked = true; 116 fHisto->Add1D("1", "Energy deposition (MeV/m << 114 fHisto->Add1D("1","Energy deposition (MeV/mm/event) in the target", 117 MeV / mm); << 115 fNSlices,0.0,fLength/mm,MeV/mm); 118 fHisto->Add1D("2", "Log10 Energy (MeV) of ga << 116 fHisto->Add1D("2","Log10 Energy (MeV) of gammas",fNBinsE,-5.,5.,1.0); 119 fHisto->Add1D("3", "Log10 Energy (MeV) of el << 117 fHisto->Add1D("3","Log10 Energy (MeV) of electrons",fNBinsE,-5.,5.,1.0); 120 fHisto->Add1D("4", "Log10 Energy (MeV) of po << 118 fHisto->Add1D("4","Log10 Energy (MeV) of positrons",fNBinsE,-5.,5.,1.0); 121 fHisto->Add1D("5", "Log10 Energy (MeV) of pr << 119 fHisto->Add1D("5","Log10 Energy (MeV) of protons",fNBinsE,-5.,5.,1.0); 122 fHisto->Add1D("6", "Log10 Energy (MeV) of ne << 120 fHisto->Add1D("6","Log10 Energy (MeV) of neutrons",fNBinsE,-5.,5.,1.0); 123 fHisto->Add1D("7", "Log10 Energy (MeV) of ch << 121 fHisto->Add1D("7","Log10 Energy (MeV) of charged pions",fNBinsE,-4.,6.,1.0); 124 fHisto->Add1D("8", "Log10 Energy (MeV) of pi << 122 fHisto->Add1D("8","Log10 Energy (MeV) of pi0",fNBinsE,-4.,6.,1.0); 125 fHisto->Add1D("9", "Log10 Energy (MeV) of ch << 123 fHisto->Add1D("9","Log10 Energy (MeV) of charged kaons",fNBinsE,-4.,6.,1.0); 126 fHisto->Add1D("10", "Log10 Energy (MeV) of n << 124 fHisto->Add1D("10","Log10 Energy (MeV) of neutral kaons",fNBinsE,-4.,6.,1.0); 127 fHisto->Add1D("11", "Log10 Energy (MeV) of d << 125 fHisto->Add1D("11","Log10 Energy (MeV) of deuterons and tritons", 128 fHisto->Add1D("12", "Log10 Energy (MeV) of H << 126 fNBinsE,-5.,5.,1.0); 129 fHisto->Add1D("13", "Log10 Energy (MeV) of G << 127 fHisto->Add1D("12","Log10 Energy (MeV) of He3 and alpha",fNBinsE,-5.,5.,1.0); 130 fHisto->Add1D("14", "Log10 Energy (MeV) of m << 128 fHisto->Add1D("13","Log10 Energy (MeV) of Generic Ions",fNBinsE,-5.,5.,1.0); 131 fHisto->Add1D("15", "log10 Energy (MeV) of s << 129 fHisto->Add1D("14","Log10 Energy (MeV) of muons",fNBinsE,-4.,6.,1.0); 132 fHisto->Add1D("16", "log10 Energy (MeV) of f << 130 fHisto->Add1D("15","log10 Energy (MeV) of side-leaked neutrons", 133 fHisto->Add1D("17", "log10 Energy (MeV) of b << 131 fNBinsE,-5.,5.,1.0); 134 fHisto->Add1D("18", "log10 Energy (MeV) of l << 132 fHisto->Add1D("16","log10 Energy (MeV) of forward-leaked neutrons", 135 fHisto->Add1D("19", "log10 Energy (MeV) of l << 133 fNBinsE,-5.,5.,1.0); 136 fHisto->Add1D("20", "Log10 Energy (MeV) of p << 134 fHisto->Add1D("17","log10 Energy (MeV) of backward-leaked neutrons", 137 fHisto->Add1D("21", "Log10 Energy (MeV) of p << 135 fNBinsE,-5.,5.,1.0); 138 fHisto->Add1D("22", "Energy deposition in th << 136 fHisto->Add1D("18","log10 Energy (MeV) of leaking protons", 139 1.0); << 137 fNBinsE,-4.,6.,1.0); 140 fHisto->Add1D("23", "EM energy deposition in << 138 fHisto->Add1D("19","log10 Energy (MeV) of leaking charged pions", 141 1.0); << 139 fNBinsE,-4.,6.,1.0); 142 fHisto->Add1D("24", "Pion energy deposition << 140 fHisto->Add1D("20","Log10 Energy (MeV) of pi+",fNBinsE,-4.,6.,1.0); 143 1.1, 1.0); << 141 fHisto->Add1D("21","Log10 Energy (MeV) of pi-",fNBinsE,-4.,6.,1.0); 144 fHisto->Add1D("25", "Proton energy depositio << 142 fHisto->Add1D("22", 145 1.1, 1.0); << 143 "Energy deposition in the target normalized to beam energy", 146 fHisto->Add1D("26", "Energy (MeV) of pi+", f << 144 110,0.0,1.1,1.0); 147 fHisto->Add1D("27", "Energy (MeV) of pi-", f << 145 fHisto->Add1D("23", 148 fHisto->Add1D("28", "Energy (MeV) of pi0", f << 146 "EM energy deposition in the target normalized to beam energy", >> 147 110,0.0,1.1,1.0); >> 148 fHisto->Add1D("24", >> 149 "Pion energy deposition in the target normalized to beam energy", >> 150 110,0.0,1.1,1.0); >> 151 fHisto->Add1D("25", >> 152 "Proton energy deposition in the target normalized to beam energy", >> 153 110,0.0,1.1,1.0); >> 154 fHisto->Add1D("26","Energy (MeV) of pi+",fNBinsE,0.,500.,1.0); >> 155 fHisto->Add1D("27","Energy (MeV) of pi-",fNBinsE,0.,500.,1.0); >> 156 fHisto->Add1D("28","Energy (MeV) of pi0",fNBinsE,0.,500.,1.0); >> 157 149 } 158 } 150 159 151 //....oooOO0OOooo........oooOO0OOooo........oo 160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 152 161 153 void HistoManager::BeginOfRun() 162 void HistoManager::BeginOfRun() 154 { 163 { 155 fR2 = fRadius * fRadius; << 164 fR2 = fRadius*fRadius; 156 fAbsZ0 = 0.5 * fLength; << 165 fAbsZ0 = 0.5*fLength; 157 fNevt = 0; << 166 fNevt = 0; 158 fNelec = 0; << 167 fNelec = 0; 159 fNposit = 0; << 168 fNposit = 0; 160 fNgam = 0; << 169 fNgam = 0; 161 fNstep = 0; << 170 fNstep = 0; 162 fNprot_leak = 0; 171 fNprot_leak = 0; 163 fNpiofNleak = 0; 172 fNpiofNleak = 0; 164 fNions = 0; << 173 fNions = 0; 165 fNdeut = 0; << 174 fNdeut = 0; 166 fNalpha = 0; << 175 fNalpha = 0; 167 fNkaons = 0; << 176 fNkaons = 0; 168 fNmuons = 0; << 177 fNmuons = 0; 169 fNcpions = 0; << 178 fNcpions = 0; 170 fNpi0 = 0; << 179 fNpi0 = 0; 171 fNneutron = 0; << 180 fNneutron = 0; 172 fNproton = 0; << 181 fNproton = 0; 173 fNaproton = 0; << 182 fNaproton = 0; 174 fNneu_forw = 0; << 183 fNneu_forw = 0; 175 fNneu_leak = 0; << 184 fNneu_leak = 0; 176 fNneu_back = 0; << 185 fNneu_back = 0; 177 186 178 fEdepSum = 0.0; << 187 fEdepSum = 0.0; 179 fEdepSum2 = 0.0; << 188 fEdepSum2 = 0.0; 180 189 181 if (!fHistoBooked) { << 190 if(!fHistoBooked) { BookHisto(); } 182 BookHisto(); << 183 } << 184 fHisto->Book(); 191 fHisto->Book(); 185 192 186 if (fVerbose > 0) { << 193 if(fVerbose > 0) { 187 G4cout << "HistoManager: Histograms are bo << 194 G4cout << "HistoManager: Histograms are booked and run has been started" >> 195 <<G4endl; 188 } 196 } 189 } 197 } 190 198 191 //....oooOO0OOooo........oooOO0OOooo........oo 199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 192 200 193 void HistoManager::EndOfRun() 201 void HistoManager::EndOfRun() 194 { 202 { 195 G4cout << "HistoManager: End of run actions 203 G4cout << "HistoManager: End of run actions are started" << G4endl; 196 204 197 // Average values 205 // Average values 198 G4cout << "================================= << 206 G4cout<<"========================================================"<<G4endl; 199 207 200 G4double x = (G4double)fNevt; 208 G4double x = (G4double)fNevt; 201 if (fNevt > 0) { << 209 if(fNevt > 0) { x = 1.0/x; } 202 x = 1.0 / x; << 203 } << 204 210 205 G4double xe = x * (G4double)fNelec; << 211 G4double xe = x*(G4double)fNelec; 206 G4double xg = x * (G4double)fNgam; << 212 G4double xg = x*(G4double)fNgam; 207 G4double xp = x * (G4double)fNposit; << 213 G4double xp = x*(G4double)fNposit; 208 G4double xs = x * (G4double)fNstep; << 214 G4double xs = x*(G4double)fNstep; 209 G4double xn = x * (G4double)fNneutron; << 215 G4double xn = x*(G4double)fNneutron; 210 G4double xpn = x * (G4double)fNproton; << 216 G4double xpn = x*(G4double)fNproton; 211 G4double xap = x * (G4double)fNaproton; << 217 G4double xap = x*(G4double)fNaproton; 212 G4double xnf = x * (G4double)fNneu_forw; << 218 G4double xnf = x*(G4double)fNneu_forw; 213 G4double xnb = x * (G4double)fNneu_leak; << 219 G4double xnb = x*(G4double)fNneu_leak; 214 G4double xnbw = x * (G4double)fNneu_back; << 220 G4double xnbw= x*(G4double)fNneu_back; 215 G4double xpl = x * (G4double)fNprot_leak; << 221 G4double xpl = x*(G4double)fNprot_leak; 216 G4double xal = x * (G4double)fNpiofNleak; << 222 G4double xal = x*(G4double)fNpiofNleak; 217 G4double xpc = x * (G4double)fNcpions; << 223 G4double xpc = x*(G4double)fNcpions; 218 G4double xp0 = x * (G4double)fNpi0; << 224 G4double xp0 = x*(G4double)fNpi0; 219 G4double xpk = x * (G4double)fNkaons; << 225 G4double xpk = x*(G4double)fNkaons; 220 G4double xpm = x * (G4double)fNmuons; << 226 G4double xpm = x*(G4double)fNmuons; 221 G4double xid = x * (G4double)fNdeut; << 227 G4double xid = x*(G4double)fNdeut; 222 G4double xia = x * (G4double)fNalpha; << 228 G4double xia = x*(G4double)fNalpha; 223 G4double xio = x * (G4double)fNions; << 229 G4double xio = x*(G4double)fNions; 224 230 225 fEdepSum *= x; << 231 fEdepSum *= x; 226 fEdepSum2 *= x; 232 fEdepSum2 *= x; 227 fEdepSum2 -= fEdepSum * fEdepSum; << 233 fEdepSum2 -= fEdepSum*fEdepSum; 228 if (fEdepSum2 > 0.0) { << 234 if(fEdepSum2 > 0.0) { fEdepSum2 = std::sqrt(fEdepSum2); } 229 fEdepSum2 = std::sqrt(fEdepSum2); << 235 else { fEdepSum2 = 0.0; } 230 } << 236 231 else { << 237 G4cout << "Beam particle " 232 fEdepSum2 = 0.0; << 238 << fPrimaryDef->GetParticleName() <<G4endl; 233 } << 239 G4cout << "Beam Energy(MeV) " 234 << 240 << fPrimaryKineticEnergy/MeV <<G4endl; 235 G4cout << "Beam particle << 241 G4cout << "Number of events " 236 G4cout << "Beam Energy(MeV) << 242 << fNevt <<G4endl; 237 G4cout << "Number of events << 243 G4cout << std::setprecision(4) << "Average energy deposit (MeV) " 238 G4cout << std::setprecision(4) << "Average e << 244 << fEdepSum/MeV 239 << " RMS(MeV) " << fEdepSum2 / MeV << 245 << " RMS(MeV) " << fEdepSum2/MeV << G4endl; 240 G4cout << std::setprecision(4) << "Average n << 246 G4cout << std::setprecision(4) << "Average number of steps " 241 G4cout << std::setprecision(4) << "Average n << 247 << xs << G4endl; 242 G4cout << std::setprecision(4) << "Average n << 248 G4cout << std::setprecision(4) << "Average number of gamma " 243 G4cout << std::setprecision(4) << "Average n << 249 << xg << G4endl; 244 G4cout << std::setprecision(4) << "Average n << 250 G4cout << std::setprecision(4) << "Average number of e- " 245 G4cout << std::setprecision(4) << "Average n << 251 << xe << G4endl; 246 G4cout << std::setprecision(4) << "Average n << 252 G4cout << std::setprecision(4) << "Average number of e+ " 247 G4cout << std::setprecision(4) << "Average n << 253 << xp << G4endl; 248 G4cout << std::setprecision(4) << "Average n << 254 G4cout << std::setprecision(4) << "Average number of neutrons " 249 G4cout << std::setprecision(4) << "Average n << 255 << xn << G4endl; 250 G4cout << std::setprecision(4) << "Average n << 256 G4cout << std::setprecision(4) << "Average number of protons " 251 G4cout << std::setprecision(4) << "Average n << 257 << xpn << G4endl; 252 G4cout << std::setprecision(4) << "Average n << 258 G4cout << std::setprecision(4) << "Average number of antiprotons " 253 G4cout << std::setprecision(4) << "Average n << 259 << xap << G4endl; 254 G4cout << std::setprecision(4) << "Average n << 260 G4cout << std::setprecision(4) << "Average number of pi+ & pi- " 255 G4cout << std::setprecision(4) << "Average n << 261 << xpc << G4endl; 256 G4cout << std::setprecision(4) << "Average n << 262 G4cout << std::setprecision(4) << "Average number of pi0 " 257 G4cout << std::setprecision(4) << "Average n << 263 << xp0 << G4endl; 258 G4cout << std::setprecision(4) << "Average n << 264 G4cout << std::setprecision(4) << "Average number of kaons " 259 G4cout << "================================= << 265 << xpk << G4endl; 260 G4cout << G4endl; << 266 G4cout << std::setprecision(4) << "Average number of muons " >> 267 << xpm << G4endl; >> 268 G4cout << std::setprecision(4) << "Average number of deuterons+tritons " >> 269 << xid << G4endl; >> 270 G4cout << std::setprecision(4) << "Average number of He3+alpha " >> 271 << xia << G4endl; >> 272 G4cout << std::setprecision(4) << "Average number of ions " >> 273 << xio << G4endl; >> 274 G4cout << std::setprecision(4) << "Average number of forward neutrons " >> 275 << xnf << G4endl; >> 276 G4cout << std::setprecision(4) << "Average number of reflected neutrons " >> 277 << xnb << G4endl; >> 278 G4cout << std::setprecision(4) << "Average number of leaked neutrons " >> 279 << xnbw << G4endl; >> 280 G4cout << std::setprecision(4) << "Average number of proton leak " >> 281 << xpl << G4endl; >> 282 G4cout << std::setprecision(4) << "Average number of pion leak " >> 283 << xal << G4endl; >> 284 G4cout<<"========================================================"<<G4endl; >> 285 G4cout<<G4endl; 261 286 262 // normalise histograms 287 // normalise histograms 263 for (G4int i = 0; i < fNHisto; i++) { << 288 for(G4int i=0; i<fNHisto; i++) { 264 fHisto->ScaleH1(i, x); << 289 fHisto->ScaleH1(i,x); 265 } 290 } 266 291 267 fHisto->Save(); 292 fHisto->Save(); 268 } 293 } 269 294 270 //....oooOO0OOooo........oooOO0OOooo........oo 295 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 271 296 272 void HistoManager::BeginOfEvent() 297 void HistoManager::BeginOfEvent() 273 { 298 { 274 fEdepEvt = 0.0; 299 fEdepEvt = 0.0; 275 fEdepEM = 0.0; << 300 fEdepEM = 0.0; 276 fEdepPI = 0.0; << 301 fEdepPI = 0.0; 277 fEdepP = 0.0; << 302 fEdepP = 0.0; 278 } 303 } 279 304 280 //....oooOO0OOooo........oooOO0OOooo........oo 305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 281 306 282 void HistoManager::EndOfEvent() 307 void HistoManager::EndOfEvent() 283 { 308 { 284 fEdepSum += fEdepEvt; << 309 fEdepSum += fEdepEvt; 285 fEdepSum2 += fEdepEvt * fEdepEvt; << 310 fEdepSum2 += fEdepEvt*fEdepEvt; 286 fHisto->Fill(21, fEdepEvt / fPrimaryKineticE << 311 fHisto->Fill(21,fEdepEvt/fPrimaryKineticEnergy,1.0); 287 fHisto->Fill(22, fEdepEM / fPrimaryKineticEn << 312 fHisto->Fill(22,fEdepEM/fPrimaryKineticEnergy,1.0); 288 fHisto->Fill(23, fEdepPI / fPrimaryKineticEn << 313 fHisto->Fill(23,fEdepPI/fPrimaryKineticEnergy,1.0); 289 fHisto->Fill(24, fEdepP / fPrimaryKineticEne << 314 fHisto->Fill(24,fEdepP/fPrimaryKineticEnergy,1.0); 290 } 315 } 291 316 292 //....oooOO0OOooo........oooOO0OOooo........oo 317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 293 318 294 void HistoManager::ScoreNewTrack(const G4Track 319 void HistoManager::ScoreNewTrack(const G4Track* track) 295 { 320 { 296 const G4ParticleDefinition* pd = track->GetD 321 const G4ParticleDefinition* pd = track->GetDefinition(); 297 const G4String name = pd->GetParticleName(); 322 const G4String name = pd->GetParticleName(); 298 const G4double ee = track->GetKineticEnergy( 323 const G4double ee = track->GetKineticEnergy(); 299 G4double e = ee; 324 G4double e = ee; 300 325 301 // Primary track 326 // Primary track 302 if (0 == track->GetParentID()) { << 327 if(0 == track->GetParentID()) { >> 328 303 fNevt++; 329 fNevt++; 304 fPrimaryKineticEnergy = e; 330 fPrimaryKineticEnergy = e; 305 fPrimaryDef = pd; 331 fPrimaryDef = pd; 306 G4ThreeVector dir = track->GetMomentumDire 332 G4ThreeVector dir = track->GetMomentumDirection(); 307 if (1 < fVerbose) << 333 if(1 < fVerbose) 308 G4cout << "### Primary " << name << " ki << 334 G4cout << "### Primary " << name 309 << "; m(MeV)= " << pd->GetPDGMass << 335 << " kinE(MeV)= " << e/MeV 310 << "; dir= " << track->GetMoment << 336 << "; m(MeV)= " << pd->GetPDGMass()/MeV >> 337 << "; pos(mm)= " << track->GetPosition()/mm >> 338 << "; dir= " << track->GetMomentumDirection() >> 339 << G4endl; 311 340 312 // Secondary track 341 // Secondary track 313 } << 342 } else { 314 else { << 343 if(1 < fVerbose) 315 if (1 < fVerbose) << 344 G4cout << "=== Secondary " << name 316 G4cout << "=== Secondary " << name << " << 345 << " kinE(MeV)= " << e/MeV 317 << "; m(MeV)= " << pd->GetPDGMass << 346 << "; m(MeV)= " << pd->GetPDGMass()/MeV 318 << "; dir= " << track->GetMoment << 347 << "; pos(mm)= " << track->GetPosition()/mm 319 e = (e > 0.0) ? std::log10(e / MeV) : -100 << 348 << "; dir= " << track->GetMomentumDirection() 320 if (pd == G4Gamma::Gamma()) { << 349 << G4endl; >> 350 e = (e > 0.0) ? std::log10(e/MeV) : -100.; >> 351 if(pd == G4Gamma::Gamma()) { 321 fNgam++; 352 fNgam++; 322 fHisto->Fill(1, e, 1.0); << 353 fHisto->Fill(1,e,1.0); 323 } << 354 } else if ( pd == G4Electron::Electron()) { 324 else if (pd == G4Electron::Electron()) { << 325 fNelec++; 355 fNelec++; 326 fHisto->Fill(2, e, 1.0); << 356 fHisto->Fill(2,e,1.0); 327 } << 357 } else if ( pd == G4Positron::Positron()) { 328 else if (pd == G4Positron::Positron()) { << 329 fNposit++; 358 fNposit++; 330 fHisto->Fill(3, e, 1.0); << 359 fHisto->Fill(3,e,1.0); 331 } << 360 } else if ( pd == G4Proton::Proton()) { 332 else if (pd == G4Proton::Proton()) { << 333 fNproton++; 361 fNproton++; 334 fHisto->Fill(4, e, 1.0); << 362 fHisto->Fill(4,e,1.0); 335 } << 363 } else if ( pd == fNeutron) { 336 else if (pd == fNeutron) { << 337 fNneutron++; 364 fNneutron++; 338 fHisto->Fill(5, e, 1.0); << 365 fHisto->Fill(5,e,1.0); 339 } << 366 } else if ( pd == G4AntiProton::AntiProton()) { 340 else if (pd == G4AntiProton::AntiProton()) << 341 fNaproton++; 367 fNaproton++; 342 } << 368 } else if ( pd == G4PionPlus::PionPlus() ) { 343 else if (pd == G4PionPlus::PionPlus()) { << 344 fNcpions++; 369 fNcpions++; 345 fHisto->Fill(6, e, 1.0); << 370 fHisto->Fill(6,e,1.0); 346 fHisto->Fill(19, e, 1.0); << 371 fHisto->Fill(19,e,1.0); 347 fHisto->Fill(25, ee, 1.0); << 372 fHisto->Fill(25,ee,1.0); 348 } << 373 349 else if (pd == G4PionMinus::PionMinus()) { << 374 } else if ( pd == G4PionMinus::PionMinus()) { 350 fNcpions++; 375 fNcpions++; 351 fHisto->Fill(6, e, 1.0); << 376 fHisto->Fill(6,e,1.0); 352 fHisto->Fill(20, e, 1.0); << 377 fHisto->Fill(20,e,1.0); 353 fHisto->Fill(26, ee, 1.0); << 378 fHisto->Fill(26,ee,1.0); 354 } << 379 355 else if (pd == G4PionZero::PionZero()) { << 380 } else if ( pd == G4PionZero::PionZero()) { 356 fNpi0++; 381 fNpi0++; 357 fHisto->Fill(7, e, 1.0); << 382 fHisto->Fill(7,e,1.0); 358 fHisto->Fill(27, ee, 1.0); << 383 fHisto->Fill(27,ee,1.0); 359 } << 384 360 else if (pd == G4KaonPlus::KaonPlus() || p << 385 } else if ( pd == G4KaonPlus::KaonPlus() || >> 386 pd == G4KaonMinus::KaonMinus()) { 361 fNkaons++; 387 fNkaons++; 362 fHisto->Fill(8, e, 1.0); << 388 fHisto->Fill(8,e,1.0); 363 } << 389 } else if ( pd == G4KaonZeroShort::KaonZeroShort() || 364 else if (pd == G4KaonZeroShort::KaonZeroSh << 390 pd == G4KaonZeroLong::KaonZeroLong()) { 365 fNkaons++; 391 fNkaons++; 366 fHisto->Fill(9, e, 1.0); << 392 fHisto->Fill(9,e,1.0); 367 } << 393 } else if ( pd == G4Deuteron::Deuteron() || pd == G4Triton::Triton()) { 368 else if (pd == G4Deuteron::Deuteron() || p << 369 fNdeut++; 394 fNdeut++; 370 fHisto->Fill(10, e, 1.0); << 395 fHisto->Fill(10,e,1.0); 371 } << 396 } else if ( pd == G4He3::He3() || pd == G4Alpha::Alpha()) { 372 else if (pd == G4He3::He3() || pd == G4Alp << 373 fNalpha++; 397 fNalpha++; 374 fHisto->Fill(11, e, 1.0); << 398 fHisto->Fill(11,e,1.0); 375 } << 399 } else if ( pd->GetParticleType() == "nucleus") { 376 else if (pd->GetParticleType() == "nucleus << 377 fNions++; 400 fNions++; 378 fHisto->Fill(12, e, 1.0); << 401 fHisto->Fill(12,e,1.0); 379 } << 402 } else if ( pd == G4MuonPlus::MuonPlus() || 380 else if (pd == G4MuonPlus::MuonPlus() || p << 403 pd == G4MuonMinus::MuonMinus()) { 381 fNmuons++; 404 fNmuons++; 382 fHisto->Fill(13, e, 1.0); << 405 fHisto->Fill(13,e,1.0); 383 } 406 } 384 } 407 } 385 } 408 } 386 409 387 //....oooOO0OOooo........oooOO0OOooo........oo 410 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 388 411 389 void HistoManager::AddTargetStep(const G4Step* 412 void HistoManager::AddTargetStep(const G4Step* step) 390 { 413 { 391 ++fNstep; 414 ++fNstep; 392 const G4double fEdep = step->GetTotalEnergyD 415 const G4double fEdep = step->GetTotalEnergyDeposit(); 393 const G4Track* track = step->GetTrack(); 416 const G4Track* track = step->GetTrack(); 394 const G4ParticleDefinition* pd = track->GetD 417 const G4ParticleDefinition* pd = track->GetDefinition(); 395 if (1 < fVerbose) { 418 if (1 < fVerbose) { 396 G4cout << "TargetSD::ProcessHits: " << pd- << 419 G4cout << "TargetSD::ProcessHits: " << pd->GetParticleName() 397 << " E(MeV)=" << track->GetKineticE << 420 << " E(MeV)=" << track->GetKineticEnergy()/CLHEP::MeV 398 << " beta1= " << step->GetPreStepPo << 421 << " beta1= " 399 << " beta2= " << step->GetPostStepP << 422 << step->GetPreStepPoint()->GetVelocity()/CLHEP::c_light >> 423 << " beta2= " >> 424 << step->GetPostStepPoint()->GetVelocity()/CLHEP::c_light 400 << " weight= " << step->GetTrack()- 425 << " weight= " << step->GetTrack()->GetWeight() 401 << " t(ns)=" << track->GetGlobalTim << 426 << " t(ns)=" << track->GetGlobalTime()/CLHEP::ns >> 427 << G4endl; 402 } 428 } 403 if (fEdep > 0.0) { << 429 if (fEdep > 0.0) { 404 G4ThreeVector pos = << 430 G4ThreeVector pos = 405 (step->GetPreStepPoint()->GetPosition() << 431 (step->GetPreStepPoint()->GetPosition() + >> 432 step->GetPostStepPoint()->GetPosition())*0.5; 406 433 407 G4double z = pos.z() + fAbsZ0; 434 G4double z = pos.z() + fAbsZ0; 408 435 409 // scoring 436 // scoring 410 fEdepEvt += fEdep; 437 fEdepEvt += fEdep; 411 fHisto->Fill(0, z, fEdep); << 438 fHisto->Fill(0,z,fEdep); 412 439 413 if (pd == G4Gamma::Gamma() || pd == G4Elec << 440 if(pd == G4Gamma::Gamma() || pd == G4Electron::Electron() >> 441 || pd == G4Positron::Positron()) { 414 fEdepEM += fEdep; 442 fEdepEM += fEdep; 415 } << 443 } else if ( pd == G4PionPlus::PionPlus() || 416 else if (pd == G4PionPlus::PionPlus() || p << 444 pd == G4PionMinus::PionMinus()) { 417 fEdepPI += fEdep; 445 fEdepPI += fEdep; 418 } << 446 } else if ( pd == G4Proton::Proton() || 419 else if (pd == G4Proton::Proton() || pd == << 447 pd == G4AntiProton::AntiProton()) { 420 fEdepP += fEdep; << 448 fEdepP += fEdep; 421 } 449 } 422 450 423 if (1 < fVerbose) { << 451 if(1 < fVerbose) { 424 G4cout << "HistoManager::AddEnergy: e(ke << 452 G4cout << "HistoManager::AddEnergy: e(keV)= " << fEdep/keV 425 << "; step(mm)= " << step->GetSte << 453 << "; z(mm)= " << z/mm 426 << " E(MeV)= " << track->GetKinet << 454 << "; step(mm)= " << step->GetStepLength()/mm >> 455 << " by " << pd->GetParticleName() >> 456 << " E(MeV)= " << track->GetKineticEnergy()/MeV >> 457 << G4endl; 427 } 458 } 428 } 459 } 429 } 460 } 430 461 431 //....oooOO0OOooo........oooOO0OOooo........oo 462 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 432 463 433 void HistoManager::AddLeakingParticle(const G4 464 void HistoManager::AddLeakingParticle(const G4Track* track) 434 { 465 { 435 const G4ParticleDefinition* pd = track->GetD 466 const G4ParticleDefinition* pd = track->GetDefinition(); 436 const G4StepPoint* sp = track->GetStep()->Ge 467 const G4StepPoint* sp = track->GetStep()->GetPreStepPoint(); 437 const G4double ekin = sp->GetKineticEnergy() 468 const G4double ekin = sp->GetKineticEnergy(); 438 G4double e = -100.; 469 G4double e = -100.; 439 if (ekin > 0.0) { << 470 if(ekin > 0.0) { 440 e = std::log10(ekin / CLHEP::MeV); << 471 e = std::log10(ekin/CLHEP::MeV); 441 } << 472 } else { 442 else { << 443 G4cout << "### HistoManager::AddLeakingPar 473 G4cout << "### HistoManager::AddLeakingParticle " << pd->GetParticleName() 444 << " Eprestep(MeV)=" << ekin << " << 474 << " Eprestep(MeV)=" << ekin << " trackID=" << track->GetTrackID() >> 475 << G4endl; 445 return; 476 return; 446 } 477 } 447 478 448 const G4ThreeVector& pos = sp->GetPosition() 479 const G4ThreeVector& pos = sp->GetPosition(); 449 const G4ThreeVector& dir = sp->GetMomentumDi 480 const G4ThreeVector& dir = sp->GetMomentumDirection(); 450 G4double x = pos.x(); 481 G4double x = pos.x(); 451 G4double y = pos.y(); 482 G4double y = pos.y(); 452 G4double z = pos.z(); 483 G4double z = pos.z(); 453 G4double vx = dir.x(); 484 G4double vx = dir.x(); 454 G4double vy = dir.y(); 485 G4double vy = dir.y(); 455 G4double vz = dir.z(); 486 G4double vz = dir.z(); 456 << 487 457 G4bool isLeaking = false; 488 G4bool isLeaking = false; 458 489 459 // Forward << 490 // Forward 460 const G4double del = 0.001 * CLHEP::mm; << 491 const G4double del = 0.001*CLHEP::mm; 461 if (std::abs(z - fAbsZ0) < del && vz > 0.0) << 492 if(std::abs(z - fAbsZ0) < del && vz > 0.0) { 462 isLeaking = true; 493 isLeaking = true; 463 if (pd == fNeutron) { << 494 if(pd == fNeutron) { 464 ++fNneu_forw; 495 ++fNneu_forw; 465 fHisto->Fill(15, e, 1.0); << 496 fHisto->Fill(15,e,1.0); 466 } << 497 } else isLeaking = true; 467 else << 468 isLeaking = true; << 469 498 470 // Backward 499 // Backward 471 } << 500 } else if (std::abs(z + fAbsZ0) < del && vz < 0.0) { 472 else if (std::abs(z + fAbsZ0) < del && vz < << 473 isLeaking = true; 501 isLeaking = true; 474 if (pd == fNeutron) { << 502 if(pd == fNeutron) { 475 ++fNneu_back; 503 ++fNneu_back; 476 fHisto->Fill(16, e, 1.0); << 504 fHisto->Fill(16,e,1.0); 477 } << 505 } else isLeaking = true; 478 else << 479 isLeaking = true; << 480 506 481 // Side 507 // Side 482 } << 508 } else if (std::abs(z) <= fAbsZ0 + del && x*vx + y*vy > 0.0 && 483 else if (std::abs(z) <= fAbsZ0 + del && x * << 509 std::abs(x*x + y*y - fR2) < del*fRadius) { 484 && std::abs(x * x + y * y - fR2) < << 485 { << 486 isLeaking = true; 510 isLeaking = true; 487 if (pd == fNeutron) { << 511 if(pd == fNeutron) { 488 ++fNneu_leak; 512 ++fNneu_leak; 489 fHisto->Fill(14, e, 1.0); << 513 fHisto->Fill(14,e,1.0); 490 } << 514 } else isLeaking = true; 491 else << 492 isLeaking = true; << 493 } 515 } 494 516 495 // protons and pions 517 // protons and pions 496 if (isLeaking) { << 518 if(isLeaking) { 497 if (pd == G4Proton::Proton()) { << 519 if(pd == G4Proton::Proton()) { 498 fHisto->Fill(17, e, 1.0); << 520 fHisto->Fill(17,e,1.0); 499 ++fNprot_leak; 521 ++fNprot_leak; 500 } << 522 } else if (pd == G4PionPlus::PionPlus() || 501 else if (pd == G4PionPlus::PionPlus() || p << 523 pd == G4PionMinus::PionMinus()) { 502 fHisto->Fill(18, e, 1.0); << 524 fHisto->Fill(18,e,1.0); 503 ++fNpiofNleak; 525 ++fNpiofNleak; 504 } 526 } 505 } 527 } 506 } 528 } 507 529 508 //....oooOO0OOooo........oooOO0OOooo........oo 530 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 509 531 510 void HistoManager::SetVerbose(G4int val) << 532 void HistoManager::SetVerbose(G4int val) 511 { 533 { 512 fVerbose = val; << 534 fVerbose = val; 513 fHisto->SetVerbose(val); 535 fHisto->SetVerbose(val); 514 } 536 } 515 537 516 //....oooOO0OOooo........oooOO0OOooo........oo 538 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 517 539 518 void HistoManager::Fill(G4int id, G4double x, 540 void HistoManager::Fill(G4int id, G4double x, G4double w) 519 { 541 { 520 fHisto->Fill(id, x, w); 542 fHisto->Fill(id, x, w); 521 } 543 } 522 544 523 //....oooOO0OOooo........oooOO0OOooo........oo 545 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 546 524 547