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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/TestEm8/src/Run.cc (Version 11.3.0) and /examples/extended/electromagnetic/TestEm8/src/Run.cc (Version 10.6.p3)


  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/TestEm8/src/Run.cc       26 /// \file electromagnetic/TestEm8/src/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 "TestParameters.hh"                   << 
 36                                                << 
 37 #include "G4ElectronIonPair.hh"                << 
 38 #include "G4LossTableManager.hh"               << 
 39 #include "G4PhysicalConstants.hh"              << 
 40 #include "G4Run.hh"                            << 
 41 #include "G4Step.hh"                               34 #include "G4Step.hh"
                                                   >>  35 #include "G4Run.hh"
                                                   >>  36 #include "G4LossTableManager.hh"
                                                   >>  37 #include "G4ElectronIonPair.hh"
 42 #include "G4SystemOfUnits.hh"                      38 #include "G4SystemOfUnits.hh"
                                                   >>  39 #include "G4PhysicalConstants.hh"
                                                   >>  40 #include "TestParameters.hh"
 43 #include "Randomize.hh"                            41 #include "Randomize.hh"
 44                                                    42 
 45 //....oooOO0OOooo........oooOO0OOooo........oo     43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 46                                                    44 
 47 Run::Run() : G4Run(), fElIonPair(0), fParam(Te <<  45 Run::Run()
                                                   >>  46  : G4Run(), fElIonPair(0), fParam(TestParameters::GetPointer())
 48 {                                                  47 {
 49   fElIonPair = G4LossTableManager::Instance()-     48   fElIonPair = G4LossTableManager::Instance()->ElectronIonPair();
                                                   >>  49   fTotStepGas = fTotCluster = fMeanCluster = fOverflow = fTotEdep 
                                                   >>  50     = fStepGas = fCluster = fMaxEnergy = 0.0; 
                                                   >>  51   fEvt = fNbins = 0;
                                                   >>  52   fFactorALICE = fParam->GetFactorALICE();
                                                   >>  53   fWidthALICE = fParam->GetEnergySmear();
 50 }                                                  54 }
 51                                                    55 
 52 //....oooOO0OOooo........oooOO0OOooo........oo     56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 53                                                    57 
                                                   >>  58 Run::~Run()
                                                   >>  59 {}
                                                   >>  60 
                                                   >>  61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >>  62 
 54 void Run::BeginOfRun()                             63 void Run::BeginOfRun()
 55 {                                                  64 {
 56   // initilise scoring                             65   // initilise scoring
 57   fTotStepGas = fTotCluster = fMeanCluster = f <<  66   fTotStepGas = fTotCluster = fMeanCluster = fOverflow = fTotEdep 
                                                   >>  67     = fStepGas = fCluster = 0.0; 
 58   fEvt = 0;                                        68   fEvt = 0;
 59                                                    69 
 60   fFactorALICE = fParam->GetFactorALICE();         70   fFactorALICE = fParam->GetFactorALICE();
 61   fWidthALICE = fParam->GetEnergySmear();          71   fWidthALICE = fParam->GetEnergySmear();
 62                                                <<  72  
 63   SetVerbose(1);                                   73   SetVerbose(1);
 64                                                    74 
 65   fNbins = fParam->GetNumberBins();                75   fNbins = fParam->GetNumberBins();
 66   fMaxEnergy = fParam->GetMaxEnergy();             76   fMaxEnergy = fParam->GetMaxEnergy();
 67                                                <<  77   
 68   fEgas.resize(fNbins, 0.0);                   <<  78   fEgas.resize(fNbins,0.0);
 69   fEdep.reset();                                   79   fEdep.reset();
 70                                                    80 
 71   if (fVerbose > 0) {                          <<  81   if(fVerbose > 0) {
 72     G4int binsCluster = fParam->GetNumberBinsC     82     G4int binsCluster = fParam->GetNumberBinsCluster();
 73     G4cout << " BinsCluster= " << binsCluster  <<  83     G4cout << " BinsCluster= " << binsCluster << "    BinsE= " <<  fNbins
 74            << "   Emax(keV)= " << fMaxEnergy / <<  84            << "   Emax(keV)= " << fMaxEnergy/keV << G4endl;
 75     G4cout << " WidthALICE(keV)= " << fWidthAL <<  85     G4cout << " WidthALICE(keV)= " << fWidthALICE/keV 
 76            << G4endl;                          <<  86            << "      FactorALICE= " << fFactorALICE << G4endl;
                                                   >>  87 
 77   }                                                88   }
 78 }                                                  89 }
 79                                                    90 
 80 //....oooOO0OOooo........oooOO0OOooo........oo     91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 81                                                    92 
 82 void Run::EndOfRun()                               93 void Run::EndOfRun()
 83 {                                                  94 {
 84   G4int nEvt = GetNumberOfEvent();                 95   G4int nEvt = GetNumberOfEvent();
 85   G4double norm = (nEvt > 0) ? 1.0 / (G4double <<  96   G4double norm = (nEvt > 0) ? 1.0/(G4double)nEvt : 0.0; 
 86                                                    97 
 87   fTotStepGas *= norm;                         <<  98   fTotStepGas  *= norm;
 88   fTotCluster *= norm;                         <<  99   fTotCluster  *= norm;
 89   fMeanCluster *= norm;                           100   fMeanCluster *= norm;
 90   fOverflow *= norm;                           << 101   fOverflow    *= norm;
 91                                                   102 
 92   G4double y1 = fEdep.mean();                     103   G4double y1 = fEdep.mean();
 93   G4double y2 = fEdep.rms();                      104   G4double y2 = fEdep.rms();
 94                                                   105 
 95   G4double de = fMaxEnergy / G4double(fNbins); << 106   G4double de = fMaxEnergy/G4double(fNbins);  
 96   G4double x1 = -de * 0.5;                     << 107   G4double x1 = -de*0.5; 
 97                                                   108 
 98   fFactorALICE = fParam->GetFactorALICE();        109   fFactorALICE = fParam->GetFactorALICE();
 99                                                   110 
100   G4cout << " ================================    111   G4cout << " ====================================================" << G4endl;
101   G4cout << "   Beam Particle: " << fParam->Ge << 112   G4cout << "   Beam Particle: " 
102          << "   Ekin(MeV)    = " << fParam->Ge << 113          << fParam->GetBeamParticle()->GetParticleName() << G4endl
103          << "   Z(mm)        = " << fParam->Ge << 114          << "   Ekin(MeV)    = " << fParam->GetBeamEnergy()/MeV
                                                   >> 115          << G4endl
                                                   >> 116          << "   Z(mm)        = " << fParam->GetPositionZ()/mm 
                                                   >> 117          << G4endl;
104   G4cout << " ================== run summary =    118   G4cout << " ================== run summary =====================" << G4endl;
105   G4int prec = G4cout.precision(5);               119   G4int prec = G4cout.precision(5);
106   G4cout << "   End of Run TotNbofEvents    =  << 120   G4cout << "   End of Run TotNbofEvents    = " 
107   G4cout << "   Energy(keV) per ADC channel =  << 121          << nEvt << G4endl;
                                                   >> 122   G4cout << "   Energy(keV) per ADC channel = " 
                                                   >> 123          << 1.0/(keV*fFactorALICE) << G4endl;
108                                                   124 
109   G4cout << G4endl;                               125   G4cout << G4endl;
110   G4cout << "   Mean energy deposit in absorbe << 126   G4cout << "   Mean energy deposit in absorber = " <<
111          << y2 * std::sqrt(norm) / keV << " ke << 127     y1/keV << " +- " << y2*std::sqrt(norm)/keV << " keV; ";
112   if (y1 > 0.0) {                              << 128   if(y1 > 0.0) { G4cout << "   RMS/Emean = " << y2/y1; }
113     G4cout << "   RMS/Emean = " << y2 / y1;    << 
114   }                                            << 
115   G4cout << G4endl;                               129   G4cout << G4endl;
116   G4cout << "   Mean number of steps in absorb << 130   G4cout << "   Mean number of steps in absorber= " 
117          << ";  mean number of ion-clusters =  << 131          << fTotStepGas << ";  mean number of ion-clusters = " 
                                                   >> 132          << fTotCluster << " MeanCluster= " << fMeanCluster    
118          << G4endl;                               133          << G4endl;
119   G4cout << G4endl;                               134   G4cout << G4endl;
120                                                   135 
121   G4cout << " ====== Energy deposit distributi << 136   G4cout << " ====== Energy deposit distribution   Noverflows= " << fOverflow 
122          << " ====== " << G4endl;              << 137          << " ====== " << G4endl ;
123   G4cout << " bin nb      Elow      entries       138   G4cout << " bin nb      Elow      entries     normalized " << G4endl;
124                                                   139 
125   std::ofstream fileOut("distribution.out", st << 140   std::ofstream fileOut("distribution.out", std::ios::out );
126   fileOut.setf(std::ios::scientific, std::ios: << 141   fileOut.setf( std::ios::scientific, std::ios::floatfield );
127                                                   142 
128   x1 = 0.0;                                       143   x1 = 0.0;
129                                                   144 
130   fileOut << fNbins << G4endl;                    145   fileOut << fNbins << G4endl;
131                                                << 146  
132   for (G4int j = 0; j < fNbins; ++j) {         << 147   for(G4int j=0; j<fNbins; ++j) 
133     G4cout << std::setw(5) << j << std::setw(1 << 148   {
134            << std::setw(12) << fEgas[j] * norm << 149     G4cout << std::setw(5) << j << std::setw(10) << x1/keV 
135     fileOut << x1 / keV << "\t" << fEgas[j] << << 150            << std::setw(12) << fEgas[j] << std::setw(12) << fEgas[j]*norm 
                                                   >> 151            << G4endl ;
                                                   >> 152     fileOut << x1/keV << "\t" << fEgas[j] << G4endl;
136     x1 += de;                                     153     x1 += de;
137   }                                               154   }
138   G4cout.precision(prec);                         155   G4cout.precision(prec);
139                                                << 156  
140   G4AnalysisManager* analysisManager = G4Analy    157   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
141   // normalize histograms                         158   // normalize histograms
142   G4double normf = fParam->GetNormFactor();       159   G4double normf = fParam->GetNormFactor();
143   analysisManager->ScaleH1(1, norm);           << 160   analysisManager->ScaleH1(1,norm);
144   analysisManager->ScaleH1(2, norm);           << 161   analysisManager->ScaleH1(2,norm);
145   analysisManager->ScaleH1(3, norm * normf);   << 162   analysisManager->ScaleH1(3,norm*normf);
146                                                << 163  
147   G4cout << " ================== run end =====    164   G4cout << " ================== run end ==========================" << G4endl;
148 }                                                 165 }
149                                                   166 
150 //....oooOO0OOooo........oooOO0OOooo........oo    167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151                                                   168 
152 void Run::BeginOfEvent()                          169 void Run::BeginOfEvent()
153 {                                                 170 {
154   fTotEdep = 0.0;                                 171   fTotEdep = 0.0;
155   fStepGas = 0;                                   172   fStepGas = 0;
156   fCluster = 0;                                   173   fCluster = 0;
157   ++fEvt;                                         174   ++fEvt;
158 }                                                 175 }
159                                                   176 
160 //....oooOO0OOooo........oooOO0OOooo........oo    177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
161                                                   178 
162 void Run::EndOfEvent()                            179 void Run::EndOfEvent()
163 {                                                 180 {
164   fTotStepGas += fStepGas;                        181   fTotStepGas += fStepGas;
165   fTotCluster += fCluster;                        182   fTotCluster += fCluster;
166                                                   183 
167   if (fWidthALICE > 0.0) {                     << 184   if(fWidthALICE > 0.0) {
168     G4double x = G4RandGauss::shoot(0., fWidth << 185     G4double x = G4RandGauss::shoot(0.,fWidthALICE);
169     fTotEdep += x;                                186     fTotEdep += x;
170     fTotEdep = std::max(fTotEdep, 0.0);           187     fTotEdep = std::max(fTotEdep, 0.0);
171   }                                               188   }
172                                                   189 
173   G4int idx = G4int(fTotEdep * fNbins / fMaxEn << 190   G4int idx = G4int(fTotEdep*fNbins/fMaxEnergy);
174                                                << 
175   if (idx < 0) {                               << 
176     fEgas[0] += 1.0;                           << 
177   }                                            << 
178   if (idx >= fNbins) {                         << 
179     fOverflow += 1.0;                          << 
180   }                                            << 
181   else {                                       << 
182     fEgas[idx] += 1.0;                         << 
183   }                                            << 
184                                                   191 
                                                   >> 192   if(idx < 0) { fEgas[0] += 1.0; }
                                                   >> 193   if(idx >= fNbins) { fOverflow += 1.0; }
                                                   >> 194   else { fEgas[idx] += 1.0; }
                                                   >> 195   
185   G4AnalysisManager* analysisManager = G4Analy    196   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
186   // fill histo                                   197   // fill histo
187   analysisManager->FillH1(1, fTotEdep / keV, 1 << 198   analysisManager->FillH1(1,fTotEdep/keV,1.0);
188   analysisManager->FillH1(2, fCluster, 1.0);   << 199   analysisManager->FillH1(2,fCluster,1.0);
189   analysisManager->FillH1(3, fTotEdep * fFacto << 200   analysisManager->FillH1(3,fTotEdep*fFactorALICE,1.0);
190   fEdep.fill(fTotEdep, 1.0);                      201   fEdep.fill(fTotEdep, 1.0);
191 }                                                 202 }
192                                                   203 
193 //....oooOO0OOooo........oooOO0OOooo........oo    204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
194                                                   205 
195 void Run::Merge(const G4Run* run)                 206 void Run::Merge(const G4Run* run)
196 {                                                 207 {
197   const Run* localRun = static_cast<const Run*    208   const Run* localRun = static_cast<const Run*>(run);
198                                                   209 
199   fTotStepGas += localRun->fTotStepGas;        << 210   fTotStepGas  += localRun->fTotStepGas;
200   fTotCluster += localRun->fTotCluster;        << 211   fTotCluster  += localRun->fTotCluster;
201   fMeanCluster += localRun->fMeanCluster;         212   fMeanCluster += localRun->fMeanCluster;
202   fOverflow += localRun->fOverflow;            << 213   fOverflow    += localRun->fOverflow;
203                                                   214 
204   G4StatDouble* stat = const_cast<G4StatDouble    215   G4StatDouble* stat = const_cast<G4StatDouble*>(localRun->GetStat());
205                                                   216 
206   fEdep.add(stat);                                217   fEdep.add(stat);
207                                                << 218  
208   for (G4int j = 0; j < fNbins; ++j) {         << 219   for(G4int j=0; j<fNbins; ++j)
209     fEgas[j] += localRun->fEgas[j];            << 220   {
                                                   >> 221     fEgas[j] += localRun->fEgas[j]; 
210   }                                               222   }
211                                                << 223   
212   G4Run::Merge(run);                              224   G4Run::Merge(run);
213 }                                                 225 }
214                                                   226 
215 //....oooOO0OOooo........oooOO0OOooo........oo    227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
216                                                   228 
217 void Run::AddEnergy(G4double edep, const G4Ste    229 void Run::AddEnergy(G4double edep, const G4Step* step)
218 {                                                 230 {
219   if (1 < fVerbose) {                          << 231   if(1 < fVerbose) {
220     G4cout << "Run::AddEnergy: e(keV)= " << ed << 232     G4cout << "Run::AddEnergy: e(keV)= " << edep/keV
                                                   >> 233            << G4endl;
221   }                                               234   }
222   fTotEdep += edep;                               235   fTotEdep += edep;
223   if (step) {                                  << 236   if(step) {
224     if (1 == step->GetTrack()->GetTrackID()) { << 237     if(1 == step->GetTrack()->GetTrackID()) { fStepGas += 1.0; }
225       fStepGas += 1.0;                         << 
226     }                                          << 
227                                                   238 
228     fMeanCluster += fElIonPair->MeanNumberOfIo    239     fMeanCluster += fElIonPair->MeanNumberOfIonsAlongStep(step);
229     fCluster += fElIonPair->SampleNumberOfIons    240     fCluster += fElIonPair->SampleNumberOfIonsAlongStep(step);
230   }                                               241   }
231 }                                                 242 }
232                                                   243 
233 //....oooOO0OOooo........oooOO0OOooo........oo    244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
234                                                   245