Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4HnManager.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: G4HnManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
29 
30 #include "G4HnManager.hh"
31 #include "G4AnalysisUtilities.hh"
32 
33 using namespace G4Analysis;
34 
35 //_____________________________________________________________________________
37  const G4AnalysisManagerState& state)
38  : G4BaseAnalysisManager(state),
39  fHnType(hnType),
40  fNofActiveObjects(0),
41  fNofAsciiObjects(0),
42  fNofPlottingObjects(0),
43  fHnVector()
44 {
45 }
46 
47 //_____________________________________________________________________________
49 {
50  for ( auto hnInformation : fHnVector ) {
51  delete hnInformation;
52  }
53 }
54 
55 //
56 // public methods
57 //
58 
59 //_____________________________________________________________________________
61 {
62  auto hnInformation = new G4HnInformation(name, nofDimensions);
63  fHnVector.push_back(hnInformation);
65 
66  return hnInformation;
67 }
68 
69 //_____________________________________________________________________________
71  G4String functionName, G4bool warn) const
72 {
73  G4int index = id - fFirstId;
74  if ( index < 0 || index >= G4int(fHnVector.size()) ) {
75  if ( warn ) {
76  G4String inFunction = "G4HnManager::";
77  if ( functionName.size() )
78  inFunction += functionName;
79  else
80  inFunction += "GetHnInformation";
81  G4ExceptionDescription description;
82  description << " " << fHnType << " histogram " << id
83  << " does not exist.";
84  G4Exception(inFunction, "Analysis_W011", JustWarning, description);
85  }
86  return nullptr;
87  }
88  return fHnVector[index];
89 }
90 
91 //_____________________________________________________________________________
93  G4int dimension,
94  G4String functionName, G4bool warn) const
95 {
96  auto hnInformation = GetHnInformation(id, functionName, warn);
97  if ( ! hnInformation ) return nullptr;
98 
99  return hnInformation->GetHnDimensionInformation(dimension);
100 }
101 
102 //_____________________________________________________________________________
104 {
105  return ( fNofActiveObjects > 0 );
106 }
107 
108 //_____________________________________________________________________________
110 {
111  return ( fNofAsciiObjects > 0 );
112 }
113 
114 //_____________________________________________________________________________
116 {
117  return ( fNofPlottingObjects > 0 );
118 }
119 
120 //_____________________________________________________________________________
122 {
123 // Set activation to a given object
124 
125  auto info = GetHnInformation(id, "SetActivation");
126 
127  if ( ! info ) return;
128 
129  // Do nothing if activation does not change
130  if ( info->GetActivation() == activation ) return;
131 
132  // Change activation and account it in fNofActiveObjects
133  info->SetActivation(activation);
134  if ( activation )
136  else
138 }
139 
140 //_____________________________________________________________________________
142 {
143 // Set activation to all objects of the given type
144 
145  //std::vector<G4HnInformation*>::iterator it;
146  //for ( it = fHnVector.begin(); it != fHnVector.end(); it++ ) {
147  // G4HnInformation* info = *it;
148 
149  for ( auto info : fHnVector ) {
150 
151  // Do nothing if activation does not change
152  if ( info->GetActivation() == activation ) continue;
153 
154  // Change activation and account it in fNofActiveObjects
155  info->SetActivation(activation);
156  if ( activation )
158  else
160  }
161 }
162 
163 //_____________________________________________________________________________
165 {
166  auto info = GetHnInformation(id, "SetAscii");
167 
168  if ( ! info ) return;
169 
170  // Do nothing if ascii does not change
171  if ( info->GetAscii() == ascii ) return;
172 
173  // Change ascii and account it in fNofAsciiObjects
174  info->SetAscii(ascii);
175  if ( ascii )
177  else
178  fNofAsciiObjects--;
179 }
180 
181 //_____________________________________________________________________________
183 {
184  auto info = GetHnInformation(id, "SetPlotting");
185 
186  if ( ! info ) return;
187 
188  // Do nothing if ascii does not change
189  if ( info->GetPlotting() == plotting ) return;
190 
191  // Change Plotting and account it in fNofPlottingObjects
192  info->SetPlotting(plotting);
193  if ( plotting )
195  else
197 }
198 
199 //_____________________________________________________________________________
201 {
202 // Set plotting to all objects of the given type
203 
204  for ( auto info : fHnVector ) {
205 
206  // Do nothing if plotting does not change
207  if ( info->GetPlotting() == plotting ) continue;
208 
209  // Change plotting and account it in fNofActiveObjects
210  info->SetPlotting(plotting);
211  if ( plotting )
213  else
215  }
216 }
217 
218 //_____________________________________________________________________________
220 {
221  auto info = GetHnInformation(id, "GetName");
222 
223  if ( ! info ) return "";
224 
225  return info->GetName();
226 }
227 
228 //_____________________________________________________________________________
230 {
231  auto info = GetHnDimensionInformation(id, kX, "GetXUnit");
232 
233  if ( ! info ) return 1.0;
234 
235  return info->fUnit;
236 }
237 
238 //_____________________________________________________________________________
240 {
241  auto info = GetHnDimensionInformation(id, kY, "GetYUnit");
242 
243  if ( ! info ) return 1.0;
244 
245  return info->fUnit;
246 }
247 
248 //_____________________________________________________________________________
250 {
251  auto info = GetHnDimensionInformation(id, kZ, "GetZUnit");
252 
253  if ( ! info ) return 1.0;
254 
255  return info->fUnit;
256 }
257 
258 //_____________________________________________________________________________
260 {
261  auto info = GetHnInformation(id, "GetActivation");
262 
263  if ( ! info ) return true;
264 
265  return info->GetActivation();
266 }
267 
268 //_____________________________________________________________________________
270 {
271  auto info = GetHnInformation(id, "GetAscii");
272 
273  if ( ! info ) return false;
274 
275  return info->GetAscii();
276 }
277 
278 //_____________________________________________________________________________
280 {
281  auto info = GetHnInformation(id, "GetPlotting");
282 
283  if ( ! info ) return false;
284 
285  return info->GetPlotting();
286 }
const XML_Char XML_Encoding * info
Definition: expat.h:530
const XML_Char * name
Definition: expat.h:151
G4String GetName(G4int id) const
Definition: G4HnManager.cc:219
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
const G4int kX
void SetPlotting(G4bool plotting)
Definition: G4HnManager.cc:200
const G4int kY
G4bool IsPlotting() const
Definition: G4HnManager.cc:115
G4int fNofPlottingObjects
Definition: G4HnManager.hh:109
G4double GetZUnit(G4int id) const
Definition: G4HnManager.cc:249
G4double GetYUnit(G4int id) const
Definition: G4HnManager.cc:239
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
void SetActivation(G4bool activation)
Definition: G4HnManager.cc:141
void SetAscii(G4int id, G4bool ascii)
Definition: G4HnManager.cc:164
G4double GetXUnit(G4int id) const
Definition: G4HnManager.cc:229
G4HnManager(const G4String &hnType, const G4AnalysisManagerState &state)
Definition: G4HnManager.cc:36
G4HnInformation * GetHnInformation(G4int id, G4String functionName="", G4bool warn=true) const
Definition: G4HnManager.cc:70
G4bool GetActivation(G4int id) const
Definition: G4HnManager.cc:259
const G4int kZ
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
G4bool IsAscii() const
Definition: G4HnManager.cc:109
std::vector< G4HnInformation * > fHnVector
Definition: G4HnManager.hh:112
virtual ~G4HnManager()
Definition: G4HnManager.cc:48
G4int fNofActiveObjects
Definition: G4HnManager.hh:107
G4int fNofAsciiObjects
Definition: G4HnManager.hh:108
G4bool GetAscii(G4int id) const
Definition: G4HnManager.cc:269
G4bool GetPlotting(G4int id) const
Definition: G4HnManager.cc:279
G4HnDimensionInformation * GetHnDimensionInformation(G4int id, G4int dimension, G4String functionName="", G4bool warn=true) const
Definition: G4HnManager.cc:92
G4bool IsActive() const
Definition: G4HnManager.cc:103
G4HnInformation * AddHnInformation(const G4String &name, G4int nofDimensions)
Definition: G4HnManager.cc:60
G4String fHnType
Definition: G4HnManager.hh:106