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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 10.7.p4)


  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 medical/GammaTherapy/src/HistoManage     26 /// \file medical/GammaTherapy/src/HistoManager.cc
 27 /// \brief Implementation of the HistoManager      27 /// \brief Implementation of the HistoManager class
 28 //                                                 28 //
 29 //                                                 29 //
 30 //                                             <<  30 // 
 31 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 33                                                    33 
 34 #include "HistoManager.hh"                         34 #include "HistoManager.hh"
 35                                                << 
 36 #include "DetectorConstruction.hh"             << 
 37                                                << 
 38 #include "G4SystemOfUnits.hh"                      35 #include "G4SystemOfUnits.hh"
                                                   >>  36 #include "DetectorConstruction.hh"
 39                                                    37 
 40 //....oooOO0OOooo........oooOO0OOooo........oo     38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 41                                                    39 
 42 HistoManager::HistoManager()                       40 HistoManager::HistoManager()
 43 {                                                  41 {
 44   fNBinsZ = 60;                                <<  42 
 45   fNBinsR = 80;                                <<  43   fNBinsZ    = 60;
 46   fNBinsE = 200;                               <<  44   fNBinsR    = 80;
 47                                                <<  45   fNBinsE    = 200;
 48   fAbsorberZ = 300. * mm;                      <<  46 
 49   fAbsorberR = 200. * mm;                      <<  47   fAbsorberZ = 300.*mm;
 50   fScoreZ = 100. * mm;                         <<  48   fAbsorberR = 200.*mm;
 51   fMaxEnergy = 50. * MeV;                      <<  49   fScoreZ    = 100.*mm;
                                                   >>  50   fMaxEnergy = 50.*MeV;
 52                                                    51 
 53   fStepZ = fStepR = fStepE = 0.0;                  52   fStepZ = fStepR = fStepE = 0.0;
 54                                                    53 
 55   Book();                                          54   Book();
                                                   >>  55 
 56 }                                                  56 }
 57                                                    57 
 58 //....oooOO0OOooo........oooOO0OOooo........oo     58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 59                                                    59 
 60 HistoManager::~HistoManager() {}               <<  60 HistoManager::~HistoManager()
                                                   >>  61 {
                                                   >>  62   delete G4AnalysisManager::Instance();
                                                   >>  63 }
 61                                                    64 
 62 //....oooOO0OOooo........oooOO0OOooo........oo     65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 63                                                    66 
 64 void HistoManager::Book()                          67 void HistoManager::Book()
 65 {                                                  68 {
                                                   >>  69 
 66   G4AnalysisManager* analysisManager = G4Analy     70   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
 67                                                    71 
 68   // Create or get analysis manager                72   // Create or get analysis manager
 69   analysisManager->SetDefaultFileType("root"); <<  73   // The choice of analysis technology is done via selection of a namespace
                                                   >>  74   // in HistoManager.hh
 70   analysisManager->SetVerboseLevel(1);             75   analysisManager->SetVerboseLevel(1);
 71   analysisManager->SetActivation(true);  // en <<  76   analysisManager->SetActivation(true);    // enable inactivation of histograms
 72                                                    77 
 73   // Creating an 1-dimensional histograms in t     78   // Creating an 1-dimensional histograms in the root directory of the tree
 74   fHisto.assign(10, 0);                        <<  79   fHisto.assign(10,0);
 75   int iHisto = 0;                              <<  80   int iHisto=0;
 76   fHisto[iHisto] = analysisManager->CreateH1(  <<  81   fHisto[iHisto] = analysisManager->CreateH1("10",
 77     "10", "Energy deposit at radius (mm) norma <<  82     "Energy deposit at radius (mm) normalised on 1st channel",
 78                                                <<  83     fNBinsR, 0., fAbsorberR/mm);
                                                   >>  84   
 79   iHisto++;                                        85   iHisto++;
 80   fHisto[iHisto] = analysisManager->CreateH1(  <<  86   fHisto[iHisto] = analysisManager->CreateH1("11",
 81     "11", "Energy deposit at radius (mm) norma <<  87     "Energy deposit at radius (mm) normalised to integral",
                                                   >>  88     fNBinsR, 0., fAbsorberR/mm);
 82                                                    89 
 83   iHisto++;                                        90   iHisto++;
 84   fHisto[iHisto] = analysisManager->CreateH1(  <<  91   fHisto[iHisto] = analysisManager->CreateH1("12",
 85     "12", "Energy deposit (MeV/kg/electron) at <<  92     "Energy deposit (MeV/kg/electron) at radius (mm)",
                                                   >>  93     fNBinsR, 0., fAbsorberR/mm);
 86                                                    94 
 87   iHisto++;                                        95   iHisto++;
 88   fHisto[iHisto] = analysisManager->CreateH1(" <<  96   fHisto[iHisto] = analysisManager->CreateH1("13",
 89                                              f <<  97     "Energy profile (MeV/kg/electron) over Z (mm)",fNBinsZ,0.,fAbsorberZ/mm);
 90                                                    98 
 91   iHisto++;                                        99   iHisto++;
 92   fHisto[iHisto] =                             << 100   fHisto[iHisto] = analysisManager->CreateH1("14",
 93     analysisManager->CreateH1("14", "Energy pr << 101     "Energy profile (MeV/kg/electron) over Z (mm) at Central Voxel",
 94                               fNBinsZ, 0., fAb << 102     fNBinsZ, 0., fAbsorberZ/mm);
 95                                                   103 
 96   iHisto++;                                       104   iHisto++;
 97   fHisto[iHisto] = analysisManager->CreateH1(" << 105   fHisto[iHisto] = analysisManager->CreateH1("15",
 98                                              f << 106     "Energy (MeV) of fGamma produced in the target",
                                                   >> 107     fNBinsE, 0., fMaxEnergy/MeV);
 99                                                   108 
100   iHisto++;                                       109   iHisto++;
101   fHisto[iHisto] = analysisManager->CreateH1(" << 110   fHisto[iHisto] = analysisManager->CreateH1("16",
102                                              0 << 111     "Energy (MeV) of fGamma before phantom",fNBinsE,0.,fMaxEnergy/MeV);
103                                                   112 
104   iHisto++;                                       113   iHisto++;
105   fHisto[iHisto] = analysisManager->CreateH1(" << 114   fHisto[iHisto] = analysisManager->CreateH1("17",
106                                              f << 115     "Energy (MeV) of electrons produced in phantom",fNBinsE,0.,fMaxEnergy/MeV);
107                                                   116 
108   iHisto++;                                       117   iHisto++;
109   fHisto[iHisto] = analysisManager->CreateH1(" << 118   fHisto[iHisto] = analysisManager->CreateH1("18",
110                                              f << 119     "Energy (MeV) of electrons produced in target",fNBinsE,0.,fMaxEnergy/MeV);
111                                                   120 
112   iHisto++;                                       121   iHisto++;
113   fHisto[iHisto] = analysisManager->CreateH1(  << 122   fHisto[iHisto] = analysisManager->CreateH1("19",
114     "19", "Gamma Energy Fluence (MeV/cm2) at r << 123     "Gamma Energy Fluence (MeV/cm2) at radius(mm) in front of phantom",
115     fAbsorberR / mm);                          << 124     fNBinsR, 0., fAbsorberR/mm);
116                                                   125 
117   // Create all histograms as inactivated      << 126   // Create all histograms as inactivated 
118   // as we have not yet set nbins, vmin, vmax     127   // as we have not yet set nbins, vmin, vmax
119   for (int i = 0; i < iHisto + 1; i++)         << 128   for(int i=0; i<iHisto+1; i++) analysisManager->SetH1Activation(i, false);
120     analysisManager->SetH1Activation(i, false) << 129 
121 }                                                 130 }
122                                                   131 
                                                   >> 132 
123 void HistoManager::Update(DetectorConstruction    133 void HistoManager::Update(DetectorConstruction* det, bool bForceActivation)
124 {                                                 134 {
                                                   >> 135 
125   G4AnalysisManager* analysisManager = G4Analy    136   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
126                                                   137 
127   if (bForceActivation) {                      << 138   if(bForceActivation) {
128     for (int i = 0; i < (int)fHisto.size(); i+ << 139     for(int i=0; i<(int)fHisto.size(); i++) 
129       analysisManager->SetH1Activation(fHisto[    140       analysisManager->SetH1Activation(fHisto[i], true);
130     analysisManager->SetActivation(true);         141     analysisManager->SetActivation(true);
131   }                                               142   }
132                                                   143 
133   if (analysisManager->IsActive()) {           << 144   if(analysisManager->IsActive()) {
                                                   >> 145 
134     // Check nBinsR / fAbsorberR histograms       146     // Check nBinsR / fAbsorberR histograms
135     if (det->GetNumberDivR() != fNBinsR || std << 147     if(det->GetNumberDivR()!=fNBinsR||
136     {                                          << 148        std::fabs(det->GetAbsorberR()-fAbsorberR)>0.01*mm)
137       fNBinsR = det->GetNumberDivR();          << 149       {
138       fAbsorberR = det->GetAbsorberR();        << 150         fNBinsR = det->GetNumberDivR();
139       std::vector<G4int> histoId{0, 1, 2, 9};  << 151         fAbsorberR = det->GetAbsorberR();
140       for (auto v : histoId) {                 << 152         std::vector<G4int> histoId { 0, 1, 2, 9 };
141         analysisManager->SetH1(fHisto[v], fNBi << 153         for(auto v : histoId)
142       }                                        << 154           {
143     }                                          << 155             analysisManager->SetH1(fHisto[v], fNBinsR, 0., fAbsorberR/mm);
                                                   >> 156           }
144                                                   157 
                                                   >> 158       }
                                                   >> 159     
145     // Check nBinsZ / fAbsorberZ histograms       160     // Check nBinsZ / fAbsorberZ histograms
146     if (det->GetNumberDivZ() != fNBinsZ || std << 161     if(det->GetNumberDivZ()!=fNBinsZ||
147     {                                          << 162        std::fabs(det->GetAbsorberZ()-fAbsorberZ)>0.01*mm)
148       fNBinsZ = det->GetNumberDivZ();          << 163       {
149       fAbsorberZ = det->GetAbsorberZ();        << 164         fNBinsZ = det->GetNumberDivZ();
150       std::vector<G4int> histoId{3, 4};        << 165         fAbsorberZ = det->GetAbsorberZ();
151       for (auto v : histoId) {                 << 166         std::vector<G4int> histoId { 3, 4 };
152         analysisManager->SetH1(fHisto[v], fNBi << 167         for(auto v : histoId)
                                                   >> 168           {
                                                   >> 169             analysisManager->SetH1(fHisto[v], fNBinsZ, 0., fAbsorberZ/mm);
                                                   >> 170           }
153       }                                           171       }
154     }                                          << 172     
155                                                << 
156     // Check nBinsE / fAbsorberE histograms       173     // Check nBinsE / fAbsorberE histograms
157     if (det->GetNumberDivE() != fNBinsE || std << 174     if(det->GetNumberDivE()!=fNBinsE||
158       fNBinsE = det->GetNumberDivE();          << 175        std::fabs(det->GetMaxEnergy()-fMaxEnergy)>0.01)
159       fMaxEnergy = det->GetMaxEnergy();        << 176       {
160       std::vector<G4int> histoId{5, 6, 7, 8};  << 177         fNBinsE = det->GetNumberDivE();
161       for (auto v : histoId) {                 << 178         fMaxEnergy = det->GetMaxEnergy();
162         analysisManager->SetH1(fHisto[v], fNBi << 179         std::vector<G4int> histoId { 5, 6, 7 ,8 };
                                                   >> 180         for(auto v : histoId)
                                                   >> 181           {
                                                   >> 182             analysisManager->SetH1(fHisto[v], fNBinsE, 0., fMaxEnergy/MeV);
                                                   >> 183           }
163       }                                           184       }
164     }                                          << 
165   }                                               185   }
                                                   >> 186 
166 }                                                 187 }
167                                                   188 
                                                   >> 189 
168 //....oooOO0OOooo........oooOO0OOooo........oo    190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169                                                   191 
170 void HistoManager::DumpHistoParameters()          192 void HistoManager::DumpHistoParameters()
171 {                                                 193 {
172   if (!G4AnalysisManager::Instance()->IsActive << 194   if(!G4AnalysisManager::Instance()->IsActive()) return;
                                                   >> 195 
                                                   >> 196   for(int i=0; i<(int)fHisto.size(); i++)
                                                   >> 197     {
                                                   >> 198       G4int histoId=fHisto[i];      
                                                   >> 199       G4String title = G4AnalysisManager::Instance()->GetH1Title(histoId);
                                                   >> 200       G4int nbins = G4AnalysisManager::Instance()->GetH1Nbins(histoId);
                                                   >> 201       G4double xmin = G4AnalysisManager::Instance()->GetH1Xmin(histoId);
                                                   >> 202       G4double xmax = G4AnalysisManager::Instance()->GetH1Xmax(histoId);
                                                   >> 203       G4double width = G4AnalysisManager::Instance()->GetH1Width(histoId);
                                                   >> 204       G4cout<<"Histogram parameters : "<<i<<" "<<histoId<<" : "<<nbins<<" ";
                                                   >> 205       G4cout<<xmin<<"/"<<xmax<<" "<<width<<G4endl;
                                                   >> 206       
                                                   >> 207     }
173                                                   208 
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 }                                                 209 }
                                                   >> 210 
                                                   >> 211 
                                                   >> 212 
                                                   >> 213 
185                                                   214