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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/analysis/B1Con/src/RunAction.cc (Version 11.3.0) and /examples/extended/analysis/B1Con/src/RunAction.cc (Version 9.1.p3)


  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 //                                                
 27 /// \file B1/src/RunAction.cc                     
 28 /// \brief Implementation of the B1::RunAction    
 29                                                   
 30 #include "RunAction.hh"                           
 31                                                   
 32 #include "DetectorConstruction.hh"                
 33 #include "PrimaryGeneratorAction.hh"              
 34                                                   
 35 #include "G4AccumulableManager.hh"                
 36 #include "G4LogicalVolume.hh"                     
 37 #include "G4LogicalVolumeStore.hh"                
 38 #include "G4Run.hh"                               
 39 #include "G4RunManager.hh"                        
 40 #include "G4SystemOfUnits.hh"                     
 41 #include "G4UnitsTable.hh"                        
 42                                                   
 43 namespace B1Con                                   
 44 {                                                 
 45                                                   
 46 //....oooOO0OOooo........oooOO0OOooo........oo    
 47                                                   
 48 RunAction::RunAction()                            
 49 {                                                 
 50   // add new units for dose                       
 51   //                                              
 52   const G4double milligray = 1.e-3 * gray;        
 53   const G4double microgray = 1.e-6 * gray;        
 54   const G4double nanogray = 1.e-9 * gray;         
 55   const G4double picogray = 1.e-12 * gray;        
 56                                                   
 57   new G4UnitDefinition("milligray", "milliGy",    
 58   new G4UnitDefinition("microgray", "microGy",    
 59   new G4UnitDefinition("nanogray", "nanoGy", "    
 60   new G4UnitDefinition("picogray", "picoGy", "    
 61                                                   
 62   // Register accumulable to the accumulable m    
 63   G4AccumulableManager* accumulableManager = G    
 64   accumulableManager->Register(fEdep);            
 65   accumulableManager->Register(fEdep2);           
 66   accumulableManager->Register(&fEdepPerEvent)    
 67 }                                                 
 68                                                   
 69 //....oooOO0OOooo........oooOO0OOooo........oo    
 70                                                   
 71 void RunAction::BeginOfRunAction(const G4Run*)    
 72 {                                                 
 73   // inform the runManager to save random numb    
 74   G4RunManager::GetRunManager()->SetRandomNumb    
 75                                                   
 76   // reset accumulables to their initial value    
 77   G4AccumulableManager* accumulableManager = G    
 78   accumulableManager->Reset();                    
 79                                                   
 80   if (IsMaster()) {                               
 81     fDoseTally = new G4ConvergenceTester("DOSE    
 82     // fDoseTally = new G4ConvergenceTester();    
 83   }                                               
 84 }                                                 
 85                                                   
 86 //....oooOO0OOooo........oooOO0OOooo........oo    
 87                                                   
 88 void RunAction::EndOfRunAction(const G4Run* ru    
 89 {                                                 
 90   G4int nofEvents = run->GetNumberOfEvent();      
 91   if (nofEvents == 0) return;                     
 92                                                   
 93   // Merge accumulables                           
 94   G4AccumulableManager* accumulableManager = G    
 95   accumulableManager->Merge();                    
 96                                                   
 97   // Compute dose = total energy deposit in a     
 98   //                                              
 99   G4double edep = fEdep.GetValue();               
100   G4double edep2 = fEdep2.GetValue();             
101                                                   
102   G4double rms = edep2 - edep * edep / nofEven    
103   if (rms > 0.)                                   
104     rms = std::sqrt(rms);                         
105   else                                            
106     rms = 0.;                                     
107                                                   
108   const auto detConstruction = static_cast<con    
109     G4RunManager::GetRunManager()->GetUserDete    
110   G4double mass = detConstruction->GetScoringV    
111   G4double dose = edep / mass;                    
112   G4double rmsDose = rms / mass;                  
113                                                   
114   // Run conditions                               
115   //  note: There is no primary generator acti    
116   //        run manager for multi-threaded mod    
117   const auto generatorAction = static_cast<con    
118     G4RunManager::GetRunManager()->GetUserPrim    
119   G4String runCondition;                          
120   if (generatorAction) {                          
121     const G4ParticleGun* particleGun = generat    
122     runCondition += particleGun->GetParticleDe    
123     runCondition += " of ";                       
124     G4double particleEnergy = particleGun->Get    
125     runCondition += G4BestUnit(particleEnergy,    
126   }                                               
127                                                   
128   // Print                                        
129   //                                              
130   if (IsMaster()) {                               
131     for (auto edepPerEvent : fEdepPerEvent.Get    
132       G4double dosePerEvent = edepPerEvent / m    
133       fDoseTally->AddScore(dosePerEvent);         
134     }                                             
135                                                   
136     fDoseTally->ShowResult();                     
137     fDoseTally->ShowHistory();                    
138     delete fDoseTally;                            
139     fDoseTally = nullptr;                         
140                                                   
141     G4cout << G4endl << "--------------------E    
142   }                                               
143   else {                                          
144     G4cout << G4endl << "--------------------E    
145   }                                               
146                                                   
147   G4cout << G4endl << " The run consists of "     
148          << " Cumulated dose per run, in scori    
149          << " rms = " << G4BestUnit(rmsDose, "    
150          << "---------------------------------    
151 }                                                 
152                                                   
153 //....oooOO0OOooo........oooOO0OOooo........oo    
154                                                   
155 void RunAction::AddEdep(G4double edep)            
156 {                                                 
157   fEdep += edep;                                  
158   fEdep2 += edep * edep;                          
159   fEdepPerEvent.AddValue(edep);                   
160 }                                                 
161                                                   
162 //....oooOO0OOooo........oooOO0OOooo........oo    
163                                                   
164 }  // namespace B1Con                             
165