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 Run.cc 26 /// \file Run.cc 27 /// \brief Implementation of the Run class 27 /// \brief Implementation of the Run class 28 // 28 // 29 // << 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 32 33 #include "Run.hh" 33 #include "Run.hh" 34 << 35 #include "DetectorConstruction.hh" 34 #include "DetectorConstruction.hh" 36 #include "HistoManager.hh" << 37 #include "PrimaryGeneratorAction.hh" 35 #include "PrimaryGeneratorAction.hh" >> 36 #include "HistoManager.hh" 38 37 39 #include "G4AutoLock.hh" << 40 #include "G4SystemOfUnits.hh" << 41 #include "G4Threading.hh" 38 #include "G4Threading.hh" >> 39 #include "G4AutoLock.hh" 42 #include "G4UnitsTable.hh" 40 #include "G4UnitsTable.hh" >> 41 #include "G4SystemOfUnits.hh" 43 42 44 // mutex in a file scope 43 // mutex in a file scope 45 44 46 namespace << 45 namespace { 47 { << 46 //Mutex to lock updating the global ion map 48 // Mutex to lock updating the global ion map << 47 G4Mutex ionIdMapMutex = G4MUTEX_INITIALIZER; 49 G4Mutex ionIdMapMutex = G4MUTEX_INITIALIZER; << 48 } 50 } // namespace << 51 49 52 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 51 54 std::map<G4String, G4int> Run::fgIonMap; << 52 std::map<G4String,G4int> Run::fgIonMap; 55 G4int Run::fgIonId = kMaxHisto1; 53 G4int Run::fgIonId = kMaxHisto1; 56 54 57 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 56 59 Run::Run(DetectorConstruction* det) : fDetecto << 57 Run::Run(DetectorConstruction* det) >> 58 : G4Run(), >> 59 fDetector(det), fParticle(nullptr), fEkin(0.) >> 60 { >> 61 fEnergyDeposit = fEnergyDeposit2 = 0.; >> 62 fEnergyFlow = fEnergyFlow2 = 0.; >> 63 } >> 64 >> 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 66 >> 67 Run::~Run() >> 68 { } 60 69 61 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 62 71 63 void Run::Merge(std::map<G4String, ParticleDat 72 void Run::Merge(std::map<G4String, ParticleData>& destinationMap, 64 const std::map<G4String, Parti 73 const std::map<G4String, ParticleData>& sourceMap) const 65 { 74 { 66 for (const auto& particleData : sourceMap) { << 75 for ( const auto& particleData : sourceMap ) { 67 G4String name = particleData.first; 76 G4String name = particleData.first; 68 const ParticleData& localData = particleDa << 77 const ParticleData& localData = particleData.second; 69 if (destinationMap.find(name) == destinati << 78 if ( destinationMap.find(name) == destinationMap.end()) { 70 destinationMap[name] = ParticleData(loca << 79 destinationMap[name] 71 loca << 80 = ParticleData(localData.fCount, >> 81 localData.fEmean, >> 82 localData.fEmin, >> 83 localData.fEmax, >> 84 localData.fTmean); 72 } 85 } 73 else { 86 else { 74 ParticleData& data = destinationMap[name << 87 ParticleData& data = destinationMap[name]; 75 data.fCount += localData.fCount; 88 data.fCount += localData.fCount; 76 data.fEmean += localData.fEmean; 89 data.fEmean += localData.fEmean; 77 G4double emin = localData.fEmin; 90 G4double emin = localData.fEmin; 78 if (emin < data.fEmin) data.fEmin = emin 91 if (emin < data.fEmin) data.fEmin = emin; 79 G4double emax = localData.fEmax; 92 G4double emax = localData.fEmax; 80 if (emax > data.fEmax) data.fEmax = emax 93 if (emax > data.fEmax) data.fEmax = emax; 81 data.fTmean = localData.fTmean; 94 data.fTmean = localData.fTmean; 82 } << 95 } 83 } 96 } 84 } 97 } 85 98 86 //....oooOO0OOooo........oooOO0OOooo........oo 99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 87 100 88 void Run::SetPrimary(G4ParticleDefinition* par 101 void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy) 89 { << 102 { 90 fParticle = particle; 103 fParticle = particle; 91 fEkin = energy; 104 fEkin = energy; 92 } 105 } 93 << 106 94 //....oooOO0OOooo........oooOO0OOooo........oo 107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 95 108 96 void Run::CountProcesses(const G4VProcess* pro << 109 void Run::CountProcesses(const G4VProcess* process) 97 { 110 { 98 if (process == nullptr) return; 111 if (process == nullptr) return; 99 G4String procName = process->GetProcessName( 112 G4String procName = process->GetProcessName(); 100 std::map<G4String, G4int>::iterator it = fPr << 113 std::map<G4String,G4int>::iterator it = fProcCounter.find(procName); 101 if (it == fProcCounter.end()) { << 114 if ( it == fProcCounter.end()) { 102 fProcCounter[procName] = 1; 115 fProcCounter[procName] = 1; 103 } 116 } 104 else { 117 else { 105 fProcCounter[procName]++; << 118 fProcCounter[procName]++; 106 } 119 } 107 } 120 } 108 << 121 109 //....oooOO0OOooo........oooOO0OOooo........oo 122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 110 123 111 void Run::ParticleCount(G4String name, G4doubl 124 void Run::ParticleCount(G4String name, G4double Ekin, G4double meanLife) 112 { 125 { 113 std::map<G4String, ParticleData>::iterator i 126 std::map<G4String, ParticleData>::iterator it = fParticleDataMap1.find(name); 114 if (it == fParticleDataMap1.end()) { << 127 if ( it == fParticleDataMap1.end()) { 115 fParticleDataMap1[name] = ParticleData(1, 128 fParticleDataMap1[name] = ParticleData(1, Ekin, Ekin, Ekin, meanLife); 116 } 129 } 117 else { 130 else { 118 ParticleData& data = it->second; 131 ParticleData& data = it->second; 119 data.fCount++; 132 data.fCount++; 120 data.fEmean += Ekin; 133 data.fEmean += Ekin; 121 // update min max << 134 //update min max 122 G4double emin = data.fEmin; 135 G4double emin = data.fEmin; 123 if (Ekin < emin) data.fEmin = Ekin; 136 if (Ekin < emin) data.fEmin = Ekin; 124 G4double emax = data.fEmax; 137 G4double emax = data.fEmax; 125 if (Ekin > emax) data.fEmax = Ekin; 138 if (Ekin > emax) data.fEmax = Ekin; 126 data.fTmean = meanLife; 139 data.fTmean = meanLife; 127 } << 140 } 128 } 141 } 129 << 142 130 //....oooOO0OOooo........oooOO0OOooo........oo 143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 131 144 132 void Run::AddEdep(G4double edep) 145 void Run::AddEdep(G4double edep) 133 { << 146 { 134 fEnergyDeposit += edep; 147 fEnergyDeposit += edep; 135 fEnergyDeposit2 += edep * edep; << 148 fEnergyDeposit2 += edep*edep; 136 } 149 } 137 << 150 138 //....oooOO0OOooo........oooOO0OOooo........oo 151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 139 152 140 void Run::AddEflow(G4double eflow) 153 void Run::AddEflow(G4double eflow) 141 { << 154 { 142 fEnergyFlow += eflow; 155 fEnergyFlow += eflow; 143 fEnergyFlow2 += eflow * eflow; << 156 fEnergyFlow2 += eflow*eflow; 144 } << 157 } 145 //....oooOO0OOooo........oooOO0OOooo........oo 158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 146 159 147 void Run::ParticleFlux(G4String name, G4double 160 void Run::ParticleFlux(G4String name, G4double Ekin) 148 { 161 { 149 std::map<G4String, ParticleData>::iterator i 162 std::map<G4String, ParticleData>::iterator it = fParticleDataMap2.find(name); 150 if (it == fParticleDataMap2.end()) { << 163 if ( it == fParticleDataMap2.end()) { 151 fParticleDataMap2[name] = ParticleData(1, << 164 fParticleDataMap2[name] = ParticleData(1, Ekin, Ekin, Ekin, -1*ns); 152 } 165 } 153 else { 166 else { 154 ParticleData& data = it->second; 167 ParticleData& data = it->second; 155 data.fCount++; 168 data.fCount++; 156 data.fEmean += Ekin; 169 data.fEmean += Ekin; 157 // update min max << 170 //update min max 158 G4double emin = data.fEmin; 171 G4double emin = data.fEmin; 159 if (Ekin < emin) data.fEmin = Ekin; 172 if (Ekin < emin) data.fEmin = Ekin; 160 G4double emax = data.fEmax; 173 G4double emax = data.fEmax; 161 if (Ekin > emax) data.fEmax = Ekin; 174 if (Ekin > emax) data.fEmax = Ekin; 162 data.fTmean = -1 * ns; << 175 data.fTmean = -1*ns; 163 } << 176 } 164 } 177 } 165 178 166 //....oooOO0OOooo........oooOO0OOooo........oo 179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 167 180 168 G4int Run::GetIonId(G4String ionName) 181 G4int Run::GetIonId(G4String ionName) 169 { 182 { 170 G4AutoLock lock(&ionIdMapMutex); << 183 G4AutoLock lock(&ionIdMapMutex); 171 // updating the global ion map needs to be l << 184 // updating the global ion map needs to be locked 172 185 173 std::map<G4String, G4int>::const_iterator it << 186 std::map<G4String,G4int>::const_iterator it = fgIonMap.find(ionName); 174 if (it == fgIonMap.end()) { << 187 if ( it == fgIonMap.end()) { 175 fgIonMap[ionName] = fgIonId; << 188 fgIonMap[ionName] = fgIonId; 176 if (fgIonId < (kMaxHisto2 - 1)) fgIonId++; << 189 if (fgIonId < (kMaxHisto2 - 1)) fgIonId++; 177 } << 190 } 178 return fgIonMap[ionName]; << 191 return fgIonMap[ionName]; 179 } 192 } 180 193 181 //....oooOO0OOooo........oooOO0OOooo........oo 194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 182 195 183 void Run::Merge(const G4Run* run) 196 void Run::Merge(const G4Run* run) 184 { 197 { 185 const Run* localRun = static_cast<const Run* 198 const Run* localRun = static_cast<const Run*>(run); 186 << 199 187 // primary particle info << 200 //primary particle info 188 // 201 // 189 fParticle = localRun->fParticle; 202 fParticle = localRun->fParticle; 190 fEkin = localRun->fEkin; << 203 fEkin = localRun->fEkin; 191 << 204 192 // accumulate sums 205 // accumulate sums 193 // 206 // 194 fEnergyDeposit += localRun->fEnergyDeposit; << 207 fEnergyDeposit += localRun->fEnergyDeposit; 195 fEnergyDeposit2 += localRun->fEnergyDeposit2 << 208 fEnergyDeposit2 += localRun->fEnergyDeposit2; 196 fEnergyFlow += localRun->fEnergyFlow; << 209 fEnergyFlow += localRun->fEnergyFlow; 197 fEnergyFlow2 += localRun->fEnergyFlow2; << 210 fEnergyFlow2 += localRun->fEnergyFlow2; 198 << 211 199 // map: processes count << 212 //map: processes count 200 for (const auto& procCounter : localRun->fPr << 213 for ( const auto& procCounter : localRun->fProcCounter ) { 201 G4String procName = procCounter.first; 214 G4String procName = procCounter.first; 202 G4int localCount = procCounter.second; 215 G4int localCount = procCounter.second; 203 if (fProcCounter.find(procName) == fProcCo << 216 if ( fProcCounter.find(procName) == fProcCounter.end()) { 204 fProcCounter[procName] = localCount; 217 fProcCounter[procName] = localCount; 205 } 218 } 206 else { 219 else { 207 fProcCounter[procName] += localCount; 220 fProcCounter[procName] += localCount; 208 } << 221 } 209 } 222 } 210 << 223 211 // map: created particles count << 224 //map: created particles count 212 Merge(fParticleDataMap1, localRun->fParticle << 225 Merge(fParticleDataMap1, localRun->fParticleDataMap1); 213 << 226 214 // map: particles flux count << 227 //map: particles flux count 215 Merge(fParticleDataMap2, localRun->fParticle << 228 Merge(fParticleDataMap2, localRun->fParticleDataMap2); 216 << 229 217 G4Run::Merge(run); << 230 G4Run::Merge(run); 218 } << 231 } 219 232 220 //....oooOO0OOooo........oooOO0OOooo........oo 233 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 221 234 222 void Run::EndOfRun() << 235 void Run::EndOfRun() 223 { 236 { 224 G4int prec = 5, wid = prec + 2; << 237 G4int prec = 5, wid = prec + 2; 225 G4int dfprec = G4cout.precision(prec); 238 G4int dfprec = G4cout.precision(prec); 226 << 239 227 // run condition << 240 //run condition 228 // 241 // 229 G4Material* material = fDetector->GetAbsorMa 242 G4Material* material = fDetector->GetAbsorMaterial(); 230 G4double density = material->GetDensity(); 243 G4double density = material->GetDensity(); 231 << 244 232 G4String Particle = fParticle->GetParticleNa << 245 G4String Particle = fParticle->GetParticleName(); 233 G4cout << "\n The run is " << numberOfEvent << 246 G4cout << "\n The run is " << numberOfEvent << " "<< Particle << " of " 234 << G4BestUnit(fEkin, "Energy") << " t << 247 << G4BestUnit(fEkin,"Energy") << " through " 235 << G4BestUnit(fDetector->GetAbsorThic << 248 << G4BestUnit(fDetector->GetAbsorThickness(),"Length") << " of " 236 << " (density: " << G4BestUnit(densit << 249 << material->GetName() << " (density: " 237 << 250 << G4BestUnit(density,"Volumic Mass") << ")" << G4endl; 238 if (numberOfEvent == 0) { << 251 239 G4cout.precision(dfprec); << 252 if (numberOfEvent == 0) { G4cout.precision(dfprec); return;} 240 return; << 253 241 } << 254 //frequency of processes 242 << 243 // frequency of processes << 244 // 255 // 245 G4cout << "\n Process calls frequency :" << 256 G4cout << "\n Process calls frequency :" << G4endl; 246 G4int index = 0; 257 G4int index = 0; 247 for (const auto& procCounter : fProcCounter) << 258 for ( const auto& procCounter : fProcCounter ) { 248 G4String procName = procCounter.first; << 259 G4String procName = procCounter.first; 249 G4int count = procCounter.second; << 260 G4int count = procCounter.second; 250 G4String space = " "; << 261 G4String space = " "; if (++index%3 == 0) space = "\n"; 251 if (++index % 3 == 0) space = "\n"; << 262 G4cout << " " << std::setw(20) << procName << "="<< std::setw(7) << count 252 G4cout << " " << std::setw(20) << procName << 263 << space; 253 } 264 } 254 G4cout << G4endl; 265 G4cout << G4endl; 255 << 266 256 // particles count << 267 //particles count 257 // 268 // 258 G4cout << "\n List of generated particles (w 269 G4cout << "\n List of generated particles (with meanLife != 0):" << G4endl; 259 << 270 260 for (const auto& particleData : fParticleDat << 271 for ( const auto& particleData : fParticleDataMap1 ) { 261 G4String name = particleData.first; 272 G4String name = particleData.first; 262 ParticleData data = particleData.second; 273 ParticleData data = particleData.second; 263 G4int count = data.fCount; 274 G4int count = data.fCount; 264 G4double eMean = data.fEmean / count; << 275 G4double eMean = data.fEmean/count; 265 G4double eMin = data.fEmin; 276 G4double eMin = data.fEmin; 266 G4double eMax = data.fEmax; 277 G4double eMax = data.fEmax; 267 G4double meanLife = data.fTmean; 278 G4double meanLife = data.fTmean; 268 << 279 269 G4cout << " " << std::setw(13) << name << 280 G4cout << " " << std::setw(13) << name << ": " << std::setw(7) << count 270 << " Emean = " << std::setw(wid) < << 281 << " Emean = " << std::setw(wid) << G4BestUnit(eMean, "Energy") 271 << G4BestUnit(eMin, "Energy") << " << 282 << "\t( " << G4BestUnit(eMin, "Energy") >> 283 << " --> " << G4BestUnit(eMax, "Energy") << ")"; 272 if (meanLife >= 0.) 284 if (meanLife >= 0.) 273 G4cout << "\tmean life = " << G4BestUnit << 285 G4cout << "\tmean life = " << G4BestUnit(meanLife, "Time") << G4endl; 274 else << 286 else G4cout << "\tstable" << G4endl; 275 G4cout << "\tstable" << G4endl; << 287 } 276 } << 288 277 << 278 // compute mean Energy deposited and rms 289 // compute mean Energy deposited and rms 279 // 290 // 280 G4int TotNbofEvents = numberOfEvent; 291 G4int TotNbofEvents = numberOfEvent; 281 fEnergyDeposit /= TotNbofEvents; << 292 fEnergyDeposit /= TotNbofEvents; fEnergyDeposit2 /= TotNbofEvents; 282 fEnergyDeposit2 /= TotNbofEvents; << 293 G4double rmsEdep = fEnergyDeposit2 - fEnergyDeposit*fEnergyDeposit; 283 G4double rmsEdep = fEnergyDeposit2 - fEnergy << 294 if (rmsEdep>0.) rmsEdep = std::sqrt(rmsEdep); 284 if (rmsEdep > 0.) << 295 else rmsEdep = 0.; 285 rmsEdep = std::sqrt(rmsEdep); << 296 286 else << 297 G4cout << "\n Mean energy deposit per event = " 287 rmsEdep = 0.; << 298 << G4BestUnit(fEnergyDeposit,"Energy") << "; rms = " 288 << 299 << G4BestUnit(rmsEdep, "Energy") 289 G4cout << "\n Mean energy deposit per event << 300 << G4endl; 290 << "; rms = " << G4BestUnit(rmsEdep, << 301 291 << 292 // compute mean Energy flow and rms 302 // compute mean Energy flow and rms 293 // 303 // 294 fEnergyFlow /= TotNbofEvents; << 304 fEnergyFlow /= TotNbofEvents; fEnergyFlow2 /= TotNbofEvents; 295 fEnergyFlow2 /= TotNbofEvents; << 305 G4double rmsEflow = fEnergyFlow2 - fEnergyFlow*fEnergyFlow; 296 G4double rmsEflow = fEnergyFlow2 - fEnergyFl << 306 if (rmsEflow>0.) rmsEflow = std::sqrt(rmsEflow); 297 if (rmsEflow > 0.) << 307 else rmsEflow = 0.; 298 rmsEflow = std::sqrt(rmsEflow); << 308 299 else << 309 G4cout << " Mean energy flow per event = " 300 rmsEflow = 0.; << 310 << G4BestUnit(fEnergyFlow,"Energy") << "; rms = " 301 << 311 << G4BestUnit(rmsEflow, "Energy") 302 G4cout << " Mean energy flow per event = << 312 << G4endl; 303 << "; rms = " << G4BestUnit(rmsEflow << 313 304 << 314 //particles flux 305 // particles flux << 315 // 306 // << 316 G4cout << "\n List of particles emerging from the target :" << G4endl; 307 G4cout << "\n List of particles emerging fro << 317 308 << 318 for ( const auto& particleData : fParticleDataMap2 ) { 309 for (const auto& particleData : fParticleDat << 310 G4String name = particleData.first; 319 G4String name = particleData.first; 311 ParticleData data = particleData.second; 320 ParticleData data = particleData.second; 312 G4int count = data.fCount; 321 G4int count = data.fCount; 313 G4double eMean = data.fEmean / count; << 322 G4double eMean = data.fEmean/count; 314 G4double eMin = data.fEmin; 323 G4double eMin = data.fEmin; 315 G4double eMax = data.fEmax; 324 G4double eMax = data.fEmax; 316 G4double Eflow = data.fEmean / TotNbofEven << 325 G4double Eflow = data.fEmean/TotNbofEvents; 317 << 326 318 G4cout << " " << std::setw(13) << name << 327 G4cout << " " << std::setw(13) << name << ": " << std::setw(7) << count 319 << " Emean = " << std::setw(wid) < << 328 << " Emean = " << std::setw(wid) << G4BestUnit(eMean, "Energy") 320 << G4BestUnit(eMin, "Energy") << " << 329 << "\t( " << G4BestUnit(eMin, "Energy") >> 330 << " --> " << G4BestUnit(eMax, "Energy") 321 << ") \tEflow/event = " << G4BestUn 331 << ") \tEflow/event = " << G4BestUnit(Eflow, "Energy") << G4endl; 322 } << 332 } 323 << 333 324 // histogram Id for populations << 334 //histogram Id for populations 325 // << 335 // 326 G4cout << "\n histo Id for populations :" << << 336 G4cout << "\n histo Id for populations :" << G4endl; 327 << 337 328 // Update the histogram titles according to << 338 // Update the histogram titles according to the ion map 329 // and print new titles << 339 // and print new titles 330 G4AnalysisManager* analysisManager = G4Analy << 340 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 331 for (const auto& ionMapElement : fgIonMap) { << 341 for ( const auto& ionMapElement : fgIonMap ) { 332 G4String ionName = ionMapElement.first; 342 G4String ionName = ionMapElement.first; 333 G4int h1Id = ionMapElement.second; << 343 G4int h1Id = ionMapElement.second; 334 // print new titles 344 // print new titles 335 G4cout << " " << std::setw(20) << ionName << 345 G4cout << " " << std::setw(20) << ionName << " id = "<< std::setw(3) << h1Id >> 346 << G4endl; 336 347 337 // update histogram ids 348 // update histogram ids 338 if (!analysisManager->GetH1(h1Id)) continu << 349 if ( ! analysisManager->GetH1(h1Id) ) continue; 339 // Skip inactive histograms, this is not n << 350 // Skip inactive histograms, this is not necessary 340 // but it makes the code safe wrt modific << 351 // but it makes the code safe wrt modifications in future 341 G4String title = analysisManager->GetH1Tit 352 G4String title = analysisManager->GetH1Title(h1Id); 342 title = ionName + title; 353 title = ionName + title; 343 analysisManager->SetH1Title(h1Id, title); 354 analysisManager->SetH1Title(h1Id, title); 344 } << 355 } 345 G4cout << G4endl; << 356 G4cout << G4endl; 346 << 357 347 // normalize histograms << 358 //normalize histograms 348 G4int ih = 2; 359 G4int ih = 2; 349 G4double binWidth = analysisManager->GetH1Wi 360 G4double binWidth = analysisManager->GetH1Width(ih); 350 G4double fac = (1. / (numberOfEvent * binWid << 361 G4double fac = (1./(numberOfEvent*binWidth))*(mm/MeV); 351 analysisManager->ScaleH1(ih, fac); << 362 analysisManager->ScaleH1(ih,fac); 352 << 363 353 for (ih = 14; ih < 24; ih++) { << 364 for (ih=14; ih<24; ih++) { 354 binWidth = analysisManager->GetH1Width(ih) 365 binWidth = analysisManager->GetH1Width(ih); 355 G4double unit = analysisManager->GetH1Unit << 366 G4double unit = analysisManager->GetH1Unit(ih); 356 fac = (second / (binWidth * unit)); << 367 fac = (second/(binWidth*unit)); 357 analysisManager->ScaleH1(ih, fac); << 368 analysisManager->ScaleH1(ih,fac); 358 } << 369 } 359 << 370 360 // remove all contents in fProcCounter, fCou << 371 //remove all contents in fProcCounter, fCount 361 fProcCounter.clear(); 372 fProcCounter.clear(); 362 fParticleDataMap1.clear(); 373 fParticleDataMap1.clear(); 363 fParticleDataMap2.clear(); 374 fParticleDataMap2.clear(); 364 fgIonMap.clear(); 375 fgIonMap.clear(); 365 << 376 366 // restore default format << 377 //restore default format 367 G4cout.precision(dfprec); << 378 G4cout.precision(dfprec); 368 } 379 } 369 380 370 //....oooOO0OOooo........oooOO0OOooo........oo 381 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 371 382