ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VAnalysisManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VAnalysisManager.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 
27 // Author: Ivana Hrivnacova, 09/07/2013 (ivana@ipno.in2p3.fr)
28 
29 #include "G4VAnalysisManager.hh"
30 #include "G4AnalysisMessenger.hh"
31 #include "G4AnalysisUtilities.hh"
32 #include "G4HnManager.hh"
33 #include "G4VH1Manager.hh"
34 #include "G4VH2Manager.hh"
35 #include "G4VH3Manager.hh"
36 #include "G4VP1Manager.hh"
37 #include "G4VP2Manager.hh"
38 #include "G4VNtupleManager.hh"
39 #include "G4VFileManager.hh"
40 
41 #include <iostream>
42 
43 using namespace G4Analysis;
44 
45 namespace {
46 
47 void NtupleMergingWarning(const G4String& functionName,
48  const G4String& outputType)
49 {
50  G4ExceptionDescription description;
51  description
52  << " " << "Ntuple merging is not available with "
53  << outputType << " output." << G4endl
54  << " " << "Setting is ignored.";
55  G4Exception(functionName, "Analysis_W041", JustWarning, description);
56 }
57 
58 }
59 
60 //_____________________________________________________________________________
62  : fState(type, isMaster),
63  fVFileManager(nullptr),
64  fPlotManager(nullptr),
65  fMessenger(G4Analysis::make_unique<G4AnalysisMessenger>(this)),
66  fH1HnManager(nullptr),
67  fH2HnManager(nullptr),
68  fH3HnManager(nullptr),
69  fP1HnManager(nullptr),
70  fP2HnManager(nullptr),
71  fVH1Manager(nullptr),
72  fVH2Manager(nullptr),
73  fVH3Manager(nullptr),
74  fVP1Manager(nullptr),
75  fVP2Manager(nullptr),
76  fVNtupleManager(nullptr)
77 {
78  //fMessenger = G4Analysis::make_unique<G4AnalysisMessenger>(this);
79 }
80 
81 //_____________________________________________________________________________
83 {
84  delete fVNtupleManager;
85 }
86 
87 //
88 // protected methods
89 //
90 
91 //_____________________________________________________________________________
93 {
94  fVH1Manager.reset(h1Manager);
95  fH1HnManager = h1Manager->GetHnManager();
96  fMessenger->SetH1HnManager(*fH1HnManager);
97 }
98 
99 //_____________________________________________________________________________
101 {
102  fVH2Manager.reset(h2Manager);
103  fH2HnManager = h2Manager->GetHnManager();
104  fMessenger->SetH2HnManager(*fH2HnManager);
105 }
106 
107 //_____________________________________________________________________________
109 {
110  fVH3Manager.reset(h3Manager);
111  fH3HnManager = h3Manager->GetHnManager();
112  fMessenger->SetH3HnManager(*fH3HnManager);
113 }
114 
115 //_____________________________________________________________________________
117 {
118  fVP1Manager.reset(p1Manager);
119  fP1HnManager = p1Manager->GetHnManager();
120  fMessenger->SetP1HnManager(*fP1HnManager);
121 }
122 
123 //_____________________________________________________________________________
125 {
126  fVP2Manager.reset(p2Manager);
127  fP2HnManager = p2Manager->GetHnManager();
128  fMessenger->SetP2HnManager(*fP2HnManager);
129 }
130 
131 //_____________________________________________________________________________
133 {
134  // fVNtupleManager.reset(ntupleManager);
135  fVNtupleManager = ntupleManager;
136 }
137 
138 //_____________________________________________________________________________
139 void G4VAnalysisManager::SetFileManager(std::shared_ptr<G4VFileManager> fileManager)
140 {
141  fVFileManager = fileManager;
142 }
143 
144 //_____________________________________________________________________________
145 void G4VAnalysisManager::SetPlotManager(std::shared_ptr<G4PlotManager> plotManager)
146 {
147  fPlotManager = plotManager;
148 }
149 
150 //_____________________________________________________________________________
152 {
153  G4bool finalResult = true;
154 
155  // Replace or add file extension .ascii
156  G4String name(fileName);
157  if ( name.find(".") != std::string::npos ) {
158  name.erase(name.find("."), name.length());
159  }
160  name.append(".ascii");
161 
162 #ifdef G4VERBOSE
163  if ( fState.GetVerboseL3() )
164  fState.GetVerboseL3()->Message("write ASCII", "file", name);
165 #endif
166 
167  std::ofstream output(name, std::ios::out);
168  if ( ! output ) {
169  G4ExceptionDescription description;
170  description
171  << "Cannot open file. File name is not defined.";
172  G4Exception("G4VAnalysisManager::WriteAscii()",
173  "Analysis_W001", JustWarning, description);
174  return false;
175  }
176  output.setf( std::ios::scientific, std::ios::floatfield );
177 
178  G4bool result = fVH1Manager->WriteOnAscii(output);
179  finalResult = finalResult && result;
180 
181  result = fVH2Manager->WriteOnAscii(output);
182  finalResult = finalResult && result;
183 
184  result = fVH3Manager->WriteOnAscii(output);
185  finalResult = finalResult && result;
186 
187  //result = fVP1Manager->WriteOnAscii(output);
188  //finalResult = finalResult && result;
189 
190  //result = fVP2Manager->WriteOnAscii(output);
191  //finalResult = finalResult && result;
192 
193 #ifdef G4VERBOSE
194  if ( fState.GetVerboseL1() )
195  fState.GetVerboseL1()->Message("write ASCII", "file", name, result);
196 #endif
197 
198  return finalResult;
199 }
200 
201 //
202 // public methods
203 //
204 
205 //_____________________________________________________________________________
207 {
208  if ( fileName != "" ) {
209  return OpenFileImpl(fileName);
210  }
211  else {
212  if ( fVFileManager->GetFileName() == "" ) {
213  G4ExceptionDescription description;
214  description
215  << "Cannot open file. File name is not defined.";
216  G4Exception("G4VFileManager::OpenFile()",
217  "Analysis_W001", JustWarning, description);
218  return false;
219  }
220  return OpenFileImpl(fVFileManager->GetFileName());
221  }
222 }
223 
224 //_____________________________________________________________________________
226 {
227  G4bool finalResult = true;
228 
229  G4bool result = WriteImpl();
230  finalResult = finalResult && result;
231 
232  if ( IsPlotting() ) {
233  result = PlotImpl();
234  finalResult = finalResult && result;
235  }
236 
237  return finalResult;
238 }
239 
240 //_____________________________________________________________________________
242 {
243  return CloseFileImpl(reset);
244 }
245 
246 //_____________________________________________________________________________
247 G4bool G4VAnalysisManager::Merge(tools::histo::hmpi* hmpi)
248 {
249  return MergeImpl(hmpi);
250 }
251 
252 //_____________________________________________________________________________
254 {
255  return PlotImpl();
256 }
257 
258 //_____________________________________________________________________________
260 {
261  return IsOpenFileImpl();
262 }
263 
264 //_____________________________________________________________________________
266 {
267  return fVFileManager->SetFileName(fileName);
268 }
269 
270 //_____________________________________________________________________________
272 {
273  return fVFileManager->SetHistoDirectoryName(dirName);
274 }
275 
276 //_____________________________________________________________________________
278 {
279  return fVFileManager->SetNtupleDirectoryName(dirName);
280 }
281 
282 //_____________________________________________________________________________
284 {
286 }
287 
288 //_____________________________________________________________________________
290 {
291  return fVFileManager->GetFileName();
292 }
293 
294 //_____________________________________________________________________________
296 {
297  return fVFileManager->GetHistoDirectoryName();
298 }
299 
300 //_____________________________________________________________________________
302 {
303  return fVFileManager->GetNtupleDirectoryName();
304 }
305 
306 //_____________________________________________________________________________
308 {
309  return fState.GetCompressionLevel();
310 }
311 
312 //_____________________________________________________________________________
314  G4int nbins, G4double xmin, G4double xmax,
315  const G4String& unitName, const G4String& fcnName,
316  const G4String& binSchemeName)
317 {
318  if ( ! CheckName(name, "H1") ) return kInvalidId;
319  if ( ! CheckNbins(nbins) ) return kInvalidId;
320  if ( ! CheckMinMax(xmin, xmax, fcnName, binSchemeName) ) return kInvalidId;
321 
322  return fVH1Manager->CreateH1(name, title, nbins, xmin, xmax,
323  unitName, fcnName, binSchemeName);
324 }
325 
326 //_____________________________________________________________________________
328  const std::vector<G4double>& edges,
329  const G4String& unitName, const G4String& fcnName)
330 {
331  if ( ! CheckName(name, "H1") ) return kInvalidId;
332  if ( ! CheckEdges(edges) ) return kInvalidId;
333 
334  return fVH1Manager->CreateH1(name, title, edges, unitName, fcnName);
335 }
336 
337 //_____________________________________________________________________________
339  G4int nxbins, G4double xmin, G4double xmax,
340  G4int nybins, G4double ymin, G4double ymax,
341  const G4String& xunitName, const G4String& yunitName,
342  const G4String& xfcnName, const G4String& yfcnName,
343  const G4String& xbinSchemeName,
344  const G4String& ybinSchemeName)
345 
346 {
347  if ( ! CheckName(name, "H2") ) return kInvalidId;
348 
349  if ( ! CheckNbins(nxbins) ) return kInvalidId;
350  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
351 
352  if ( ! CheckNbins(nybins) ) return kInvalidId;
353  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
354 
355  return fVH2Manager->CreateH2(name, title,
356  nxbins, xmin, xmax, nybins, ymin, ymax,
357  xunitName, yunitName, xfcnName, yfcnName,
358  xbinSchemeName, ybinSchemeName);
359 }
360 
361 //_____________________________________________________________________________
363  const std::vector<G4double>& xedges,
364  const std::vector<G4double>& yedges,
365  const G4String& xunitName, const G4String& yunitName,
366  const G4String& xfcnName, const G4String& yfcnName)
367 
368 {
369  if ( ! CheckName(name, "H2") ) return kInvalidId;
370 
371  if ( ! CheckEdges(xedges) ) return kInvalidId;
372  if ( ! CheckEdges(yedges) ) return kInvalidId;
373 
374  return fVH2Manager->CreateH2(name, title,
375  xedges, yedges,
376  xunitName, yunitName, xfcnName, yfcnName);
377 }
378 
379 //_____________________________________________________________________________
381  G4int nxbins, G4double xmin, G4double xmax,
382  G4int nybins, G4double ymin, G4double ymax,
383  G4int nzbins, G4double zmin, G4double zmax,
384  const G4String& xunitName, const G4String& yunitName,
385  const G4String& zunitName,
386  const G4String& xfcnName, const G4String& yfcnName,
387  const G4String& zfcnName,
388  const G4String& xbinSchemeName,
389  const G4String& ybinSchemeName,
390  const G4String& zbinSchemeName)
391 
392 {
393  if ( ! CheckName(name, "H3") ) return kInvalidId;
394 
395  if ( ! CheckNbins(nxbins) ) return kInvalidId;
396  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
397 
398  if ( ! CheckNbins(nybins) ) return kInvalidId;
399  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
400 
401  if ( ! CheckNbins(nzbins) ) return kInvalidId;
402  if ( ! CheckMinMax(zmin, zmax, zfcnName, zbinSchemeName) ) return kInvalidId;
403 
404  return fVH3Manager->CreateH3(name, title,
405  nxbins, xmin, xmax, nybins, ymin, ymax,
406  nzbins, zmin, zmax,
407  xunitName, yunitName, zunitName,
408  xfcnName, yfcnName, zfcnName,
409  xbinSchemeName, ybinSchemeName, zbinSchemeName);
410 }
411 
412 //_____________________________________________________________________________
414  const std::vector<G4double>& xedges,
415  const std::vector<G4double>& yedges,
416  const std::vector<G4double>& zedges,
417  const G4String& xunitName, const G4String& yunitName,
418  const G4String& zunitName,
419  const G4String& xfcnName, const G4String& yfcnName,
420  const G4String& zfcnName)
421 
422 {
423  if ( ! CheckName(name, "H3") ) return kInvalidId;
424 
425  if ( ! CheckEdges(xedges) ) return kInvalidId;
426  if ( ! CheckEdges(yedges) ) return kInvalidId;
427  if ( ! CheckEdges(zedges) ) return kInvalidId;
428 
429  return fVH3Manager->CreateH3(name, title,
430  xedges, yedges, zedges,
431  xunitName, yunitName, zunitName,
432  xfcnName, yfcnName, zfcnName);
433 }
434 
435 //_____________________________________________________________________________
437  G4int nbins, G4double xmin, G4double xmax,
438  const G4String& unitName, const G4String& fcnName,
439  const G4String& binSchemeName)
440 {
441  if ( ! CheckNbins(nbins) ) return kInvalidId;
442  if ( ! CheckMinMax(xmin, xmax, fcnName, binSchemeName) ) return kInvalidId;
443 
444  return fVH1Manager->SetH1(id, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
445 }
446 
447 //_____________________________________________________________________________
449  const std::vector<G4double>& edges,
450  const G4String& unitName, const G4String& fcnName)
451 {
452  if ( ! CheckEdges(edges) ) return kInvalidId;
453 
454  return fVH1Manager->SetH1(id, edges, unitName, fcnName);
455 }
456 
457 //_____________________________________________________________________________
459  G4int nxbins, G4double xmin, G4double xmax,
460  G4int nybins, G4double ymin, G4double ymax,
461  const G4String& xunitName, const G4String& yunitName,
462  const G4String& xfcnName, const G4String& yfcnName,
463  const G4String& xbinSchemeName,
464  const G4String& ybinSchemeName)
465 {
466  if ( ! CheckNbins(nxbins) ) return kInvalidId;
467  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
468 
469  if ( ! CheckNbins(nybins) ) return kInvalidId;
470  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
471 
472  return fVH2Manager->SetH2(id, nxbins, xmin, xmax, nybins, ymin, ymax,
473  xunitName, yunitName, xfcnName, yfcnName,
474  xbinSchemeName, ybinSchemeName);
475 }
476 
477 //_____________________________________________________________________________
479  const std::vector<G4double>& xedges,
480  const std::vector<G4double>& yedges,
481  const G4String& xunitName, const G4String& yunitName,
482  const G4String& xfcnName, const G4String& yfcnName)
483 {
484  if ( ! CheckEdges(xedges) ) return kInvalidId;
485  if ( ! CheckEdges(yedges) ) return kInvalidId;
486 
487  return fVH2Manager->SetH2(id, xedges, yedges,
488  xunitName, yunitName, xfcnName, yfcnName);
489 }
490 
491 //_____________________________________________________________________________
493  G4int nxbins, G4double xmin, G4double xmax,
494  G4int nybins, G4double ymin, G4double ymax,
495  G4int nzbins, G4double zmin, G4double zmax,
496  const G4String& xunitName, const G4String& yunitName,
497  const G4String& zunitName,
498  const G4String& xfcnName, const G4String& yfcnName,
499  const G4String& zfcnName,
500  const G4String& xbinSchemeName,
501  const G4String& ybinSchemeName,
502  const G4String& zbinSchemeName)
503 {
504  if ( ! CheckNbins(nxbins) ) return kInvalidId;
505  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
506 
507  if ( ! CheckNbins(nybins) ) return kInvalidId;
508  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
509 
510  if ( ! CheckNbins(nzbins) ) return kInvalidId;
511  if ( ! CheckMinMax(zmin, zmax, zfcnName, zbinSchemeName) ) return kInvalidId;
512 
513  return fVH3Manager->SetH3(id,
514  nxbins, xmin, xmax, nybins, ymin, ymax,
515  nzbins, zmin, zmax,
516  xunitName, yunitName, zunitName,
517  xfcnName, yfcnName, zfcnName,
518  xbinSchemeName, ybinSchemeName, zbinSchemeName);
519 }
520 
521 //_____________________________________________________________________________
523  const std::vector<G4double>& xedges,
524  const std::vector<G4double>& yedges,
525  const std::vector<G4double>& zedges,
526  const G4String& xunitName, const G4String& yunitName,
527  const G4String& zunitName,
528  const G4String& xfcnName, const G4String& yfcnName,
529  const G4String& zfcnName)
530 {
531  if ( ! CheckEdges(xedges) ) return kInvalidId;
532  if ( ! CheckEdges(yedges) ) return kInvalidId;
533  if ( ! CheckEdges(zedges) ) return kInvalidId;
534 
535  return fVH3Manager->SetH3(id, xedges, yedges, zedges,
536  xunitName, yunitName, zunitName,
537  xfcnName, yfcnName, zfcnName);
538 }
539 
540 //_____________________________________________________________________________
542 {
543  return fVH1Manager->ScaleH1(id, factor);
544 }
545 
546 //_____________________________________________________________________________
548 {
549  return fVH2Manager->ScaleH2(id, factor);
550 }
551 
552 //_____________________________________________________________________________
554 {
555  return fVH3Manager->ScaleH3(id, factor);
556 }
557 
558 //_____________________________________________________________________________
560  G4int nbins, G4double xmin, G4double xmax,
562  const G4String& xunitName, const G4String& yunitName,
563  const G4String& xfcnName, const G4String& yfcnName,
564  const G4String& xbinSchemeName)
565 {
566  if ( ! CheckName(name, "P1") ) return kInvalidId;
567  if ( ! CheckNbins(nbins) ) return kInvalidId;
568  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
569  if ( ymin != 0. || ymax != 0. ) {
570  // Do not check default values
571  if ( ! CheckMinMax(ymin, ymax) ) return kInvalidId;
572  }
573 
574  return fVP1Manager->CreateP1(name, title, nbins, xmin, xmax, ymin, ymax,
575  xunitName, yunitName, xfcnName, yfcnName,
576  xbinSchemeName);
577 }
578 
579 //_____________________________________________________________________________
581  const std::vector<G4double>& edges,
583  const G4String& xunitName, const G4String& yunitName,
584  const G4String& xfcnName, const G4String& yfcnName)
585 {
586  if ( ! CheckName(name, "P1") ) return kInvalidId;
587  if ( ! CheckEdges(edges) ) return kInvalidId;
588  if ( ymin != 0. || ymax != 0. ) {
589  // Do not check default values
590  if ( ! CheckMinMax(ymin, ymax) ) return kInvalidId;
591  }
592 
593  return fVP1Manager->CreateP1(name, title, edges, ymin, ymax,
594  xunitName, yunitName, xfcnName, yfcnName);
595 }
596 
597 //_____________________________________________________________________________
599  G4int nxbins, G4double xmin, G4double xmax,
600  G4int nybins, G4double ymin, G4double ymax,
601  G4double zmin, G4double zmax,
602  const G4String& xunitName, const G4String& yunitName,
603  const G4String& zunitName,
604  const G4String& xfcnName, const G4String& yfcnName,
605  const G4String& zfcnName,
606  const G4String& xbinSchemeName,
607  const G4String& ybinSchemeName)
608 {
609  if ( ! CheckName(name, "P2") ) return kInvalidId;
610  if ( ! CheckNbins(nxbins) ) return kInvalidId;
611  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
612  if ( ! CheckMinMax(ymin, ymax, yfcnName, xbinSchemeName) ) return kInvalidId;
613  if ( zmin != 0. || zmax != 0. ) {
614  // Do not check default values
615  if ( ! CheckMinMax(zmin, zmax) ) return kInvalidId;
616  }
617 
618  return fVP2Manager->CreateP2(name, title,
619  nxbins, xmin, xmax, nybins, ymin, ymax,
620  zmin, zmax,
621  xunitName, yunitName, zunitName,
622  xfcnName, yfcnName, zfcnName,
623  xbinSchemeName, ybinSchemeName);
624 }
625 
626 //_____________________________________________________________________________
628  const std::vector<G4double>& xedges,
629  const std::vector<G4double>& yedges,
630  G4double zmin, G4double zmax,
631  const G4String& xunitName, const G4String& yunitName,
632  const G4String& zunitName,
633  const G4String& xfcnName, const G4String& yfcnName,
634  const G4String& zfcnName)
635 {
636  if ( ! CheckName(name, "P2") ) return kInvalidId;
637  if ( ! CheckEdges(xedges) ) return kInvalidId;
638  if ( ! CheckEdges(yedges) ) return kInvalidId;
639  if ( zmin != 0. || zmax != 0. ) {
640  // Do not check default values
641  if ( ! CheckMinMax(zmin, zmax) ) return kInvalidId;
642  }
643 
644  return fVP2Manager->CreateP2(name, title, xedges, yedges, zmin, zmax,
645  xunitName, yunitName, zunitName,
646  xfcnName, yfcnName, zfcnName);
647 }
648 
649 //_____________________________________________________________________________
651  G4int nbins, G4double xmin, G4double xmax,
653  const G4String& xunitName, const G4String& yunitName,
654  const G4String& xfcnName, const G4String& yfcnName,
655  const G4String& xbinSchemeName)
656 {
657  if ( ! CheckNbins(nbins) ) return kInvalidId;
658  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
659  if ( ymin != 0. || ymax != 0. ) {
660  // Do not check default values
661  if ( ! CheckMinMax(ymin, ymax) ) return kInvalidId;
662  }
663 
664  return fVP1Manager->SetP1(id, nbins, xmin, xmax, ymin, ymax,
665  xunitName, yunitName, xfcnName, yfcnName,
666  xbinSchemeName);
667 }
668 
669 //_____________________________________________________________________________
671  const std::vector<G4double>& edges,
673  const G4String& xunitName, const G4String& yunitName,
674  const G4String& xfcnName, const G4String& yfcnName)
675 {
676  if ( ! CheckEdges(edges) ) return kInvalidId;
677  if ( ymin != 0. || ymax != 0. ) {
678  // Do not check default values
679  if ( ! CheckMinMax(ymin, ymax) ) return kInvalidId;
680  }
681 
682  return fVP1Manager->SetP1(id, edges, ymin, ymax,
683  xunitName, yunitName, xfcnName, yfcnName);
684 }
685 
686 //_____________________________________________________________________________
688  G4int nxbins, G4double xmin, G4double xmax,
689  G4int nybins, G4double ymin, G4double ymax,
690  G4double zmin, G4double zmax,
691  const G4String& xunitName, const G4String& yunitName,
692  const G4String& zunitName,
693  const G4String& xfcnName, const G4String& yfcnName,
694  const G4String& zfcnName,
695  const G4String& xbinSchemeName,
696  const G4String& ybinSchemeName)
697 {
698  if ( ! CheckNbins(nxbins) ) return kInvalidId;
699  if ( ! CheckNbins(nybins) ) return kInvalidId;
700  if ( ! CheckMinMax(xmin, xmax, xfcnName, xbinSchemeName) ) return kInvalidId;
701  if ( ! CheckMinMax(ymin, ymax, yfcnName, ybinSchemeName) ) return kInvalidId;
702  if ( zmin != 0. || zmax != 0. ) {
703  // Do not check default values
704  if ( ! CheckMinMax(zmin, zmax) ) return kInvalidId;
705  }
706 
707  return fVP2Manager->SetP2(id, nxbins, xmin, xmax, nybins, ymin, ymax,
708  zmin, zmax,
709  xunitName, yunitName, zunitName,
710  xfcnName, yfcnName, zfcnName,
711  xbinSchemeName, ybinSchemeName);
712 }
713 
714 //_____________________________________________________________________________
716  const std::vector<G4double>& xedges,
717  const std::vector<G4double>& yedges,
718  G4double zmin, G4double zmax,
719  const G4String& xunitName,
720  const G4String& yunitName,
721  const G4String& zunitName,
722  const G4String& xfcnName,
723  const G4String& yfcnName,
724  const G4String& zfcnName)
725 {
726  if ( ! CheckEdges(xedges) ) return kInvalidId;
727  if ( ! CheckEdges(yedges) ) return kInvalidId;
728  if ( zmin != 0. || zmax != 0. ) {
729  // Do not check default values
730  if ( ! CheckMinMax(zmin, zmax) ) return kInvalidId;
731  }
732 
733  return fVP2Manager->SetP2(id, xedges, yedges, zmin, zmax,
734  xunitName, yunitName, zunitName,
735  xfcnName, yfcnName, zfcnName);
736 }
737 
738 //_____________________________________________________________________________
740 {
741  return fVP1Manager->ScaleP1(id, factor);
742 }
743 
744 //_____________________________________________________________________________
746 {
747  return fVP2Manager->ScaleP2(id, factor);
748 }
749 
750 //_____________________________________________________________________________
752  const G4String& title)
753 {
754  if ( ! CheckName(name, "Ntuple") ) return kInvalidId;
755 
756  return fVNtupleManager->CreateNtuple(name, title);
757 }
758 
759 //_____________________________________________________________________________
761 {
762  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
763 
764  return fVNtupleManager->CreateNtupleIColumn(name, 0);
765 }
766 
767 //_____________________________________________________________________________
769 {
770  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
771 
772  return fVNtupleManager->CreateNtupleFColumn(name, 0);
773 }
774 
775 //_____________________________________________________________________________
777 {
778  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
779 
780  return fVNtupleManager->CreateNtupleDColumn(name, 0);
781 }
782 
783 //_____________________________________________________________________________
785 {
786  if ( ! CheckName(name, "NtupleSColumn") ) return kInvalidId;
787 
788  return fVNtupleManager->CreateNtupleSColumn(name);
789 }
790 
791 //_____________________________________________________________________________
793  std::vector<int>& vector)
794 {
795  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
796 
797  return fVNtupleManager->CreateNtupleIColumn(name, &vector);
798 }
799 
800 //_____________________________________________________________________________
802  std::vector<float>& vector)
803 {
804  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
805 
806  return fVNtupleManager->CreateNtupleFColumn(name, &vector);
807 }
808 
809 //_____________________________________________________________________________
811  std::vector<double>& vector)
812 {
813  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
814 
815  return fVNtupleManager->CreateNtupleDColumn(name, &vector);
816 }
817 
818 //_____________________________________________________________________________
820 {
821  return fVNtupleManager->FinishNtuple();
822 }
823 
824 //_____________________________________________________________________________
826  G4int /*nofReducedNtupleFiles*/)
827 {
828 // The function is overridden in the managers which supports ntuple merging
829 // Here we give just a warning that the feature is not available.
830 
831  NtupleMergingWarning("G4VAnalysisManager::SetNtupleMerging", GetType());
832 }
833 
834 //_____________________________________________________________________________
836  G4bool /*rowMode*/)
837 {
838 // The function is overridden in the managers which supports ntuple merging
839 // Here we give just a warning that the feature is not available.
840 
841  NtupleMergingWarning("G4VAnalysisManager::SetNtupleRowWise", GetType());
842 }
843 
844 //_____________________________________________________________________________
845 void G4VAnalysisManager::SetBasketSize(unsigned int /*basketSize*/)
846 {
847 // The function is overridden in the managers which supports ntuple merging
848 // Here we give just a warning that the feature is not available.
849 
850  NtupleMergingWarning("G4VAnalysisManager::SetBasketSize", GetType());
851 }
852 
853 //_____________________________________________________________________________
854 void G4VAnalysisManager::SetBasketEntries(unsigned int /*basketEntries*/)
855 {
856 // The function is overridden in the managers which supports ntuple merging
857 // Here we give just a warning that the feature is not available.
858 
859  NtupleMergingWarning("G4VAnalysisManager::SetBasketEntries", GetType());
860 }
861 
862 //_____________________________________________________________________________
864  const G4String& name)
865 {
866  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
867 
868  return fVNtupleManager->CreateNtupleIColumn(ntupleId, name, 0);
869 }
870 
871 //_____________________________________________________________________________
873  const G4String& name)
874 {
875  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
876 
877  return fVNtupleManager->CreateNtupleFColumn(ntupleId, name, 0);
878 }
879 
880 
881 //_____________________________________________________________________________
883  const G4String& name)
884 {
885  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
886 
887  return fVNtupleManager->CreateNtupleDColumn(ntupleId, name, 0);
888 }
889 
890 //_____________________________________________________________________________
892  const G4String& name)
893 {
894  if ( ! CheckName(name, "NtupleSColumn") ) return kInvalidId;
895 
896  return fVNtupleManager->CreateNtupleSColumn(ntupleId, name);
897 }
898 
899 //_____________________________________________________________________________
901  const G4String& name,
902  std::vector<int>& vector)
903 {
904  if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
905 
906  return fVNtupleManager->CreateNtupleIColumn(ntupleId, name, &vector);
907 }
908 
909 //_____________________________________________________________________________
911  const G4String& name,
912  std::vector<float>& vector)
913 {
914  if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
915 
916  return fVNtupleManager->CreateNtupleFColumn(ntupleId, name, &vector);
917 }
918 
919 //_____________________________________________________________________________
921  const G4String& name,
922  std::vector<double>& vector)
923 {
924  if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
925 
926  return fVNtupleManager->CreateNtupleDColumn(ntupleId, name, &vector);
927 }
928 
929 //_____________________________________________________________________________
931 {
932  return fVNtupleManager->FinishNtuple(ntupleId);
933 }
934 
935 //_____________________________________________________________________________
937 {
938  G4bool finalResult = true;
939 
940  G4bool result = SetFirstH1Id(firstId);
941  finalResult = finalResult && result;
942 
943  result = SetFirstH2Id(firstId);
944  finalResult = finalResult && result;
945 
946  result = SetFirstH3Id(firstId);
947  finalResult = finalResult && result;
948 
949  return finalResult;
950 }
951 
952 //_____________________________________________________________________________
954 {
955  return fH1HnManager->SetFirstId(firstId);
956 }
957 
958 //_____________________________________________________________________________
960 {
961  return fH2HnManager->SetFirstId(firstId);
962 }
963 
964 //_____________________________________________________________________________
966 {
967  return fH3HnManager->SetFirstId(firstId);
968 }
969 
970 //_____________________________________________________________________________
972 {
973  G4bool finalResult = true;
974 
975  G4bool result = SetFirstP1Id(firstId);
976  finalResult = finalResult && result;
977 
978  result = SetFirstP2Id(firstId);
979  finalResult = finalResult && result;
980 
981  return finalResult;
982 }
983 
984 //_____________________________________________________________________________
986 {
987  return fP1HnManager->SetFirstId(firstId);
988 }
989 
990 //_____________________________________________________________________________
992 {
993  return fP2HnManager->SetFirstId(firstId);
994 }
995 
996 //_____________________________________________________________________________
998 {
999  return fVNtupleManager->SetFirstId(firstId);
1000 }
1001 
1002 //_____________________________________________________________________________
1004 {
1005  return fVNtupleManager->SetFirstNtupleColumnId(firstId);
1006 }
1007 
1008 // Fill methods in .icc
1009 
1010 //_____________________________________________________________________________
1012 {
1013  fState.SetIsActivation(activation);
1014 }
1015 
1016 // GetActivation() in .icc
1017 
1018 //_____________________________________________________________________________
1020 {
1021 // Return true if activation option is selected and any of managers has
1022 // an activated object.
1023 
1024  return fState.GetIsActivation() &&
1025  ( fH1HnManager->IsActive() ||
1026  fH2HnManager->IsActive() ||
1027  fH3HnManager->IsActive() ||
1028  fP1HnManager->IsActive() ||
1029  fP2HnManager->IsActive() );
1030 }
1031 
1032 //_____________________________________________________________________________
1034 {
1035 // Return true any of managers has an object with activated ASCII option.
1036 
1037  return ( fH1HnManager->IsAscii() ||
1038  fH2HnManager->IsAscii() ||
1039  fH3HnManager->IsAscii() ||
1040  fP1HnManager->IsAscii() ||
1041  fP2HnManager->IsAscii() );
1042 }
1043 
1044 //_____________________________________________________________________________
1046 {
1047 // Return true any of managers has an object with activated plotting option.
1048 
1049  return ( fH1HnManager->IsPlotting() ||
1050  fH2HnManager->IsPlotting() ||
1051  fH3HnManager->IsPlotting() ||
1052  fP1HnManager->IsPlotting() ||
1053  fP2HnManager->IsPlotting() );
1054 }
1055 
1056 //_____________________________________________________________________________
1058 {
1059 // Return first H1 id
1060 
1061  return fH1HnManager->GetFirstId();
1062 }
1063 
1064 //_____________________________________________________________________________
1066 {
1067 // Return first H2 id
1068 
1069  return fH2HnManager->GetFirstId();
1070 }
1071 
1072 //_____________________________________________________________________________
1074 {
1075 // Return first H3 id
1076 
1077  return fH3HnManager->GetFirstId();
1078 }
1079 
1080 //_____________________________________________________________________________
1082 {
1083 // Return first P1 id
1084 
1085  return fP1HnManager->GetFirstId();
1086 }
1087 
1088 //_____________________________________________________________________________
1090 {
1091 // Return first P2 id
1092 
1093  return fP2HnManager->GetFirstId();
1094 }
1095 
1096 //_____________________________________________________________________________
1098 {
1099 // Return first Ntuple id
1100 
1101  return fVNtupleManager->GetFirstId();
1102 }
1103 
1104 //_____________________________________________________________________________
1106 {
1107 // Return first Ntuple column id
1108 
1110 }
1111 
1112 //_____________________________________________________________________________
1114 {
1115  return fH1HnManager->GetNofHns();
1116 }
1117 
1118 //_____________________________________________________________________________
1120 {
1121  return fH2HnManager->GetNofHns();
1122 }
1123 
1124 //_____________________________________________________________________________
1126 {
1127  return fH3HnManager->GetNofHns();
1128 }
1129 
1130 //_____________________________________________________________________________
1132 {
1133  return fP1HnManager->GetNofHns();
1134 }
1135 
1136 //_____________________________________________________________________________
1138 {
1139  return fP2HnManager->GetNofHns();
1140 }
1141 
1142 //_____________________________________________________________________________
1144 {
1145  return fVNtupleManager->GetNofNtuples();
1146 }
1147 
1148 // GetH1Id(), GetH2Id in .icc
1149 
1150 //_____________________________________________________________________________
1152 {
1153 // Set activation to a given H1 object
1154 
1155  fH1HnManager->SetActivation(id, activation);
1156 }
1157 
1158 //_____________________________________________________________________________
1160 {
1161 // Set activation to all H1 objects
1162 
1163  fH1HnManager->SetActivation(activation);
1164 }
1165 
1166 //_____________________________________________________________________________
1168 {
1169  fH1HnManager->SetAscii(id, ascii);
1170 }
1171 
1172 //_____________________________________________________________________________
1174 {
1175  fH1HnManager->SetPlotting(id, plotting);
1176 }
1177 
1178 //_____________________________________________________________________________
1180 {
1181 // Set activation to a given H2 object
1182 
1183  fH2HnManager->SetActivation(id, activation);
1184 }
1185 
1186 //_____________________________________________________________________________
1188 {
1189 // Set activation to all H2 objects
1190 
1191  fH2HnManager->SetActivation(activation);
1192 }
1193 
1194 //_____________________________________________________________________________
1196 {
1197  fH2HnManager->SetAscii(id, ascii);
1198 }
1199 
1200 //_____________________________________________________________________________
1202 {
1203  fH2HnManager->SetPlotting(id, plotting);
1204 }
1205 
1206 //_____________________________________________________________________________
1208 {
1209 // Set activation to a given H3 object
1210 
1211  fH3HnManager->SetActivation(id, activation);
1212 }
1213 
1214 //_____________________________________________________________________________
1216 {
1217 // Set activation to all H3 objects
1218 
1219  fH3HnManager->SetActivation(activation);
1220 }
1221 
1222 //_____________________________________________________________________________
1224 {
1225  fH3HnManager->SetAscii(id, ascii);
1226 }
1227 
1228 //_____________________________________________________________________________
1230 {
1231  fH3HnManager->SetPlotting(id, plotting);
1232 }
1233 
1234 //_____________________________________________________________________________
1236 {
1237 // Set activation to a given P1 object
1238 
1239  fP1HnManager->SetActivation(id, activation);
1240 }
1241 
1242 //_____________________________________________________________________________
1244 {
1245 // Set activation to all P1 objects
1246 
1247  fP1HnManager->SetActivation(activation);
1248 }
1249 
1250 //_____________________________________________________________________________
1252 {
1253  fP1HnManager->SetAscii(id, ascii);
1254 }
1255 
1256 //_____________________________________________________________________________
1258 {
1259  fP1HnManager->SetPlotting(id, plotting);
1260 }
1261 
1262 //_____________________________________________________________________________
1264 {
1265 // Set activation to a given P2 object
1266 
1267  fP2HnManager->SetActivation(id, activation);
1268 }
1269 
1270 //_____________________________________________________________________________
1272 {
1273 // Set activation to all P2 objects
1274 
1275  fP2HnManager->SetActivation(activation);
1276 }
1277 
1278 //_____________________________________________________________________________
1280 {
1281  fP2HnManager->SetAscii(id, ascii);
1282 }
1283 
1284 //_____________________________________________________________________________
1286 {
1287  fP2HnManager->SetPlotting(id, plotting);
1288 }
1289 
1290 //_____________________________________________________________________________
1292 {
1293 // Set activation to a given P2 object
1294 
1295  fVNtupleManager->SetActivation(id, activation);
1296 }
1297 
1298 //_____________________________________________________________________________
1300 {
1301 // Set activation to all P2 objects
1302 
1303  fVNtupleManager->SetActivation(activation);
1304 }
1305 
1306 // Access methods in .icc
1307 
1308 //_____________________________________________________________________________
1310 {
1311  fState.SetVerboseLevel(verboseLevel);
1312 }
1313 
1314 // GetVerboseLevel() in .icc
1315