Geant4  10.00.p01
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 78126 2013-12-03 17:43:56Z gcosmo $
27 //
30 
31 #include "TFile.h"
32 #include "TH1.h"
33 #include "TH2.h"
34 #include "TROOT.h"
35 #include "G4SystemOfUnits.hh"
36 #include "Analysis.hh"
37 
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 {
43  static Analysis the_analysis;
44  return &the_analysis;
45 }
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 {
50  // define histograms
51  fincident_map = new TH2D("incident map", "Incident Distributuon",
52  50, -5., 5.,
53  50, -5., 5.);
54  fincident_map-> GetXaxis()-> SetTitle("X (cm)");
55  fincident_map-> GetYaxis()-> SetTitle("Y (cm)");
56  fincident_map-> SetStats(0);
57 
58  fincident_x_hist = new TH1D("incident x", "Incident X", 100, -5., 5.);
59  fincident_x_hist-> GetXaxis()-> SetTitle("X (cm)");
60  fincident_x_hist-> SetFillColor(kRed);
61 
62  fdose_map = new TH2D("dose map", "Dose Distribution",
63  500, 0., 50.,
64  200, -10., 10.);
65  fdose_map-> GetXaxis()-> SetTitle("Z (cm)");
66  fdose_map-> GetYaxis()-> SetTitle("X (cm)");
67  fdose_map-> SetStats(0);
68 
69  fdose_hist = new TH1D("dose", "Dose Distribution", 500, 0., 50.);
70  fdose_hist-> GetXaxis()-> SetTitle("Z (cm)");
71  fdose_hist-> GetYaxis()-> SetTitle("Dose (GeV)");
72  fdose_hist-> SetFillColor(kBlue);
73  fdose_hist-> SetStats(0);
74 }
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 {
79  delete fincident_map;
80  delete fincident_x_hist;
81  delete fdose_map;
82  delete fdose_hist;
83 }
84 
85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 {
88  return;
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 {
94  fincident_map-> Reset();
95  fincident_x_hist-> Reset();
96  fdose_map-> Reset();
97  fdose_hist-> Reset();
98 
99  return;
100 }
101 
102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103 void Analysis::Save(const G4String& fname)
104 {
105  TFile* file = new TFile(fname.c_str(), "RECREATE", "Geant4 ROOT analysis");
106 
107  fincident_map-> Write();
108  fincident_x_hist-> Write();
109  fdose_map-> Write();
110  fdose_hist-> Write();
111 
112  file-> Close();
113 
114  delete file;
115 
116  return;
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 {
122  if ( ! fincidentFlag ) {
123  fincident_map-> Fill(p.x()/cm, p.y()/cm);
124  fincident_x_hist-> Fill(p.x()/cm);
125 
126  fincidentFlag = true;
127  }
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 {
133  const G4double Z0 = 25.*cm;
134  const G4double dxy = 10.*mm;
135 
136  if ( std::abs(p.y()) < dxy ) {
137  fdose_map-> Fill((p.z()+Z0)/cm, p.x()/cm, dedx/GeV);
138 
139  if ( std::abs(p.x()) < dxy ) {
140  fdose_hist-> Fill((p.z()+Z0)/cm, dedx/GeV);
141  }
142  }
143 }
static const double cm
Definition: G4SIunits.hh:106
void Update()
Definition: Analysis.cc:86
CLHEP::Hep3Vector G4ThreeVector
void FillDose(const G4ThreeVector &p, G4double dedx)
Definition: Analysis.cc:131
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
TH1D * fdose_hist
Definition: Analysis.hh:66
TH2D * fincident_map
Definition: Analysis.hh:62
static Analysis * GetAnalysis()
Definition: Analysis.cc:41
void Save(const G4String &fname)
Definition: Analysis.cc:103
static const double GeV
Definition: G4SIunits.hh:196
Analysis()
Definition: Analysis.cc:48
void Clear()
Definition: Analysis.cc:92
TH1D * fincident_x_hist
Definition: Analysis.hh:63
TH2D * fdose_map
Definition: Analysis.hh:65
static G4ThreadLocal G4int fincidentFlag
Definition: Analysis.hh:68
void FillIncident(const G4ThreeVector &p)
Definition: Analysis.cc:120
double G4double
Definition: G4Types.hh:76
static const double mm
Definition: G4SIunits.hh:102
~Analysis()
Definition: Analysis.cc:77