File indexing completed on 2025-01-18 09:59:12
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 #include "G4HnInformation.hh"
0028
0029 #include "G4THnToolsManager.hh"
0030
0031
0032 template <typename HT>
0033 inline
0034 G4bool G4ToolsAnalysisManager::WriteT(
0035 const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector)
0036 {
0037 auto result = true;
0038
0039 for ( auto& [ht, info] : hnVector) {
0040 auto activation = info->GetActivation();
0041
0042
0043
0044 if ( ( fState.GetIsActivation() && ( ! activation ) ) ||
0045 ( info->GetDeleted() ) ) continue;
0046
0047 auto name = info->GetName();
0048 auto fileName = info->GetFileName();
0049 auto fileManager = GetFileManager(fileName);
0050
0051
0052 if ( ! fileManager ) {
0053 G4Analysis::Warn(
0054 "Cannot get file manager for file " + fileName + ".\n" +
0055 "Writing " + G4Analysis::GetHnType<HT>() + " " + name + " will be skipped.",
0056 fkClass, "WriteT");
0057 continue;
0058 }
0059
0060 auto fileKind = " in file ";
0061 if ( fileName != "" ) {
0062 fileKind = " in extra file ";
0063 } else {
0064 fileName = fileManager->GetFullFileName();
0065 }
0066
0067
0068 if (! fileManager->HasCycles() && fState.GetCycle() > 0) {
0069 name += "_v" + std::to_string(fState.GetCycle());
0070 }
0071
0072 Message(G4Analysis::kVL4, "write", G4Analysis::GetHnType<HT>(),
0073 name + fileKind + fileName);
0074
0075 if ( ! fileManager->template GetHnFileManager<HT>()->Write(ht, name, fileName) ) {
0076 G4Analysis::Warn(
0077 "Writing " + G4Analysis::GetHnType<HT>() + " " + name +
0078 " to file " + fileName + " failed.",
0079 fkClass, "WriteT");
0080 result = false;
0081 }
0082
0083 if (result) {
0084
0085 fileManager->SetIsEmpty(fileName, false);
0086 }
0087
0088 Message(G4Analysis::kVL3, "write", G4Analysis::GetHnType<HT>(),
0089 name + " in the " + fileKind + " file " + fileName);
0090 }
0091
0092 return result;
0093 }
0094
0095
0096 inline
0097 G4bool G4ToolsAnalysisManager::IsOpenFileImpl() const
0098 {
0099 return fVFileManager->IsOpenFile();
0100 }
0101
0102
0103 inline
0104 tools::histo::h1d* G4ToolsAnalysisManager::GetH1(G4int id, G4bool warn,
0105 G4bool onlyIfActive) const
0106 {
0107 return fH1Manager->GetT(id, warn, onlyIfActive);
0108 }
0109
0110
0111 inline
0112 tools::histo::h2d* G4ToolsAnalysisManager::GetH2(G4int id, G4bool warn,
0113 G4bool onlyIfActive) const
0114 {
0115 return fH2Manager->GetT(id, warn, onlyIfActive);
0116 }
0117
0118
0119 inline
0120 tools::histo::h3d* G4ToolsAnalysisManager::GetH3(G4int id, G4bool warn,
0121 G4bool onlyIfActive) const
0122 {
0123 return fH3Manager->GetT(id, warn, onlyIfActive);
0124 }
0125
0126
0127 inline
0128 tools::histo::p1d* G4ToolsAnalysisManager::GetP1(G4int id, G4bool warn,
0129 G4bool onlyIfActive) const
0130 {
0131 return fP1Manager->GetT(id, warn, onlyIfActive);
0132 }
0133
0134
0135 inline
0136 tools::histo::p2d* G4ToolsAnalysisManager::GetP2(G4int id, G4bool warn,
0137 G4bool onlyIfActive) const
0138 {
0139 return fP2Manager->GetT(id, warn, onlyIfActive);
0140 }
0141
0142
0143 inline
0144 std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::BeginH1()
0145 {
0146 return fH1Manager->BeginT();
0147 }
0148
0149
0150 inline
0151 std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::EndH1()
0152 {
0153 return fH1Manager->EndT();
0154 }
0155
0156
0157 inline
0158 std::vector<tools::histo::h1d*>::const_iterator
0159 G4ToolsAnalysisManager::BeginConstH1() const
0160 {
0161 return fH1Manager->BeginConstT();
0162 }
0163
0164
0165 inline
0166 std::vector<tools::histo::h1d*>::const_iterator
0167 G4ToolsAnalysisManager::EndConstH1() const
0168 {
0169 return fH1Manager->EndConstT();
0170 }
0171
0172
0173 inline
0174 std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::BeginH2()
0175 {
0176 return fH2Manager->BeginT();
0177 }
0178
0179
0180 inline
0181 std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::EndH2()
0182 {
0183 return fH2Manager->EndT();
0184 }
0185
0186
0187 inline
0188 std::vector<tools::histo::h2d*>::const_iterator
0189 G4ToolsAnalysisManager::BeginConstH2() const
0190 {
0191 return fH2Manager->BeginConstT();
0192 }
0193
0194
0195 inline
0196 std::vector<tools::histo::h2d*>::const_iterator
0197 G4ToolsAnalysisManager::EndConstH2() const
0198 {
0199 return fH2Manager->EndConstT();
0200 }
0201
0202
0203 inline
0204 std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::BeginH3()
0205 {
0206 return fH3Manager->BeginT();
0207 }
0208
0209
0210 inline
0211 std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::EndH3()
0212 {
0213 return fH3Manager->EndT();
0214 }
0215
0216
0217 inline
0218 std::vector<tools::histo::h3d*>::const_iterator
0219 G4ToolsAnalysisManager::BeginConstH3() const
0220 {
0221 return fH3Manager->BeginConstT();
0222 }
0223
0224
0225 inline
0226 std::vector<tools::histo::h3d*>::const_iterator
0227 G4ToolsAnalysisManager::EndConstH3() const
0228 {
0229 return fH3Manager->EndConstT();
0230 }
0231
0232
0233 inline
0234 std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::BeginP1()
0235 {
0236 return fP1Manager->BeginT();
0237 }
0238
0239
0240 inline
0241 std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::EndP1()
0242 {
0243 return fP1Manager->EndT();
0244 }
0245
0246
0247 inline
0248 std::vector<tools::histo::p1d*>::const_iterator
0249 G4ToolsAnalysisManager::BeginConstP1() const
0250 {
0251 return fP1Manager->BeginConstT();
0252 }
0253
0254
0255 inline
0256 std::vector<tools::histo::p1d*>::const_iterator
0257 G4ToolsAnalysisManager::EndConstP1() const
0258 {
0259 return fP1Manager->EndConstT();
0260 }
0261
0262
0263 inline
0264 std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::BeginP2()
0265 {
0266 return fP2Manager->BeginT();
0267 }
0268
0269
0270 inline
0271 std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::EndP2()
0272 {
0273 return fP2Manager->EndT();
0274 }
0275
0276
0277 inline
0278 std::vector<tools::histo::p2d*>::const_iterator
0279 G4ToolsAnalysisManager::BeginConstP2() const
0280 {
0281 return fP2Manager->BeginConstT();
0282 }
0283
0284
0285 inline
0286 std::vector<tools::histo::p2d*>::const_iterator
0287 G4ToolsAnalysisManager::EndConstP2() const
0288 {
0289 return fP2Manager->EndConstT();
0290 }