Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Analysis.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: Analysis.cc 76431 2013-11-10 20:28:49Z kmura $
27 //
30 
31 //#include "TFile.h"
32 //#include "TH1.h"
33 //#include "TH2.h"
34 //#include "TROOT.h"
35 #include "G4AutoDelete.hh"
36 #include "G4SystemOfUnits.hh"
37 #include "Analysis.hh"
38 
39 //Select format of output here
40 #include "g4root.hh"
41 G4ThreadLocal G4int Analysis::fincidentFlag = false;
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 Analysis*
47 {
48  if (!the_analysis)
49  {
50  the_analysis = new Analysis();
52  }
53  return the_analysis;
54 }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 Analysis::Analysis() :
58  fincident_x_hist(0), fincident_map(0), fdose_hist(0), fdose_map(0),
59  fdose_prof(0), fdose_map_prof(0), fdose_map3d(0)
60 {
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 void
66 {
67  G4AnalysisManager* mgr = G4AnalysisManager::Instance();
68  //mgr->SetVerboseLevel(1);
69  fincident_x_hist = mgr->CreateH1("incident_x", "Incident X", 100, -5 * cm,
70  5 * cm, "cm");
71  fincident_map = mgr->CreateH2("incident_map", "Incident Map", 50, -5 * cm,
72  5 * cm, 50, -5 * cm, 5 * cm, "cm", "cm");
73  fdose_hist
74  = mgr->CreateH1("dose", "Dose distribution", 500, 0, 50 * cm, "cm");
75  fdose_map = mgr->CreateH2("dose_map", "Dose distribution", 500, 0, 50 * cm,
76  200, -10 * cm, 10 * cm, "cm", "cm");
77  fdose_map3d = mgr->CreateH3("dose_map_3d", "Dose distribution", 30, 0,
78  50 * cm, 20, -10 * cm, 10 * cm, 20, -10 * cm, 10 * cm, "cm", "cm", "cm");
79  fdose_prof = mgr->CreateP1("dose_prof", "Dose distribution", 300, 0, 30 * cm,
80  0, 100 * MeV, "cm", "MeV");
81  fdose_map_prof = mgr->CreateP2("dose_map_prof", "Dose distribution", 300, 0,
82  30 * cm, 80, -4 * cm, 4 * cm, 0, 100 * MeV, "cm", "cm", "MeV");
83 
84 }
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88 {
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 void
94 {
95  return;
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 void
101 {
102  return;
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 void
108 {
109  G4AnalysisManager* mgr = G4AnalysisManager::Instance();
110  mgr->OpenFile(fname.c_str());
111  mgr->Write();
112  return;
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116 void
118 {
119  G4AnalysisManager* mgr = G4AnalysisManager::Instance();
120  mgr->CloseFile();
121  return;
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125 void
127 {
128  if (!fincidentFlag)
129  {
130  G4AnalysisManager* mgr = G4AnalysisManager::Instance();
131  mgr->FillH2(fincident_map, p.x(), p.y());
132  mgr->FillH1(fincident_x_hist, p.x());
133  fincidentFlag = true;
134  }
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138 void
140 {
141  const G4double dxy = 10. * mm;
142  if (std::abs(p.y()) < dxy)
143  {
144  G4AnalysisManager* mgr = G4AnalysisManager::Instance();
145  const G4double Z0 = 25. * cm;
146 
147  mgr->FillH2(fdose_map, p.z() + Z0, p.x(), dedx / GeV);
148  mgr->FillP2(fdose_map_prof, p.z() + Z0, p.x(), dedx);
149  mgr->FillH3(fdose_map3d, p.z() + Z0, p.x(), p.y(), dedx / GeV);
150  if (std::abs(p.x()) < dxy)
151  {
152  mgr->FillH1(fdose_hist, p.z() + Z0, dedx / GeV);
153  mgr->FillP1(fdose_prof, p.z() + Z0, dedx);
154  }
155  }
156 
157 }
G4int CreateH3(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4int nzbins, G4double zmin, G4double zmax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear", const G4String &zbinSchemeName="linear")
void Update()
Definition: Analysis.cc:91
static constexpr double mm
Definition: G4SIunits.hh:115
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
double x() const
const char * p
Definition: xmltok.h:285
void FillDose(const G4ThreeVector &p, G4double dedx)
Definition: Analysis.cc:137
G4bool FillP2(G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight=1.0)
G4int CreateP1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear")
G4bool FillP1(G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0)
#define G4ThreadLocal
Definition: tls.hh:89
void Close()
Definition: Analysis.cc:117
int G4int
Definition: G4Types.hh:78
G4bool OpenFile(const G4String &fileName="")
double z() const
void Register(T *inst)
Definition: G4AutoDelete.hh:65
static Analysis * GetAnalysis()
Definition: Analysis.cc:45
static constexpr double cm
Definition: G4SIunits.hh:119
void Save(const G4String &fname)
Definition: Analysis.cc:108
void Book()
Definition: Analysis.cc:65
void Clear()
Definition: Analysis.cc:97
G4int CreateP2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4double zmin=0, G4double zmax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
G4bool FillH2(G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0)
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
double y() const
void FillIncident(const G4ThreeVector &p)
Definition: Analysis.cc:126
static constexpr double GeV
Definition: G4SIunits.hh:217
static constexpr double MeV
Definition: G4SIunits.hh:214
string fname
Definition: test.py:308
G4ThreadLocal Analysis * the_analysis
Definition: Analysis.cc:40
G4bool FillH3(G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight=1.0)
double G4double
Definition: G4Types.hh:76
~Analysis()
Definition: Analysis.cc:82
G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")