Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/hadronic/Hadr06/src/Run.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/hadronic/Hadr06/src/Run.cc (Version 11.3.0) and /examples/extended/hadronic/Hadr06/src/Run.cc (Version 10.1.p2)


  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 electromagnetic/TestEm11/src/Run.cc
 27 /// \brief Implementation of the Run class         27 /// \brief Implementation of the Run class
 28 //                                                 28 //
 29 //                                             <<  29 // $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $
                                                   >>  30 // 
 30 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 31 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32                                                    33 
 33 #include "Run.hh"                                  34 #include "Run.hh"
 34                                                << 
 35 #include "DetectorConstruction.hh"                 35 #include "DetectorConstruction.hh"
 36 #include "HistoManager.hh"                     << 
 37 #include "PrimaryGeneratorAction.hh"               36 #include "PrimaryGeneratorAction.hh"
                                                   >>  37 #include "HistoManager.hh"
 38                                                    38 
 39 #include "G4SystemOfUnits.hh"                  << 
 40 #include "G4UnitsTable.hh"                         39 #include "G4UnitsTable.hh"
                                                   >>  40 #include "G4SystemOfUnits.hh"
                                                   >>  41 
                                                   >>  42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >>  43 
                                                   >>  44 Run::Run(DetectorConstruction* det)
                                                   >>  45 : G4Run(),
                                                   >>  46   fDetector(det), fParticle(0), fEkin(0.)
                                                   >>  47 {
                                                   >>  48   fEnergyDeposit = fEnergyDeposit2 = 0.;
                                                   >>  49   fEnergyFlow    = fEnergyFlow2    = 0.;  
                                                   >>  50 }
 41                                                    51 
 42 //....oooOO0OOooo........oooOO0OOooo........oo     52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 43                                                    53 
 44 Run::Run(DetectorConstruction* det) : fDetecto <<  54 Run::~Run()
                                                   >>  55 { }
 45                                                    56 
 46 //....oooOO0OOooo........oooOO0OOooo........oo     57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 47                                                    58 
 48 void Run::SetPrimary(G4ParticleDefinition* par     59 void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy)
 49 {                                              <<  60 { 
 50   fParticle = particle;                            61   fParticle = particle;
 51   fEkin = energy;                                  62   fEkin = energy;
 52 }                                                  63 }
 53                                                <<  64  
 54 //....oooOO0OOooo........oooOO0OOooo........oo     65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 55                                                    66 
 56 void Run::CountProcesses(const G4VProcess* pro <<  67 void Run::CountProcesses(const G4VProcess* process) 
 57 {                                                  68 {
 58   if (process == nullptr) return;              << 
 59   G4String procName = process->GetProcessName(     69   G4String procName = process->GetProcessName();
 60   std::map<G4String, G4int>::iterator it = fPr <<  70   std::map<G4String,G4int>::iterator it = fProcCounter.find(procName);
 61   if (it == fProcCounter.end()) {              <<  71   if ( it == fProcCounter.end()) {
 62     fProcCounter[procName] = 1;                    72     fProcCounter[procName] = 1;
 63   }                                                73   }
 64   else {                                           74   else {
 65     fProcCounter[procName]++;                  <<  75     fProcCounter[procName]++; 
 66   }                                                76   }
 67 }                                                  77 }
 68                                                <<  78                   
 69 //....oooOO0OOooo........oooOO0OOooo........oo     79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70                                                    80 
 71 void Run::ParticleCount(G4String name, G4doubl <<  81 void Run::ParticleCount(G4String name, G4double Ekin)
 72 {                                                  82 {
 73   std::map<G4String, ParticleData>::iterator i     83   std::map<G4String, ParticleData>::iterator it = fParticleDataMap1.find(name);
 74   if (it == fParticleDataMap1.end()) {         <<  84   if ( it == fParticleDataMap1.end()) {
 75     fParticleDataMap1[name] = ParticleData(1,  <<  85     fParticleDataMap1[name] = ParticleData(1, Ekin, Ekin, Ekin);
 76   }                                                86   }
 77   else {                                           87   else {
 78     ParticleData& data = it->second;               88     ParticleData& data = it->second;
 79     data.fCount++;                                 89     data.fCount++;
 80     data.fEmean += Ekin;                           90     data.fEmean += Ekin;
 81     // update min max                          <<  91     //update min max
 82     G4double emin = data.fEmin;                    92     G4double emin = data.fEmin;
 83     if (Ekin < emin) data.fEmin = Ekin;            93     if (Ekin < emin) data.fEmin = Ekin;
 84     G4double emax = data.fEmax;                    94     G4double emax = data.fEmax;
 85     if (Ekin > emax) data.fEmax = Ekin;        <<  95     if (Ekin > emax) data.fEmax = Ekin; 
 86     data.fTmean = meanLife;                    <<  96   }   
 87   }                                            << 
 88 }                                                  97 }
 89                                                <<  98                  
 90 //....oooOO0OOooo........oooOO0OOooo........oo     99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 91                                                   100 
 92 void Run::SumEnergies(G4double edep, G4double  << 101 void Run::AddEdep(G4double edep)
 93 {                                              << 102 { 
 94   fEnergyDeposit += edep;                         103   fEnergyDeposit += edep;
 95   fEnergyDeposit2 += edep * edep;              << 104   fEnergyDeposit2 += edep*edep;
 96                                                << 
 97   fEnergyFlow += eflow;                        << 
 98   fEnergyFlow2 += eflow * eflow;               << 
 99                                                << 
100   fEnergyTotal += etot;                        << 
101   fEnergyTotal2 += etot * etot;                << 
102 }                                                 105 }
                                                   >> 106                  
                                                   >> 107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103                                                   108 
                                                   >> 109 void Run::AddEflow(G4double eflow)
                                                   >> 110 { 
                                                   >> 111   fEnergyFlow += eflow;
                                                   >> 112   fEnergyFlow2 += eflow*eflow;
                                                   >> 113 }                  
104 //....oooOO0OOooo........oooOO0OOooo........oo    114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105                                                   115 
106 void Run::ParticleFlux(G4String name, G4double    116 void Run::ParticleFlux(G4String name, G4double Ekin)
107 {                                                 117 {
108   std::map<G4String, ParticleData>::iterator i    118   std::map<G4String, ParticleData>::iterator it = fParticleDataMap2.find(name);
109   if (it == fParticleDataMap2.end()) {         << 119   if ( it == fParticleDataMap2.end()) {
110     fParticleDataMap2[name] = ParticleData(1,  << 120     fParticleDataMap2[name] = ParticleData(1, Ekin, Ekin, Ekin);
111   }                                               121   }
112   else {                                          122   else {
113     ParticleData& data = it->second;              123     ParticleData& data = it->second;
114     data.fCount++;                                124     data.fCount++;
115     data.fEmean += Ekin;                          125     data.fEmean += Ekin;
116     // update min max                          << 126     //update min max
117     G4double emin = data.fEmin;                   127     G4double emin = data.fEmin;
118     if (Ekin < emin) data.fEmin = Ekin;           128     if (Ekin < emin) data.fEmin = Ekin;
119     G4double emax = data.fEmax;                   129     G4double emax = data.fEmax;
120     if (Ekin > emax) data.fEmax = Ekin;        << 130     if (Ekin > emax) data.fEmax = Ekin; 
121     data.fTmean = -1 * ns;                     << 131   }   
122   }                                            << 
123 }                                                 132 }
124                                                   133 
125 //....oooOO0OOooo........oooOO0OOooo........oo    134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126                                                   135 
127 void Run::Merge(const G4Run* run)                 136 void Run::Merge(const G4Run* run)
128 {                                                 137 {
129   const Run* localRun = static_cast<const Run*    138   const Run* localRun = static_cast<const Run*>(run);
130                                                << 139   
131   // primary particle info                     << 140   //primary particle info
132   //                                              141   //
133   fParticle = localRun->fParticle;                142   fParticle = localRun->fParticle;
134   fEkin = localRun->fEkin;                     << 143   fEkin     = localRun->fEkin;
135                                                << 144   
136   // accumulate sums                              145   // accumulate sums
137   //                                              146   //
138   fEnergyDeposit += localRun->fEnergyDeposit;  << 147   fEnergyDeposit   += localRun->fEnergyDeposit;  
139   fEnergyDeposit2 += localRun->fEnergyDeposit2 << 148   fEnergyDeposit2  += localRun->fEnergyDeposit2;
140   fEnergyFlow += localRun->fEnergyFlow;        << 149   fEnergyFlow      += localRun->fEnergyFlow;
141   fEnergyFlow2 += localRun->fEnergyFlow2;      << 150   fEnergyFlow2     += localRun->fEnergyFlow2;
142   fEnergyTotal += localRun->fEnergyTotal;      << 151       
143   fEnergyTotal2 += localRun->fEnergyTotal2;    << 152   //map: processes count
144                                                << 153   std::map<G4String,G4int>::const_iterator itp;
145   // map: processes count                      << 154   for ( itp = localRun->fProcCounter.begin();
146   std::map<G4String, G4int>::const_iterator it << 155         itp != localRun->fProcCounter.end(); ++itp ) {
147   for (itp = localRun->fProcCounter.begin(); i << 156 
148     G4String procName = itp->first;               157     G4String procName = itp->first;
149     G4int localCount = itp->second;               158     G4int localCount = itp->second;
150     if (fProcCounter.find(procName) == fProcCo << 159     if ( fProcCounter.find(procName) == fProcCounter.end()) {
151       fProcCounter[procName] = localCount;        160       fProcCounter[procName] = localCount;
152     }                                             161     }
153     else {                                        162     else {
154       fProcCounter[procName] += localCount;       163       fProcCounter[procName] += localCount;
155     }                                          << 164     }  
156   }                                               165   }
157                                                << 166   
158   // map: created particles count              << 167   //map: created particles count    
159   std::map<G4String, ParticleData>::const_iter << 168   std::map<G4String,ParticleData>::const_iterator itc;
160   for (itc = localRun->fParticleDataMap1.begin << 169   for (itc = localRun->fParticleDataMap1.begin(); 
                                                   >> 170        itc != localRun->fParticleDataMap1.end(); ++itc) {
                                                   >> 171     
161     G4String name = itc->first;                   172     G4String name = itc->first;
162     const ParticleData& localData = itc->secon << 173     const ParticleData& localData = itc->second;   
163     if (fParticleDataMap1.find(name) == fParti << 174     if ( fParticleDataMap1.find(name) == fParticleDataMap1.end()) {
164       fParticleDataMap1[name] = ParticleData(l << 175       fParticleDataMap1[name]
165                                              l << 176        = ParticleData(localData.fCount, 
                                                   >> 177                       localData.fEmean, 
                                                   >> 178                       localData.fEmin, 
                                                   >> 179                       localData.fEmax);
166     }                                             180     }
167     else {                                        181     else {
168       ParticleData& data = fParticleDataMap1[n << 182       ParticleData& data = fParticleDataMap1[name];   
169       data.fCount += localData.fCount;            183       data.fCount += localData.fCount;
170       data.fEmean += localData.fEmean;            184       data.fEmean += localData.fEmean;
171       G4double emin = localData.fEmin;            185       G4double emin = localData.fEmin;
172       if (emin < data.fEmin) data.fEmin = emin    186       if (emin < data.fEmin) data.fEmin = emin;
173       G4double emax = localData.fEmax;            187       G4double emax = localData.fEmax;
174       if (emax > data.fEmax) data.fEmax = emax << 188       if (emax > data.fEmax) data.fEmax = emax; 
175       data.fTmean = localData.fTmean;          << 189     }   
176     }                                          << 
177   }                                               190   }
178                                                << 191   
179   // map: particles flux count                 << 192   //map: particles flux count       
180   std::map<G4String, ParticleData>::const_iter << 193   std::map<G4String,ParticleData>::const_iterator itn;
181   for (itn = localRun->fParticleDataMap2.begin << 194   for (itn = localRun->fParticleDataMap2.begin(); 
                                                   >> 195        itn != localRun->fParticleDataMap2.end(); ++itn) {
                                                   >> 196     
182     G4String name = itn->first;                   197     G4String name = itn->first;
183     const ParticleData& localData = itn->secon << 198     const ParticleData& localData = itn->second;   
184     if (fParticleDataMap2.find(name) == fParti << 199     if ( fParticleDataMap2.find(name) == fParticleDataMap2.end()) {
185       fParticleDataMap2[name] = ParticleData(l << 200       fParticleDataMap2[name]
186                                              l << 201        = ParticleData(localData.fCount, 
                                                   >> 202                       localData.fEmean, 
                                                   >> 203                       localData.fEmin, 
                                                   >> 204                       localData.fEmax);
187     }                                             205     }
188     else {                                        206     else {
189       ParticleData& data = fParticleDataMap2[n << 207       ParticleData& data = fParticleDataMap2[name];   
190       data.fCount += localData.fCount;            208       data.fCount += localData.fCount;
191       data.fEmean += localData.fEmean;            209       data.fEmean += localData.fEmean;
192       G4double emin = localData.fEmin;            210       G4double emin = localData.fEmin;
193       if (emin < data.fEmin) data.fEmin = emin    211       if (emin < data.fEmin) data.fEmin = emin;
194       G4double emax = localData.fEmax;            212       G4double emax = localData.fEmax;
195       if (emax > data.fEmax) data.fEmax = emax << 213       if (emax > data.fEmax) data.fEmax = emax; 
196       data.fTmean = localData.fTmean;          << 214     }   
197     }                                          << 
198   }                                               215   }
199                                                   216 
200   G4Run::Merge(run);                           << 217   G4Run::Merge(run); 
201 }                                              << 218 } 
202                                                   219 
203 //....oooOO0OOooo........oooOO0OOooo........oo    220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204                                                   221 
205 void Run::EndOfRun()                           << 222 void Run::EndOfRun() 
206 {                                                 223 {
207   G4int prec = 5, wid = prec + 2;              << 224   G4int prec = 5, wid = prec + 2;  
208   G4int dfprec = G4cout.precision(prec);          225   G4int dfprec = G4cout.precision(prec);
209                                                << 226   
210   // run condition                             << 227   //run condition
211   //                                              228   //
212   G4Material* material = fDetector->GetMateria    229   G4Material* material = fDetector->GetMaterial();
213   G4double density = material->GetDensity();      230   G4double density = material->GetDensity();
214                                                << 231    
215   G4String Particle = fParticle->GetParticleNa << 232   G4String Particle = fParticle->GetParticleName();    
216   G4cout << "\n The run is " << numberOfEvent  << 233   G4cout << "\n The run is " << numberOfEvent << " "<< Particle << " of "
217          << G4BestUnit(fEkin, "Energy") << " t << 234          << G4BestUnit(fEkin,"Energy") << " through " 
218          << G4BestUnit(fDetector->GetRadius(), << 235          << G4BestUnit(fDetector->GetRadius(),"Length") << " of "
219          << " (density: " << G4BestUnit(densit << 236          << material->GetName() << " (density: " 
220                                                << 237          << G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
221   if (numberOfEvent == 0) {                    << 238 
222     G4cout.precision(dfprec);                  << 239   if (numberOfEvent == 0) { G4cout.precision(dfprec);   return;}
223     return;                                    << 240              
224   }                                            << 241   //frequency of processes
225                                                << 
226   // frequency of processes                    << 
227   //                                              242   //
228   G4cout << "\n Process calls frequency :" <<     243   G4cout << "\n Process calls frequency :" << G4endl;
229   G4int index = 0;                                244   G4int index = 0;
230   std::map<G4String, G4int>::iterator it;      << 245   std::map<G4String,G4int>::iterator it;    
231   for (it = fProcCounter.begin(); it != fProcC    246   for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
232     G4String procName = it->first;             << 247      G4String procName = it->first;
233     G4int count = it->second;                  << 248      G4int    count    = it->second;
234     G4String space = " ";                      << 249      G4String space = " "; if (++index%3 == 0) space = "\n";
235     if (++index % 3 == 0) space = "\n";        << 250      G4cout << " " << std::setw(20) << procName << "="<< std::setw(7) << count
236     G4cout << " " << std::setw(20) << procName << 251             << space;
237   }                                               252   }
238   G4cout << G4endl;                               253   G4cout << G4endl;
239                                                << 254   
                                                   >> 255   //particles count
                                                   >> 256   //
                                                   >> 257   G4cout << "\n List of generated particles:" << G4endl;
                                                   >> 258      
                                                   >> 259  std::map<G4String,ParticleData>::iterator itc;               
                                                   >> 260  for (itc = fParticleDataMap1.begin(); itc != fParticleDataMap1.end(); itc++) { 
                                                   >> 261     G4String name = itc->first;
                                                   >> 262     ParticleData data = itc->second;
                                                   >> 263     G4int count = data.fCount;
                                                   >> 264     G4double eMean = data.fEmean/count;
                                                   >> 265     G4double eMin = data.fEmin;
                                                   >> 266     G4double eMax = data.fEmax;    
                                                   >> 267          
                                                   >> 268     G4cout << "  " << std::setw(13) << name << ": " << std::setw(7) << count
                                                   >> 269            << "  Emean = " << std::setw(wid) << G4BestUnit(eMean, "Energy")
                                                   >> 270            << "\t( "  << G4BestUnit(eMin, "Energy")
                                                   >> 271            << " --> " << G4BestUnit(eMax, "Energy") 
                                                   >> 272            << ")" << G4endl;           
                                                   >> 273  }
                                                   >> 274    
240   // compute mean Energy deposited and rms        275   // compute mean Energy deposited and rms
241   //                                              276   //
242   G4int TotNbofEvents = numberOfEvent;            277   G4int TotNbofEvents = numberOfEvent;
243   fEnergyDeposit /= TotNbofEvents;             << 278   fEnergyDeposit /= TotNbofEvents; fEnergyDeposit2 /= TotNbofEvents;
244   fEnergyDeposit2 /= TotNbofEvents;            << 279   G4double rmsEdep = fEnergyDeposit2 - fEnergyDeposit*fEnergyDeposit;
245   G4double rmsEdep = fEnergyDeposit2 - fEnergy << 280   if (rmsEdep>0.) rmsEdep = std::sqrt(rmsEdep);
246   if (rmsEdep > 0.)                            << 281   else            rmsEdep = 0.;
247     rmsEdep = std::sqrt(rmsEdep);              << 282   
248   else                                         << 283   G4cout << "\n Mean energy deposit per event = "
249     rmsEdep = 0.;                              << 284          << G4BestUnit(fEnergyDeposit,"Energy") << ";  rms = "
250                                                << 285          << G4BestUnit(rmsEdep,      "Energy") 
251   G4cout << "\n Mean energy deposit per event  << 286          << G4endl;
252          << ";  rms = " << G4BestUnit(rmsEdep, << 287   
253                                                << 288   // compute mean Energy flow and rms
254   // compute mean Energy leakage and rms       << 
255   //                                           << 
256   fEnergyFlow /= TotNbofEvents;                << 
257   fEnergyFlow2 /= TotNbofEvents;               << 
258   G4double rmsEflow = fEnergyFlow2 - fEnergyFl << 
259   if (rmsEflow > 0.)                           << 
260     rmsEflow = std::sqrt(rmsEflow);            << 
261   else                                         << 
262     rmsEflow = 0.;                             << 
263                                                << 
264   G4cout << " Mean energy leakage per event =  << 
265          << ";  rms = " << G4BestUnit(rmsEflow << 
266                                                << 
267   // energy balance                            << 
268   //                                           << 
269   fEnergyTotal /= TotNbofEvents;               << 
270   fEnergyTotal2 /= TotNbofEvents;              << 
271   G4double rmsEtotal = fEnergyTotal2 - fEnergy << 
272   if (rmsEtotal > 0.)                          << 
273     rmsEtotal = std::sqrt(rmsEtotal);          << 
274   else                                         << 
275     rmsEflow = 0.;                             << 
276                                                << 
277   G4cout << "\n Mean energy total   per event  << 
278          << ";  rms = " << G4BestUnit(rmsEtota << 
279                                                << 
280   // particles at creation                     << 
281   //                                           << 
282   if (fParticleDataMap1.size() > 0) {          << 
283     G4cout << "\n List of particles at creatio << 
284     std::map<G4String, ParticleData>::iterator << 
285     for (itc = fParticleDataMap1.begin(); itc  << 
286       G4String name = itc->first;              << 
287       ParticleData data = itc->second;         << 
288       G4int count = data.fCount;               << 
289       G4double eMean = data.fEmean / count;    << 
290       G4double eMin = data.fEmin;              << 
291       G4double eMax = data.fEmax;              << 
292       G4double meanLife = data.fTmean;         << 
293                                                << 
294       G4cout << "  " << std::setw(13) << name  << 
295              << "  Emean = " << std::setw(wid) << 
296              << G4BestUnit(eMin, "Energy") <<  << 
297       if (meanLife >= 0.)                      << 
298         G4cout << "\tmean life = " << G4BestUn << 
299       else                                     << 
300         G4cout << "\tstable" << G4endl;        << 
301     }                                          << 
302   }                                            << 
303                                                << 
304   // emerging particles                        << 
305   //                                              289   //
306   G4cout << "\n List of particles emerging fro << 290   fEnergyFlow /= TotNbofEvents; fEnergyFlow2 /= TotNbofEvents;
307                                                << 291   G4double rmsEflow = fEnergyFlow2 - fEnergyFlow*fEnergyFlow;
308   std::map<G4String, ParticleData>::iterator i << 292   if (rmsEflow>0.) rmsEflow = std::sqrt(rmsEflow);
309   for (itn = fParticleDataMap2.begin(); itn != << 293   else             rmsEflow = 0.;
                                                   >> 294   
                                                   >> 295   G4cout << " Mean energy flow per event    = "
                                                   >> 296          << G4BestUnit(fEnergyFlow,"Energy") << ";  rms = "
                                                   >> 297          << G4BestUnit(rmsEflow,   "Energy") 
                                                   >> 298          << G4endl;
                                                   >> 299                                 
                                                   >> 300  //particles flux
                                                   >> 301  //
                                                   >> 302  G4cout << "\n List of particles leaving the absorber :" << G4endl;
                                                   >> 303      
                                                   >> 304  std::map<G4String,ParticleData>::iterator itn;               
                                                   >> 305  for (itn = fParticleDataMap2.begin(); itn != fParticleDataMap2.end(); itn++) { 
310     G4String name = itn->first;                   306     G4String name = itn->first;
311     ParticleData data = itn->second;              307     ParticleData data = itn->second;
312     G4int count = data.fCount;                    308     G4int count = data.fCount;
313     G4double eMean = data.fEmean / count;      << 309     G4double eMean = data.fEmean/count;
314     G4double eMin = data.fEmin;                   310     G4double eMin = data.fEmin;
315     G4double eMax = data.fEmax;                   311     G4double eMax = data.fEmax;
316     G4double Eflow = data.fEmean / TotNbofEven << 312     G4double Eflow = data.fEmean/TotNbofEvents;        
317                                                << 313          
318     G4cout << "  " << std::setw(13) << name <<    314     G4cout << "  " << std::setw(13) << name << ": " << std::setw(7) << count
319            << "  Emean = " << std::setw(wid) < << 315            << "  Emean = " << std::setw(wid) << G4BestUnit(eMean, "Energy")
320            << G4BestUnit(eMin, "Energy") << "  << 316            << "\t( "  << G4BestUnit(eMin, "Energy")
321            << ") \tEleak/event = " << G4BestUn << 317            << " --> " << G4BestUnit(eMax, "Energy") 
322   }                                            << 318            << ") \tEflow/event = " << G4BestUnit(Eflow, "Energy") << G4endl;
323                                                << 319  }
324   // normalize histograms                      << 320  
325   G4AnalysisManager* analysisManager = G4Analy << 321   //normalize histograms
326                                                << 322   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();        
327   G4int ih = 2;                                << 323   for (G4int ih=1; ih<14; ih++) {
328   G4double binWidth = analysisManager->GetH1Wi << 324     G4double binWidth = analysisManager->GetH1Width(ih);
329   G4double fac = (1. / (numberOfEvent * binWid << 325     G4double unit     = analysisManager->GetH1Unit(ih);  
330   analysisManager->ScaleH1(ih, fac);           << 326     G4double fac = unit/binWidth;
331                                                << 327     ///G4double fac = unit/(numberOfEvent*binWidth);
332   // remove all contents in fProcCounter, fCou << 328     if (ih == 2) fac = (1./(numberOfEvent*binWidth))*(mm/MeV);    
                                                   >> 329     analysisManager->ScaleH1(ih,fac);
                                                   >> 330   }  
                                                   >> 331            
                                                   >> 332   //remove all contents in fProcCounter, fCount 
333   fProcCounter.clear();                           333   fProcCounter.clear();
334   fParticleDataMap2.clear();                      334   fParticleDataMap2.clear();
335                                                << 335                           
336   // restore default format                    << 336   //restore default format         
337   G4cout.precision(dfprec);                    << 337   G4cout.precision(dfprec);   
338 }                                                 338 }
339                                                   339 
340 //....oooOO0OOooo........oooOO0OOooo........oo    340 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
341                                                   341