File indexing completed on 2025-01-31 09:22:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include "ChemNtupleManager.hh"
0031
0032 #include "G4UnitsTable.hh"
0033 #include "G4Filesystem.hh"
0034
0035
0036
0037 void ChemNtupleManager::Book()
0038 {
0039 std::string outFolder = "chem_output";
0040 const G4fs::path outFolderP{outFolder};
0041 G4fs::file_status s = G4fs::file_status{};
0042 auto isExist = G4fs::status_known(s) ? G4fs::exists(s) : G4fs::exists(outFolderP);
0043 if (! isExist) {
0044 G4fs::create_directory(outFolderP);
0045 }
0046 G4String slash = "";
0047 #if defined(_WIN32) || defined(WIN32)
0048 slash= "\\";
0049 #else
0050 G4String slashu = "/";
0051 slash = slashu;
0052 #endif
0053 G4String fullFileName = outFolder+slash+fFileName;
0054
0055
0056 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0057 G4bool fileOpen = analysisManager->OpenFile(fullFileName.c_str());
0058 if (!fileOpen) {
0059 G4cout << "\n---> HistoManager::book(): cannot open " << fFileName
0060 << G4endl;
0061 return;
0062 }
0063 }
0064
0065
0066
0067 void ChemNtupleManager::Save()
0068 {
0069 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0070 analysisManager->Write();
0071 analysisManager->CloseFile();
0072 }
0073
0074
0075
0076 void ChemNtupleManager::FillNtupleIColumn(G4int icol, G4int ival)
0077 {
0078 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0079 analysisManager->FillNtupleIColumn(icol,ival);
0080 }
0081
0082
0083
0084 void ChemNtupleManager::FillNtupleFColumn(G4int icol, G4float fval)
0085 {
0086 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0087 analysisManager->FillNtupleFColumn(icol,fval);
0088 }
0089
0090
0091
0092 void ChemNtupleManager::FillNtupleDColumn(G4int id, G4int icol, G4double dval)
0093 {
0094 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0095 analysisManager->FillNtupleDColumn(id,icol,dval);
0096 }
0097
0098
0099
0100 void ChemNtupleManager::AddNtupleRow()
0101 {
0102 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0103 analysisManager->AddNtupleRow();
0104 }
0105
0106
0107
0108 void ChemNtupleManager::AddNtupleRow(G4int id)
0109 {
0110 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0111 analysisManager->AddNtupleRow(id);
0112 }
0113
0114
0115
0116 void ChemNtupleManager::CreateNtuples()
0117 {
0118 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0119 analysisManager->SetVerboseLevel(1);
0120 analysisManager->SetDefaultFileType("root");
0121
0122 const G4String directoryName = "ntuple";
0123 if (analysisManager->GetNtupleDirectoryName() != directoryName) {
0124 analysisManager->SetNtupleDirectoryName(directoryName);
0125 }
0126
0127
0128 if (analysisManager->GetFirstNtupleId() != 1) analysisManager->SetFirstNtupleId(1);
0129
0130
0131
0132 analysisManager->CreateNtuple("ntuple_2","DB_chemical_stage");
0133 analysisManager->CreateNtupleDColumn(1,"strand");
0134 analysisManager->CreateNtupleDColumn(1,"copyNumber");
0135 analysisManager->CreateNtupleDColumn(1,"xp");
0136 analysisManager->CreateNtupleDColumn(1,"yp");
0137 analysisManager->CreateNtupleDColumn(1,"zp");
0138 analysisManager->CreateNtupleDColumn(1,"time");
0139 analysisManager->CreateNtupleDColumn(1,"base");
0140 analysisManager->FinishNtuple(1);
0141 }
0142
0143