Geant4-11
G4ToolsAnalysisManager.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
27#include "G4HnInformation.hh"
28#include "G4H1ToolsManager.hh"
29#include "G4H2ToolsManager.hh"
30#include "G4H3ToolsManager.hh"
31#include "G4P1ToolsManager.hh"
32#include "G4P2ToolsManager.hh"
33
34//_____________________________________________________________________________
35template <typename HT>
36inline
37G4bool G4ToolsAnalysisManager::WriteT(const std::vector<HT*>& htVector,
38 const std::vector<G4HnInformation*>& hnVector)
39{
40 auto result = true;
41
42 for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
43 auto info = hnVector[i];
44 auto activation = info->GetActivation();
45 // skip writing if activation is enabled and H1 is inactivated
46 if ( fState.GetIsActivation() && ( ! activation ) ) continue;
47
48 auto name = info->GetName();
49 auto ht = htVector[i];
50
51 auto fileName = info->GetFileName();
52 auto fileManager = GetFileManager(fileName);
53
54 // skip writing if cannot get file manager (wrong file extension)
55 if ( ! fileManager ) {
56 G4Analysis::Warn(
57 "Cannot get file manager for file " + fileName + ".\n" +
58 "Writing " + G4Analysis::GetHnType<HT>() + " " + name + " will be skipped.",
59 fkClass, "WriteT");
60 continue;
61 }
62
63 auto fileKind = " in file ";
64 if ( fileName != "" ) {
65 fileKind = " in extra file ";
66 } else {
67 fileName = fileManager->GetFullFileName();
68 }
69
70 Message(G4Analysis::kVL4, "write", G4Analysis::GetHnType<HT>(),
71 name + fileKind + fileName);
72
73 if ( ! fileManager->GetHnFileManager<HT>()->Write(ht, name, fileName) ) {
74 G4Analysis::Warn(
75 "Writing " + G4Analysis::GetHnType<HT>() + " " + name +
76 " to file " + fileName + " failed.",
77 fkClass, "WriteT");
78 result = false;
79 }
80
81 // notify that file has a written object
82 fileManager->SetIsEmpty(fileName, false);
83
84 Message(G4Analysis::kVL3, "write", G4Analysis::GetHnType<HT>(),
85 name + " in the " + fileKind + " file " + fileName);
86 }
87
88 return result;
89}
90
91//_____________________________________________________________________________
92inline
93tools::histo::h1d* G4ToolsAnalysisManager::GetH1(G4int id, G4bool warn,
94 G4bool onlyIfActive) const
95{
96 return fH1Manager->GetH1(id, warn, onlyIfActive);
97}
98
99//_____________________________________________________________________________
100inline
101tools::histo::h2d* G4ToolsAnalysisManager::GetH2(G4int id, G4bool warn,
102 G4bool onlyIfActive) const
103{
104 return fH2Manager->GetH2(id, warn, onlyIfActive);
105}
106
107//_____________________________________________________________________________
108inline
109tools::histo::h3d* G4ToolsAnalysisManager::GetH3(G4int id, G4bool warn,
110 G4bool onlyIfActive) const
111{
112 return fH3Manager->GetH3(id, warn, onlyIfActive);
113}
114
115//_____________________________________________________________________________
116inline
117tools::histo::p1d* G4ToolsAnalysisManager::GetP1(G4int id, G4bool warn,
118 G4bool onlyIfActive) const
119{
120 return fP1Manager->GetP1(id, warn, onlyIfActive);
121}
122
123//_____________________________________________________________________________
124inline
125tools::histo::p2d* G4ToolsAnalysisManager::GetP2(G4int id, G4bool warn,
126 G4bool onlyIfActive) const
127{
128 return fP2Manager->GetP2(id, warn, onlyIfActive);
129}
130
131//_____________________________________________________________________________
132inline
133std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::BeginH1()
134{
135 return fH1Manager->BeginH1();
136}
137
138//_____________________________________________________________________________
139inline
140std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::EndH1()
141{
142 return fH1Manager->EndH1();
143}
144
145//_____________________________________________________________________________
146inline
147std::vector<tools::histo::h1d*>::const_iterator
148G4ToolsAnalysisManager::BeginConstH1() const
149{
150 return fH1Manager->BeginConstH1();
151}
152
153//_____________________________________________________________________________
154inline
155std::vector<tools::histo::h1d*>::const_iterator
156G4ToolsAnalysisManager::EndConstH1() const
157{
158 return fH1Manager->EndConstH1();
159}
160
161//_____________________________________________________________________________
162inline
163std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::BeginH2()
164{
165 return fH2Manager->BeginH2();
166}
167
168//_____________________________________________________________________________
169inline
170std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::EndH2()
171{
172 return fH2Manager->EndH2();
173}
174
175//_____________________________________________________________________________
176inline
177std::vector<tools::histo::h2d*>::const_iterator
178G4ToolsAnalysisManager::BeginConstH2() const
179{
180 return fH2Manager->BeginConstH2();
181}
182
183//_____________________________________________________________________________
184inline
185std::vector<tools::histo::h2d*>::const_iterator
186G4ToolsAnalysisManager::EndConstH2() const
187{
188 return fH2Manager->EndConstH2();
189}
190
191//_____________________________________________________________________________
192inline
193std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::BeginH3()
194{
195 return fH3Manager->BeginH3();
196}
197
198//_____________________________________________________________________________
199inline
200std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::EndH3()
201{
202 return fH3Manager->EndH3();
203}
204
205//_____________________________________________________________________________
206inline
207std::vector<tools::histo::h3d*>::const_iterator
208G4ToolsAnalysisManager::BeginConstH3() const
209{
210 return fH3Manager->BeginConstH3();
211}
212
213//_____________________________________________________________________________
214inline
215std::vector<tools::histo::h3d*>::const_iterator
216G4ToolsAnalysisManager::EndConstH3() const
217{
218 return fH3Manager->EndConstH3();
219}
220
221//_____________________________________________________________________________
222inline
223std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::BeginP1()
224{
225 return fP1Manager->BeginP1();
226}
227
228//_____________________________________________________________________________
229inline
230std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::EndP1()
231{
232 return fP1Manager->EndP1();
233}
234
235//_____________________________________________________________________________
236inline
237std::vector<tools::histo::p1d*>::const_iterator
238G4ToolsAnalysisManager::BeginConstP1() const
239{
240 return fP1Manager->BeginConstP1();
241}
242
243//_____________________________________________________________________________
244inline
245std::vector<tools::histo::p1d*>::const_iterator
246G4ToolsAnalysisManager::EndConstP1() const
247{
248 return fP1Manager->EndConstP1();
249}
250
251//_____________________________________________________________________________
252inline
253std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::BeginP2()
254{
255 return fP2Manager->BeginP2();
256}
257
258//_____________________________________________________________________________
259inline
260std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::EndP2()
261{
262 return fP2Manager->EndP2();
263}
264
265//_____________________________________________________________________________
266inline
267std::vector<tools::histo::p2d*>::const_iterator
268G4ToolsAnalysisManager::BeginConstP2() const
269{
270 return fP2Manager->BeginConstP2();
271}
272
273//_____________________________________________________________________________
274inline
275std::vector<tools::histo::p2d*>::const_iterator
276G4ToolsAnalysisManager::EndConstP2() const
277{
278 return fP2Manager->EndConstP2();
279}
280