source: trunk/examples/extended/parallel/MPI/exMPI02/src/Analysis.cc

Last change on this file was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 5.0 KB
Line 
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,v 1.1 2007/11/16 14:29:33 kmura Exp $
27// $Name: geant4-09-04-beta-01 $
28//
29// ====================================================================
30//   Analysis.cc
31//
32//                                         2007 Q
33// ====================================================================
34#include "Analysis.hh"
35
36// ROOT headers
37#include "TROOT.h"
38#include "TFile.h"
39#include "TH1.h"
40#include "TH2.h"
41
42// ====================================================================
43//
44// class description
45//
46// ====================================================================
47
48Analysis* Analysis::myanalysis= 0;
49
50
51////////////////////
52Analysis::Analysis()
53////////////////////
54{
55  // ROOT style
56  gROOT->Reset();
57
58  // define histograms
59  incident_map = new TH2D("incident map", "Incident Distributuon",
60                          50, -5., 5.,
61                          50, -5., 5.);
62  incident_map-> GetXaxis()-> SetTitle("X (cm)");
63  incident_map-> GetYaxis()-> SetTitle("Y (cm)");
64  incident_map-> SetStats(0);
65
66  incident_x_hist = new TH1D("incident x", "Incident X", 100, -5., 5.);
67  incident_x_hist-> GetXaxis()-> SetTitle("X (cm)");
68  incident_x_hist-> SetFillColor(kRed);
69
70  dose_map = new TH2D("dose map", "Dose Distribution", 
71                      500, 0., 50.,
72                      200, -10., 10.);
73  dose_map-> GetXaxis()-> SetTitle("Z (cm)");
74  dose_map-> GetYaxis()-> SetTitle("X (cm)");
75  dose_map-> SetStats(0);
76
77  dose_hist = new TH1D("dose", "Dose Distribution", 500, 0., 50.);
78  dose_hist-> GetXaxis()-> SetTitle("Z (cm)");
79  dose_hist-> GetYaxis()-> SetTitle("Dose (GeV)");
80  dose_hist-> SetFillColor(kBlue);
81  dose_hist-> SetStats(0);
82
83}
84
85
86/////////////////////
87Analysis::~Analysis()
88/////////////////////
89{
90  delete incident_map;
91  delete incident_x_hist;
92  delete dose_map;
93  delete dose_hist;
94
95  myanalysis=0;
96}
97
98
99/////////////////////////////////
100Analysis* Analysis::GetAnalysis()
101/////////////////////////////////
102{
103  if (myanalysis == 0) {
104    myanalysis = new Analysis();
105  }
106
107  return myanalysis;
108}
109
110
111///////////////////////
112void Analysis::Update()
113///////////////////////
114{
115  return;
116}
117
118
119//////////////////////
120void Analysis::Clear()
121//////////////////////
122{
123  incident_map-> Reset();
124  incident_x_hist-> Reset();
125  dose_map-> Reset();
126  dose_hist-> Reset();
127
128  return;
129}
130
131
132//////////////////////////////////////////
133void Analysis::Save(const G4String& fname)
134//////////////////////////////////////////
135{
136  TFile* file = new TFile(fname.c_str(),
137                          "RECREATE", "Geant4 ROOT analysis");
138  incident_map-> Write();
139  incident_x_hist-> Write();
140  dose_map-> Write();
141  dose_hist-> Write();
142
143  file-> Close();
144
145  delete file;
146
147  return;
148}
149
150
151///////////////////////////////////////////////////
152void Analysis::FillIncident(const G4ThreeVector& p)
153///////////////////////////////////////////////////
154{
155  if(! incidentFlag) {
156    incident_map-> Fill(p.x()/cm, p.y()/cm);
157    incident_x_hist-> Fill(p.x()/cm);
158
159    incidentFlag= true;
160  }
161}
162
163
164//////////////////////////////////////////////////////////////
165void Analysis::FillDose(const G4ThreeVector& p, G4double dedx)
166//////////////////////////////////////////////////////////////
167{
168  const G4double Z0= 25.*cm;
169  const G4double dxy= 10.*mm;
170
171  if(std::abs(p.y()) < dxy ) {
172    dose_map-> Fill((p.z()+Z0)/cm, p.x()/cm, dedx/GeV);
173   
174    if(std::abs(p.x()) < dxy) {
175      dose_hist-> Fill((p.z()+Z0)/cm, dedx/GeV);
176    }
177  }
178}
179
Note: See TracBrowser for help on using the repository browser.