Geant4  10.02
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 
70 //
71 // protected methods
72 //
73 
74 //_____________________________________________________________________________
76 {
77  fVH1Manager.reset(h1Manager);
78  fH1HnManager = h1Manager->GetHnManager();
79  fMessenger->SetH1HnManager(*fH1HnManager);
80 }
81 
82 //_____________________________________________________________________________
84 {
85  fVH2Manager.reset(h2Manager);
86  fH2HnManager = h2Manager->GetHnManager();
87  fMessenger->SetH2HnManager(*fH2HnManager);
88 }
89 
90 //_____________________________________________________________________________
92 {
93  fVH3Manager.reset(h3Manager);
94  fH3HnManager = h3Manager->GetHnManager();
95  fMessenger->SetH3HnManager(*fH3HnManager);
96 }
97 
98 //_____________________________________________________________________________
100 {
101  fVP1Manager.reset(p1Manager);
102  fP1HnManager = p1Manager->GetHnManager();
103  fMessenger->SetP1HnManager(*fP1HnManager);
104 }
105 
106 //_____________________________________________________________________________
108 {
109  fVP2Manager.reset(p2Manager);
110  fP2HnManager = p2Manager->GetHnManager();
111  fMessenger->SetP2HnManager(*fP2HnManager);
112 }
113 
114 //_____________________________________________________________________________
116 {
117  fVNtupleManager.reset(ntupleManager);
118 }
119 
120 //_____________________________________________________________________________
121 void G4VAnalysisManager::SetFileManager(std::shared_ptr<G4VFileManager> fileManager)
122 {
123  fVFileManager = fileManager;
124 }
125 
126 //_____________________________________________________________________________
128 {
129  G4bool finalResult = true;
130 
131  // Replace or add file extension .ascii
132  G4String name(fileName);
133  if ( name.find(".") != std::string::npos ) {
134  name.erase(name.find("."), name.length());
135  }
136  name.append(".ascii");
137 
138 #ifdef G4VERBOSE
139  if ( fState.GetVerboseL3() )
140  fState.GetVerboseL3()->Message("write ASCII", "file", name);
141 #endif
142 
143  std::ofstream output(name, std::ios::out);
144  if ( ! output ) {
145  G4ExceptionDescription description;
146  description
147  << "Cannot open file. File name is not defined.";
148  G4Exception("G4VAnalysisManager::WriteAscii()",
149  "Analysis_W001", JustWarning, description);
150  return false;
151  }
152  output.setf( std::ios::scientific, std::ios::floatfield );
153 
154  G4bool result = fVH1Manager->WriteOnAscii(output);
155  finalResult = finalResult && result;
156 
157  result = fVH2Manager->WriteOnAscii(output);
158  finalResult = finalResult && result;
159 
160  result = fVH3Manager->WriteOnAscii(output);
161  finalResult = finalResult && result;
162 
163  //result = fVP1Manager->WriteOnAscii(output);
164  //finalResult = finalResult && result;
165 
166  //result = fVP2Manager->WriteOnAscii(output);
167  //finalResult = finalResult && result;
168 
169 #ifdef G4VERBOSE
170  if ( fState.GetVerboseL1() )
171  fState.GetVerboseL1()->Message("write ASCII", "file", name, result);
172 #endif
173 
174  return finalResult;
175 }
176 
177 //
178 // public methods
179 //
180 
181 //_____________________________________________________________________________
183 {
184  if ( fileName != "" ) {
185  return OpenFileImpl(fileName);
186  }
187  else {
188  if ( fVFileManager->GetFileName() == "" ) {
189  G4ExceptionDescription description;
190  description
191  << "Cannot open file. File name is not defined.";
192  G4Exception("G4VFileManager::OpenFile()",
193  "Analysis_W001", JustWarning, description);
194  return false;
195  }
196  return OpenFileImpl(fVFileManager->GetFileName());
197  }
198 }
199 
200 //_____________________________________________________________________________
202 {
203  G4bool finalResult = true;
204 
205  G4bool result = WriteImpl();
206  finalResult = finalResult && result;
207 
208  if ( IsPlotting() ) {
209  result = PlotImpl();
210  finalResult = finalResult && result;
211  }
212 
213  return finalResult;
214 }
215 
216 //_____________________________________________________________________________
218 {
219  return CloseFileImpl();
220 }
221 
222 //_____________________________________________________________________________
223 G4bool G4VAnalysisManager::Merge(tools::histo::hmpi* hmpi)
224 {
225  return MergeImpl(hmpi);
226 }
227 
228 //_____________________________________________________________________________
230 {
231  return PlotImpl();
232 }
233 
234 //_____________________________________________________________________________
236 {
237  return IsOpenFileImpl();
238 }
239 
240 //_____________________________________________________________________________
242 {
243  return fVFileManager->SetFileName(fileName);
244 }
245 
246 //_____________________________________________________________________________
248 {
249  return fVFileManager->SetHistoDirectoryName(dirName);
250 }
251 
252 //_____________________________________________________________________________
254 {
255  return fVFileManager->SetNtupleDirectoryName(dirName);
256 }
257 
258 //_____________________________________________________________________________
260 {
262 }
263 
264 //_____________________________________________________________________________
266 {
267  return fVFileManager->GetFileName();
268 }
269 
270 //_____________________________________________________________________________
272 {
273  return fVFileManager->GetHistoDirectoryName();
274 }
275 
276 //_____________________________________________________________________________
278 {
279  return fVFileManager->GetNtupleDirectoryName();
280 }
281 
282 //_____________________________________________________________________________
284 {
285  return fState.GetCompressionLevel();
286 }
287 
288 //_____________________________________________________________________________
290  G4int nbins, G4double xmin, G4double xmax,
291  const G4String& unitName, const G4String& fcnName,
292  const G4String& binSchemeName)
293 {
294  if ( ! CheckName(name, "H1") ) return kInvalidId;
295  if ( ! CheckNbins(nbins) ) return kInvalidId;
296  if ( ! CheckMinMax(xmin, xmax, fcnName, binSchemeName) ) return kInvalidId;
297 
298  return fVH1Manager->CreateH1(name, title, nbins, xmin, xmax,
299  unitName, fcnName, binSchemeName);
300 }
301 
302 //_____________________________________________________________________________
304  const std::vector<G4double>& edges,
305  const G4String& unitName, const G4String& fcnName)
306 {
307  if ( ! CheckName(name, "H1") ) return kInvalidId;
308  if ( ! CheckEdges(edges) ) return kInvalidId;
309 
310  return fVH1Manager->CreateH1(name, title, edges, unitName, fcnName);
311 }
312 
313 //_____________________________________________________________________________
315  G4int nxbins, G4double xmin, G4double xmax,
316  G4int nybins, G4double ymin, G4double ymax,
317  const G4String& xunitName, const G4String& yunitName,
318  const G4String& xfcnName, const G4String& yfcnName,
319  const G4String& xbinSchemeName,
320  const G4String& ybinSchemeName)
321 
322 {
323  if ( ! CheckName(name, "H2") ) return kInvalidId;
324 
325  if ( ! CheckNbins(nxbins) ) return kInvalidId;
326  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
327 
328  if ( ! CheckNbins(nybins) ) return kInvalidId;
329  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
330 
331  return fVH2Manager->CreateH2(name, title,
332  nxbins, xmin, xmax, nybins, ymin, ymax,
333  xunitName, yunitName, xfcnName, yfcnName,
334  xbinSchemeName, ybinSchemeName);
335 }
336 
337 //_____________________________________________________________________________
339  const std::vector<G4double>& xedges,
340  const std::vector<G4double>& yedges,
341  const G4String& xunitName, const G4String& yunitName,
342  const G4String& xfcnName, const G4String& yfcnName)
343 
344 {
345  if ( ! CheckName(name, "H2") ) return kInvalidId;
346 
347  if ( ! CheckEdges(xedges) ) return kInvalidId;
348  if ( ! CheckEdges(yedges) ) return kInvalidId;
349 
350  return fVH2Manager->CreateH2(name, title,
351  xedges, yedges,
352  xunitName, yunitName, xfcnName, yfcnName);
353 }
354 
355 //_____________________________________________________________________________
357  G4int nxbins, G4double xmin, G4double xmax,
358  G4int nybins, G4double ymin, G4double ymax,
359  G4int nzbins, G4double zmin, G4double zmax,
360  const G4String& xunitName, const G4String& yunitName,
361  const G4String& zunitName,
362  const G4String& xfcnName, const G4String& yfcnName,
363  const G4String& zfcnName,
364  const G4String& xbinSchemeName,
365  const G4String& ybinSchemeName,
366  const G4String& zbinSchemeName)
367 
368 {
369  if ( ! CheckName(name, "H3") ) return kInvalidId;
370 
371  if ( ! CheckNbins(nxbins) ) return kInvalidId;
372  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
373 
374  if ( ! CheckNbins(nybins) ) return kInvalidId;
375  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
376 
377  if ( ! CheckNbins(nzbins) ) return kInvalidId;
378  if ( ! CheckMinMax(zmin, zmax, zfcnName, zbinSchemeName) ) return kInvalidId;
379 
380  return fVH3Manager->CreateH3(name, title,
381  nxbins, xmin, xmax, nybins, ymin, ymax,
382  nzbins, zmin, zmax,
383  xunitName, yunitName, zunitName,
384  xfcnName, yfcnName, zfcnName,
385  xbinSchemeName, ybinSchemeName, zbinSchemeName);
386 }
387 
388 //_____________________________________________________________________________
390  const std::vector<G4double>& xedges,
391  const std::vector<G4double>& yedges,
392  const std::vector<G4double>& zedges,
393  const G4String& xunitName, const G4String& yunitName,
394  const G4String& zunitName,
395  const G4String& xfcnName, const G4String& yfcnName,
396  const G4String& zfcnName)
397 
398 {
399  if ( ! CheckName(name, "H3") ) return kInvalidId;
400 
401  if ( ! CheckEdges(xedges) ) return kInvalidId;
402  if ( ! CheckEdges(yedges) ) return kInvalidId;
403  if ( ! CheckEdges(zedges) ) return kInvalidId;
404 
405  return fVH3Manager->CreateH3(name, title,
406  xedges, yedges, zedges,
407  xunitName, yunitName, zunitName,
408  xfcnName, yfcnName, zfcnName);
409 }
410 
411 //_____________________________________________________________________________
413  G4int nbins, G4double xmin, G4double xmax,
414  const G4String& unitName, const G4String& fcnName,
415  const G4String& binSchemeName)
416 {
417  if ( ! CheckNbins(nbins) ) return kInvalidId;
418  if ( ! CheckMinMax(xmin, xmax, fcnName, binSchemeName) ) return kInvalidId;
419 
420  return fVH1Manager->SetH1(id, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
421 }
422 
423 //_____________________________________________________________________________
425  const std::vector<G4double>& edges,
426  const G4String& unitName, const G4String& fcnName)
427 {
428  if ( ! CheckEdges(edges) ) return kInvalidId;
429 
430  return fVH1Manager->SetH1(id, edges, unitName, fcnName);
431 }
432 
433 //_____________________________________________________________________________
435  G4int nxbins, G4double xmin, G4double xmax,
436  G4int nybins, G4double ymin, G4double ymax,
437  const G4String& xunitName, const G4String& yunitName,
438  const G4String& xfcnName, const G4String& yfcnName,
439  const G4String& xbinSchemeName,
440  const G4String& ybinSchemeName)
441 {
442  if ( ! CheckNbins(nxbins) ) return kInvalidId;
443  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
444 
445  if ( ! CheckNbins(nybins) ) return kInvalidId;
446  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
447 
448  return fVH2Manager->SetH2(id, nxbins, xmin, xmax, nybins, ymin, ymax,
449  xunitName, yunitName, xfcnName, yfcnName,
450  xbinSchemeName, ybinSchemeName);
451 }
452 
453 //_____________________________________________________________________________
455  const std::vector<G4double>& xedges,
456  const std::vector<G4double>& yedges,
457  const G4String& xunitName, const G4String& yunitName,
458  const G4String& xfcnName, const G4String& yfcnName)
459 {
460  if ( ! CheckEdges(xedges) ) return kInvalidId;
461  if ( ! CheckEdges(yedges) ) return kInvalidId;
462 
463  return fVH2Manager->SetH2(id, xedges, yedges,
464  xunitName, yunitName, xfcnName, yfcnName);
465 }
466 
467 //_____________________________________________________________________________
469  G4int nxbins, G4double xmin, G4double xmax,
470  G4int nybins, G4double ymin, G4double ymax,
471  G4int nzbins, G4double zmin, G4double zmax,
472  const G4String& xunitName, const G4String& yunitName,
473  const G4String& zunitName,
474  const G4String& xfcnName, const G4String& yfcnName,
475  const G4String& zfcnName,
476  const G4String& xbinSchemeName,
477  const G4String& ybinSchemeName,
478  const G4String& zbinSchemeName)
479 {
480  if ( ! CheckNbins(nxbins) ) return kInvalidId;
481  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
482 
483  if ( ! CheckNbins(nybins) ) return kInvalidId;
484  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
485 
486  if ( ! CheckNbins(nzbins) ) return kInvalidId;
487  if ( ! CheckMinMax(zmin, zmax, zfcnName, zbinSchemeName) ) return kInvalidId;
488 
489  return fVH3Manager->SetH3(id,
490  nxbins, xmin, xmax, nybins, ymin, ymax,
491  nzbins, zmin, zmax,
492  xunitName, yunitName, zunitName,
493  xfcnName, yfcnName, zfcnName,
494  xbinSchemeName, ybinSchemeName, zbinSchemeName);
495 }
496 
497 //_____________________________________________________________________________
499  const std::vector<G4double>& xedges,
500  const std::vector<G4double>& yedges,
501  const std::vector<G4double>& zedges,
502  const G4String& xunitName, const G4String& yunitName,
503  const G4String& zunitName,
504  const G4String& xfcnName, const G4String& yfcnName,
505  const G4String& zfcnName)
506 {
507  if ( ! CheckEdges(xedges) ) return kInvalidId;
508  if ( ! CheckEdges(yedges) ) return kInvalidId;
509  if ( ! CheckEdges(zedges) ) return kInvalidId;
510 
511  return fVH3Manager->SetH3(id, xedges, yedges, zedges,
512  xunitName, yunitName, zunitName,
513  xfcnName, yfcnName, zfcnName);
514 }
515 
516 //_____________________________________________________________________________
518 {
519  return fVH1Manager->ScaleH1(id, factor);
520 }
521 
522 //_____________________________________________________________________________
524 {
525  return fVH2Manager->ScaleH2(id, factor);
526 }
527 
528 //_____________________________________________________________________________
530 {
531  return fVH3Manager->ScaleH3(id, factor);
532 }
533 
534 //_____________________________________________________________________________
536  G4int nbins, G4double xmin, G4double xmax,
537  G4double ymin, G4double ymax,
538  const G4String& xunitName, const G4String& yunitName,
539  const G4String& xfcnName, const G4String& yfcnName,
540  const G4String& xbinSchemeName)
541 {
542  if ( ! CheckName(name, "P1") ) return kInvalidId;
543  if ( ! CheckNbins(nbins) ) return kInvalidId;
544  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
545  if ( ! CheckMinMax(ymin, ymax) ) return kInvalidId;
546 
547  return fVP1Manager->CreateP1(name, title, nbins, xmin, xmax, ymin, ymax,
548  xunitName, yunitName, xfcnName, yfcnName,
549  xbinSchemeName);
550 }
551 
552 //_____________________________________________________________________________
554  const std::vector<G4double>& edges,
555  G4double ymin, G4double ymax,
556  const G4String& xunitName, const G4String& yunitName,
557  const G4String& xfcnName, const G4String& yfcnName)
558 {
559  if ( ! CheckName(name, "P1") ) return kInvalidId;
560  if ( ! CheckEdges(edges) ) return kInvalidId;
561 
562  return fVP1Manager->CreateP1(name, title, edges, ymin, ymax,
563  xunitName, yunitName, xfcnName, yfcnName);
564 }
565 
566 //_____________________________________________________________________________
568  G4int nxbins, G4double xmin, G4double xmax,
569  G4int nybins, G4double ymin, G4double ymax,
570  G4double zmin, G4double zmax,
571  const G4String& xunitName, const G4String& yunitName,
572  const G4String& zunitName,
573  const G4String& xfcnName, const G4String& yfcnName,
574  const G4String& zfcnName,
575  const G4String& xbinSchemeName,
576  const G4String& ybinSchemeName)
577 {
578  if ( ! CheckName(name, "P2") ) return kInvalidId;
579  if ( ! CheckNbins(nxbins) ) return kInvalidId;
580  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
581  if ( ! CheckMinMax(ymin, ymax, yfcnName, xbinSchemeName) ) return kInvalidId;
582  if ( ! CheckMinMax(zmin, zmax) ) return kInvalidId;
583 
584  return fVP2Manager->CreateP2(name, title,
585  nxbins, xmin, xmax, nybins, ymin, ymax,
586  zmin, zmax,
587  xunitName, yunitName, zunitName,
588  xfcnName, yfcnName, zfcnName,
589  xbinSchemeName, ybinSchemeName);
590 }
591 
592 //_____________________________________________________________________________
594  const std::vector<G4double>& xedges,
595  const std::vector<G4double>& yedges,
596  G4double zmin, G4double zmax,
597  const G4String& xunitName, const G4String& yunitName,
598  const G4String& zunitName,
599  const G4String& xfcnName, const G4String& yfcnName,
600  const G4String& zfcnName)
601 {
602  if ( ! CheckName(name, "P2") ) return kInvalidId;
603  if ( ! CheckEdges(xedges) ) return kInvalidId;
604  if ( ! CheckEdges(yedges) ) return kInvalidId;
605 
606  return fVP2Manager->CreateP2(name, title, xedges, yedges, zmin, zmax,
607  xunitName, yunitName, zunitName,
608  xfcnName, yfcnName, zfcnName);
609 }
610 
611 //_____________________________________________________________________________
613  G4int nbins, G4double xmin, G4double xmax,
614  G4double ymin, G4double ymax,
615  const G4String& xunitName, const G4String& yunitName,
616  const G4String& xfcnName, const G4String& yfcnName,
617  const G4String& xbinSchemeName)
618 {
619  if ( ! CheckNbins(nbins) ) return kInvalidId;
620  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
621 
622  return fVP1Manager->SetP1(id, nbins, xmin, xmax, ymin, ymax,
623  xunitName, yunitName, xfcnName, yfcnName,
624  xbinSchemeName);
625 }
626 
627 //_____________________________________________________________________________
629  const std::vector<G4double>& edges,
630  G4double ymin, G4double ymax,
631  const G4String& xunitName, const G4String& yunitName,
632  const G4String& xfcnName, const G4String& yfcnName)
633 {
634  if ( ! CheckEdges(edges) ) return kInvalidId;
635 
636  return fVP1Manager->SetP1(id, edges, ymin, ymax,
637  xunitName, yunitName, xfcnName, yfcnName);
638 }
639 
640 //_____________________________________________________________________________
642  G4int nxbins, G4double xmin, G4double xmax,
643  G4int nybins, G4double ymin, G4double ymax,
644  G4double zmin, G4double zmax,
645  const G4String& xunitName, const G4String& yunitName,
646  const G4String& zunitName,
647  const G4String& xfcnName, const G4String& yfcnName,
648  const G4String& zfcnName,
649  const G4String& xbinSchemeName,
650  const G4String& ybinSchemeName)
651 {
652  if ( ! CheckNbins(nxbins) ) return kInvalidId;
653  if ( ! CheckNbins(nybins) ) return kInvalidId;
654  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
655  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
656 
657  return fVP2Manager->SetP2(id, nxbins, xmin, xmax, nybins, ymin, ymax,
658  zmin, zmax,
659  xunitName, yunitName, zunitName,
660  xfcnName, yfcnName, zfcnName,
661  xbinSchemeName, ybinSchemeName);
662 }
663 
664 //_____________________________________________________________________________
666  const std::vector<G4double>& xedges,
667  const std::vector<G4double>& yedges,
668  G4double zmin, G4double zmax,
669  const G4String& xunitName,
670  const G4String& yunitName,
671  const G4String& zunitName,
672  const G4String& xfcnName,
673  const G4String& yfcnName,
674  const G4String& zfcnName)
675 {
676  if ( ! CheckEdges(xedges) ) return kInvalidId;
677  if ( ! CheckEdges(yedges) ) return kInvalidId;
678 
679  return fVP2Manager->SetP2(id, xedges, yedges, zmin, zmax,
680  xunitName, yunitName, zunitName,
681  xfcnName, yfcnName, zfcnName);
682 }
683 
684 //_____________________________________________________________________________
686 {
687  return fVP1Manager->ScaleP1(id, factor);
688 }
689 
690 //_____________________________________________________________________________
692 {
693  return fVP2Manager->ScaleP2(id, factor);
694 }
695 
696 //_____________________________________________________________________________
698  const G4String& title)
699 {
700  if ( ! CheckName(name, "Ntuple") ) return kInvalidId;
701 
702  return fVNtupleManager->CreateNtuple(name, title);
703 }
704 
705 //_____________________________________________________________________________
707 {
708  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
709 
710  return fVNtupleManager->CreateNtupleIColumn(name, 0);
711 }
712 
713 //_____________________________________________________________________________
715 {
716  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
717 
718  return fVNtupleManager->CreateNtupleFColumn(name, 0);
719 }
720 
721 //_____________________________________________________________________________
723 {
724  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
725 
726  return fVNtupleManager->CreateNtupleDColumn(name, 0);
727 }
728 
729 //_____________________________________________________________________________
731 {
732  if ( ! CheckName(name, "NtupleSColumn") ) return kInvalidId;
733 
734  return fVNtupleManager->CreateNtupleSColumn(name);
735 }
736 
737 //_____________________________________________________________________________
739  std::vector<int>& vector)
740 {
741  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
742 
743  return fVNtupleManager->CreateNtupleIColumn(name, &vector);
744 }
745 
746 //_____________________________________________________________________________
748  std::vector<float>& vector)
749 {
750  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
751 
752  return fVNtupleManager->CreateNtupleFColumn(name, &vector);
753 }
754 
755 //_____________________________________________________________________________
757  std::vector<double>& vector)
758 {
759  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
760 
761  return fVNtupleManager->CreateNtupleDColumn(name, &vector);
762 }
763 
764 //_____________________________________________________________________________
766 {
767  return fVNtupleManager->FinishNtuple();
768 }
769 
770 //_____________________________________________________________________________
772  const G4String& name)
773 {
774  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
775 
776  return fVNtupleManager->CreateNtupleIColumn(ntupleId, name, 0);
777 }
778 
779 //_____________________________________________________________________________
781  const G4String& name)
782 {
783  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
784 
785  return fVNtupleManager->CreateNtupleFColumn(ntupleId, name, 0);
786 }
787 
788 
789 //_____________________________________________________________________________
791  const G4String& name)
792 {
793  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
794 
795  return fVNtupleManager->CreateNtupleDColumn(ntupleId, name, 0);
796 }
797 
798 //_____________________________________________________________________________
800  const G4String& name)
801 {
802  if ( ! CheckName(name, "NtupleSColumn") ) return kInvalidId;
803 
804  return fVNtupleManager->CreateNtupleSColumn(ntupleId, name);
805 }
806 
807 //_____________________________________________________________________________
809  const G4String& name,
810  std::vector<int>& vector)
811 {
812  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
813 
814  return fVNtupleManager->CreateNtupleIColumn(ntupleId, name, &vector);
815 }
816 
817 //_____________________________________________________________________________
819  const G4String& name,
820  std::vector<float>& vector)
821 {
822  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
823 
824  return fVNtupleManager->CreateNtupleFColumn(ntupleId, name, &vector);
825 }
826 
827 //_____________________________________________________________________________
829  const G4String& name,
830  std::vector<double>& vector)
831 {
832  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
833 
834  return fVNtupleManager->CreateNtupleDColumn(ntupleId, name, &vector);
835 }
836 
837 //_____________________________________________________________________________
839 {
840  return fVNtupleManager->FinishNtuple(ntupleId);
841 }
842 
843 //_____________________________________________________________________________
845 {
846  G4bool finalResult = true;
847 
848  G4bool result = SetFirstH1Id(firstId);
849  finalResult = finalResult && result;
850 
851  result = SetFirstH2Id(firstId);
852  finalResult = finalResult && result;
853 
854  result = SetFirstH3Id(firstId);
855  finalResult = finalResult && result;
856 
857  return finalResult;
858 }
859 
860 //_____________________________________________________________________________
862 {
863  return fH1HnManager->SetFirstId(firstId);
864 }
865 
866 //_____________________________________________________________________________
868 {
869  return fH2HnManager->SetFirstId(firstId);
870 }
871 
872 //_____________________________________________________________________________
874 {
875  return fH3HnManager->SetFirstId(firstId);
876 }
877 
878 //_____________________________________________________________________________
880 {
881  G4bool finalResult = true;
882 
883  G4bool result = SetFirstP1Id(firstId);
884  finalResult = finalResult && result;
885 
886  result = SetFirstP2Id(firstId);
887  finalResult = finalResult && result;
888 
889  return finalResult;
890 }
891 
892 //_____________________________________________________________________________
894 {
895  return fP1HnManager->SetFirstId(firstId);
896 }
897 
898 //_____________________________________________________________________________
900 {
901  return fP2HnManager->SetFirstId(firstId);
902 }
903 
904 //_____________________________________________________________________________
906 {
907  return fVNtupleManager->SetFirstId(firstId);
908 }
909 
910 //_____________________________________________________________________________
912 {
913  return fVNtupleManager->SetFirstNtupleColumnId(firstId);
914 }
915 
916 // Fill methods in .icc
917 
918 //_____________________________________________________________________________
920 {
921  fState.SetIsActivation(activation);
922 }
923 
924 // GetActivation() in .icc
925 
926 //_____________________________________________________________________________
928 {
929 // Return true if activation option is selected and any of managers has
930 // an activated object.
931 
932  return fState.GetIsActivation() &&
933  ( fH1HnManager->IsActive() ||
934  fH2HnManager->IsActive() ||
935  fH3HnManager->IsActive() ||
936  fP1HnManager->IsActive() ||
937  fP2HnManager->IsActive() );
938 }
939 
940 //_____________________________________________________________________________
942 {
943 // Return true any of managers has an object with activated ASCII option.
944 
945  return ( fH1HnManager->IsAscii() ||
946  fH2HnManager->IsAscii() ||
947  fH3HnManager->IsAscii() ||
948  fP1HnManager->IsAscii() ||
949  fP2HnManager->IsAscii() );
950 }
951 
952 //_____________________________________________________________________________
954 {
955 // Return true any of managers has an object with activated plotting option.
956 
957  return ( fH1HnManager->IsPlotting() ||
958  fH2HnManager->IsPlotting() ||
959  fH3HnManager->IsPlotting() ||
960  fP1HnManager->IsPlotting() ||
961  fP2HnManager->IsPlotting() );
962 }
963 
964 //_____________________________________________________________________________
966 {
967 // Return first H1 id
968 
969  return fH1HnManager->GetFirstId();
970 }
971 
972 //_____________________________________________________________________________
974 {
975 // Return first H2 id
976 
977  return fH2HnManager->GetFirstId();
978 }
979 
980 //_____________________________________________________________________________
982 {
983 // Return first H3 id
984 
985  return fH3HnManager->GetFirstId();
986 }
987 
988 //_____________________________________________________________________________
990 {
991 // Return first P1 id
992 
993  return fP1HnManager->GetFirstId();
994 }
995 
996 //_____________________________________________________________________________
998 {
999 // Return first P2 id
1000 
1001  return fP2HnManager->GetFirstId();
1002 }
1003 
1004 //_____________________________________________________________________________
1006 {
1007 // Return first Ntuple id
1008 
1009  return fVNtupleManager->GetFirstId();
1010 }
1011 
1012 //_____________________________________________________________________________
1014 {
1015 // Return first Ntuple column id
1016 
1017  return fVNtupleManager->GetFirstNtupleColumnId();
1018 }
1019 
1020 //_____________________________________________________________________________
1022 {
1023  return fH1HnManager->GetNofHns();
1024 }
1025 
1026 //_____________________________________________________________________________
1028 {
1029  return fH2HnManager->GetNofHns();
1030 }
1031 
1032 //_____________________________________________________________________________
1034 {
1035  return fH3HnManager->GetNofHns();
1036 }
1037 
1038 //_____________________________________________________________________________
1040 {
1041  return fP1HnManager->GetNofHns();
1042 }
1043 
1044 //_____________________________________________________________________________
1046 {
1047  return fP2HnManager->GetNofHns();
1048 }
1049 
1050 //_____________________________________________________________________________
1052 {
1053  return fVNtupleManager->GetNofNtuples();
1054 }
1055 
1056 // GetH1Id(), GetH2Id in .icc
1057 
1058 //_____________________________________________________________________________
1060 {
1061 // Set activation to a given H1 object
1062 
1063  fH1HnManager->SetActivation(id, activation);
1064 }
1065 
1066 //_____________________________________________________________________________
1068 {
1069 // Set activation to all H1 objects
1070 
1071  fH1HnManager->SetActivation(activation);
1072 }
1073 
1074 //_____________________________________________________________________________
1076 {
1077  fH1HnManager->SetAscii(id, ascii);
1078 }
1079 
1080 //_____________________________________________________________________________
1082 {
1083  fH1HnManager->SetPlotting(id, plotting);
1084 }
1085 
1086 //_____________________________________________________________________________
1088 {
1089 // Set activation to a given H2 object
1090 
1091  fH2HnManager->SetActivation(id, activation);
1092 }
1093 
1094 //_____________________________________________________________________________
1096 {
1097 // Set activation to all H2 objects
1098 
1099  fH2HnManager->SetActivation(activation);
1100 }
1101 
1102 //_____________________________________________________________________________
1104 {
1105  fH2HnManager->SetAscii(id, ascii);
1106 }
1107 
1108 //_____________________________________________________________________________
1110 {
1111  fH2HnManager->SetPlotting(id, plotting);
1112 }
1113 
1114 //_____________________________________________________________________________
1116 {
1117 // Set activation to a given H3 object
1118 
1119  fH3HnManager->SetActivation(id, activation);
1120 }
1121 
1122 //_____________________________________________________________________________
1124 {
1125 // Set activation to all H3 objects
1126 
1127  fH3HnManager->SetActivation(activation);
1128 }
1129 
1130 //_____________________________________________________________________________
1132 {
1133  fH3HnManager->SetAscii(id, ascii);
1134 }
1135 
1136 //_____________________________________________________________________________
1138 {
1139  fH3HnManager->SetPlotting(id, plotting);
1140 }
1141 
1142 //_____________________________________________________________________________
1144 {
1145 // Set activation to a given P1 object
1146 
1147  fP1HnManager->SetActivation(id, activation);
1148 }
1149 
1150 //_____________________________________________________________________________
1152 {
1153 // Set activation to all P1 objects
1154 
1155  fP1HnManager->SetActivation(activation);
1156 }
1157 
1158 //_____________________________________________________________________________
1160 {
1161  fP1HnManager->SetAscii(id, ascii);
1162 }
1163 
1164 //_____________________________________________________________________________
1166 {
1167  fP1HnManager->SetPlotting(id, plotting);
1168 }
1169 
1170 //_____________________________________________________________________________
1172 {
1173 // Set activation to a given P2 object
1174 
1175  fP2HnManager->SetActivation(id, activation);
1176 }
1177 
1178 //_____________________________________________________________________________
1180 {
1181 // Set activation to all P2 objects
1182 
1183  fP2HnManager->SetActivation(activation);
1184 }
1185 
1186 //_____________________________________________________________________________
1188 {
1189  fP2HnManager->SetAscii(id, ascii);
1190 }
1191 
1192 //_____________________________________________________________________________
1194 {
1195  fP2HnManager->SetPlotting(id, plotting);
1196 }
1197 
1198 //_____________________________________________________________________________
1200 {
1201 // Set activation to a given P2 object
1202 
1203  fVNtupleManager->SetActivation(id, activation);
1204 }
1205 
1206 //_____________________________________________________________________________
1208 {
1209 // Set activation to all P2 objects
1210 
1211  fVNtupleManager->SetActivation(activation);
1212 }
1213 
1214 // Access methods in .icc
1215 
1216 //_____________________________________________________________________________
1218 {
1219  fState.SetVerboseLevel(verboseLevel);
1220 }
1221 
1222 // GetVerboseLevel() in .icc
1223 
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)
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)
G4String name
Definition: TRTMaterials.hh:40
virtual G4bool WriteImpl()=0
void SetVerboseLevel(G4int verboseLevel)
std::unique_ptr< G4VNtupleManager > fVNtupleManager
void SetH2Plotting(G4int id, G4bool plotting)
G4bool IsAscii() const
void SetH2Activation(G4bool activation)
G4int CreateNtuple(const G4String &name, const G4String &title)
G4int GetFirstP2Id() const
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")
G4int GetFirstH2Id() const
std::unique_ptr< G4VP2Manager > fVP2Manager
G4int GetFirstH1Id() const
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)
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 CheckName(const G4String &name, const G4String &objectType)
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 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)
static const G4double factor
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 CreateNtupleDColumn(const G4String &name)
std::shared_ptr< G4HnManager > fH2HnManager
double G4double
Definition: G4Types.hh:76
void SetNtupleActivation(G4bool activation)
void SetP1Plotting(G4int id, G4bool plotting)
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