Geant4  10.03
G4VAnalysisManager.cc
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 // $Id: G4VAnalysisManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Author: Ivana Hrivnacova, 09/07/2013 (ivana@ipno.in2p3.fr)
29 
30 #include "G4VAnalysisManager.hh"
31 #include "G4AnalysisMessenger.hh"
32 #include "G4AnalysisUtilities.hh"
33 #include "G4HnManager.hh"
34 #include "G4VH1Manager.hh"
35 #include "G4VH2Manager.hh"
36 #include "G4VH3Manager.hh"
37 #include "G4VP1Manager.hh"
38 #include "G4VP2Manager.hh"
39 #include "G4VNtupleManager.hh"
40 #include "G4VFileManager.hh"
41 
42 #include <iostream>
43 
44 using namespace G4Analysis;
45 
46 //_____________________________________________________________________________
48  : fState(type, isMaster),
49  fVFileManager(nullptr),
50  fMessenger(G4Analysis::make_unique<G4AnalysisMessenger>(this)),
51  fH1HnManager(nullptr),
52  fH2HnManager(nullptr),
53  fH3HnManager(nullptr),
54  fP1HnManager(nullptr),
55  fP2HnManager(nullptr),
56  fVH1Manager(nullptr),
57  fVH2Manager(nullptr),
58  fVH3Manager(nullptr),
59  fVP1Manager(nullptr),
60  fVP2Manager(nullptr),
61  fVNtupleManager(nullptr)
62 {
63  //fMessenger = G4Analysis::make_unique<G4AnalysisMessenger>(this);
64 }
65 
66 //_____________________________________________________________________________
68 {
69  delete fVNtupleManager;
70 }
71 
72 //
73 // protected methods
74 //
75 
76 //_____________________________________________________________________________
78 {
79  fVH1Manager.reset(h1Manager);
80  fH1HnManager = h1Manager->GetHnManager();
81  fMessenger->SetH1HnManager(*fH1HnManager);
82 }
83 
84 //_____________________________________________________________________________
86 {
87  fVH2Manager.reset(h2Manager);
88  fH2HnManager = h2Manager->GetHnManager();
89  fMessenger->SetH2HnManager(*fH2HnManager);
90 }
91 
92 //_____________________________________________________________________________
94 {
95  fVH3Manager.reset(h3Manager);
96  fH3HnManager = h3Manager->GetHnManager();
97  fMessenger->SetH3HnManager(*fH3HnManager);
98 }
99 
100 //_____________________________________________________________________________
102 {
103  fVP1Manager.reset(p1Manager);
104  fP1HnManager = p1Manager->GetHnManager();
105  fMessenger->SetP1HnManager(*fP1HnManager);
106 }
107 
108 //_____________________________________________________________________________
110 {
111  fVP2Manager.reset(p2Manager);
112  fP2HnManager = p2Manager->GetHnManager();
113  fMessenger->SetP2HnManager(*fP2HnManager);
114 }
115 
116 //_____________________________________________________________________________
118 {
119  // fVNtupleManager.reset(ntupleManager);
120  fVNtupleManager = ntupleManager;
121 }
122 
123 //_____________________________________________________________________________
124 void G4VAnalysisManager::SetFileManager(std::shared_ptr<G4VFileManager> fileManager)
125 {
126  fVFileManager = fileManager;
127 }
128 
129 //_____________________________________________________________________________
131 {
132  G4bool finalResult = true;
133 
134  // Replace or add file extension .ascii
135  G4String name(fileName);
136  if ( name.find(".") != std::string::npos ) {
137  name.erase(name.find("."), name.length());
138  }
139  name.append(".ascii");
140 
141 #ifdef G4VERBOSE
142  if ( fState.GetVerboseL3() )
143  fState.GetVerboseL3()->Message("write ASCII", "file", name);
144 #endif
145 
146  std::ofstream output(name, std::ios::out);
147  if ( ! output ) {
148  G4ExceptionDescription description;
149  description
150  << "Cannot open file. File name is not defined.";
151  G4Exception("G4VAnalysisManager::WriteAscii()",
152  "Analysis_W001", JustWarning, description);
153  return false;
154  }
155  output.setf( std::ios::scientific, std::ios::floatfield );
156 
157  G4bool result = fVH1Manager->WriteOnAscii(output);
158  finalResult = finalResult && result;
159 
160  result = fVH2Manager->WriteOnAscii(output);
161  finalResult = finalResult && result;
162 
163  result = fVH3Manager->WriteOnAscii(output);
164  finalResult = finalResult && result;
165 
166  //result = fVP1Manager->WriteOnAscii(output);
167  //finalResult = finalResult && result;
168 
169  //result = fVP2Manager->WriteOnAscii(output);
170  //finalResult = finalResult && result;
171 
172 #ifdef G4VERBOSE
173  if ( fState.GetVerboseL1() )
174  fState.GetVerboseL1()->Message("write ASCII", "file", name, result);
175 #endif
176 
177  return finalResult;
178 }
179 
180 //
181 // public methods
182 //
183 
184 //_____________________________________________________________________________
186 {
187  if ( fileName != "" ) {
188  return OpenFileImpl(fileName);
189  }
190  else {
191  if ( fVFileManager->GetFileName() == "" ) {
192  G4ExceptionDescription description;
193  description
194  << "Cannot open file. File name is not defined.";
195  G4Exception("G4VFileManager::OpenFile()",
196  "Analysis_W001", JustWarning, description);
197  return false;
198  }
199  return OpenFileImpl(fVFileManager->GetFileName());
200  }
201 }
202 
203 //_____________________________________________________________________________
205 {
206  G4bool finalResult = true;
207 
208  G4bool result = WriteImpl();
209  finalResult = finalResult && result;
210 
211  if ( IsPlotting() ) {
212  result = PlotImpl();
213  finalResult = finalResult && result;
214  }
215 
216  return finalResult;
217 }
218 
219 //_____________________________________________________________________________
221 {
222  return CloseFileImpl();
223 }
224 
225 //_____________________________________________________________________________
226 G4bool G4VAnalysisManager::Merge(tools::histo::hmpi* hmpi)
227 {
228  return MergeImpl(hmpi);
229 }
230 
231 //_____________________________________________________________________________
233 {
234  return PlotImpl();
235 }
236 
237 //_____________________________________________________________________________
239 {
240  return IsOpenFileImpl();
241 }
242 
243 //_____________________________________________________________________________
245 {
246  return fVFileManager->SetFileName(fileName);
247 }
248 
249 //_____________________________________________________________________________
251 {
252  return fVFileManager->SetHistoDirectoryName(dirName);
253 }
254 
255 //_____________________________________________________________________________
257 {
258  return fVFileManager->SetNtupleDirectoryName(dirName);
259 }
260 
261 //_____________________________________________________________________________
263 {
265 }
266 
267 //_____________________________________________________________________________
269 {
270  return fVFileManager->GetFileName();
271 }
272 
273 //_____________________________________________________________________________
275 {
276  return fVFileManager->GetHistoDirectoryName();
277 }
278 
279 //_____________________________________________________________________________
281 {
282  return fVFileManager->GetNtupleDirectoryName();
283 }
284 
285 //_____________________________________________________________________________
287 {
288  return fState.GetCompressionLevel();
289 }
290 
291 //_____________________________________________________________________________
293  G4int nbins, G4double xmin, G4double xmax,
294  const G4String& unitName, const G4String& fcnName,
295  const G4String& binSchemeName)
296 {
297  if ( ! CheckName(name, "H1") ) return kInvalidId;
298  if ( ! CheckNbins(nbins) ) return kInvalidId;
299  if ( ! CheckMinMax(xmin, xmax, fcnName, binSchemeName) ) return kInvalidId;
300 
301  return fVH1Manager->CreateH1(name, title, nbins, xmin, xmax,
302  unitName, fcnName, binSchemeName);
303 }
304 
305 //_____________________________________________________________________________
307  const std::vector<G4double>& edges,
308  const G4String& unitName, const G4String& fcnName)
309 {
310  if ( ! CheckName(name, "H1") ) return kInvalidId;
311  if ( ! CheckEdges(edges) ) return kInvalidId;
312 
313  return fVH1Manager->CreateH1(name, title, edges, unitName, fcnName);
314 }
315 
316 //_____________________________________________________________________________
318  G4int nxbins, G4double xmin, G4double xmax,
319  G4int nybins, G4double ymin, G4double ymax,
320  const G4String& xunitName, const G4String& yunitName,
321  const G4String& xfcnName, const G4String& yfcnName,
322  const G4String& xbinSchemeName,
323  const G4String& ybinSchemeName)
324 
325 {
326  if ( ! CheckName(name, "H2") ) return kInvalidId;
327 
328  if ( ! CheckNbins(nxbins) ) return kInvalidId;
329  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
330 
331  if ( ! CheckNbins(nybins) ) return kInvalidId;
332  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
333 
334  return fVH2Manager->CreateH2(name, title,
335  nxbins, xmin, xmax, nybins, ymin, ymax,
336  xunitName, yunitName, xfcnName, yfcnName,
337  xbinSchemeName, ybinSchemeName);
338 }
339 
340 //_____________________________________________________________________________
342  const std::vector<G4double>& xedges,
343  const std::vector<G4double>& yedges,
344  const G4String& xunitName, const G4String& yunitName,
345  const G4String& xfcnName, const G4String& yfcnName)
346 
347 {
348  if ( ! CheckName(name, "H2") ) return kInvalidId;
349 
350  if ( ! CheckEdges(xedges) ) return kInvalidId;
351  if ( ! CheckEdges(yedges) ) return kInvalidId;
352 
353  return fVH2Manager->CreateH2(name, title,
354  xedges, yedges,
355  xunitName, yunitName, xfcnName, yfcnName);
356 }
357 
358 //_____________________________________________________________________________
360  G4int nxbins, G4double xmin, G4double xmax,
361  G4int nybins, G4double ymin, G4double ymax,
362  G4int nzbins, G4double zmin, G4double zmax,
363  const G4String& xunitName, const G4String& yunitName,
364  const G4String& zunitName,
365  const G4String& xfcnName, const G4String& yfcnName,
366  const G4String& zfcnName,
367  const G4String& xbinSchemeName,
368  const G4String& ybinSchemeName,
369  const G4String& zbinSchemeName)
370 
371 {
372  if ( ! CheckName(name, "H3") ) return kInvalidId;
373 
374  if ( ! CheckNbins(nxbins) ) return kInvalidId;
375  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
376 
377  if ( ! CheckNbins(nybins) ) return kInvalidId;
378  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
379 
380  if ( ! CheckNbins(nzbins) ) return kInvalidId;
381  if ( ! CheckMinMax(zmin, zmax, zfcnName, zbinSchemeName) ) return kInvalidId;
382 
383  return fVH3Manager->CreateH3(name, title,
384  nxbins, xmin, xmax, nybins, ymin, ymax,
385  nzbins, zmin, zmax,
386  xunitName, yunitName, zunitName,
387  xfcnName, yfcnName, zfcnName,
388  xbinSchemeName, ybinSchemeName, zbinSchemeName);
389 }
390 
391 //_____________________________________________________________________________
393  const std::vector<G4double>& xedges,
394  const std::vector<G4double>& yedges,
395  const std::vector<G4double>& zedges,
396  const G4String& xunitName, const G4String& yunitName,
397  const G4String& zunitName,
398  const G4String& xfcnName, const G4String& yfcnName,
399  const G4String& zfcnName)
400 
401 {
402  if ( ! CheckName(name, "H3") ) return kInvalidId;
403 
404  if ( ! CheckEdges(xedges) ) return kInvalidId;
405  if ( ! CheckEdges(yedges) ) return kInvalidId;
406  if ( ! CheckEdges(zedges) ) return kInvalidId;
407 
408  return fVH3Manager->CreateH3(name, title,
409  xedges, yedges, zedges,
410  xunitName, yunitName, zunitName,
411  xfcnName, yfcnName, zfcnName);
412 }
413 
414 //_____________________________________________________________________________
416  G4int nbins, G4double xmin, G4double xmax,
417  const G4String& unitName, const G4String& fcnName,
418  const G4String& binSchemeName)
419 {
420  if ( ! CheckNbins(nbins) ) return kInvalidId;
421  if ( ! CheckMinMax(xmin, xmax, fcnName, binSchemeName) ) return kInvalidId;
422 
423  return fVH1Manager->SetH1(id, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
424 }
425 
426 //_____________________________________________________________________________
428  const std::vector<G4double>& edges,
429  const G4String& unitName, const G4String& fcnName)
430 {
431  if ( ! CheckEdges(edges) ) return kInvalidId;
432 
433  return fVH1Manager->SetH1(id, edges, unitName, fcnName);
434 }
435 
436 //_____________________________________________________________________________
438  G4int nxbins, G4double xmin, G4double xmax,
439  G4int nybins, G4double ymin, G4double ymax,
440  const G4String& xunitName, const G4String& yunitName,
441  const G4String& xfcnName, const G4String& yfcnName,
442  const G4String& xbinSchemeName,
443  const G4String& ybinSchemeName)
444 {
445  if ( ! CheckNbins(nxbins) ) return kInvalidId;
446  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
447 
448  if ( ! CheckNbins(nybins) ) return kInvalidId;
449  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
450 
451  return fVH2Manager->SetH2(id, nxbins, xmin, xmax, nybins, ymin, ymax,
452  xunitName, yunitName, xfcnName, yfcnName,
453  xbinSchemeName, ybinSchemeName);
454 }
455 
456 //_____________________________________________________________________________
458  const std::vector<G4double>& xedges,
459  const std::vector<G4double>& yedges,
460  const G4String& xunitName, const G4String& yunitName,
461  const G4String& xfcnName, const G4String& yfcnName)
462 {
463  if ( ! CheckEdges(xedges) ) return kInvalidId;
464  if ( ! CheckEdges(yedges) ) return kInvalidId;
465 
466  return fVH2Manager->SetH2(id, xedges, yedges,
467  xunitName, yunitName, xfcnName, yfcnName);
468 }
469 
470 //_____________________________________________________________________________
472  G4int nxbins, G4double xmin, G4double xmax,
473  G4int nybins, G4double ymin, G4double ymax,
474  G4int nzbins, G4double zmin, G4double zmax,
475  const G4String& xunitName, const G4String& yunitName,
476  const G4String& zunitName,
477  const G4String& xfcnName, const G4String& yfcnName,
478  const G4String& zfcnName,
479  const G4String& xbinSchemeName,
480  const G4String& ybinSchemeName,
481  const G4String& zbinSchemeName)
482 {
483  if ( ! CheckNbins(nxbins) ) return kInvalidId;
484  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
485 
486  if ( ! CheckNbins(nybins) ) return kInvalidId;
487  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
488 
489  if ( ! CheckNbins(nzbins) ) return kInvalidId;
490  if ( ! CheckMinMax(zmin, zmax, zfcnName, zbinSchemeName) ) return kInvalidId;
491 
492  return fVH3Manager->SetH3(id,
493  nxbins, xmin, xmax, nybins, ymin, ymax,
494  nzbins, zmin, zmax,
495  xunitName, yunitName, zunitName,
496  xfcnName, yfcnName, zfcnName,
497  xbinSchemeName, ybinSchemeName, zbinSchemeName);
498 }
499 
500 //_____________________________________________________________________________
502  const std::vector<G4double>& xedges,
503  const std::vector<G4double>& yedges,
504  const std::vector<G4double>& zedges,
505  const G4String& xunitName, const G4String& yunitName,
506  const G4String& zunitName,
507  const G4String& xfcnName, const G4String& yfcnName,
508  const G4String& zfcnName)
509 {
510  if ( ! CheckEdges(xedges) ) return kInvalidId;
511  if ( ! CheckEdges(yedges) ) return kInvalidId;
512  if ( ! CheckEdges(zedges) ) return kInvalidId;
513 
514  return fVH3Manager->SetH3(id, xedges, yedges, zedges,
515  xunitName, yunitName, zunitName,
516  xfcnName, yfcnName, zfcnName);
517 }
518 
519 //_____________________________________________________________________________
521 {
522  return fVH1Manager->ScaleH1(id, factor);
523 }
524 
525 //_____________________________________________________________________________
527 {
528  return fVH2Manager->ScaleH2(id, factor);
529 }
530 
531 //_____________________________________________________________________________
533 {
534  return fVH3Manager->ScaleH3(id, factor);
535 }
536 
537 //_____________________________________________________________________________
539  G4int nbins, G4double xmin, G4double xmax,
540  G4double ymin, G4double ymax,
541  const G4String& xunitName, const G4String& yunitName,
542  const G4String& xfcnName, const G4String& yfcnName,
543  const G4String& xbinSchemeName)
544 {
545  if ( ! CheckName(name, "P1") ) return kInvalidId;
546  if ( ! CheckNbins(nbins) ) return kInvalidId;
547  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
548  if ( ymin != 0. || ymax != 0. ) {
549  // Do not check default values
550  if ( ! CheckMinMax(ymin, ymax) ) return kInvalidId;
551  }
552 
553  return fVP1Manager->CreateP1(name, title, nbins, xmin, xmax, ymin, ymax,
554  xunitName, yunitName, xfcnName, yfcnName,
555  xbinSchemeName);
556 }
557 
558 //_____________________________________________________________________________
560  const std::vector<G4double>& edges,
561  G4double ymin, G4double ymax,
562  const G4String& xunitName, const G4String& yunitName,
563  const G4String& xfcnName, const G4String& yfcnName)
564 {
565  if ( ! CheckName(name, "P1") ) return kInvalidId;
566  if ( ! CheckEdges(edges) ) return kInvalidId;
567  if ( ymin != 0. || ymax != 0. ) {
568  // Do not check default values
569  if ( ! CheckMinMax(ymin, ymax) ) return kInvalidId;
570  }
571 
572  return fVP1Manager->CreateP1(name, title, edges, ymin, ymax,
573  xunitName, yunitName, xfcnName, yfcnName);
574 }
575 
576 //_____________________________________________________________________________
578  G4int nxbins, G4double xmin, G4double xmax,
579  G4int nybins, G4double ymin, G4double ymax,
580  G4double zmin, G4double zmax,
581  const G4String& xunitName, const G4String& yunitName,
582  const G4String& zunitName,
583  const G4String& xfcnName, const G4String& yfcnName,
584  const G4String& zfcnName,
585  const G4String& xbinSchemeName,
586  const G4String& ybinSchemeName)
587 {
588  if ( ! CheckName(name, "P2") ) return kInvalidId;
589  if ( ! CheckNbins(nxbins) ) return kInvalidId;
590  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
591  if ( ! CheckMinMax(ymin, ymax, yfcnName, xbinSchemeName) ) return kInvalidId;
592  if ( zmin != 0. || zmax != 0. ) {
593  // Do not check default values
594  if ( ! CheckMinMax(zmin, zmax) ) return kInvalidId;
595  }
596 
597  return fVP2Manager->CreateP2(name, title,
598  nxbins, xmin, xmax, nybins, ymin, ymax,
599  zmin, zmax,
600  xunitName, yunitName, zunitName,
601  xfcnName, yfcnName, zfcnName,
602  xbinSchemeName, ybinSchemeName);
603 }
604 
605 //_____________________________________________________________________________
607  const std::vector<G4double>& xedges,
608  const std::vector<G4double>& yedges,
609  G4double zmin, G4double zmax,
610  const G4String& xunitName, const G4String& yunitName,
611  const G4String& zunitName,
612  const G4String& xfcnName, const G4String& yfcnName,
613  const G4String& zfcnName)
614 {
615  if ( ! CheckName(name, "P2") ) return kInvalidId;
616  if ( ! CheckEdges(xedges) ) return kInvalidId;
617  if ( ! CheckEdges(yedges) ) return kInvalidId;
618  if ( zmin != 0. || zmax != 0. ) {
619  // Do not check default values
620  if ( ! CheckMinMax(zmin, zmax) ) return kInvalidId;
621  }
622 
623  return fVP2Manager->CreateP2(name, title, xedges, yedges, zmin, zmax,
624  xunitName, yunitName, zunitName,
625  xfcnName, yfcnName, zfcnName);
626 }
627 
628 //_____________________________________________________________________________
630  G4int nbins, G4double xmin, G4double xmax,
631  G4double ymin, G4double ymax,
632  const G4String& xunitName, const G4String& yunitName,
633  const G4String& xfcnName, const G4String& yfcnName,
634  const G4String& xbinSchemeName)
635 {
636  if ( ! CheckNbins(nbins) ) return kInvalidId;
637  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
638  if ( ymin != 0. || ymax != 0. ) {
639  // Do not check default values
640  if ( ! CheckMinMax(ymin, ymax) ) return kInvalidId;
641  }
642 
643  return fVP1Manager->SetP1(id, nbins, xmin, xmax, ymin, ymax,
644  xunitName, yunitName, xfcnName, yfcnName,
645  xbinSchemeName);
646 }
647 
648 //_____________________________________________________________________________
650  const std::vector<G4double>& edges,
651  G4double ymin, G4double ymax,
652  const G4String& xunitName, const G4String& yunitName,
653  const G4String& xfcnName, const G4String& yfcnName)
654 {
655  if ( ! CheckEdges(edges) ) return kInvalidId;
656  if ( ymin != 0. || ymax != 0. ) {
657  // Do not check default values
658  if ( ! CheckMinMax(ymin, ymax) ) return kInvalidId;
659  }
660 
661  return fVP1Manager->SetP1(id, edges, ymin, ymax,
662  xunitName, yunitName, xfcnName, yfcnName);
663 }
664 
665 //_____________________________________________________________________________
667  G4int nxbins, G4double xmin, G4double xmax,
668  G4int nybins, G4double ymin, G4double ymax,
669  G4double zmin, G4double zmax,
670  const G4String& xunitName, const G4String& yunitName,
671  const G4String& zunitName,
672  const G4String& xfcnName, const G4String& yfcnName,
673  const G4String& zfcnName,
674  const G4String& xbinSchemeName,
675  const G4String& ybinSchemeName)
676 {
677  if ( ! CheckNbins(nxbins) ) return kInvalidId;
678  if ( ! CheckNbins(nybins) ) return kInvalidId;
679  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
680  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
681  if ( zmin != 0. || zmax != 0. ) {
682  // Do not check default values
683  if ( ! CheckMinMax(zmin, zmax) ) return kInvalidId;
684  }
685 
686  return fVP2Manager->SetP2(id, nxbins, xmin, xmax, nybins, ymin, ymax,
687  zmin, zmax,
688  xunitName, yunitName, zunitName,
689  xfcnName, yfcnName, zfcnName,
690  xbinSchemeName, ybinSchemeName);
691 }
692 
693 //_____________________________________________________________________________
695  const std::vector<G4double>& xedges,
696  const std::vector<G4double>& yedges,
697  G4double zmin, G4double zmax,
698  const G4String& xunitName,
699  const G4String& yunitName,
700  const G4String& zunitName,
701  const G4String& xfcnName,
702  const G4String& yfcnName,
703  const G4String& zfcnName)
704 {
705  if ( ! CheckEdges(xedges) ) return kInvalidId;
706  if ( ! CheckEdges(yedges) ) return kInvalidId;
707  if ( zmin != 0. || zmax != 0. ) {
708  // Do not check default values
709  if ( ! CheckMinMax(zmin, zmax) ) return kInvalidId;
710  }
711 
712  return fVP2Manager->SetP2(id, xedges, yedges, zmin, zmax,
713  xunitName, yunitName, zunitName,
714  xfcnName, yfcnName, zfcnName);
715 }
716 
717 //_____________________________________________________________________________
719 {
720  return fVP1Manager->ScaleP1(id, factor);
721 }
722 
723 //_____________________________________________________________________________
725 {
726  return fVP2Manager->ScaleP2(id, factor);
727 }
728 
729 //_____________________________________________________________________________
731  const G4String& title)
732 {
733  if ( ! CheckName(name, "Ntuple") ) return kInvalidId;
734 
735  return fVNtupleManager->CreateNtuple(name, title);
736 }
737 
738 //_____________________________________________________________________________
740 {
741  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
742 
743  return fVNtupleManager->CreateNtupleIColumn(name, 0);
744 }
745 
746 //_____________________________________________________________________________
748 {
749  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
750 
751  return fVNtupleManager->CreateNtupleFColumn(name, 0);
752 }
753 
754 //_____________________________________________________________________________
756 {
757  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
758 
759  return fVNtupleManager->CreateNtupleDColumn(name, 0);
760 }
761 
762 //_____________________________________________________________________________
764 {
765  if ( ! CheckName(name, "NtupleSColumn") ) return kInvalidId;
766 
767  return fVNtupleManager->CreateNtupleSColumn(name);
768 }
769 
770 //_____________________________________________________________________________
772  std::vector<int>& vector)
773 {
774  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
775 
776  return fVNtupleManager->CreateNtupleIColumn(name, &vector);
777 }
778 
779 //_____________________________________________________________________________
781  std::vector<float>& vector)
782 {
783  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
784 
785  return fVNtupleManager->CreateNtupleFColumn(name, &vector);
786 }
787 
788 //_____________________________________________________________________________
790  std::vector<double>& vector)
791 {
792  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
793 
794  return fVNtupleManager->CreateNtupleDColumn(name, &vector);
795 }
796 
797 //_____________________________________________________________________________
799 {
800  return fVNtupleManager->FinishNtuple();
801 }
802 
803 //_____________________________________________________________________________
805  const G4String& name)
806 {
807  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
808 
809  return fVNtupleManager->CreateNtupleIColumn(ntupleId, name, 0);
810 }
811 
812 //_____________________________________________________________________________
814  const G4String& name)
815 {
816  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
817 
818  return fVNtupleManager->CreateNtupleFColumn(ntupleId, name, 0);
819 }
820 
821 
822 //_____________________________________________________________________________
824  const G4String& name)
825 {
826  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
827 
828  return fVNtupleManager->CreateNtupleDColumn(ntupleId, name, 0);
829 }
830 
831 //_____________________________________________________________________________
833  const G4String& name)
834 {
835  if ( ! CheckName(name, "NtupleSColumn") ) return kInvalidId;
836 
837  return fVNtupleManager->CreateNtupleSColumn(ntupleId, name);
838 }
839 
840 //_____________________________________________________________________________
842  const G4String& name,
843  std::vector<int>& vector)
844 {
845  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
846 
847  return fVNtupleManager->CreateNtupleIColumn(ntupleId, name, &vector);
848 }
849 
850 //_____________________________________________________________________________
852  const G4String& name,
853  std::vector<float>& vector)
854 {
855  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
856 
857  return fVNtupleManager->CreateNtupleFColumn(ntupleId, name, &vector);
858 }
859 
860 //_____________________________________________________________________________
862  const G4String& name,
863  std::vector<double>& vector)
864 {
865  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
866 
867  return fVNtupleManager->CreateNtupleDColumn(ntupleId, name, &vector);
868 }
869 
870 //_____________________________________________________________________________
872 {
873  return fVNtupleManager->FinishNtuple(ntupleId);
874 }
875 
876 //_____________________________________________________________________________
878 {
879  G4bool finalResult = true;
880 
881  G4bool result = SetFirstH1Id(firstId);
882  finalResult = finalResult && result;
883 
884  result = SetFirstH2Id(firstId);
885  finalResult = finalResult && result;
886 
887  result = SetFirstH3Id(firstId);
888  finalResult = finalResult && result;
889 
890  return finalResult;
891 }
892 
893 //_____________________________________________________________________________
895 {
896  return fH1HnManager->SetFirstId(firstId);
897 }
898 
899 //_____________________________________________________________________________
901 {
902  return fH2HnManager->SetFirstId(firstId);
903 }
904 
905 //_____________________________________________________________________________
907 {
908  return fH3HnManager->SetFirstId(firstId);
909 }
910 
911 //_____________________________________________________________________________
913 {
914  G4bool finalResult = true;
915 
916  G4bool result = SetFirstP1Id(firstId);
917  finalResult = finalResult && result;
918 
919  result = SetFirstP2Id(firstId);
920  finalResult = finalResult && result;
921 
922  return finalResult;
923 }
924 
925 //_____________________________________________________________________________
927 {
928  return fP1HnManager->SetFirstId(firstId);
929 }
930 
931 //_____________________________________________________________________________
933 {
934  return fP2HnManager->SetFirstId(firstId);
935 }
936 
937 //_____________________________________________________________________________
939 {
940  return fVNtupleManager->SetFirstId(firstId);
941 }
942 
943 //_____________________________________________________________________________
945 {
946  return fVNtupleManager->SetFirstNtupleColumnId(firstId);
947 }
948 
949 // Fill methods in .icc
950 
951 //_____________________________________________________________________________
953 {
954  fState.SetIsActivation(activation);
955 }
956 
957 // GetActivation() in .icc
958 
959 //_____________________________________________________________________________
961 {
962 // Return true if activation option is selected and any of managers has
963 // an activated object.
964 
965  return fState.GetIsActivation() &&
966  ( fH1HnManager->IsActive() ||
967  fH2HnManager->IsActive() ||
968  fH3HnManager->IsActive() ||
969  fP1HnManager->IsActive() ||
970  fP2HnManager->IsActive() );
971 }
972 
973 //_____________________________________________________________________________
975 {
976 // Return true any of managers has an object with activated ASCII option.
977 
978  return ( fH1HnManager->IsAscii() ||
979  fH2HnManager->IsAscii() ||
980  fH3HnManager->IsAscii() ||
981  fP1HnManager->IsAscii() ||
982  fP2HnManager->IsAscii() );
983 }
984 
985 //_____________________________________________________________________________
987 {
988 // Return true any of managers has an object with activated plotting option.
989 
990  return ( fH1HnManager->IsPlotting() ||
991  fH2HnManager->IsPlotting() ||
992  fH3HnManager->IsPlotting() ||
993  fP1HnManager->IsPlotting() ||
994  fP2HnManager->IsPlotting() );
995 }
996 
997 //_____________________________________________________________________________
999 {
1000 // Return first H1 id
1001 
1002  return fH1HnManager->GetFirstId();
1003 }
1004 
1005 //_____________________________________________________________________________
1007 {
1008 // Return first H2 id
1009 
1010  return fH2HnManager->GetFirstId();
1011 }
1012 
1013 //_____________________________________________________________________________
1015 {
1016 // Return first H3 id
1017 
1018  return fH3HnManager->GetFirstId();
1019 }
1020 
1021 //_____________________________________________________________________________
1023 {
1024 // Return first P1 id
1025 
1026  return fP1HnManager->GetFirstId();
1027 }
1028 
1029 //_____________________________________________________________________________
1031 {
1032 // Return first P2 id
1033 
1034  return fP2HnManager->GetFirstId();
1035 }
1036 
1037 //_____________________________________________________________________________
1039 {
1040 // Return first Ntuple id
1041 
1042  return fVNtupleManager->GetFirstId();
1043 }
1044 
1045 //_____________________________________________________________________________
1047 {
1048 // Return first Ntuple column id
1049 
1051 }
1052 
1053 //_____________________________________________________________________________
1055 {
1056  return fH1HnManager->GetNofHns();
1057 }
1058 
1059 //_____________________________________________________________________________
1061 {
1062  return fH2HnManager->GetNofHns();
1063 }
1064 
1065 //_____________________________________________________________________________
1067 {
1068  return fH3HnManager->GetNofHns();
1069 }
1070 
1071 //_____________________________________________________________________________
1073 {
1074  return fP1HnManager->GetNofHns();
1075 }
1076 
1077 //_____________________________________________________________________________
1079 {
1080  return fP2HnManager->GetNofHns();
1081 }
1082 
1083 //_____________________________________________________________________________
1085 {
1086  return fVNtupleManager->GetNofNtuples();
1087 }
1088 
1089 // GetH1Id(), GetH2Id in .icc
1090 
1091 //_____________________________________________________________________________
1093 {
1094 // Set activation to a given H1 object
1095 
1096  fH1HnManager->SetActivation(id, activation);
1097 }
1098 
1099 //_____________________________________________________________________________
1101 {
1102 // Set activation to all H1 objects
1103 
1104  fH1HnManager->SetActivation(activation);
1105 }
1106 
1107 //_____________________________________________________________________________
1109 {
1110  fH1HnManager->SetAscii(id, ascii);
1111 }
1112 
1113 //_____________________________________________________________________________
1115 {
1116  fH1HnManager->SetPlotting(id, plotting);
1117 }
1118 
1119 //_____________________________________________________________________________
1121 {
1122 // Set activation to a given H2 object
1123 
1124  fH2HnManager->SetActivation(id, activation);
1125 }
1126 
1127 //_____________________________________________________________________________
1129 {
1130 // Set activation to all H2 objects
1131 
1132  fH2HnManager->SetActivation(activation);
1133 }
1134 
1135 //_____________________________________________________________________________
1137 {
1138  fH2HnManager->SetAscii(id, ascii);
1139 }
1140 
1141 //_____________________________________________________________________________
1143 {
1144  fH2HnManager->SetPlotting(id, plotting);
1145 }
1146 
1147 //_____________________________________________________________________________
1149 {
1150 // Set activation to a given H3 object
1151 
1152  fH3HnManager->SetActivation(id, activation);
1153 }
1154 
1155 //_____________________________________________________________________________
1157 {
1158 // Set activation to all H3 objects
1159 
1160  fH3HnManager->SetActivation(activation);
1161 }
1162 
1163 //_____________________________________________________________________________
1165 {
1166  fH3HnManager->SetAscii(id, ascii);
1167 }
1168 
1169 //_____________________________________________________________________________
1171 {
1172  fH3HnManager->SetPlotting(id, plotting);
1173 }
1174 
1175 //_____________________________________________________________________________
1177 {
1178 // Set activation to a given P1 object
1179 
1180  fP1HnManager->SetActivation(id, activation);
1181 }
1182 
1183 //_____________________________________________________________________________
1185 {
1186 // Set activation to all P1 objects
1187 
1188  fP1HnManager->SetActivation(activation);
1189 }
1190 
1191 //_____________________________________________________________________________
1193 {
1194  fP1HnManager->SetAscii(id, ascii);
1195 }
1196 
1197 //_____________________________________________________________________________
1199 {
1200  fP1HnManager->SetPlotting(id, plotting);
1201 }
1202 
1203 //_____________________________________________________________________________
1205 {
1206 // Set activation to a given P2 object
1207 
1208  fP2HnManager->SetActivation(id, activation);
1209 }
1210 
1211 //_____________________________________________________________________________
1213 {
1214 // Set activation to all P2 objects
1215 
1216  fP2HnManager->SetActivation(activation);
1217 }
1218 
1219 //_____________________________________________________________________________
1221 {
1222  fP2HnManager->SetAscii(id, ascii);
1223 }
1224 
1225 //_____________________________________________________________________________
1227 {
1228  fP2HnManager->SetPlotting(id, plotting);
1229 }
1230 
1231 //_____________________________________________________________________________
1233 {
1234 // Set activation to a given P2 object
1235 
1236  fVNtupleManager->SetActivation(id, activation);
1237 }
1238 
1239 //_____________________________________________________________________________
1241 {
1242 // Set activation to all P2 objects
1243 
1244  fVNtupleManager->SetActivation(activation);
1245 }
1246 
1247 // Access methods in .icc
1248 
1249 //_____________________________________________________________________________
1251 {
1252  fState.SetVerboseLevel(verboseLevel);
1253 }
1254 
1255 // GetVerboseLevel() in .icc
1256 
G4int CreateH3(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4int nzbins, G4double zmin, G4double zmax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear", const G4String &zbinSchemeName="linear")
void SetP1Manager(G4VP1Manager *p1Manager)
G4bool SetHistoDirectoryName(const G4String &dirName)
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
void SetH2Ascii(G4int id, G4bool ascii)
G4String GetNtupleDirectoryName() const
std::unique_ptr< T > make_unique(Args &&...args)
void SetH3Plotting(G4int id, G4bool plotting)
G4int CreateNtupleIColumn(const G4String &name)
G4bool SetFirstHistoId(G4int firstId)
virtual G4bool MergeImpl(tools::histo::hmpi *hmpi)=0
void SetCompressionLevel(G4int level)
virtual G4int GetNofNtuples() const =0
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
void SetCompressionLevel(G4int level)
G4bool ScaleH1(G4int id, G4double factor)
G4bool ScaleH2(G4int id, G4double factor)
void SetH1Manager(G4VH1Manager *h1Manager)
void SetP2Activation(G4bool activation)
virtual G4bool WriteImpl()=0
void SetVerboseLevel(G4int verboseLevel)
G4bool SetFirstId(G4int firstId)
void SetH2Plotting(G4int id, G4bool plotting)
G4bool IsAscii() const
void SetH2Activation(G4bool activation)
G4int CreateNtuple(const G4String &name, const G4String &title)
G4int GetFirstP2Id() const
virtual G4int CreateNtupleSColumn(const G4String &name)=0
G4int CreateP1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear")
const char * name(G4int ptype)
G4int GetFirstH2Id() const
std::unique_ptr< G4VP2Manager > fVP2Manager
G4int GetFirstH1Id() const
G4VNtupleManager * fVNtupleManager
G4bool SetFileName(const G4String &fileName)
G4bool ScaleH3(G4int id, G4double factor)
virtual std::shared_ptr< G4HnManager > GetHnManager()=0
G4int CreateNtupleSColumn(const G4String &name)
G4bool SetNtupleDirectoryName(const G4String &dirName)
int G4int
Definition: G4Types.hh:78
G4int GetFirstP1Id() const
void SetP1Activation(G4bool activation)
G4bool SetH3(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nzbins, G4double zmin, G4double zmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear", const G4String &zbinSchemeName="linear")
G4int GetFirstNtupleColumnId() const
G4bool OpenFile(const G4String &fileName="")
void SetH3Manager(G4VH3Manager *h3Manager)
G4bool SetFirstH1Id(G4int firstId)
G4VAnalysisManager(const G4String &type, G4bool isMaster)
std::shared_ptr< G4HnManager > fH1HnManager
void SetH3Ascii(G4int id, G4bool ascii)
virtual G4int CreateNtuple(const G4String &name, const G4String &title)=0
G4bool SetFirstProfileId(G4int firstId)
virtual G4bool PlotImpl()=0
const G4AnalysisVerbose * GetVerboseL3() const
virtual std::shared_ptr< G4HnManager > GetHnManager()=0
std::unique_ptr< G4VH2Manager > fVH2Manager
void SetH1Ascii(G4int id, G4bool ascii)
G4bool SetP1(G4int id, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear")
void SetP2Manager(G4VP2Manager *p2Manager)
virtual std::shared_ptr< G4HnManager > GetHnManager()=0
G4bool SetFirstNtupleColumnId(G4int firstId)
G4bool CheckName(const G4String &name, const G4String &objectType)
virtual void FinishNtuple()=0
G4int GetNofNtuples() const
std::shared_ptr< G4VFileManager > fVFileManager
bool G4bool
Definition: G4Types.hh:79
virtual G4bool OpenFileImpl(const G4String &fileName)=0
void SetIsActivation(G4bool isActivation)
G4int GetFirstH3Id() const
G4bool SetFirstP1Id(G4int firstId)
virtual G4bool IsOpenFileImpl() const =0
std::unique_ptr< G4VH1Manager > fVH1Manager
virtual G4int CreateNtupleFColumn(const G4String &name, std::vector< float > *vector)=0
virtual G4int CreateNtupleIColumn(const G4String &name, std::vector< int > *vector)=0
virtual std::shared_ptr< G4HnManager > GetHnManager()=0
G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
G4String GetFileName() const
std::shared_ptr< G4HnManager > fP2HnManager
G4bool IsActive() const
G4bool ScaleP2(G4int id, G4double factor)
std::unique_ptr< G4VP1Manager > fVP1Manager
G4String GetHistoDirectoryName() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4bool SetH2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
void SetFileManager(std::shared_ptr< G4VFileManager > fileManager)
void SetH2Manager(G4VH2Manager *h2Manager)
G4bool SetP2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4double zmin=0, G4double zmax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
G4bool SetFirstNtupleId(G4int firstId)
G4bool SetFirstH3Id(G4int firstId)
G4bool IsOpenFile() const
G4bool SetFirstP2Id(G4int firstId)
std::shared_ptr< G4HnManager > fH3HnManager
std::unique_ptr< G4AnalysisMessenger > fMessenger
G4int CreateP2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4double zmin=0, G4double zmax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
void SetH1Plotting(G4int id, G4bool plotting)
G4String & append(const G4String &)
void SetH1Activation(G4bool activation)
void SetActivation(G4bool activation)
void SetP2Ascii(G4int id, G4bool ascii)
G4int CreateNtupleFColumn(const G4String &name)
G4int GetCompressionLevel() const
void SetH3Activation(G4bool activation)
void SetP1Ascii(G4int id, G4bool ascii)
std::shared_ptr< G4HnManager > fP1HnManager
G4bool CheckNbins(G4int nbins)
G4bool SetFirstNtupleColumnId(G4int firstId)
G4bool SetFirstH2Id(G4int firstId)
G4int GetFirstNtupleColumnId() const
G4int CreateNtupleDColumn(const G4String &name)
std::shared_ptr< G4HnManager > fH2HnManager
virtual void SetActivation(G4bool activation)=0
double G4double
Definition: G4Types.hh:76
void SetNtupleActivation(G4bool activation)
void SetP1Plotting(G4int id, G4bool plotting)
virtual G4int CreateNtupleDColumn(const G4String &name, std::vector< double > *vector)=0
G4AnalysisManagerState fState
void SetVerboseLevel(G4int verboseLevel)
const G4int kInvalidId
void SetP2Plotting(G4int id, G4bool plotting)
std::unique_ptr< G4VH3Manager > fVH3Manager
virtual G4bool CloseFileImpl()=0
virtual std::shared_ptr< G4HnManager > GetHnManager()=0
G4int GetFirstNtupleId() const
const G4AnalysisVerbose * GetVerboseL1() const
void SetNtupleManager(G4VNtupleManager *ntupleManager)
G4bool CheckMinMax(G4double xmin, G4double xmax, const G4String &fcnName="none", const G4String &binSchemeName="linear")
G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
G4bool CheckEdges(const std::vector< G4double > &edges)
G4bool ScaleP1(G4int id, G4double factor)
G4bool WriteAscii(const G4String &fileName)
G4bool Merge(tools::histo::hmpi *hmpi)
G4bool IsPlotting() const