Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ToolsAnalysisManager.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 // $Id: G4ToolsAnalysisManager.cc 91116 2015-06-20 12:33:45Z ihrivnac $
27 
28 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
29 
31 #include "G4H1ToolsManager.hh"
32 #include "G4H2ToolsManager.hh"
33 #include "G4H3ToolsManager.hh"
34 #include "G4P1ToolsManager.hh"
35 #include "G4P2ToolsManager.hh"
36 #include "G4PlotManager.hh"
37 #include "G4MPIToolsManager.hh"
38 
39 //_____________________________________________________________________________
41  : G4VAnalysisManager(type, isMaster),
42  fH1Manager(nullptr),
43  fH2Manager(nullptr),
44  fH3Manager(nullptr),
45  fP1Manager(nullptr),
46  fP2Manager(nullptr)
47 {
48  // Create managers
54  // The managers will be deleted by the base class
55 
56  // Set managers to base class which takes then their ownership
62 }
63 
64 //_____________________________________________________________________________
66 {}
67 
68 //
69 // protected methods
70 //
71 
72 //_____________________________________________________________________________
74 {
75 
76  // Only master thread performs plotting
77  if ( G4Threading::IsWorkerThread() ) return true;
78 
79  auto finalResult = true;
80 
81  // Create plotter
82  G4PlotManager plotManager(fState);
83  plotManager.OpenFile(fVFileManager->GetPlotFileName());
84 
85  // H1
86  auto result
89  finalResult = finalResult && result;
90 
91  // H2
92  result
93  = plotManager.PlotAndWrite<tools::histo::h2d>(fH2Manager->GetH2Vector(),
95  finalResult = finalResult && result;
96 
97  // H3
98  // not yet available in tools
99 
100  // P1
101  result
102  = plotManager.PlotAndWrite<tools::histo::p1d>(fP1Manager->GetP1Vector(),
104  finalResult = finalResult && result;
105 
106  // P2
107  // not yet available in tools
108 
109  result = plotManager.CloseFile();
110  finalResult = finalResult && result;
111 
112  return finalResult;
113 }
114 
115 //_____________________________________________________________________________
116 G4bool G4ToolsAnalysisManager::MergeImpl(tools::histo::hmpi* hmpi)
117 {
118 
119  // if ( G4Threading::IsWorkerThread() ) return true;
120 
121  if ( ! hmpi ) return false;
122 
123  G4bool finalResult = true;
124 
125  // Create MPI manager
126  G4MPIToolsManager mpiToolsManager(fState, hmpi);
127 
128  // H1
129  G4bool result
130  = mpiToolsManager.Merge<tools::histo::h1d>(fH1Manager->GetH1Vector(),
132  finalResult = finalResult && result;
133 
134  // H2
135  result
136  = mpiToolsManager.Merge<tools::histo::h2d>(fH2Manager->GetH2Vector(),
138  finalResult = finalResult && result;
139 
140  // H3
141  result
142  = mpiToolsManager.Merge<tools::histo::h3d>(fH3Manager->GetH3Vector(),
144  finalResult = finalResult && result;
145 
146  // P1
147  result
148  = mpiToolsManager.Merge<tools::histo::p1d>(fP1Manager->GetP1Vector(),
150  finalResult = finalResult && result;
151 
152  // P2
153  result
154  = mpiToolsManager.Merge<tools::histo::p2d>(fP2Manager->GetP2Vector(),
156  finalResult = finalResult && result;
157 
158  return finalResult;
159 }
160 
161 //_____________________________________________________________________________
163 {
164 // Reset histograms and profiles
165 
166  auto finalResult = true;
167 
168  auto result = fH1Manager->Reset();
169  finalResult = finalResult && result;
170 
171  result = fH2Manager->Reset();
172  finalResult = finalResult && result;
173 
174  result = fH3Manager->Reset();
175  finalResult = finalResult && result;
176 
177  result = fP1Manager->Reset();
178  finalResult = finalResult && result;
179 
180  result = fP2Manager->Reset();
181  finalResult = finalResult && result;
182 
183  return finalResult;
184 }
185 
186 
const std::vector< tools::histo::p2d * > & GetP2Vector() const
G4bool Reset()
G4bool CloseFile()
virtual G4bool PlotImpl() final
void SetH1Manager(G4VH1Manager *h1Manager)
G4bool OpenFile(const G4String &fileName)
void SetH3Manager(G4VH3Manager *h3Manager)
G4bool Merge(const std::vector< T * > &htVector, const std::vector< G4HnInformation * > &hnVector)
TH1D * h1d
const std::vector< tools::histo::h1d * > & GetH1Vector() const
const std::vector< tools::histo::h3d * > & GetH3Vector() const
bool G4bool
Definition: G4Types.hh:79
const std::vector< G4HnInformation * > & GetHnVector() const
G4AnalysisManagerState fState
void SetH2Manager(G4VH2Manager *h2Manager)
const std::vector< G4HnInformation * > & GetHnVector() const
G4bool IsWorkerThread()
Definition: G4Threading.cc:129
std::shared_ptr< G4VFileManager > fVFileManager
const std::vector< G4HnInformation * > & GetHnVector() const
const std::vector< G4HnInformation * > & GetHnVector() const
G4double G4ParticleHPJENDLHEData::G4double result
const std::vector< tools::histo::h2d * > & GetH2Vector() const
G4ToolsAnalysisManager(const G4String &type, G4bool isMaster=true)
const std::vector< tools::histo::p1d * > & GetP1Vector() const
void SetP2Manager(G4VP2Manager *p2Manager)
const std::vector< G4HnInformation * > & GetHnVector() const
void SetP1Manager(G4VP1Manager *p1Manager)
G4bool PlotAndWrite(const std::vector< T * > &htVector, const std::vector< G4HnInformation * > &hnVector)
virtual G4bool MergeImpl(tools::histo::hmpi *hmpi) final