Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/electromagnetic/TestEm9/src/HistoManager.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/electromagnetic/TestEm9/src/HistoManager.cc (Version 11.3.0) and /examples/extended/electromagnetic/TestEm9/src/HistoManager.cc (Version 9.4)


  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 electromagnetic/TestEm9/src/HistoMan << 
 27 /// \brief Implementation of the HistoManager  << 
 28 //                                             << 
 29 //                                             << 
 30 //--------------------------------------------     26 //---------------------------------------------------------------------------
 31 //                                                 27 //
 32 // ClassName:   HistoManager                       28 // ClassName:   HistoManager
 33 //                                                 29 //
 34 //                                                 30 //
 35 // Author:      V.Ivanchenko 30/01/01              31 // Author:      V.Ivanchenko 30/01/01
 36 //                                                 32 //
 37 //--------------------------------------------     33 //----------------------------------------------------------------------------
 38 //                                                 34 //
 39                                                    35 
 40 //....oooOO0OOooo........oooOO0OOooo........oo     36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 41 //....oooOO0OOooo........oooOO0OOooo........oo     37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 42                                                    38 
 43 #include "HistoManager.hh"                         39 #include "HistoManager.hh"
 44                                                << 
 45 #include "EmAcceptance.hh"                     << 
 46 #include "Histo.hh"                            << 
 47                                                << 
 48 #include "G4Electron.hh"                       << 
 49 #include "G4EmProcessSubType.hh"               << 
 50 #include "G4Gamma.hh"                          << 
 51 #include "G4GammaGeneralProcess.hh"            << 
 52 #include "G4MaterialCutsCouple.hh"                 40 #include "G4MaterialCutsCouple.hh"
 53 #include "G4Positron.hh"                       <<  41 #include "G4EmProcessSubType.hh"
 54 #include "G4SystemOfUnits.hh"                  <<  42 #include "G4VProcess.hh"
 55 #include "G4UnitsTable.hh"                     << 
 56 #include "G4VEmProcess.hh"                         43 #include "G4VEmProcess.hh"
 57 #include "G4VEnergyLossProcess.hh"                 44 #include "G4VEnergyLossProcess.hh"
 58 #include "G4VProcess.hh"                       <<  45 #include "G4UnitsTable.hh"
                                                   >>  46 #include "Histo.hh"
                                                   >>  47 #include "EmAcceptance.hh"
 59                                                    48 
 60 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 61                                                    50 
 62 HistoManager* HistoManager::fManager = nullptr <<  51 HistoManager* HistoManager::fManager = 0;
 63                                                    52 
 64 //....oooOO0OOooo........oooOO0OOooo........oo     53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 65                                                    54 
 66 HistoManager* HistoManager::GetPointer()           55 HistoManager* HistoManager::GetPointer()
 67 {                                                  56 {
 68   if (nullptr == fManager) {                   <<  57   if(!fManager) {
 69     fManager = new HistoManager();                 58     fManager = new HistoManager();
 70   }                                                59   }
 71   return fManager;                                 60   return fManager;
 72 }                                                  61 }
 73                                                    62 
 74 //....oooOO0OOooo........oooOO0OOooo........oo     63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 75                                                    64 
 76 HistoManager::HistoManager()                       65 HistoManager::HistoManager()
 77   : fGamma(G4Gamma::Gamma()),                  <<  66 {
 78     fElectron(G4Electron::Electron()),         <<  67   verbose = 1;
 79     fPositron(G4Positron::Positron()),         <<  68   nEvt1   = -1;
 80     fHisto(new Histo())                        <<  69   nEvt2   = -1;
 81 {                                              <<  70   nmax    = 3;
 82   fVerbose = 1;                                <<  71   histo   = new Histo();
 83   fEvt1 = -1;                                  <<  72   bookHisto();
 84   fEvt2 = -1;                                  << 
 85   fNmax = 3;                                   << 
 86   fMaxEnergy = 50.0 * MeV;                     << 
 87   fBeamEnergy = 1. * GeV;                      << 
 88   fMaxEnergyAbs = 10. * MeV;                   << 
 89   fBinsE = 100;                                << 
 90   fBinsEA = 40;                                << 
 91   fBinsED = 100;                               << 
 92   fNHisto = 13;                                << 
 93                                                << 
 94   BookHisto();                                 << 
 95 }                                                  73 }
 96                                                    74 
 97 //....oooOO0OOooo........oooOO0OOooo........oo     75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 98                                                    76 
 99 HistoManager::~HistoManager()                      77 HistoManager::~HistoManager()
100 {                                                  78 {
101   delete fHisto;                               <<  79   delete histo;
102 }                                                  80 }
103                                                    81 
104 //....oooOO0OOooo........oooOO0OOooo........oo     82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
105                                                    83 
106 void HistoManager::BookHisto()                 <<  84 void HistoManager::bookHisto()
107 {                                                  85 {
108   fHisto->Add1D("10", "Evis/E0 in central crys <<  86   maxEnergy = 50.0*MeV;
109   fHisto->Add1D("11", "Evis/E0 in 3x3", fBinsE <<  87   beamEnergy= 1.*GeV;
110   fHisto->Add1D("12", "Evis/E0 in 5x5", fBinsE <<  88   maxEnergyAbs = 10.*MeV;
111   fHisto->Add1D("13", "Energy (MeV) of delta-e <<  89   thKinE    = 1.*MeV;
112   fHisto->Add1D("14", "Energy (MeV) of gammas" <<  90   nBinsE = 100;
113   fHisto->Add1D("15", "Energy (MeV) in abs1",  <<  91   nBinsEA= 40;
114   fHisto->Add1D("16", "Energy (MeV) in abs2",  <<  92   nBinsED= 100;
115   fHisto->Add1D("17", "Energy (MeV) in abs3",  <<  93   nTuple = false;
116   fHisto->Add1D("18", "Energy (MeV) in abs4",  <<  94   nHisto = 13;
117   fHisto->Add1D("19", "Number of vertex hits", <<  95 
118   fHisto->Add1D("20", "E1/E9 Ratio", fBinsED,  <<  96   // initialise acceptance
119   fHisto->Add1D("21", "E1/E25 Ratio", fBinsED, <<  97   for(G4int i=0; i<nmax; i++) {
120   fHisto->Add1D("22", "E9/E25 Ratio", fBinsED, <<  98     edeptrue[i] = 1.0;
                                                   >>  99     rmstrue[i]  = 1.0;
                                                   >> 100     limittrue[i]= DBL_MAX;
                                                   >> 101   }
                                                   >> 102 
                                                   >> 103   histo->add1D("10",
                                                   >> 104     "Evis/E0 in central crystal",nBinsED,0.0,1,1.0);
                                                   >> 105 
                                                   >> 106   histo->add1D("11",
                                                   >> 107     "Evis/E0 in 3x3",nBinsED,0.0,1.0,1.0);
                                                   >> 108 
                                                   >> 109   histo->add1D("12",
                                                   >> 110     "Evis/E0 in 5x5",nBinsED,0.0,1.0,1.0);
                                                   >> 111 
                                                   >> 112   histo->add1D("13",
                                                   >> 113     "Energy (MeV) of delta-electrons",nBinsE,0.0,maxEnergy,MeV);
                                                   >> 114 
                                                   >> 115   histo->add1D("14",
                                                   >> 116     "Energy (MeV) of gammas",nBinsE,0.0,maxEnergy,MeV);
                                                   >> 117 
                                                   >> 118   histo->add1D("15",
                                                   >> 119     "Energy (MeV) in abs1",nBinsEA,0.0,maxEnergyAbs,MeV);
                                                   >> 120 
                                                   >> 121   histo->add1D("16",
                                                   >> 122     "Energy (MeV) in abs2",nBinsEA,0.0,maxEnergyAbs,MeV);
                                                   >> 123 
                                                   >> 124   histo->add1D("17",
                                                   >> 125     "Energy (MeV) in abs3",nBinsEA,0.0,maxEnergyAbs,MeV);
                                                   >> 126 
                                                   >> 127   histo->add1D("18",
                                                   >> 128     "Energy (MeV) in abs4",nBinsEA,0.0,maxEnergyAbs,MeV);
                                                   >> 129 
                                                   >> 130   histo->add1D("19",
                                                   >> 131     "Number of vertex hits",20,-0.5,19.5,1.0);
                                                   >> 132 
                                                   >> 133   histo->add1D("20",
                                                   >> 134     "E1/E9 Ratio",nBinsED,0.0,1,1.0);
                                                   >> 135 
                                                   >> 136   histo->add1D("21",
                                                   >> 137     "E1/25 Ratio",nBinsED,0.0,1.0,1.0);
                                                   >> 138 
                                                   >> 139   histo->add1D("22",
                                                   >> 140     "E9/E25 Ratio",nBinsED,0.0,1.0,1.0);
                                                   >> 141 
                                                   >> 142   if(nTuple) {
                                                   >> 143     histo->addTuple( "100", "Dose deposite","float r, z, e" );
                                                   >> 144   }
121 }                                                 145 }
122                                                   146 
123 //....oooOO0OOooo........oooOO0OOooo........oo    147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
124                                                   148 
125 void HistoManager::BeginOfRun()                   149 void HistoManager::BeginOfRun()
126 {                                                 150 {
127   // initilise scoring                            151   // initilise scoring
128   fEvt = 0;                                    << 152   n_evt  = 0;
129   fElec = 0;                                   << 153   n_elec = 0;
130   fPosit = 0;                                  << 154   n_posit= 0;
131   fGam = 0;                                    << 155   n_gam  = 0;
132   fStep = 0;                                   << 156   n_step = 0;
133   fLowe = 0;                                   << 157   n_lowe = 0;
134                                                << 158 
135   for (G4int i = 0; i < 6; i++) {              << 159   for(G4int i=0; i<6; i++) {
136     fStat[i] = 0;                              << 160     stat[i] = 0;
137     fEdep[i] = 0.0;                            << 161     edep[i] = 0.0;
138     fErms[i] = 0.0;                            << 162     erms[i] = 0.0;
139     if (i < 3) {                               << 163     if(i < 3) {
140       fEdeptr[i] = 0.0;                        << 164       edeptr[i] = 0.0;
141       fErmstr[i] = 0.0;                        << 165       ermstr[i] = 0.0;
142     }                                             166     }
143   }                                               167   }
144                                                   168 
145   // initialise counters                       << 169   histo->book();
146   fBrem.resize(93, 0.0);                       << 
147   fPhot.resize(93, 0.0);                       << 
148   fComp.resize(93, 0.0);                       << 
149   fConv.resize(93, 0.0);                       << 
150                                                << 
151   // initialise acceptance - by default is not << 
152   for (G4int i = 0; i < fNmax; i++) {          << 
153     fEdeptrue[i] = 1.0;                        << 
154     fRmstrue[i] = 1.0;                         << 
155     fLimittrue[i] = 10.;                       << 
156   }                                            << 
157                                                << 
158   if (fHisto->IsActive()) {                    << 
159     for (G4int i = 0; i < fNHisto; ++i) {      << 
160       fHisto->Activate(i, true);               << 
161     }                                          << 
162     fHisto->Book();                            << 
163                                                   170 
164     if (fVerbose > 0) {                        << 171   brem.resize(93,0.0);
165       G4cout << "HistoManager: Histograms are  << 172   phot.resize(93,0.0);
166     }                                          << 173   comp.resize(93,0.0);
                                                   >> 174   conv.resize(93,0.0);
                                                   >> 175 
                                                   >> 176   if(verbose > 0) {
                                                   >> 177     G4cout << "HistoManager: Histograms are booked and run has been started"
                                                   >> 178            << G4endl;
167   }                                               179   }
168 }                                                 180 }
169                                                   181 
170 //....oooOO0OOooo........oooOO0OOooo........oo    182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
171                                                   183 
172 void HistoManager::EndOfRun(G4int runID)       << 184 void HistoManager::EndOfRun()
173 {                                                 185 {
174   G4cout << "HistoManager: End of run actions  << 186 
                                                   >> 187   G4cout << "HistoManager: End of run actions are started" << G4endl;
175   G4String nam[6] = {"1x1", "3x3", "5x5", "E1/    188   G4String nam[6] = {"1x1", "3x3", "5x5", "E1/E9 ", "E1/E25", "E9/E25"};
176                                                   189 
177   // average                                      190   // average
178                                                   191 
179   G4cout << "================================= << 192   G4cout<<"================================================================="<<G4endl;
180   G4double x = (G4double)fEvt;                 << 193   G4double x = (G4double)n_evt;
181   if (fEvt > 0) x = 1.0 / x;                   << 194   if(n_evt > 0) x = 1.0/x;
182   G4int j;                                        195   G4int j;
183   for (j = 0; j < fNmax; j++) {                << 196   for(j=0; j<nmax; j++) {
                                                   >> 197 
184     // total mean                                 198     // total mean
185     fEdep[j] *= x;                             << 199     edep[j] *= x;
186     G4double y = fErms[j] * x - fEdep[j] * fEd << 200     G4double y = erms[j]*x - edep[j]*edep[j];
187     if (y < 0.0) y = 0.0;                      << 201     if(y < 0.0) y = 0.0;
188     fErms[j] = std::sqrt(y);                   << 202     erms[j] = std::sqrt(y);
189                                                   203 
190     // trancated mean                             204     // trancated mean
191     G4double xx = G4double(fStat[j]);          << 205     G4double xx = G4double(stat[j]);
192     if (xx > 0.0) xx = 1.0 / xx;               << 206     if(xx > 0.0) xx = 1.0/xx;
193     fEdeptr[j] *= xx;                          << 207     edeptr[j] *= xx;
194     y = fErmstr[j] * xx - fEdeptr[j] * fEdeptr << 208     y = ermstr[j]*xx - edeptr[j]*edeptr[j];
195     if (y < 0.0) y = 0.0;                      << 209     if(y < 0.0) y = 0.0;
196     fErmstr[j] = std::sqrt(y);                 << 210     ermstr[j] = std::sqrt(y);
197   }                                            << 211   }
198   G4double xe = x * (G4double)fElec;           << 212   G4double xe = x*(G4double)n_elec;
199   G4double xg = x * (G4double)fGam;            << 213   G4double xg = x*(G4double)n_gam;
200   G4double xp = x * (G4double)fPosit;          << 214   G4double xp = x*(G4double)n_posit;
201   G4double xs = x * fStep;                     << 215   G4double xs = x*n_step;
202                                                   216 
203   G4double f = 100. * std::sqrt(fBeamEnergy /  << 217   G4double f = 100.*std::sqrt(beamEnergy/GeV);
204                                                   218 
205   G4cout << "Number of events             " << << 219   G4cout                         << "Number of events             " << n_evt <<G4endl;
206   G4cout << std::setprecision(4) << "Average n    220   G4cout << std::setprecision(4) << "Average number of e-         " << xe << G4endl;
207   G4cout << std::setprecision(4) << "Average n    221   G4cout << std::setprecision(4) << "Average number of gamma      " << xg << G4endl;
208   G4cout << std::setprecision(4) << "Average n    222   G4cout << std::setprecision(4) << "Average number of e+         " << xp << G4endl;
209   G4cout << std::setprecision(4) << "Average n    223   G4cout << std::setprecision(4) << "Average number of steps      " << xs << G4endl;
210                                                << 224   
211   for (j = 0; j < 3; ++j) {                    << 225   for(j=0; j<3; j++) {
212     G4double ex = fEdeptr[j];                  << 226     G4double e = edeptr[j];
213     G4double sx = fErmstr[j];                  << 227     G4double s = ermstr[j];
214     G4double xx = G4double(fStat[j]);          << 228     G4double xx= G4double(stat[j]);
215     if (xx > 0.0) xx = 1.0 / xx;               << 229     if(xx > 0.0) xx = 1.0/xx;
216     G4double r = sx * std::sqrt(xx);           << 230     G4double r = s*std::sqrt(xx);
217     G4cout << std::setprecision(4) << "Edep "  << 231     G4cout << std::setprecision(4) << "Edep " << nam[j] << " =                   " << e
218            << r;                               << 232            << " +- " << r;
219     if (ex > 0.1) G4cout << "  res=  " << f *  << 233     if(e > 0.0) G4cout << "  res=  " << f*s/e << " %";
220     G4cout << G4endl;                             234     G4cout << G4endl;
221   }                                               235   }
222   if (fLimittrue[0] < 10. || fLimittrue[1] < 1 << 236   if(limittrue[0] != DBL_MAX || limittrue[1] != DBL_MAX || limittrue[2] != DBL_MAX) {
223     G4cout << "===========  Mean values withou << 237     G4cout<<"===========  Mean values without trancating ====================="<<G4endl;
224     for (j = 0; j < fNmax; j++) {              << 238     for(j=0; j<nmax; j++) {
225       G4double ex = fEdep[j];                  << 239       G4double e = edep[j];
226       G4double sx = fErms[j];                  << 240       G4double s = erms[j];
227       G4double rx = sx * std::sqrt(x);         << 241       G4double r = s*std::sqrt(x);
228       G4cout << std::setprecision(4) << "Edep  << 242       G4cout << std::setprecision(4) << "Edep " << nam[j] << " =                   " << e
229              << rx;                            << 243        << " +- " << r;
230       if (ex > 0.0) G4cout << "  res=  " << f  << 244       if(e > 0.0) G4cout << "  res=  " << f*s/e << " %";
231       G4cout << G4endl;                           245       G4cout << G4endl;
232     }                                             246     }
233   }                                               247   }
234   G4cout << "===========  Ratios without tranc << 248   G4cout<<"===========  Ratios without trancating ==========================="<<G4endl;
235   for (j = 3; j < 6; ++j) {                    << 249   for(j=3; j<6; j++) {
236     G4double e = fEdep[j];                     << 250     G4double e = edep[j];
237     G4double xx = G4double(fStat[j]);          << 251     G4double xx= G4double(stat[j]);
238     if (xx > 0.0) xx = 1.0 / xx;               << 252     if(xx > 0.0) xx = 1.0/xx;
239     e *= xx;                                      253     e *= xx;
240     G4double y = fErms[j] * xx - e * e;        << 254     G4double y = erms[j]*xx - e*e;
241     G4double r = 0.0;                             255     G4double r = 0.0;
242     if (y > 0.0) r = std::sqrt(y * xx);        << 256     if(y > 0.0) r = std::sqrt(y*xx);
243     G4cout << "  " << nam[j] << " =            << 257     G4cout << "  " << nam[j] << " =                   " << e
                                                   >> 258            << " +- " << r;
244     G4cout << G4endl;                             259     G4cout << G4endl;
245   }                                               260   }
246   G4cout << std::setprecision(4) << "Beam Ener << 261   G4cout << std::setprecision(4) << "Beam Energy                  " << beamEnergy/GeV 
247          << G4endl;                            << 262    << " GeV" << G4endl;
248   if (fLowe > 0) G4cout << "Number of events E << 263   if(n_lowe > 0)          G4cout << "Number of events E/E0<0.8    " << n_lowe << G4endl; 
249   G4cout << "================================= << 264   G4cout<<"=================================================================="<<G4endl;
250   G4cout << G4endl;                            << 265   G4cout<<G4endl;
251                                                   266 
252   // normalise histograms                         267   // normalise histograms
253   if (fHisto->IsActive()) {                    << 268   for(G4int i=0; i<nHisto; i++) {
254     for (G4int i = 0; i < fNHisto; ++i) {      << 269     histo->scale(i,x);
255       fHisto->ScaleH1(i, x);                   << 
256     }                                          << 
257     fHisto->Save();                            << 
258   }                                            << 
259   if (0 < runID) {                             << 
260     return;                                    << 
261   }                                               270   }
262                                                   271 
263   // Acceptance only for the first run         << 272   histo->save();
                                                   >> 273 
                                                   >> 274   // Acceptance
264   EmAcceptance acc;                               275   EmAcceptance acc;
265   G4bool isStarted = false;                       276   G4bool isStarted = false;
266   for (j = 0; j < fNmax; j++) {                << 277   for (j=0; j<nmax; j++) {
267     G4double ltrue = fLimittrue[j];            << 278 
                                                   >> 279     G4double ltrue = limittrue[j];
268     if (ltrue < DBL_MAX) {                        280     if (ltrue < DBL_MAX) {
269       if (!isStarted) {                           281       if (!isStarted) {
270         acc.BeginOfAcceptance("Crystal Calorim << 282         acc.BeginOfAcceptance("Crystal Calorimeter",n_evt);
271         isStarted = true;                         283         isStarted = true;
272       }                                           284       }
273       G4double etrue = fEdeptrue[j];           << 285       G4double etrue = edeptrue[j];
274       G4double rtrue = fRmstrue[j];            << 286       G4double rtrue = rmstrue[j];
275       acc.EmAcceptanceGauss("Edep" + nam[j], f << 287       acc.EmAcceptanceGauss("Edep"+nam[j],n_evt,edeptr[j],etrue,rtrue,ltrue);
276       acc.EmAcceptanceGauss("Erms" + nam[j], f << 288       acc.EmAcceptanceGauss("Erms"+nam[j],n_evt,ermstr[j],rtrue,rtrue,2.0*ltrue);
277     }                                             289     }
278   }                                               290   }
279   if (isStarted) acc.EndOfAcceptance();        << 291   if(isStarted) acc.EndOfAcceptance();
280                                                   292 
281   // atom frequency                               293   // atom frequency
282   G4cout << "   Z  bremsstrahlung photoeffect     294   G4cout << "   Z  bremsstrahlung photoeffect  compton    conversion" << G4endl;
283   for (j = 1; j < 93; ++j) {                   << 295   for(j=1; j<93; ++j) {
284     G4int n1 = G4int(fBrem[j] * x);            << 296     G4int n1 = G4int(brem[j]*x);
285     G4int n2 = G4int(fPhot[j] * x);            << 297     G4int n2 = G4int(phot[j]*x);
286     G4int n3 = G4int(fComp[j] * x);            << 298     G4int n3 = G4int(comp[j]*x);
287     G4int n4 = G4int(fConv[j] * x);            << 299     G4int n4 = G4int(conv[j]*x);
288     if (n1 + n2 + n3 + n4 > 0) {               << 300     if(n1 + n2 + n3 + n4 > 0) {
289       G4cout << std::setw(4) << j << std::setw << 301       G4cout << std::setw(4) << j << std::setw(12) << n1 << std::setw(12) << n2
290              << n3 << std::setw(12) << n4 << G << 302        << std::setw(12) << n3 << std::setw(12) << n4 << G4endl;
291     }                                             303     }
292   }                                               304   }
293 }                                                 305 }
294                                                   306 
295 //....oooOO0OOooo........oooOO0OOooo........oo    307 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
296                                                   308 
297 void HistoManager::BeginOfEvent()                 309 void HistoManager::BeginOfEvent()
298 {                                                 310 {
299   ++fEvt;                                      << 311   n_evt++;
300                                                   312 
301   fEabs1 = 0.0;                                << 313   Eabs1  = 0.0;
302   fEabs2 = 0.0;                                << 314   Eabs2  = 0.0;
303   fEabs3 = 0.0;                                << 315   Eabs3  = 0.0;
304   fEabs4 = 0.0;                                << 316   Eabs4  = 0.0;
305   fEvertex.clear();                            << 317   Evertex.clear();
306   fNvertex.clear();                            << 318   Nvertex.clear();
307   for (G4int i = 0; i < 25; i++) {             << 319   for (G4int i=0; i<25; i++) {
308     fE[i] = 0.0;                               << 320     E[i] = 0.0;
309   }                                               321   }
310 }                                                 322 }
311                                                   323 
312 //....oooOO0OOooo........oooOO0OOooo........oo    324 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
313                                                   325 
314 void HistoManager::EndOfEvent()                   326 void HistoManager::EndOfEvent()
315 {                                                 327 {
316   G4double e9 = 0.0;                              328   G4double e9 = 0.0;
317   G4double e25 = 0.0;                          << 329   G4double e25= 0.0;
318   for (G4int i = 0; i < 25; i++) {             << 330   for (G4int i=0; i<25; i++) {
319     fE[i] /= fBeamEnergy;                      << 331     E[i] /= beamEnergy;
320     e25 += fE[i];                              << 332     e25 += E[i];
321     if ((6 <= i && 8 >= i) || (11 <= i && 13 > << 333     if( ( 6<=i &&  8>=i) || (11<=i && 13>=i) || (16<=i && 18>=i)) e9 += E[i];
322   }                                               334   }
323                                                   335 
324   if (1 < fVerbose && e25 < 0.8) {             << 336   if(e25 < 0.8) {
325     ++fLowe;                                   << 337     n_lowe++;
326     G4cout << "### in the event# " << fEvt <<  << 338     G4cout << "### in the event# " << n_evt << "  E25= " << e25 << G4endl;
327   }                                               339   }
328                                                   340 
329   // compute ratios                               341   // compute ratios
330   G4double e0 = fE[12];                        << 342   G4double e0 = E[12];
331   G4double e19 = 0.0;                          << 343   G4double e19  = 0.0;
332   G4double e125 = 0.0;                            344   G4double e125 = 0.0;
333   G4double e925 = 0.0;                            345   G4double e925 = 0.0;
334   if (e9 > 0.0) {                              << 346   if(e9 > 0.0) {
335     e19 = e0 / e9;                             << 347     e19 = e0/e9;
336     e125 = e0 / e25;                           << 348     e125 = e0/e25;
337     e925 = e9 / e25;                           << 349     e925 = e9/e25;
338     fEdep[3] += e19;                           << 350     edep[3] += e19;
339     fErms[3] += e19 * e19;                     << 351     erms[3] += e19*e19;
340     fEdep[4] += e125;                          << 352     edep[4] += e125;
341     fErms[4] += e125 * e125;                   << 353     erms[4] += e125*e125;
342     fEdep[5] += e925;                          << 354     edep[5] += e925;
343     fErms[5] += e925 * e925;                   << 355     erms[5] += e925*e925;
344     fStat[3] += 1;                             << 356     stat[3] += 1;
345     fStat[4] += 1;                             << 357     stat[4] += 1;
346     fStat[5] += 1;                             << 358     stat[5] += 1;
347   }                                            << 359   }
348                                                << 360 
349   // Fill histo                                << 361   // fill histo
350   fHisto->Fill(0, e0, 1.0);                    << 362   histo->fill(0,e0,1.0);
351   fHisto->Fill(1, e9, 1.0);                    << 363   histo->fill(1,e9,1.0);
352   fHisto->Fill(2, e25, 1.0);                   << 364   histo->fill(2,e25,1.0);
353   fHisto->Fill(5, fEabs1, 1.0);                << 365   histo->fill(5,Eabs1,1.0);
354   fHisto->Fill(6, fEabs2, 1.0);                << 366   histo->fill(6,Eabs2,1.0);
355   fHisto->Fill(7, fEabs3, 1.0);                << 367   histo->fill(7,Eabs3,1.0);
356   fHisto->Fill(8, fEabs4, 1.0);                << 368   histo->fill(8,Eabs4,1.0);
357   fHisto->Fill(9, G4double(fNvertex.size()), 1 << 369   histo->fill(9,G4double(Nvertex.size()),1.0);
358   fHisto->Fill(10, e19, 1.0);                  << 370   histo->fill(10,e19,1.0);
359   fHisto->Fill(11, e125, 1.0);                 << 371   histo->fill(11,e125,1.0);
360   fHisto->Fill(12, e925, 1.0);                 << 372   histo->fill(12,e925,1.0);
361                                                   373 
362   // compute sums                                 374   // compute sums
363   fEdep[0] += e0;                              << 375   edep[0] += e0;
364   fErms[0] += e0 * e0;                         << 376   erms[0] += e0*e0;
365   fEdep[1] += e9;                              << 377   edep[1] += e9;
366   fErms[1] += e9 * e9;                         << 378   erms[1] += e9*e9;
367   fEdep[2] += e25;                             << 379   edep[2] += e25;
368   fErms[2] += e25 * e25;                       << 380   erms[2] += e25*e25;
369                                                   381 
370   // trancated mean                               382   // trancated mean
371   if (std::abs(e0 - fEdeptrue[0]) < fRmstrue[0 << 383   if(limittrue[0] == DBL_MAX || std::abs(e0-edeptrue[0])<rmstrue[0]*limittrue[0]) {
372     fStat[0] += 1;                             << 384     stat[0] += 1;
373     fEdeptr[0] += e0;                          << 385     edeptr[0] += e0;
374     fErmstr[0] += e0 * e0;                     << 386     ermstr[0] += e0*e0;
375   }                                            << 387   }
376   if (std::abs(e9 - fEdeptrue[1]) < fRmstrue[1 << 388   if(limittrue[1] == DBL_MAX || std::abs(e9-edeptrue[1])<rmstrue[1]*limittrue[1]) {
377     fStat[1] += 1;                             << 389     stat[1] += 1;
378     fEdeptr[1] += e9;                          << 390     edeptr[1] += e9;
379     fErmstr[1] += e9 * e9;                     << 391     ermstr[1] += e9*e9;
380   }                                            << 392   }
381   if (std::abs(e25 - fEdeptrue[2]) < fRmstrue[ << 393   if(limittrue[2] == DBL_MAX || std::abs(e25-edeptrue[2])<rmstrue[2]*limittrue[2]) {
382     fStat[2] += 1;                             << 394     stat[2] += 1;
383     fEdeptr[2] += e25;                         << 395     edeptr[2] += e25;
384     fErmstr[2] += e25 * e25;                   << 396     ermstr[2] += e25*e25;
385   }                                               397   }
                                                   >> 398   if(nTuple) histo->addRow();
                                                   >> 399 
386 }                                                 400 }
387                                                   401 
388 //....oooOO0OOooo........oooOO0OOooo........oo    402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
389                                                   403 
390 void HistoManager::ScoreNewTrack(const G4Track    404 void HistoManager::ScoreNewTrack(const G4Track* aTrack)
391 {                                                 405 {
392   // Save primary parameters                   << 406   //Save primary parameters
393   ResetTrackLength();                             407   ResetTrackLength();
394   const G4ParticleDefinition* particle = aTrac    408   const G4ParticleDefinition* particle = aTrack->GetDefinition();
395   const G4DynamicParticle* dynParticle = aTrac    409   const G4DynamicParticle* dynParticle = aTrack->GetDynamicParticle();
396                                                << 410   G4String name = particle->GetParticleName();
397   G4int pid = aTrack->GetParentID();              411   G4int pid = aTrack->GetParentID();
398   G4double kinE = dynParticle->GetKineticEnerg    412   G4double kinE = dynParticle->GetKineticEnergy();
399   G4ThreeVector pos = aTrack->GetVertexPositio    413   G4ThreeVector pos = aTrack->GetVertexPosition();
400                                                   414 
401   // primary                                      415   // primary
402   if (0 == pid) {                              << 416   if(0 == pid) {
                                                   >> 417 
                                                   >> 418     beamEnergy = kinE;
                                                   >> 419     histo->fillTuple("TKIN", kinE/MeV);
                                                   >> 420 
403     G4double mass = 0.0;                          421     G4double mass = 0.0;
404     if (particle) {                            << 422     if(particle) {
405       mass = particle->GetPDGMass();              423       mass = particle->GetPDGMass();
                                                   >> 424       histo->fillTuple("MASS", mass/MeV);
                                                   >> 425       histo->fillTuple("CHAR",(particle->GetPDGCharge())/eplus);
                                                   >> 426       G4double beta = 1.;
                                                   >> 427   if(mass > 0.) {
                                                   >> 428           G4double gamma = kinE/mass + 1.;
                                                   >> 429           beta = std::sqrt(1. - 1./(gamma*gamma));
                                                   >> 430   }
406     }                                             431     }
407                                                   432 
408     G4ThreeVector dir = dynParticle->GetMoment    433     G4ThreeVector dir = dynParticle->GetMomentumDirection();
409     if (1 < fVerbose) {                        << 434     if(1 < verbose) {
410       G4cout << "TrackingAction: Primary kinE( << 435       G4cout << "TrackingAction: Primary kinE(MeV)= " << kinE/MeV
411              << "; pos= " << pos << ";  dir= " << 436            << "; m(MeV)= " << mass/MeV
                                                   >> 437            << "; pos= " << pos << ";  dir= " << dir << G4endl;
412     }                                             438     }
413                                                   439 
414     // secondary                                  440     // secondary
415   }                                            << 441   } else {
416   else {                                       << 
417     const G4VProcess* proc = aTrack->GetCreato    442     const G4VProcess* proc = aTrack->GetCreatorProcess();
418     G4int type = proc->GetProcessSubType();       443     G4int type = proc->GetProcessSubType();
419                                                << 444     if(type == fBremsstrahlung) {
420     if (type == fBremsstrahlung) {             << 445       const G4Element* elm = static_cast<const G4VEnergyLossProcess*>(proc)->GetCurrentElement();
421       auto elm = static_cast<const G4VEnergyLo << 446       if(elm) {
422       if (nullptr != elm) {                    << 447   G4int Z = G4int(elm->GetZ());
423         G4int Z = elm->GetZasInt();            << 448         if(Z > 0 && Z < 93) { brem[Z] += 1.0; }
424         if (Z > 0 && Z < 93) {                 << 
425           fBrem[Z] += 1.0;                     << 
426         }                                      << 
427       }                                           449       }
428     }                                          << 450     } else if(type == fPhotoElectricEffect) {
429     else if (type == fPhotoElectricEffect) {   << 451       const G4Element* elm = static_cast<const G4VEmProcess*>(proc)->GetCurrentElement();
430       auto elm = static_cast<const G4VEmProces << 452       if(elm) {
431       if (nullptr != elm) {                    << 453   G4int Z = G4int(elm->GetZ());
432         G4int Z = elm->GetZasInt();            << 454         if(Z > 0 && Z < 93) { phot[Z] += 1.0; }
433         if (Z > 0 && Z < 93) {                 << 
434           fPhot[Z] += 1.0;                     << 
435         }                                      << 
436       }                                           455       }
437     }                                          << 456     } else if(type == fGammaConversion) {
438     else if (type == fGammaConversion) {       << 457       const G4Element* elm = static_cast<const G4VEmProcess*>(proc)->GetCurrentElement();
439       auto elm = static_cast<const G4VEmProces << 458       if(elm) {
440       if (nullptr != elm) {                    << 459   G4int Z = G4int(elm->GetZ());
441         G4int Z = elm->GetZasInt();            << 460         if(Z > 0 && Z < 93) { conv[Z] += 1.0; }
442         if (Z > 0 && Z < 93) {                 << 
443           fConv[Z] += 1.0;                     << 
444         }                                      << 
445       }                                           461       }
446     }                                          << 462     } else if(type == fComptonScattering) {
447     else if (type == fComptonScattering) {     << 463       const G4Element* elm = static_cast<const G4VEmProcess*>(proc)->GetCurrentElement();
448       auto elm = static_cast<const G4VEmProces << 464       if(elm) {
449       if (nullptr != elm) {                    << 465   G4int Z = G4int(elm->GetZ());
450         G4int Z = elm->GetZasInt();            << 466         if(Z > 0 && Z < 93) { comp[Z] += 1.0; }
451         if (Z > 0 && Z < 93) {                 << 
452           fComp[Z] += 1.0;                     << 
453         }                                      << 
454       }                                           467       }
455     }                                             468     }
456                                                   469 
457     // delta-electron                             470     // delta-electron
458     if (particle == fElectron) {               << 471     if (0 < pid && "e-" == name) {
459       if (1 < fVerbose) {                      << 472       if(1 < verbose) {
460         G4cout << "TrackingAction: Secondary e << 473   G4cout << "TrackingAction: Secondary electron " << G4endl;
461       }                                           474       }
462       AddDeltaElectron(dynParticle);              475       AddDeltaElectron(dynParticle);
463     }                                          << 476 
464     else if (particle == fPositron) {          << 477     } else if (0 < pid && "e+" == name) {
465       if (1 < fVerbose) {                      << 478       if(1 < verbose) {
466         G4cout << "TrackingAction: Secondary p << 479   G4cout << "TrackingAction: Secondary positron " << G4endl;
467       }                                           480       }
468       AddPositron(dynParticle);                   481       AddPositron(dynParticle);
469     }                                          << 482 
470     else if (particle == fGamma) {             << 483     } else if (0 < pid && "gamma" == name) {
471       if (1 < fVerbose) {                      << 484       if(1 < verbose) {
472         G4cout << "TrackingAction: Secondary g << 485   G4cout << "TrackingAction: Secondary gamma; parentID= " << pid
                                                   >> 486          << " E= " << kinE << G4endl;
473       }                                           487       }
474       AddPhoton(dynParticle);                     488       AddPhoton(dynParticle);
475     }                                             489     }
476   }                                               490   }
477 }                                                 491 }
478                                                   492 
479 //....oooOO0OOooo........oooOO0OOooo........oo    493 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
480                                                   494 
481 void HistoManager::AddEnergy(G4double edep, G4    495 void HistoManager::AddEnergy(G4double edep, G4int volIndex, G4int copyNo)
482 {                                                 496 {
483   if (1 < fVerbose) {                          << 497   if(1 < verbose) {
484     G4cout << "HistoManager::AddEnergy: e(keV) << 498     G4cout << "HistoManager::AddEnergy: e(keV)= " << edep/keV
485            << "; copyNo= " << copyNo << G4endl << 499            << "; volIdx= " << volIndex
486   }                                            << 500            << "; copyNo= " << copyNo
487   if (0 == volIndex) {                         << 501            << G4endl;
488     fE[copyNo] += edep;                        << 502   }
489   }                                            << 503   if(0 == volIndex) {
490   else if (1 == volIndex) {                    << 504     E[copyNo] += edep;
491     fEabs1 += edep;                            << 505   } else if (1 == volIndex) {
492   }                                            << 506     Eabs1 += edep;
493   else if (2 == volIndex) {                    << 507   } else if (2 == volIndex) {
494     fEabs2 += edep;                            << 508     Eabs2 += edep;
495   }                                            << 509   } else if (3 == volIndex) {
496   else if (3 == volIndex) {                    << 510     Eabs3 += edep;
497     fEabs3 += edep;                            << 511   } else if (4 == volIndex) {
498   }                                            << 512     Eabs4 += edep;
499   else if (4 == volIndex) {                    << 513   } else if (5 == volIndex) {
500     fEabs4 += edep;                            << 514     G4int n = Nvertex.size();
501   }                                            << 
502   else if (5 == volIndex) {                    << 
503     G4int n = fNvertex.size();                 << 
504     G4bool newPad = true;                         515     G4bool newPad = true;
505     if (n > 0) {                                  516     if (n > 0) {
506       for (G4int i = 0; i < n; i++) {          << 517       for(G4int i=0; i<n; i++) {
507         if (copyNo == fNvertex[i]) {           << 518         if (copyNo == Nvertex[i]) {
508           newPad = false;                         519           newPad = false;
509           fEvertex[i] += edep;                 << 520           Evertex[i] += edep;
510           break;                                  521           break;
511         }                                         522         }
512       }                                           523       }
513     }                                             524     }
514     if (newPad) {                              << 525     if(newPad) {
515       fNvertex.push_back(copyNo);              << 526       Nvertex.push_back(copyNo);
516       fEvertex.push_back(edep);                << 527       Evertex.push_back(edep);
517     }                                             528     }
518   }                                               529   }
519 }                                                 530 }
520                                                   531 
521 //....oooOO0OOooo........oooOO0OOooo........oo    532 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
522                                                   533 
523 void HistoManager::AddDeltaElectron(const G4Dy    534 void HistoManager::AddDeltaElectron(const G4DynamicParticle* elec)
524 {                                                 535 {
525   G4double e = elec->GetKineticEnergy() / MeV; << 536   G4double e = elec->GetKineticEnergy()/MeV;
526   if (e > 0.0) {                               << 537   if(e > 0.0) n_elec++;
527     ++fElec;                                   << 538   histo->fill(3,e,1.0);
528     fHisto->Fill(3, e, 1.0);                   << 
529   }                                            << 
530 }                                                 539 }
531                                                   540 
532 //....oooOO0OOooo........oooOO0OOooo........oo    541 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
533                                                   542 
534 void HistoManager::AddPhoton(const G4DynamicPa    543 void HistoManager::AddPhoton(const G4DynamicParticle* ph)
535 {                                                 544 {
536   G4double e = ph->GetKineticEnergy() / MeV;   << 545   G4double e = ph->GetKineticEnergy()/MeV;
537   if (e > 0.0) {                               << 546   if(e > 0.0) n_gam++;
538     ++fGam;                                    << 547   histo->fill(4,e,1.0);
539     fHisto->Fill(4, e, 1.0);                   << 
540   }                                            << 
541 }                                                 548 }
542                                                   549 
543 //....oooOO0OOooo........oooOO0OOooo........oo    550 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
544                                                   551 
545 void HistoManager::SetEdepAndRMS(G4int i, cons << 552 void HistoManager::SetEdepAndRMS(G4int i, G4ThreeVector val)
546 {                                                 553 {
547   if (i < fNmax && i >= 0) {                   << 554   if(i<nmax && i>=0) {
548     if (val[0] > 0.0) fEdeptrue[i] = val[0];   << 555     if(val[0] > 0.0) edeptrue[i] = val[0];
549     if (val[1] > 0.0) fRmstrue[i] = val[1];    << 556     if(val[1] > 0.0) rmstrue[i] = val[1];
550     if (val[2] > 0.0) fLimittrue[i] = val[2];  << 557     if(val[2] > 0.0) limittrue[i] = val[2];
551   }                                               558   }
552 }                                                 559 }
553                                                   560 
554 //....oooOO0OOooo........oooOO0OOooo........oo    561 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 562 
555                                                   563