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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/medical/GammaTherapy/src/HistoManager.cc (Version 11.3.0) and /examples/extended/medical/GammaTherapy/src/HistoManager.cc (Version 9.1.p2)


  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 medical/GammaTherapy/src/HistoManage    
 27 /// \brief Implementation of the HistoManager     
 28 //                                                
 29 //                                                
 30 //                                                
 31 //....oooOO0OOooo........oooOO0OOooo........oo    
 32 //....oooOO0OOooo........oooOO0OOooo........oo    
 33                                                   
 34 #include "HistoManager.hh"                        
 35                                                   
 36 #include "DetectorConstruction.hh"                
 37                                                   
 38 #include "G4SystemOfUnits.hh"                     
 39                                                   
 40 //....oooOO0OOooo........oooOO0OOooo........oo    
 41                                                   
 42 HistoManager::HistoManager()                      
 43 {                                                 
 44   fNBinsZ = 60;                                   
 45   fNBinsR = 80;                                   
 46   fNBinsE = 200;                                  
 47                                                   
 48   fAbsorberZ = 300. * mm;                         
 49   fAbsorberR = 200. * mm;                         
 50   fScoreZ = 100. * mm;                            
 51   fMaxEnergy = 50. * MeV;                         
 52                                                   
 53   fStepZ = fStepR = fStepE = 0.0;                 
 54                                                   
 55   Book();                                         
 56 }                                                 
 57                                                   
 58 //....oooOO0OOooo........oooOO0OOooo........oo    
 59                                                   
 60 HistoManager::~HistoManager() {}                  
 61                                                   
 62 //....oooOO0OOooo........oooOO0OOooo........oo    
 63                                                   
 64 void HistoManager::Book()                         
 65 {                                                 
 66   G4AnalysisManager* analysisManager = G4Analy    
 67                                                   
 68   // Create or get analysis manager               
 69   analysisManager->SetDefaultFileType("root");    
 70   analysisManager->SetVerboseLevel(1);            
 71   analysisManager->SetActivation(true);  // en    
 72                                                   
 73   // Creating an 1-dimensional histograms in t    
 74   fHisto.assign(10, 0);                           
 75   int iHisto = 0;                                 
 76   fHisto[iHisto] = analysisManager->CreateH1(     
 77     "10", "Energy deposit at radius (mm) norma    
 78                                                   
 79   iHisto++;                                       
 80   fHisto[iHisto] = analysisManager->CreateH1(     
 81     "11", "Energy deposit at radius (mm) norma    
 82                                                   
 83   iHisto++;                                       
 84   fHisto[iHisto] = analysisManager->CreateH1(     
 85     "12", "Energy deposit (MeV/kg/electron) at    
 86                                                   
 87   iHisto++;                                       
 88   fHisto[iHisto] = analysisManager->CreateH1("    
 89                                              f    
 90                                                   
 91   iHisto++;                                       
 92   fHisto[iHisto] =                                
 93     analysisManager->CreateH1("14", "Energy pr    
 94                               fNBinsZ, 0., fAb    
 95                                                   
 96   iHisto++;                                       
 97   fHisto[iHisto] = analysisManager->CreateH1("    
 98                                              f    
 99                                                   
100   iHisto++;                                       
101   fHisto[iHisto] = analysisManager->CreateH1("    
102                                              0    
103                                                   
104   iHisto++;                                       
105   fHisto[iHisto] = analysisManager->CreateH1("    
106                                              f    
107                                                   
108   iHisto++;                                       
109   fHisto[iHisto] = analysisManager->CreateH1("    
110                                              f    
111                                                   
112   iHisto++;                                       
113   fHisto[iHisto] = analysisManager->CreateH1(     
114     "19", "Gamma Energy Fluence (MeV/cm2) at r    
115     fAbsorberR / mm);                             
116                                                   
117   // Create all histograms as inactivated         
118   // as we have not yet set nbins, vmin, vmax     
119   for (int i = 0; i < iHisto + 1; i++)            
120     analysisManager->SetH1Activation(i, false)    
121 }                                                 
122                                                   
123 void HistoManager::Update(DetectorConstruction    
124 {                                                 
125   G4AnalysisManager* analysisManager = G4Analy    
126                                                   
127   if (bForceActivation) {                         
128     for (int i = 0; i < (int)fHisto.size(); i+    
129       analysisManager->SetH1Activation(fHisto[    
130     analysisManager->SetActivation(true);         
131   }                                               
132                                                   
133   if (analysisManager->IsActive()) {              
134     // Check nBinsR / fAbsorberR histograms       
135     if (det->GetNumberDivR() != fNBinsR || std    
136     {                                             
137       fNBinsR = det->GetNumberDivR();             
138       fAbsorberR = det->GetAbsorberR();           
139       std::vector<G4int> histoId{0, 1, 2, 9};     
140       for (auto v : histoId) {                    
141         analysisManager->SetH1(fHisto[v], fNBi    
142       }                                           
143     }                                             
144                                                   
145     // Check nBinsZ / fAbsorberZ histograms       
146     if (det->GetNumberDivZ() != fNBinsZ || std    
147     {                                             
148       fNBinsZ = det->GetNumberDivZ();             
149       fAbsorberZ = det->GetAbsorberZ();           
150       std::vector<G4int> histoId{3, 4};           
151       for (auto v : histoId) {                    
152         analysisManager->SetH1(fHisto[v], fNBi    
153       }                                           
154     }                                             
155                                                   
156     // Check nBinsE / fAbsorberE histograms       
157     if (det->GetNumberDivE() != fNBinsE || std    
158       fNBinsE = det->GetNumberDivE();             
159       fMaxEnergy = det->GetMaxEnergy();           
160       std::vector<G4int> histoId{5, 6, 7, 8};     
161       for (auto v : histoId) {                    
162         analysisManager->SetH1(fHisto[v], fNBi    
163       }                                           
164     }                                             
165   }                                               
166 }                                                 
167                                                   
168 //....oooOO0OOooo........oooOO0OOooo........oo    
169                                                   
170 void HistoManager::DumpHistoParameters()          
171 {                                                 
172   if (!G4AnalysisManager::Instance()->IsActive    
173                                                   
174   for (int i = 0; i < (int)fHisto.size(); i++)    
175     G4int histoId = fHisto[i];                    
176     G4String title = G4AnalysisManager::Instan    
177     G4int nbins = G4AnalysisManager::Instance(    
178     G4double xmin = G4AnalysisManager::Instanc    
179     G4double xmax = G4AnalysisManager::Instanc    
180     G4double width = G4AnalysisManager::Instan    
181     G4cout << "Histogram parameters : " << i <    
182     G4cout << xmin << "/" << xmax << " " << wi    
183   }                                               
184 }                                                 
185