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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 1.0)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 /// \file electromagnetic/TestEm8/src/Run.cc      
 27 /// \brief Implementation of the Run class        
 28 //                                                
 29 //                                                
 30 //....oooOO0OOooo........oooOO0OOooo........oo    
 31 //....oooOO0OOooo........oooOO0OOooo........oo    
 32                                                   
 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"                              
 42 #include "G4SystemOfUnits.hh"                     
 43 #include "Randomize.hh"                           
 44                                                   
 45 //....oooOO0OOooo........oooOO0OOooo........oo    
 46                                                   
 47 Run::Run() : G4Run(), fElIonPair(0), fParam(Te    
 48 {                                                 
 49   fElIonPair = G4LossTableManager::Instance()-    
 50 }                                                 
 51                                                   
 52 //....oooOO0OOooo........oooOO0OOooo........oo    
 53                                                   
 54 void Run::BeginOfRun()                            
 55 {                                                 
 56   // initilise scoring                            
 57   fTotStepGas = fTotCluster = fMeanCluster = f    
 58   fEvt = 0;                                       
 59                                                   
 60   fFactorALICE = fParam->GetFactorALICE();        
 61   fWidthALICE = fParam->GetEnergySmear();         
 62                                                   
 63   SetVerbose(1);                                  
 64                                                   
 65   fNbins = fParam->GetNumberBins();               
 66   fMaxEnergy = fParam->GetMaxEnergy();            
 67                                                   
 68   fEgas.resize(fNbins, 0.0);                      
 69   fEdep.reset();                                  
 70                                                   
 71   if (fVerbose > 0) {                             
 72     G4int binsCluster = fParam->GetNumberBinsC    
 73     G4cout << " BinsCluster= " << binsCluster     
 74            << "   Emax(keV)= " << fMaxEnergy /    
 75     G4cout << " WidthALICE(keV)= " << fWidthAL    
 76            << G4endl;                             
 77   }                                               
 78 }                                                 
 79                                                   
 80 //....oooOO0OOooo........oooOO0OOooo........oo    
 81                                                   
 82 void Run::EndOfRun()                              
 83 {                                                 
 84   G4int nEvt = GetNumberOfEvent();                
 85   G4double norm = (nEvt > 0) ? 1.0 / (G4double    
 86                                                   
 87   fTotStepGas *= norm;                            
 88   fTotCluster *= norm;                            
 89   fMeanCluster *= norm;                           
 90   fOverflow *= norm;                              
 91                                                   
 92   G4double y1 = fEdep.mean();                     
 93   G4double y2 = fEdep.rms();                      
 94                                                   
 95   G4double de = fMaxEnergy / G4double(fNbins);    
 96   G4double x1 = -de * 0.5;                        
 97                                                   
 98   fFactorALICE = fParam->GetFactorALICE();        
 99                                                   
100   G4cout << " ================================    
101   G4cout << "   Beam Particle: " << fParam->Ge    
102          << "   Ekin(MeV)    = " << fParam->Ge    
103          << "   Z(mm)        = " << fParam->Ge    
104   G4cout << " ================== run summary =    
105   G4int prec = G4cout.precision(5);               
106   G4cout << "   End of Run TotNbofEvents    =     
107   G4cout << "   Energy(keV) per ADC channel =     
108                                                   
109   G4cout << G4endl;                               
110   G4cout << "   Mean energy deposit in absorbe    
111          << y2 * std::sqrt(norm) / keV << " ke    
112   if (y1 > 0.0) {                                 
113     G4cout << "   RMS/Emean = " << y2 / y1;       
114   }                                               
115   G4cout << G4endl;                               
116   G4cout << "   Mean number of steps in absorb    
117          << ";  mean number of ion-clusters =     
118          << G4endl;                               
119   G4cout << G4endl;                               
120                                                   
121   G4cout << " ====== Energy deposit distributi    
122          << " ====== " << G4endl;                 
123   G4cout << " bin nb      Elow      entries       
124                                                   
125   std::ofstream fileOut("distribution.out", st    
126   fileOut.setf(std::ios::scientific, std::ios:    
127                                                   
128   x1 = 0.0;                                       
129                                                   
130   fileOut << fNbins << G4endl;                    
131                                                   
132   for (G4int j = 0; j < fNbins; ++j) {            
133     G4cout << std::setw(5) << j << std::setw(1    
134            << std::setw(12) << fEgas[j] * norm    
135     fileOut << x1 / keV << "\t" << fEgas[j] <<    
136     x1 += de;                                     
137   }                                               
138   G4cout.precision(prec);                         
139                                                   
140   G4AnalysisManager* analysisManager = G4Analy    
141   // normalize histograms                         
142   G4double normf = fParam->GetNormFactor();       
143   analysisManager->ScaleH1(1, norm);              
144   analysisManager->ScaleH1(2, norm);              
145   analysisManager->ScaleH1(3, norm * normf);      
146                                                   
147   G4cout << " ================== run end =====    
148 }                                                 
149                                                   
150 //....oooOO0OOooo........oooOO0OOooo........oo    
151                                                   
152 void Run::BeginOfEvent()                          
153 {                                                 
154   fTotEdep = 0.0;                                 
155   fStepGas = 0;                                   
156   fCluster = 0;                                   
157   ++fEvt;                                         
158 }                                                 
159                                                   
160 //....oooOO0OOooo........oooOO0OOooo........oo    
161                                                   
162 void Run::EndOfEvent()                            
163 {                                                 
164   fTotStepGas += fStepGas;                        
165   fTotCluster += fCluster;                        
166                                                   
167   if (fWidthALICE > 0.0) {                        
168     G4double x = G4RandGauss::shoot(0., fWidth    
169     fTotEdep += x;                                
170     fTotEdep = std::max(fTotEdep, 0.0);           
171   }                                               
172                                                   
173   G4int idx = G4int(fTotEdep * fNbins / fMaxEn    
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                                                   
185   G4AnalysisManager* analysisManager = G4Analy    
186   // fill histo                                   
187   analysisManager->FillH1(1, fTotEdep / keV, 1    
188   analysisManager->FillH1(2, fCluster, 1.0);      
189   analysisManager->FillH1(3, fTotEdep * fFacto    
190   fEdep.fill(fTotEdep, 1.0);                      
191 }                                                 
192                                                   
193 //....oooOO0OOooo........oooOO0OOooo........oo    
194                                                   
195 void Run::Merge(const G4Run* run)                 
196 {                                                 
197   const Run* localRun = static_cast<const Run*    
198                                                   
199   fTotStepGas += localRun->fTotStepGas;           
200   fTotCluster += localRun->fTotCluster;           
201   fMeanCluster += localRun->fMeanCluster;         
202   fOverflow += localRun->fOverflow;               
203                                                   
204   G4StatDouble* stat = const_cast<G4StatDouble    
205                                                   
206   fEdep.add(stat);                                
207                                                   
208   for (G4int j = 0; j < fNbins; ++j) {            
209     fEgas[j] += localRun->fEgas[j];               
210   }                                               
211                                                   
212   G4Run::Merge(run);                              
213 }                                                 
214                                                   
215 //....oooOO0OOooo........oooOO0OOooo........oo    
216                                                   
217 void Run::AddEnergy(G4double edep, const G4Ste    
218 {                                                 
219   if (1 < fVerbose) {                             
220     G4cout << "Run::AddEnergy: e(keV)= " << ed    
221   }                                               
222   fTotEdep += edep;                               
223   if (step) {                                     
224     if (1 == step->GetTrack()->GetTrackID()) {    
225       fStepGas += 1.0;                            
226     }                                             
227                                                   
228     fMeanCluster += fElIonPair->MeanNumberOfIo    
229     fCluster += fElIonPair->SampleNumberOfIons    
230   }                                               
231 }                                                 
232                                                   
233 //....oooOO0OOooo........oooOO0OOooo........oo    
234