ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Analysis.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Analysis.cc
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 //
29 
30 #include "TFile.h"
31 #include "TH1.h"
32 #include "TH2.h"
33 #include "TROOT.h"
34 #include "G4SystemOfUnits.hh"
35 #include "Analysis.hh"
36 #include "G4AutoLock.hh"
37 
40 
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 {
46  if ( ! the_analysis ) the_analysis = new Analysis;
47  return the_analysis;
48 }
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 {
53  G4AutoLock l(&rootm);
54  // define histograms
55  fincident_map = new TH2D("incident map", "Incident Distributuon",
56  50, -5., 5.,
57  50, -5., 5.);
58  fincident_map-> GetXaxis()-> SetTitle("X (cm)");
59  fincident_map-> GetYaxis()-> SetTitle("Y (cm)");
61 
62  fincident_x_hist = new TH1D("incident x", "Incident X", 100, -5., 5.);
63  fincident_x_hist-> GetXaxis()-> SetTitle("X (cm)");
65 
66  fdose_map = new TH2D("dose map", "Dose Distribution",
67  500, 0., 50.,
68  200, -10., 10.);
69  fdose_map-> GetXaxis()-> SetTitle("Z (cm)");
70  fdose_map-> GetYaxis()-> SetTitle("X (cm)");
71  fdose_map-> SetStats(0);
72 
73  fdose_hist = new TH1D("dose", "Dose Distribution", 500, 0., 50.);
74  fdose_hist-> GetXaxis()-> SetTitle("Z (cm)");
75  fdose_hist-> GetYaxis()-> SetTitle("Dose (GeV)");
76  fdose_hist-> SetFillColor(kBlue);
77  fdose_hist-> SetStats(0);
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 {
83  delete fincident_map;
84  delete fincident_x_hist;
85  delete fdose_map;
86  delete fdose_hist;
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 {
92  return;
93 }
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
97 {
98  fincident_map-> Reset();
100  fdose_map-> Reset();
101  fdose_hist-> Reset();
102 
103  return;
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 {
109  G4AutoLock l(&rootm);
110  TFile* file = new TFile(fname.c_str(), "RECREATE", "Geant4 ROOT analysis");
111 
112  fincident_map-> Write();
113  fincident_x_hist-> Write();
114  fdose_map-> Write();
115  fdose_hist-> Write();
116 
117  file-> Close();
118 
119  delete file;
120 
121  return;
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126 {
127  if ( ! fincidentFlag ) {
128  fincident_map-> Fill(p.x()/cm, p.y()/cm);
129  fincident_x_hist-> Fill(p.x()/cm);
130 
131  fincidentFlag = true;
132  }
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137 {
138  const G4double Z0 = 25.*cm;
139  const G4double dxy = 10.*mm;
140 
141  if ( std::abs(p.y()) < dxy ) {
142  fdose_map-> Fill((p.z()+Z0)/cm, p.x()/cm, dedx/GeV);
143 
144  if ( std::abs(p.x()) < dxy ) {
145  fdose_hist-> Fill((p.z()+Z0)/cm, dedx/GeV);
146  }
147  }
148 }