50void NtupleMergingWarning(std::string_view className,
51 std::string_view functionName,
55 "Ntuple merging is not available with " + outputType +
" output.\n" +
56 "Setting is ignored.", className, functionName);
69 fMessenger = std::make_unique<G4AnalysisMessenger>(
this);
75 fgMasterInstance =
this;
78 if (fgMasterInstance !=
nullptr) {
80 fgMasterInstance->fWorkerManagers.push_back(
this);
94G4bool G4VAnalysisManager::WriteFromUI()
103 for (
auto workerManger : fWorkerManagers) {
108 result &= workerManger->Write();
130 for (
auto workerManger : fWorkerManagers) {
135 result &= workerManger->CloseFile(reset);
148G4bool G4VAnalysisManager::ResetFromUI()
157 for (
auto workerManger : fWorkerManagers) {
162 result &= workerManger->Reset();
181 fVH1Manager.reset(h1Manager);
189 fVH2Manager.reset(h2Manager);
197 fVH3Manager.reset(h3Manager);
205 fVP1Manager.reset(p1Manager);
213 fVP2Manager.reset(p2Manager);
228 std::shared_ptr<G4VNtupleFileManager> ntupleFileManager)
238 if ( fH1HnManager !=
nullptr ) fH1HnManager->SetFileManager(fileManager);
239 if ( fH2HnManager !=
nullptr ) fH2HnManager->SetFileManager(fileManager);
240 if ( fH3HnManager !=
nullptr ) fH3HnManager->SetFileManager(fileManager);
241 if ( fP1HnManager !=
nullptr ) fP1HnManager->SetFileManager(fileManager);
242 if ( fP2HnManager !=
nullptr ) fP2HnManager->SetFileManager(std::move(fileManager));
255 if (name.find(
'.') != std::string::npos) {
256 name.erase(name.find(
'.'), name.length());
258 name.append(
".ascii");
262 std::ofstream output(name, std::ios::out);
264 Warn(
"Cannot open file. File name is not defined.",
265 fkClass,
"WriteAscii");
268 output.setf( std::ios::scientific, std::ios::floatfield );
270 result &= fVH1Manager->WriteOnAscii(output);
271 result &= fVH2Manager->WriteOnAscii(output);
272 result &= fVH3Manager->WriteOnAscii(output);
273 result &= fVP1Manager->WriteOnAscii(output);
274 result &= fVP2Manager->WriteOnAscii(output);
276 Message(
kVL1,
"write ASCII",
"file", name, result);
282std::shared_ptr<G4VFileManager>
287 if ((extension.size() != 0u) && extension !=
GetFileType()) {
289 "The file extension differs from " +
GetFileType() +
" output type.\n" +
291 fkClass,
"GetFileManager");
311 if ( fileName !=
"" ) {
315 Warn(
"Cannot open file. File name is not defined.", fkClass,
"OpenFile");
418 fState.SetCompressionLevel(level);
451 std::array<G4HnDimension, kDim1> bins = {
453 std::array<G4HnDimensionInformation, kDim1> info = {
456 return fVH1Manager->Create(name, title, bins, info);
461 const std::vector<G4double>& edges,
464 std::array<G4HnDimension, kDim1> bins = {
466 std::array<G4HnDimensionInformation, kDim1> info = {
469 return fVH1Manager->Create(name, title, bins, info);
482 std::array<G4HnDimension, kDim2> bins = {
485 std::array<G4HnDimensionInformation, kDim2> info = {
489 return fVH2Manager->Create(name, title, bins, info);
494 const std::vector<G4double>& xedges,
495 const std::vector<G4double>& yedges,
500 std::array<G4HnDimension, kDim2> bins = {
502 std::array<G4HnDimensionInformation, kDim2> info = {
506 return fVH2Manager->Create(name, title, bins, info);
523 std::array<G4HnDimension, kDim3> bins = {
527 std::array<G4HnDimensionInformation, kDim3> info = {
532 return fVH3Manager->Create(name, title, bins, info);
537 const std::vector<G4double>& xedges,
538 const std::vector<G4double>& yedges,
539 const std::vector<G4double>& zedges,
546 std::array<G4HnDimension, kDim3> bins = {
548 std::array<G4HnDimensionInformation, kDim3> info = {
553 return fVH3Manager->Create(name, title, bins, info);
562 std::array<G4HnDimension, kDim1> bins = {
564 std::array<G4HnDimensionInformation, kDim1> info = {
567 return fVH1Manager->Set(
id, bins, info);
572 const std::vector<G4double>& edges,
575 std::array<G4HnDimension, kDim1> bins = {
577 std::array<G4HnDimensionInformation, kDim1> info = {
580 return fVH1Manager->Set(
id, bins, info);
592 std::array<G4HnDimension, kDim2> bins = {
595 std::array<G4HnDimensionInformation, kDim2> info = {
599 return fVH2Manager->Set(
id, bins, info);
604 const std::vector<G4double>& xedges,
605 const std::vector<G4double>& yedges,
609 std::array<G4HnDimension, kDim2> bins = {
611 std::array<G4HnDimensionInformation, kDim2> info = {
615 return fVH2Manager->Set(
id, bins, info);
631 std::array<G4HnDimension, kDim3> bins = {
635 std::array<G4HnDimensionInformation, kDim3> info = {
640 return fVH3Manager->Set(
id, bins, info);
645 const std::vector<G4double>& xedges,
646 const std::vector<G4double>& yedges,
647 const std::vector<G4double>& zedges,
653 std::array<G4HnDimension, kDim3> bins = {
655 std::array<G4HnDimensionInformation, kDim3> info = {
660 return fVH3Manager->Set(
id, bins, info);
666 return fVH1Manager->Scale(
id, factor);
672 return fVH2Manager->Scale(
id, factor);
678 return fVH3Manager->Scale(
id, factor);
689 std::array<G4HnDimension, kDim2> bins = {
692 std::array<G4HnDimensionInformation, kDim2> info = {
696 return fVP1Manager->Create(name, title, bins, info);
701 const std::vector<G4double>& edges,
706 std::array<G4HnDimension, kDim2> bins = {
708 std::array<G4HnDimensionInformation, kDim2> info = {
712 return fVP1Manager->Create(name, title, bins, info);
727 std::array<G4HnDimension, kDim3> bins = {
731 std::array<G4HnDimensionInformation, kDim3> info = {
736 return fVP2Manager->Create(name, title, bins, info);
741 const std::vector<G4double>& xedges,
742 const std::vector<G4double>& yedges,
749 std::array<G4HnDimension, kDim3> bins = {
751 std::array<G4HnDimensionInformation, kDim3> info = {
756 return fVP2Manager->Create(name, title, bins, info);
767 std::array<G4HnDimension, kDim2> bins = {
770 std::array<G4HnDimensionInformation, kDim2> info = {
774 return fVP1Manager->Set(
id, bins, info);
779 const std::vector<G4double>& edges,
784 std::array<G4HnDimension, kDim2> bins = {
786 std::array<G4HnDimensionInformation, kDim2> info = {
790 return fVP1Manager->Set(
id, bins, info);
805 std::array<G4HnDimension, kDim3> bins = {
809 std::array<G4HnDimensionInformation, kDim3> info = {
814 return fVP2Manager->Set(
id, bins, info);
819 const std::vector<G4double>& xedges,
820 const std::vector<G4double>& yedges,
829 std::array<G4HnDimension, kDim3> bins = {
831 std::array<G4HnDimensionInformation, kDim3> info = {
836 return fVP2Manager->Set(
id, bins, info);
842 return fVP1Manager->Scale(
id, factor);
848 return fVP2Manager->Scale(
id, factor);
884 std::vector<int>& vector)
891 std::vector<float>& vector)
898 std::vector<double>& vector)
905 std::vector<std::string>& vector)
927 NtupleMergingWarning(fkClass,
"SetNtupleMerging",
GetType());
937 NtupleMergingWarning(fkClass,
"SetNtupleRowWise",
GetType());
946 NtupleMergingWarning(fkClass,
"SetBasketSize",
GetType());
955 NtupleMergingWarning(fkClass,
"SetBasketEntries",
GetType());
990 std::vector<int>& vector)
998 std::vector<float>& vector)
1006 std::vector<double>& vector)
1014 std::vector<std::string>& vector)
1044 return fH1HnManager->SetFirstId(firstId);
1050 return fH2HnManager->SetFirstId(firstId);
1056 return fH3HnManager->SetFirstId(firstId);
1073 return fP1HnManager->SetFirstId(firstId);
1079 return fP2HnManager->SetFirstId(firstId);
1113 fState.SetIsActivation(activation);
1125 ( fH1HnManager->IsActive() ||
1126 fH2HnManager->IsActive() ||
1127 fH3HnManager->IsActive() ||
1128 fP1HnManager->IsActive() ||
1129 fP2HnManager->IsActive() );
1137 return ( fH1HnManager->IsAscii() ||
1138 fH2HnManager->IsAscii() ||
1139 fH3HnManager->IsAscii() ||
1140 fP1HnManager->IsAscii() ||
1141 fP2HnManager->IsAscii() );
1149 return ( fH1HnManager->IsPlotting() ||
1150 fH2HnManager->IsPlotting() ||
1151 fH3HnManager->IsPlotting() ||
1152 fP1HnManager->IsPlotting() ||
1153 fP2HnManager->IsPlotting() );
1161 return fH1HnManager->GetFirstId();
1169 return fH2HnManager->GetFirstId();
1177 return fH3HnManager->GetFirstId();
1185 return fP1HnManager->GetFirstId();
1193 return fP2HnManager->GetFirstId();
1215 return fH1HnManager->GetNofHns();
1221 return fH2HnManager->GetNofHns();
1227 return fH3HnManager->GetNofHns();
1233 return fP1HnManager->GetNofHns();
1239 return fP2HnManager->GetNofHns();
1257 return fVH1Manager->List(
G4cout, onlyIfActive);
1263 return fVH2Manager->List(
G4cout, onlyIfActive);
1269 return fVH3Manager->List(
G4cout, onlyIfActive);
1275 return fVP1Manager->List(
G4cout, onlyIfActive);
1281 return fVP2Manager->List(
G4cout, onlyIfActive);
1297 result &=
ListH1(onlyIfActive);
1298 result &=
ListH2(onlyIfActive);
1299 result &=
ListH3(onlyIfActive);
1300 result &=
ListP1(onlyIfActive);
1301 result &=
ListP2(onlyIfActive);
1312 fH1HnManager->SetActivation(
id, activation);
1320 fH1HnManager->SetActivation(activation);
1326 fH1HnManager->SetAscii(
id, ascii);
1332 fH1HnManager->SetPlotting(
id, plotting);
1338 fH1HnManager->SetFileName(
id, fileName);
1346 fH2HnManager->SetActivation(
id, activation);
1354 fH2HnManager->SetActivation(activation);
1360 fH2HnManager->SetAscii(
id, ascii);
1366 fH2HnManager->SetPlotting(
id, plotting);
1372 fH2HnManager->SetFileName(
id, fileName);
1380 fH3HnManager->SetActivation(
id, activation);
1388 fH3HnManager->SetActivation(activation);
1394 fH3HnManager->SetAscii(
id, ascii);
1400 fH3HnManager->SetPlotting(
id, plotting);
1406 fH3HnManager->SetFileName(
id, fileName);
1414 fP1HnManager->SetActivation(
id, activation);
1422 fP1HnManager->SetActivation(activation);
1428 fP1HnManager->SetAscii(
id, ascii);
1434 fP1HnManager->SetPlotting(
id, plotting);
1440 fP1HnManager->SetFileName(
id, fileName);
1448 fP2HnManager->SetActivation(
id, activation);
1456 fP2HnManager->SetActivation(activation);
1462 fP2HnManager->SetAscii(
id, ascii);
1468 fP2HnManager->SetPlotting(
id, plotting);
1474 fP2HnManager->SetFileName(
id, fileName);
1520 fState.SetVerboseLevel(verboseLevel);
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
G4int GetCompressionLevel() const
G4bool GetIsMaster() const
G4bool GetIsActivation() const
G4bool ListNtuple(G4bool onlyIfActive=true) 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")
virtual G4bool MergeImpl(tools::histo::hmpi *hmpi)=0
G4int GetFirstP2Id() const
void SetH1Ascii(G4int id, G4bool ascii)
G4int GetFirstNtupleId() const
virtual G4bool IsOpenFileImpl() const =0
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")
G4int GetFirstH2Id() const
void SetH3Manager(G4VTBaseHnManager< 3 > *h3Manager)
void SetH2FileName(G4int id, const G4String &fileName)
G4VAnalysisManager()=delete
void SetH1Activation(G4bool activation)
G4bool ListH1(G4bool onlyIfActive=true) const
virtual std::shared_ptr< G4VFileManager > GetFileManager(const G4String &fileName)
virtual ~G4VAnalysisManager()
void SetH1Plotting(G4int id, G4bool plotting)
void SetH3Ascii(G4int id, G4bool ascii)
G4int GetNofNtuples() const
void SetH3Activation(G4bool activation)
G4int GetFirstP1Id() const
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")
G4int CreateNtupleIColumn(const G4String &name)
virtual G4bool WriteImpl()=0
G4String GetHistoDirectoryName() const
G4int CreateNtupleDColumn(const G4String &name)
void SetH3Plotting(G4int id, G4bool plotting)
void SetP2FileName(G4int id, const G4String &fileName)
void SetNtupleFileName(const G4String &fileName)
G4int CreateNtupleFColumn(const G4String &name)
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 GetFirstH1Id() const
void SetP2Plotting(G4int id, G4bool plotting)
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")
G4bool SetFirstP1Id(G4int firstId)
void SetP2Manager(G4VTBaseHnManager< 3 > *p2Manager)
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")
std::shared_ptr< G4VNtupleFileManager > fVNtupleFileManager
virtual G4bool OpenFileImpl(const G4String &fileName)=0
void SetActivation(G4bool activation)
G4bool SetFirstNtupleColumnId(G4int firstId)
G4String GetFileName() const
G4bool ListH2(G4bool onlyIfActive=true) const
G4bool CloseFile(G4bool reset=true)
G4bool OpenFile(const G4String &fileName="")
void SetH3FileName(G4int id, const G4String &fileName)
virtual void ClearImpl()=0
std::shared_ptr< G4NtupleBookingManager > fNtupleBookingManager
G4bool ScaleP1(G4int id, G4double factor)
G4bool ScaleH3(G4int id, G4double factor)
void SetH2Ascii(G4int id, G4bool ascii)
G4bool ListP2(G4bool onlyIfActive=true) const
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
G4int CreateNtupleSColumn(const G4String &name)
virtual G4bool PlotImpl()=0
G4bool IsPlotting() const
void SetP1Ascii(G4int id, G4bool ascii)
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")
G4bool SetFirstH3Id(G4int firstId)
G4bool SetHistoDirectoryName(const G4String &dirName)
G4AnalysisManagerState fState
void SetP2Activation(G4bool activation)
void SetH1FileName(G4int id, const G4String &fileName)
virtual void SetNtupleRowWise(G4bool rowWise, G4bool rowMode=true)
void SetP1Plotting(G4int id, G4bool plotting)
void SetH1Manager(G4VTBaseHnManager< 1 > *h1Manager)
virtual void SetBasketSize(unsigned int basketSize)
void SetP1Manager(G4VTBaseHnManager< 2 > *p1Manager)
void SetFileManager(std::shared_ptr< G4VFileManager > fileManager)
void SetP1FileName(G4int id, const G4String &fileName)
G4bool WriteAscii(const G4String &fileName)
virtual void SetNtupleMerging(G4bool mergeNtuples, G4int nofReducedNtupleFiles=0)
G4bool ListP1(G4bool onlyIfActive=true) const
void SetP1Activation(G4bool activation)
virtual void SetBasketEntries(unsigned int basketEntries)
G4int GetFirstNtupleColumnId() const
void SetVerboseLevel(G4int verboseLevel)
G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
void SetH2Activation(G4bool activation)
G4int CreateNtuple(const G4String &name, const G4String &title)
std::shared_ptr< G4VNtupleManager > fVNtupleManager
void SetNtupleManager(std::shared_ptr< G4VNtupleManager > ntupleManager)
G4bool SetFirstH2Id(G4int firstId)
G4bool SetFirstP2Id(G4int firstId)
G4bool List(G4bool onlyIfActive=true) const
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")
G4String GetFileType() const
virtual G4bool ResetImpl()=0
std::shared_ptr< G4VFileManager > fVFileManager
G4bool SetFileName(const G4String &fileName)
void SetCompressionLevel(G4int level)
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")
void SetNtupleActivation(G4bool activation)
G4int GetCompressionLevel() const
G4bool SetFirstH1Id(G4int firstId)
G4bool ScaleH1(G4int id, G4double factor)
G4String GetNtupleDirectoryName() const
G4bool SetFirstNtupleId(G4int firstId)
G4bool IsOpenFile() const
G4bool SetFirstHistoId(G4int firstId)
G4bool SetFirstProfileId(G4int firstId)
G4bool SetNtupleDirectoryName(const G4String &dirName)
void SetH2Manager(G4VTBaseHnManager< 2 > *h2Manager)
G4int GetFirstH3Id() const
G4bool ScaleP2(G4int id, G4double factor)
virtual G4bool CloseFileImpl(G4bool reset)=0
G4bool ScaleH2(G4int id, G4double factor)
G4bool Merge(tools::histo::hmpi *hmpi)
void SetP2Ascii(G4int id, G4bool ascii)
void SetH2Plotting(G4int id, G4bool plotting)
G4bool ListH3(G4bool onlyIfActive=true) const
void SetNtupleFileManager(std::shared_ptr< G4VNtupleFileManager > ntupleFileManager)
virtual std::shared_ptr< G4HnManager > GetHnManager()=0
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
void G4SetThreadId(G4int aNewValue)