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.5.p1)


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