Geant4 Cross Reference |
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