49void NtupleMergingWarning(std::string_view className,
50 std::string_view functionName,
54 "Ntuple merging is not available with " + outputType +
" output.\n" +
55 "Setting is ignored.", className, functionName);
68 fMessenger = std::make_unique<G4AnalysisMessenger>(
this);
74 fgMasterInstance =
this;
77 if (fgMasterInstance !=
nullptr) {
79 fgMasterInstance->fWorkerManagers.push_back(
this);
93G4bool G4VAnalysisManager::WriteFromUI()
102 for (
auto workerManger : fWorkerManagers) {
107 result &= workerManger->Write();
129 for (
auto workerManger : fWorkerManagers) {
134 result &= workerManger->CloseFile(reset);
147G4bool G4VAnalysisManager::ResetFromUI()
156 for (
auto workerManger : fWorkerManagers) {
161 result &= workerManger->Reset();
183 Warn(
"Cannot set default file type " + value +
184 " different than the analysis manager type " +
GetType(),
185 fkClass,
"SetDefault");
189 fH1HnManager->SetDefaultFileType(value);
190 fH2HnManager->SetDefaultFileType(value);
191 fH3HnManager->SetDefaultFileType(value);
192 fP1HnManager->SetDefaultFileType(value);
193 fP2HnManager->SetDefaultFileType(value);
205 fVH1Manager.reset(h1Manager);
214 fVH2Manager.reset(h2Manager);
223 fVH3Manager.reset(h3Manager);
232 fVP1Manager.reset(p1Manager);
241 fVP2Manager.reset(p2Manager);
257 std::shared_ptr<G4VNtupleFileManager> ntupleFileManager)
267 if ( fH1HnManager !=
nullptr ) fH1HnManager->SetFileManager(fileManager);
268 if ( fH2HnManager !=
nullptr ) fH2HnManager->SetFileManager(fileManager);
269 if ( fH3HnManager !=
nullptr ) fH3HnManager->SetFileManager(fileManager);
270 if ( fP1HnManager !=
nullptr ) fP1HnManager->SetFileManager(fileManager);
271 if ( fP2HnManager !=
nullptr ) fP2HnManager->SetFileManager(std::move(fileManager));
284 if (name.find(
'.') != std::string::npos) {
285 name.erase(name.find(
'.'), name.length());
287 name.append(
".ascii");
291 std::ofstream output(name, std::ios::out);
293 Warn(
"Cannot open file. File name is not defined.",
294 fkClass,
"WriteAscii");
297 output.setf( std::ios::scientific, std::ios::floatfield );
299 result &= fVH1Manager->WriteOnAscii(output);
300 result &= fVH2Manager->WriteOnAscii(output);
301 result &= fVH3Manager->WriteOnAscii(output);
302 result &= fVP1Manager->WriteOnAscii(output);
303 result &= fVP2Manager->WriteOnAscii(output);
305 Message(
kVL1,
"write ASCII",
"file", name, result);
311std::shared_ptr<G4VFileManager>
316 if ((extension.size() != 0u) && extension !=
GetFileType()) {
318 "The file extension differs from " +
GetFileType() +
" output type.\n" +
320 fkClass,
"GetFileManager");
340 if ( fileName !=
"" ) {
344 Warn(
"Cannot open file. File name is not defined.", fkClass,
"OpenFile");
492 std::array<G4HnDimension, kDim1> bins = {
494 std::array<G4HnDimensionInformation, kDim1> info = {
497 return fVH1Manager->Create(name, title, bins, info);
502 const std::vector<G4double>& edges,
505 std::array<G4HnDimension, kDim1> bins = {
507 std::array<G4HnDimensionInformation, kDim1> info = {
510 return fVH1Manager->Create(name, title, bins, info);
523 std::array<G4HnDimension, kDim2> bins = {
526 std::array<G4HnDimensionInformation, kDim2> info = {
530 return fVH2Manager->Create(name, title, bins, info);
535 const std::vector<G4double>& xedges,
536 const std::vector<G4double>& yedges,
541 std::array<G4HnDimension, kDim2> bins = {
543 std::array<G4HnDimensionInformation, kDim2> info = {
547 return fVH2Manager->Create(name, title, bins, info);
564 std::array<G4HnDimension, kDim3> bins = {
568 std::array<G4HnDimensionInformation, kDim3> info = {
573 return fVH3Manager->Create(name, title, bins, info);
578 const std::vector<G4double>& xedges,
579 const std::vector<G4double>& yedges,
580 const std::vector<G4double>& zedges,
587 std::array<G4HnDimension, kDim3> bins = {
589 std::array<G4HnDimensionInformation, kDim3> info = {
594 return fVH3Manager->Create(name, title, bins, info);
603 std::array<G4HnDimension, kDim1> bins = {
605 std::array<G4HnDimensionInformation, kDim1> info = {
608 return fVH1Manager->Set(
id, bins, info);
613 const std::vector<G4double>& edges,
616 std::array<G4HnDimension, kDim1> bins = {
618 std::array<G4HnDimensionInformation, kDim1> info = {
621 return fVH1Manager->Set(
id, bins, info);
633 std::array<G4HnDimension, kDim2> bins = {
636 std::array<G4HnDimensionInformation, kDim2> info = {
640 return fVH2Manager->Set(
id, bins, info);
645 const std::vector<G4double>& xedges,
646 const std::vector<G4double>& yedges,
650 std::array<G4HnDimension, kDim2> bins = {
652 std::array<G4HnDimensionInformation, kDim2> info = {
656 return fVH2Manager->Set(
id, bins, info);
672 std::array<G4HnDimension, kDim3> bins = {
676 std::array<G4HnDimensionInformation, kDim3> info = {
681 return fVH3Manager->Set(
id, bins, info);
686 const std::vector<G4double>& xedges,
687 const std::vector<G4double>& yedges,
688 const std::vector<G4double>& zedges,
694 std::array<G4HnDimension, kDim3> bins = {
696 std::array<G4HnDimensionInformation, kDim3> info = {
701 return fVH3Manager->Set(
id, bins, info);
707 return fVH1Manager->Scale(
id, factor);
713 return fVH2Manager->Scale(
id, factor);
719 return fVH3Manager->Scale(
id, factor);
730 std::array<G4HnDimension, kDim2> bins = {
733 std::array<G4HnDimensionInformation, kDim2> info = {
737 return fVP1Manager->Create(name, title, bins, info);
742 const std::vector<G4double>& edges,
747 std::array<G4HnDimension, kDim2> bins = {
749 std::array<G4HnDimensionInformation, kDim2> info = {
753 return fVP1Manager->Create(name, title, bins, info);
768 std::array<G4HnDimension, kDim3> bins = {
772 std::array<G4HnDimensionInformation, kDim3> info = {
777 return fVP2Manager->Create(name, title, bins, info);
782 const std::vector<G4double>& xedges,
783 const std::vector<G4double>& yedges,
790 std::array<G4HnDimension, kDim3> bins = {
792 std::array<G4HnDimensionInformation, kDim3> info = {
797 return fVP2Manager->Create(name, title, bins, info);
808 std::array<G4HnDimension, kDim2> bins = {
811 std::array<G4HnDimensionInformation, kDim2> info = {
815 return fVP1Manager->Set(
id, bins, info);
820 const std::vector<G4double>& edges,
825 std::array<G4HnDimension, kDim2> bins = {
827 std::array<G4HnDimensionInformation, kDim2> info = {
831 return fVP1Manager->Set(
id, bins, info);
846 std::array<G4HnDimension, kDim3> bins = {
850 std::array<G4HnDimensionInformation, kDim3> info = {
855 return fVP2Manager->Set(
id, bins, info);
860 const std::vector<G4double>& xedges,
861 const std::vector<G4double>& yedges,
870 std::array<G4HnDimension, kDim3> bins = {
872 std::array<G4HnDimensionInformation, kDim3> info = {
877 return fVP2Manager->Set(
id, bins, info);
883 return fVP1Manager->Scale(
id, factor);
889 return fVP2Manager->Scale(
id, factor);
925 std::vector<int>& vector)
932 std::vector<float>& vector)
939 std::vector<double>& vector)
946 std::vector<std::string>& vector)
968 NtupleMergingWarning(fkClass,
"SetNtupleMerging",
GetType());
978 NtupleMergingWarning(fkClass,
"SetNtupleRowWise",
GetType());
987 NtupleMergingWarning(fkClass,
"SetBasketSize",
GetType());
996 NtupleMergingWarning(fkClass,
"SetBasketEntries",
GetType());
1031 std::vector<int>& vector)
1039 std::vector<float>& vector)
1047 std::vector<double>& vector)
1055 std::vector<std::string>& vector)
1085 return fH1HnManager->SetFirstId(firstId);
1091 return fH2HnManager->SetFirstId(firstId);
1097 return fH3HnManager->SetFirstId(firstId);
1114 return fP1HnManager->SetFirstId(firstId);
1120 return fP2HnManager->SetFirstId(firstId);
1154 fState.SetIsActivation(activation);
1166 ( fH1HnManager->IsActive() ||
1167 fH2HnManager->IsActive() ||
1168 fH3HnManager->IsActive() ||
1169 fP1HnManager->IsActive() ||
1170 fP2HnManager->IsActive() );
1178 return ( fH1HnManager->IsAscii() ||
1179 fH2HnManager->IsAscii() ||
1180 fH3HnManager->IsAscii() ||
1181 fP1HnManager->IsAscii() ||
1182 fP2HnManager->IsAscii() );
1190 return ( fH1HnManager->IsPlotting() ||
1191 fH2HnManager->IsPlotting() ||
1192 fH3HnManager->IsPlotting() ||
1193 fP1HnManager->IsPlotting() ||
1194 fP2HnManager->IsPlotting() );
1202 return fH1HnManager->GetFirstId();
1210 return fH2HnManager->GetFirstId();
1218 return fH3HnManager->GetFirstId();
1226 return fP1HnManager->GetFirstId();
1234 return fP2HnManager->GetFirstId();
1256 return fVH1Manager->GetNofHns(onlyIfExist);
1262 return fVH2Manager->GetNofHns(onlyIfExist);
1268 return fVH3Manager->GetNofHns(onlyIfExist);
1274 return fVP1Manager->GetNofHns(onlyIfExist);
1280 return fVP2Manager->GetNofHns(onlyIfExist);
1294 return fVH1Manager->List(
G4cout, onlyIfActive);
1300 return fVH2Manager->List(
G4cout, onlyIfActive);
1306 return fVH3Manager->List(
G4cout, onlyIfActive);
1312 return fVP1Manager->List(
G4cout, onlyIfActive);
1318 return fVP2Manager->List(
G4cout, onlyIfActive);
1331 result &=
ListH1(onlyIfActive);
1332 result &=
ListH2(onlyIfActive);
1333 result &=
ListH3(onlyIfActive);
1334 result &=
ListP1(onlyIfActive);
1335 result &=
ListP2(onlyIfActive);
1346 fH1HnManager->SetActivation(
id, activation);
1354 fH1HnManager->SetActivation(activation);
1360 fH1HnManager->SetAscii(
id, ascii);
1366 fH1HnManager->SetPlotting(
id, plotting);
1372 fH1HnManager->SetFileName(
id, fileName);
1380 fH2HnManager->SetActivation(
id, activation);
1388 fH2HnManager->SetActivation(activation);
1394 fH2HnManager->SetAscii(
id, ascii);
1400 fH2HnManager->SetPlotting(
id, plotting);
1406 fH2HnManager->SetFileName(
id, fileName);
1414 fH3HnManager->SetActivation(
id, activation);
1422 fH3HnManager->SetActivation(activation);
1428 fH3HnManager->SetAscii(
id, ascii);
1434 fH3HnManager->SetPlotting(
id, plotting);
1440 fH3HnManager->SetFileName(
id, fileName);
1448 fP1HnManager->SetActivation(
id, activation);
1456 fP1HnManager->SetActivation(activation);
1462 fP1HnManager->SetAscii(
id, ascii);
1468 fP1HnManager->SetPlotting(
id, plotting);
1474 fP1HnManager->SetFileName(
id, fileName);
1482 fP2HnManager->SetActivation(
id, activation);
1490 fP2HnManager->SetActivation(activation);
1496 fP2HnManager->SetAscii(
id, ascii);
1502 fP2HnManager->SetPlotting(
id, plotting);
1508 fP2HnManager->SetFileName(
id, fileName);
1552 return fVH1Manager->Delete(
id, keepSetting);
1558 return fVH2Manager->Delete(
id, keepSetting);
1564 return fVH3Manager->Delete(
id, keepSetting);
1570 return fVP1Manager->Delete(
id, keepSetting);
1576 return fVP2Manager->Delete(
id, keepSetting);
1596 fState.SetVerboseLevel(verboseLevel);
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
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
G4bool DeleteH1(G4int id, G4bool keepSetting=false)
void SetP1Manager(G4VTBaseHnManager< kDim2 > *p1Manager)
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")
void SetP2Manager(G4VTBaseHnManager< kDim3 > *p2Manager)
G4int GetFirstH2Id() const
G4int GetNofH3s(G4bool onlyIfExist=false) const
void SetH2FileName(G4int id, const G4String &fileName)
G4VAnalysisManager()=delete
void SetH1Activation(G4bool activation)
G4bool DeleteNtuple(G4int id, G4bool clear=false)
G4bool ListH1(G4bool onlyIfActive=true) const
virtual std::shared_ptr< G4VFileManager > GetFileManager(const G4String &fileName)
virtual ~G4VAnalysisManager()
virtual void SetDefaultFileTypeImpl(const G4String &value)
void SetH1Plotting(G4int id, G4bool plotting)
void SetH3Ascii(G4int id, G4bool ascii)
G4int GetNofH2s(G4bool onlyIfExist=false) const
void SetH3Activation(G4bool activation)
G4int GetFirstP1Id() const
G4bool DeleteP1(G4int id, G4bool keepSetting=false)
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 GetNofH1s(G4bool onlyIfExist=false) const
G4int CreateNtupleDColumn(const G4String &name)
void SetH3Plotting(G4int id, G4bool plotting)
G4int GetNofP1s(G4bool onlyIfExist=false) const
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
G4bool DeleteP2(G4int id, G4bool keepSetting=false)
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)
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")
G4int GetNofP2s(G4bool onlyIfExist=false) const
std::shared_ptr< G4VNtupleFileManager > fVNtupleFileManager
void SetH1Manager(G4VTBaseHnManager< kDim1 > *h1Manager)
virtual G4bool OpenFileImpl(const G4String &fileName)=0
void SetH3Manager(G4VTBaseHnManager< kDim3 > *h3Manager)
void SetActivation(G4bool activation)
G4bool SetFirstNtupleColumnId(G4int firstId)
G4String GetFileName() const
G4bool ListH2(G4bool onlyIfActive=true) const
G4String GetDefaultFileType() 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 DeleteH2(G4int id, G4bool keepSetting=false)
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)
virtual void SetBasketSize(unsigned int basketSize)
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 DeleteH3(G4int id, G4bool keepSetting=false)
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
virtual G4String GetDefaultFileTypeImpl() const
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
void SetH2Manager(G4VTBaseHnManager< kDim2 > *h2Manager)
G4bool SetFirstNtupleId(G4int firstId)
G4bool IsOpenFile() const
G4bool SetFirstHistoId(G4int firstId)
G4bool SetFirstProfileId(G4int firstId)
G4bool SetNtupleDirectoryName(const G4String &dirName)
G4int GetFirstH3Id() const
G4bool ScaleP2(G4int id, G4double factor)
virtual G4bool CloseFileImpl(G4bool reset)=0
G4bool ScaleH2(G4int id, G4double factor)
void SetDefaultFileType(const G4String &value)
G4bool Merge(tools::histo::hmpi *hmpi)
void SetP2Ascii(G4int id, G4bool ascii)
void SetH2Plotting(G4int id, G4bool plotting)
G4bool ListH3(G4bool onlyIfActive=true) const
G4int GetNofNtuples(G4bool onlyIfExist=false) 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)