Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4Hdf5NtupleManager.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id$
27 
28 // Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
29 
30 #include "G4Hdf5NtupleManager.hh"
31 #include "G4Hdf5FileManager.hh"
33 #include "G4AnalysisUtilities.hh"
34 #include "G4UnitsTable.hh"
35 
36 #include "tools/ntuple_booking"
37 
38 #include <iostream>
39 //#include <cstdio>
40 
41 using namespace G4Analysis;
42 
43 //_____________________________________________________________________________
45  : G4TNtupleManager<tools::hdf5::ntuple>(state),
46  fFileManager(nullptr)
47 {}
48 
49 //_____________________________________________________________________________
51 {}
52 
53 //
54 // private methods
55 //
56 //_____________________________________________________________________________
58  G4TNtupleDescription<tools::hdf5::ntuple>* /*ntupleDescription*/,
59  const G4String& /*name*/, const G4String& /*title*/)
60 {
61  // Ntuple will be created at finish ntuple from ntuple_booking
62 }
63 
64 //_____________________________________________________________________________
67 {
68  // create a file for this ntuple
69  // if ( ! fFileManager->CreateNtupleFile(ntupleDescription) ) return;
70 
71  // Check ntuple directory
72  if ( fFileManager->GetNtupleDirectory() < 0 ) {
73  G4String inFunction = "G4Hdf5NtupleManager::::CreateTNtupleFromBooking";
74  G4ExceptionDescription description;
75  description << " "
76  << "Cannot create ntuple. Ntuple directory does not exist." << G4endl;
77  G4Exception(inFunction, "Analysis_W002", JustWarning, description);
78  return;
79  }
80 
81  auto basketSize = fFileManager->GetBasketSize();
82  // auto compressionLevel = fState.GetCompressionLevel();
83  auto compressionLevel = 0;
84 
85  // create ntuple
86  ntupleDescription->fNtuple
87  = new tools::hdf5::ntuple(
88  G4cout, fFileManager->GetNtupleDirectory(), ntupleDescription->fNtupleBooking,
89  compressionLevel, basketSize);
90 
91  fNtupleVector.push_back(ntupleDescription->fNtuple);
92 }
93 
94 //_____________________________________________________________________________
96  G4TNtupleDescription<tools::hdf5::ntuple>* /*ntupleDescription*/)
97 {
98  // if ( ! ntupleDescription->fNtuple ) return;
99 
100  // Only ntuple description is created on CreateNtuple call
101  // CreateTNtupleFromBooking(ntupleDescription);
102 
103  fFileManager->LockNtupleDirectoryName();
104 }
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
TTree * ntuple
#define G4endl
Definition: G4ios.hh:61
std::shared_ptr< G4Hdf5FileManager > fFileManager
G4Hdf5NtupleManager(const G4AnalysisManagerState &state)
virtual void CreateTNtupleFromBooking(NtupleDescriptionType *ntupleDescription) final
virtual void CreateTNtuple(NtupleDescriptionType *ntupleDescription, const G4String &name, const G4String &title) final
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
G4GLOB_DLL std::ostream G4cout
tools::ntuple_booking fNtupleBooking
virtual void FinishTNtuple(NtupleDescriptionType *ntupleDescription) final
std::vector< tools::hdf5::ntuple * > fNtupleVector