43 fNtupleBookingVector(),
45 fFirstNtupleColumnId(0),
46 fLockFirstNtupleColumnId(false)
59G4NtupleBookingManager::GetNtupleBookingInFunction(
65 G4String inFunction =
"G4NtupleBookingManager::";
66 inFunction += functionName;
68 description <<
" " <<
"ntuple booking " <<
id <<
" does not exist.";
102 ntupleBooking->fNtupleBooking.set_name(name);
103 ntupleBooking->fNtupleBooking.set_title(title);
111 description << name <<
" ntupleId " << index +
fFirstId;
121 std::vector<int>* vector)
128 std::vector<float>* vector)
135 std::vector<double>* vector)
154 G4int ntupleId,
const G4String& name, std::vector<int>* vector)
156 return CreateNtupleTColumn<int>(ntupleId, name, vector);
161 G4int ntupleId,
const G4String& name, std::vector<float>* vector)
163 return CreateNtupleTColumn<float>(ntupleId, name, vector);
168 G4int ntupleId,
const G4String& name, std::vector<double>* vector)
170 return CreateNtupleTColumn<double>(ntupleId, name, vector);
177 return CreateNtupleTColumn<std::string>(ntupleId, name,
nullptr);
185 return GetNtupleBookingInFunction(ntupleId,
"FinishNtuple");
191 if ( fLockFirstNtupleColumnId ) {
194 <<
"Cannot set FirstNtupleColumnId as its value was already used.";
195 G4Exception(
"G4BaseNtupleManager::SetFirstNtupleColumnId()",
200 fFirstNtupleColumnId = firstId;
209 ntupleBooking->fActivation = activation;
218 = GetNtupleBookingInFunction(ntupleId,
"SetActivation");
219 if ( ! ntupleBooking )
return;
221 ntupleBooking->fActivation = activation;
226 G4int ntupleId)
const
229 = GetNtupleBookingInFunction(ntupleId,
"GetActivation");
230 if ( ! ntupleBooking )
return false;
232 return ntupleBooking->fActivation;
240 ntupleBooking->fFileName = fileName;
249 = GetNtupleBookingInFunction(ntupleId,
"SetFileName");
250 if ( ! ntupleBooking )
return;
253 if ( ntupleBooking->fFileName == fileName )
return;
255 auto ntupleFileName = fileName;
257 if ( extension.size() ) {
260 if ( output == G4AnalysisOutput::kNone ) {
263 <<
"The file extension " << extension <<
"is not supported.";
270 if ( fFileType.size() ) {
272 ntupleFileName = fileName +
"." + fFileType;
279 ntupleBooking->fFileName = ntupleFileName;
284 G4int ntupleId)
const
287 = GetNtupleBookingInFunction(ntupleId,
"GetFileName");
288 if ( ! ntupleBooking )
return "";
290 return ntupleBooking->fFileName;
301 if ( fFileType == fileType )
return;
304 fFileType = fileType;
310 if ( ! (ntupleBooking->fFileName).size() )
continue;
312 auto extension =
GetExtension(ntupleBooking->fFileName);
313 if ( fFileType == extension )
continue;
316 auto baseFileName =
GetBaseName(ntupleBooking->fFileName);
317 auto ntupleFileName = baseFileName +
"." + fFileType;
318 if ( extension.size()) {
321 <<
"Writing ntuples in files of different output types "
322 << fFileType <<
", " << extension <<
" is not supported." <<
G4endl
323 <<
"Ntuple " << ntupleBooking->fNtupleBooking.name()
324 <<
" will be written in " << ntupleFileName;
330 ntupleBooking->fFileName = ntupleFileName;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
const G4AnalysisVerbose * GetVerboseL2() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState
G4bool GetActivation(G4int ntupleId) const
G4bool SetFirstNtupleColumnId(G4int firstId)
std::vector< G4NtupleBooking * > fNtupleBookingVector
G4int CreateNtupleSColumn(const G4String &name)
G4String GetFileName(G4int id) const
G4NtupleBooking * FinishNtuple()
G4int CreateNtupleDColumn(const G4String &name, std::vector< double > *vector)
G4int CreateNtuple(const G4String &name, const G4String &title)
G4int CreateNtupleFColumn(const G4String &name, std::vector< float > *vector)
~G4NtupleBookingManager()
G4NtupleBookingManager(const G4AnalysisManagerState &state)
void SetFileName(const G4String &fileName)
G4int CreateNtupleIColumn(const G4String &name, std::vector< int > *vector)
void SetFileType(const G4String &fileType)
void SetActivation(G4bool activation)
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4AnalysisOutput GetOutput(const G4String &outputName, G4bool warn=true)
G4String GetBaseName(const G4String &fileName)