Geant4-11
G4TScoreHistFiller.icc
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// class description:
27//
28// This class implements filling histogram
29// In order to avoid introducing dependency on the analysis category,
30// the analysis manager type is defined via template.
31//
32// Created : M. Asai (Sept. 2020)
33//
34//
35
36template <typename T>
37G4TScoreHistFiller<T>::G4TScoreHistFiller()
38{
39 ;
40}
41
42template <typename T>
43G4TScoreHistFiller<T>::~G4TScoreHistFiller()
44{
45}
46
47template <typename T>
48void G4TScoreHistFiller<T>::CreateAnalysisManager()
49{
50 // get/create analysis manager
51 fAnalysisManager = T::Instance();
52
53 fAnalysisManager->SetVerboseLevel(fVerboseLevel);
54}
55
56template <typename T>
57G4VScoreHistFiller* G4TScoreHistFiller<T>::CreateInstance() const
58{
59 auto instance = new G4TScoreHistFiller();
60 instance->SetVerboseLevel(fVerboseLevel);
61
62 return instance;
63}
64
65template <typename T>
66void G4TScoreHistFiller<T>::SetVerboseLevel(G4int value)
67{
68 fVerboseLevel = value;
69 if(fAnalysisManager)
70 {
71 fAnalysisManager->SetVerboseLevel(value);
72 }
73}
74
75template <typename T>
76void G4TScoreHistFiller<T>::FillH1(G4int id, G4double value, G4double weight)
77{
78 if(!fAnalysisManager)
79 {
80 CreateAnalysisManager();
81 }
82
83 if(!CheckH1(id))
84 {
85 G4ExceptionDescription description;
86 description << " "
87 << "Cannot fill histogram id=" << id
88 << ". Histogram is not defined.";
89 G4Exception("G4TScoreHistFiller<T>::FillH1", "Digits_hits_utils_001",
90 JustWarning, description);
91
92 return;
93 }
94
95 fAnalysisManager->FillH1(id, value, weight);
96
97#ifdef G4VERBOSE
98 if(fVerboseLevel > 1)
99 {
100 G4cout << "--- done G4TScoreHistFiller<T>::FillH1 : id = " << id << G4endl;
101 }
102#endif
103}
104
105template <typename T>
106void G4TScoreHistFiller<T>::FillH2(G4int id, G4double xvalue, G4double yvalue,
107 G4double weight)
108{
109 if(!fAnalysisManager)
110 {
111 CreateAnalysisManager();
112 }
113
114 if(!CheckH2(id))
115 {
116 G4ExceptionDescription description;
117 description << " "
118 << "Cannot fill histogram id=" << id
119 << ". Histogram is not defined.";
120 G4Exception("G4TScoreHistFiller<T>::FillH2", "Digits_hits_utils_001",
121 JustWarning, description);
122
123 return;
124 }
125
126 fAnalysisManager->FillH2(id, xvalue, yvalue, weight);
127
128#ifdef G4VERBOSE
129 if(fVerboseLevel > 1)
130 {
131 G4cout << "--- done G4TScoreHistFiller<T>::FillH2 : id = " << id << G4endl;
132 }
133#endif
134}
135
136template <typename T>
137void G4TScoreHistFiller<T>::FillH3(G4int id, G4double xvalue, G4double yvalue,
138 G4double zvalue, G4double weight)
139{
140 if(!fAnalysisManager)
141 {
142 CreateAnalysisManager();
143 }
144
145 if(!CheckH3(id))
146 {
147 G4ExceptionDescription description;
148 description << " "
149 << "Cannot fill histogram id=" << id
150 << ". Histogram is not defined.";
151 G4Exception("G4TScoreHistFiller<T>::FillH3", "Digits_hits_utils_001",
152 JustWarning, description);
153
154 return;
155 }
156
157 fAnalysisManager->FillH3(id, xvalue, yvalue, zvalue, weight);
158
159#ifdef G4VERBOSE
160 if(fVerboseLevel > 1)
161 {
162 G4cout << "--- done G4TScoreHistFiller<T>::FillH3 : id = " << id << G4endl;
163 }
164#endif
165}
166
167template <typename T>
168void G4TScoreHistFiller<T>::FillP1(G4int id, G4double xvalue, G4double yvalue,
169 G4double weight)
170{
171 if(!fAnalysisManager)
172 {
173 CreateAnalysisManager();
174 }
175
176 if(!CheckP1(id))
177 {
178 G4ExceptionDescription description;
179 description << " "
180 << "Cannot fill histogram id=" << id
181 << ". Histogram is not defined.";
182 G4Exception("G4TScoreHistFiller<T>::FillP1", "Digits_hits_utils_001",
183 JustWarning, description);
184
185 return;
186 }
187
188 fAnalysisManager->FillP1(id, xvalue, yvalue, weight);
189
190#ifdef G4VERBOSE
191 if(fVerboseLevel > 1)
192 {
193 G4cout << "--- done G4TScoreHistFiller<T>::FillP1 : id = " << id << G4endl;
194 }
195#endif
196}
197
198template <typename T>
199void G4TScoreHistFiller<T>::FillP2(G4int id, G4double xvalue, G4double yvalue,
200 G4double zvalue, G4double weight)
201{
202 if(!fAnalysisManager)
203 {
204 CreateAnalysisManager();
205 }
206
207 if(!CheckP2(id))
208 {
209 G4ExceptionDescription description;
210 description << " "
211 << "Cannot fill histogram id=" << id
212 << ". Histogram is not defined.";
213 G4Exception("G4TScoreHistFiller<T>::FillP2", "Digits_hits_utils_001",
214 JustWarning, description);
215
216 return;
217 }
218
219 fAnalysisManager->FillP2(id, xvalue, yvalue, zvalue, weight);
220
221#ifdef G4VERBOSE
222 if(fVerboseLevel > 1)
223 {
224 G4cout << "--- done G4TScoreHistFiller<T>::FillP2 : id = " << id << G4endl;
225 }
226#endif
227}
228
229template <typename T>
230G4bool G4TScoreHistFiller<T>::CheckH1(G4int id)
231{
232 return (fAnalysisManager->GetH1(id) != nullptr);
233}
234
235template <typename T>
236G4bool G4TScoreHistFiller<T>::CheckH2(G4int id)
237{
238 return (fAnalysisManager->GetH2(id) != nullptr);
239}
240
241template <typename T>
242G4bool G4TScoreHistFiller<T>::CheckH3(G4int id)
243{
244 return (fAnalysisManager->GetH3(id) != nullptr);
245}
246
247template <typename T>
248G4bool G4TScoreHistFiller<T>::CheckP1(G4int id)
249{
250 return (fAnalysisManager->GetP1(id) != nullptr);
251}
252
253template <typename T>
254G4bool G4TScoreHistFiller<T>::CheckP2(G4int id)
255{
256 return (fAnalysisManager->GetP2(id) != nullptr);
257}