2// ********************************************************************
3// * License and Disclaimer *
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. *
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. *
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// ********************************************************************
27#include "G4HnInformation.hh"
28#include "G4H1ToolsManager.hh"
29#include "G4H2ToolsManager.hh"
30#include "G4H3ToolsManager.hh"
31#include "G4P1ToolsManager.hh"
32#include "G4P2ToolsManager.hh"
34//_____________________________________________________________________________
37G4bool G4ToolsAnalysisManager::WriteT(const std::vector<HT*>& htVector,
38 const std::vector<G4HnInformation*>& hnVector)
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;
48 auto name = info->GetName();
49 auto ht = htVector[i];
51 auto fileName = info->GetFileName();
52 auto fileManager = GetFileManager(fileName);
54 // skip writing if cannot get file manager (wrong file extension)
55 if ( ! fileManager ) {
57 "Cannot get file manager for file " + fileName + ".\n" +
58 "Writing " + G4Analysis::GetHnType<HT>() + " " + name + " will be skipped.",
63 auto fileKind = " in file ";
64 if ( fileName != "" ) {
65 fileKind = " in extra file ";
67 fileName = fileManager->GetFullFileName();
70 Message(G4Analysis::kVL4, "write", G4Analysis::GetHnType<HT>(),
71 name + fileKind + fileName);
73 if ( ! fileManager->GetHnFileManager<HT>()->Write(ht, name, fileName) ) {
75 "Writing " + G4Analysis::GetHnType<HT>() + " " + name +
76 " to file " + fileName + " failed.",
81 // notify that file has a written object
82 fileManager->SetIsEmpty(fileName, false);
84 Message(G4Analysis::kVL3, "write", G4Analysis::GetHnType<HT>(),
85 name + " in the " + fileKind + " file " + fileName);
91//_____________________________________________________________________________
93tools::histo::h1d* G4ToolsAnalysisManager::GetH1(G4int id, G4bool warn,
94 G4bool onlyIfActive) const
96 return fH1Manager->GetH1(id, warn, onlyIfActive);
99//_____________________________________________________________________________
101tools::histo::h2d* G4ToolsAnalysisManager::GetH2(G4int id, G4bool warn,
102 G4bool onlyIfActive) const
104 return fH2Manager->GetH2(id, warn, onlyIfActive);
107//_____________________________________________________________________________
109tools::histo::h3d* G4ToolsAnalysisManager::GetH3(G4int id, G4bool warn,
110 G4bool onlyIfActive) const
112 return fH3Manager->GetH3(id, warn, onlyIfActive);
115//_____________________________________________________________________________
117tools::histo::p1d* G4ToolsAnalysisManager::GetP1(G4int id, G4bool warn,
118 G4bool onlyIfActive) const
120 return fP1Manager->GetP1(id, warn, onlyIfActive);
123//_____________________________________________________________________________
125tools::histo::p2d* G4ToolsAnalysisManager::GetP2(G4int id, G4bool warn,
126 G4bool onlyIfActive) const
128 return fP2Manager->GetP2(id, warn, onlyIfActive);
131//_____________________________________________________________________________
133std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::BeginH1()
135 return fH1Manager->BeginH1();
138//_____________________________________________________________________________
140std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::EndH1()
142 return fH1Manager->EndH1();
145//_____________________________________________________________________________
147std::vector<tools::histo::h1d*>::const_iterator
148G4ToolsAnalysisManager::BeginConstH1() const
150 return fH1Manager->BeginConstH1();
153//_____________________________________________________________________________
155std::vector<tools::histo::h1d*>::const_iterator
156G4ToolsAnalysisManager::EndConstH1() const
158 return fH1Manager->EndConstH1();
161//_____________________________________________________________________________
163std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::BeginH2()
165 return fH2Manager->BeginH2();
168//_____________________________________________________________________________
170std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::EndH2()
172 return fH2Manager->EndH2();
175//_____________________________________________________________________________
177std::vector<tools::histo::h2d*>::const_iterator
178G4ToolsAnalysisManager::BeginConstH2() const
180 return fH2Manager->BeginConstH2();
183//_____________________________________________________________________________
185std::vector<tools::histo::h2d*>::const_iterator
186G4ToolsAnalysisManager::EndConstH2() const
188 return fH2Manager->EndConstH2();
191//_____________________________________________________________________________
193std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::BeginH3()
195 return fH3Manager->BeginH3();
198//_____________________________________________________________________________
200std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::EndH3()
202 return fH3Manager->EndH3();
205//_____________________________________________________________________________
207std::vector<tools::histo::h3d*>::const_iterator
208G4ToolsAnalysisManager::BeginConstH3() const
210 return fH3Manager->BeginConstH3();
213//_____________________________________________________________________________
215std::vector<tools::histo::h3d*>::const_iterator
216G4ToolsAnalysisManager::EndConstH3() const
218 return fH3Manager->EndConstH3();
221//_____________________________________________________________________________
223std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::BeginP1()
225 return fP1Manager->BeginP1();
228//_____________________________________________________________________________
230std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::EndP1()
232 return fP1Manager->EndP1();
235//_____________________________________________________________________________
237std::vector<tools::histo::p1d*>::const_iterator
238G4ToolsAnalysisManager::BeginConstP1() const
240 return fP1Manager->BeginConstP1();
243//_____________________________________________________________________________
245std::vector<tools::histo::p1d*>::const_iterator
246G4ToolsAnalysisManager::EndConstP1() const
248 return fP1Manager->EndConstP1();
251//_____________________________________________________________________________
253std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::BeginP2()
255 return fP2Manager->BeginP2();
258//_____________________________________________________________________________
260std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::EndP2()
262 return fP2Manager->EndP2();
265//_____________________________________________________________________________
267std::vector<tools::histo::p2d*>::const_iterator
268G4ToolsAnalysisManager::BeginConstP2() const
270 return fP2Manager->BeginConstP2();
273//_____________________________________________________________________________
275std::vector<tools::histo::p2d*>::const_iterator
276G4ToolsAnalysisManager::EndConstP2() const
278 return fP2Manager->EndConstP2();