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 | // |
---|
27 | // $Id: TiaraCellScorer.cc,v 1.5 2006/06/29 15:44:37 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // ---------------------------------------------------------------------- |
---|
31 | // GEANT 4 class source file |
---|
32 | // |
---|
33 | // TiaraCellScorer.cc |
---|
34 | // |
---|
35 | // ---------------------------------------------------------------------- |
---|
36 | |
---|
37 | #include <cmath> |
---|
38 | #include "TiaraCellScorer.hh" |
---|
39 | #include "G4GeometryCell.hh" |
---|
40 | #include "G4Step.hh" |
---|
41 | #include "G4StepPoint.hh" |
---|
42 | #include "G4CellScoreValues.hh" |
---|
43 | #include "Randomize.hh" |
---|
44 | |
---|
45 | #ifdef G4ANALYSIS_USE |
---|
46 | TiaraCellScorer::TiaraCellScorer(AIDA::IHistogramFactory *hf, |
---|
47 | const G4String &histBaseName, |
---|
48 | const std::vector<double> |
---|
49 | &binEdgesScinti, |
---|
50 | const std::vector<double> |
---|
51 | &binEdgesBonner, |
---|
52 | const TiaraTally &tally) : |
---|
53 | fBaseName(histBaseName), |
---|
54 | // fEnergyHisto(hf->createHistogram1D(histBaseName, |
---|
55 | // histBaseName + ": flux vs. energy", |
---|
56 | // binEdgesScinti)), |
---|
57 | //fEnergyFluxHisto(hf->createHistogram1D(histBaseName + "Eflux", |
---|
58 | // histBaseName + ": energy flux vs. energy", |
---|
59 | // binEdgesScinti)), |
---|
60 | |
---|
61 | //fEnergyHistoBonner(hf->createHistogram1D(histBaseName + "Bonner", |
---|
62 | // histBaseName + ": flux vs. energy", |
---|
63 | // binEdgesBonner)), |
---|
64 | //fEnergyFluxHistoBonner(hf->createHistogram1D(histBaseName + "BonnerEflux", |
---|
65 | // histBaseName + ": energy flux vs. energy", |
---|
66 | // binEdgesBonner)), |
---|
67 | |
---|
68 | fTally(tally) |
---|
69 | { |
---|
70 | //G4cout << "porca troia" << G4endl; |
---|
71 | G4cout << hf << " hf in G4" << G4endl; |
---|
72 | fEnergyHisto = hf->createHistogram1D(histBaseName, |
---|
73 | histBaseName + ": flux vs. energy", |
---|
74 | binEdgesScinti); |
---|
75 | fEnergyFluxHisto = hf->createHistogram1D(histBaseName + "Eflux", |
---|
76 | histBaseName + ": energy flux vs. energy", |
---|
77 | binEdgesScinti); |
---|
78 | fEnergyHistoBonner = hf->createHistogram1D(histBaseName + "Bonner", |
---|
79 | histBaseName + ": flux vs. energy", |
---|
80 | binEdgesBonner); |
---|
81 | fEnergyFluxHistoBonner = hf->createHistogram1D(histBaseName + "BonnerEflux", |
---|
82 | histBaseName + ": energy flux vs. energy", |
---|
83 | binEdgesBonner); |
---|
84 | } |
---|
85 | #else |
---|
86 | TiaraCellScorer::TiaraCellScorer(const G4String &histBaseName, |
---|
87 | const TiaraTally &tally) : |
---|
88 | fBaseName(histBaseName), |
---|
89 | fTally(tally) |
---|
90 | {} |
---|
91 | #endif |
---|
92 | |
---|
93 | |
---|
94 | TiaraCellScorer::~TiaraCellScorer() |
---|
95 | {} |
---|
96 | |
---|
97 | void TiaraCellScorer::ScoreAnExitingStep(const G4Step &aStep, |
---|
98 | const G4GeometryCell &pre_gCell){ |
---|
99 | fG4CellScorer.ScoreAnExitingStep(aStep, pre_gCell); |
---|
100 | FillHisto(aStep); |
---|
101 | } |
---|
102 | |
---|
103 | void TiaraCellScorer::ScoreAnEnteringStep(const G4Step &aStep, |
---|
104 | const G4GeometryCell &post_gCell){ |
---|
105 | fG4CellScorer.ScoreAnEnteringStep(aStep, post_gCell); |
---|
106 | return; |
---|
107 | } |
---|
108 | |
---|
109 | void TiaraCellScorer::ScoreAnInVolumeStep(const G4Step &aStep, |
---|
110 | const G4GeometryCell &post_gCell){ |
---|
111 | fG4CellScorer.ScoreAnInVolumeStep(aStep, post_gCell); |
---|
112 | FillHisto(aStep); |
---|
113 | } |
---|
114 | |
---|
115 | void TiaraCellScorer::FillHisto(const G4Step &aStep){ |
---|
116 | |
---|
117 | G4StepPoint *p = 0; |
---|
118 | p = aStep.GetPreStepPoint(); |
---|
119 | |
---|
120 | G4double sl = aStep.GetStepLength() / cm; |
---|
121 | G4double w = p->GetWeight(); |
---|
122 | G4double slw = sl * w; |
---|
123 | |
---|
124 | G4double e(p->GetKineticEnergy()); |
---|
125 | |
---|
126 | #ifdef G4ANALYSIS_USE |
---|
127 | fEnergyHisto->fill(e, slw); |
---|
128 | fEnergyFluxHisto->fill(e, slw*e); |
---|
129 | fEnergyHistoBonner->fill(e/eV, slw); |
---|
130 | fEnergyFluxHistoBonner->fill(e/eV, slw*e/eV); |
---|
131 | #else |
---|
132 | G4cout << fBaseName << ": Energy: " << e << ", sl*w: " << slw << "\n"; |
---|
133 | #endif |
---|
134 | |
---|
135 | fTally.fill(e, slw); |
---|
136 | |
---|
137 | } |
---|
138 | |
---|
139 | void TiaraCellScorer::EndOfEventAction() { |
---|
140 | #ifndef G4ANALYSIS_USE |
---|
141 | G4cout << fBaseName << ": end of event" << G4endl; |
---|
142 | #endif |
---|
143 | fTally.EndOfEventAction(); |
---|
144 | } |
---|
145 | |
---|
146 | const TiaraTally &TiaraCellScorer::GetTally() const { |
---|
147 | return fTally; |
---|
148 | } |
---|
149 | |
---|