Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 26 27 #include "G4HnInformation.hh" << 27 #include "G4H1ToolsManager.hh" 28 << 28 #include "G4H2ToolsManager.hh" 29 #include "G4THnToolsManager.hh" << 29 #include "G4H3ToolsManager.hh" 30 << 30 #include "G4P1ToolsManager.hh" 31 //____________________________________________ << 31 #include "G4P2ToolsManager.hh" 32 template <typename HT> << 33 inline << 34 G4bool G4ToolsAnalysisManager::WriteT( << 35 const std::vector<std::pair<HT*, G4HnInforma << 36 { << 37 auto result = true; << 38 << 39 for ( auto& [ht, info] : hnVector) { << 40 auto activation = info->GetActivation(); << 41 << 42 // skip writing if activation is enabled a << 43 // or if histogram was deleted << 44 if ( ( fState.GetIsActivation() && ( ! act << 45 ( info->GetDeleted() ) ) continue; << 46 << 47 auto name = info->GetName(); << 48 auto fileName = info->GetFileName(); << 49 auto fileManager = GetFileManager(fileName << 50 << 51 // skip writing if cannot get file manager << 52 if ( ! fileManager ) { << 53 G4Analysis::Warn( << 54 "Cannot get file manager for file " + << 55 "Writing " + G4Analysis::GetHnType<HT> << 56 fkClass, "WriteT"); << 57 continue; << 58 } << 59 << 60 auto fileKind = " in file "; << 61 if ( fileName != "" ) { << 62 fileKind = " in extra file "; << 63 } else { << 64 fileName = fileManager->GetFullFileName( << 65 } << 66 << 67 // update name with a cycle number << 68 if (! fileManager->HasCycles() && fState.G << 69 name += "_v" + std::to_string(fState.Get << 70 } << 71 << 72 Message(G4Analysis::kVL4, "write", G4Analy << 73 name + fileKind + fileName); << 74 << 75 if ( ! fileManager->template GetHnFileMana << 76 G4Analysis::Warn( << 77 "Writing " + G4Analysis::GetHnType<HT> << 78 " to file " + fileName + " failed.", << 79 fkClass, "WriteT"); << 80 result = false; << 81 } << 82 << 83 if (result) { << 84 // notify that file has a written object << 85 fileManager->SetIsEmpty(fileName, false) << 86 } << 87 << 88 Message(G4Analysis::kVL3, "write", G4Analy << 89 name + " in the " + fileKind + " file " << 90 } << 91 << 92 return result; << 93 } << 94 32 95 //____________________________________________ 33 //_____________________________________________________________________________ 96 inline << 34 inline 97 G4bool G4ToolsAnalysisManager::IsOpenFileImpl( << 98 { << 99 return fVFileManager->IsOpenFile(); << 100 } << 101 << 102 //____________________________________________ << 103 inline << 104 tools::histo::h1d* G4ToolsAnalysisManager::Ge 35 tools::histo::h1d* G4ToolsAnalysisManager::GetH1(G4int id, G4bool warn, 105 << 36 G4bool onlyIfActive) const 106 { 37 { 107 return fH1Manager->GetT(id, warn, onlyIfActi << 38 return fH1Manager->GetH1(id, warn, onlyIfActive); 108 } 39 } 109 40 110 //____________________________________________ 41 //_____________________________________________________________________________ 111 inline << 42 inline 112 tools::histo::h2d* G4ToolsAnalysisManager::Ge 43 tools::histo::h2d* G4ToolsAnalysisManager::GetH2(G4int id, G4bool warn, 113 << 44 G4bool onlyIfActive) const 114 { 45 { 115 return fH2Manager->GetT(id, warn, onlyIfActi << 46 return fH2Manager->GetH2(id, warn, onlyIfActive); 116 } 47 } 117 48 118 //____________________________________________ 49 //_____________________________________________________________________________ 119 inline << 50 inline 120 tools::histo::h3d* G4ToolsAnalysisManager::Ge 51 tools::histo::h3d* G4ToolsAnalysisManager::GetH3(G4int id, G4bool warn, 121 << 52 G4bool onlyIfActive) const 122 { 53 { 123 return fH3Manager->GetT(id, warn, onlyIfActi << 54 return fH3Manager->GetH3(id, warn, onlyIfActive); 124 } 55 } 125 56 126 //____________________________________________ 57 //_____________________________________________________________________________ 127 inline << 58 inline 128 tools::histo::p1d* G4ToolsAnalysisManager::Ge 59 tools::histo::p1d* G4ToolsAnalysisManager::GetP1(G4int id, G4bool warn, 129 << 60 G4bool onlyIfActive) const 130 { 61 { 131 return fP1Manager->GetT(id, warn, onlyIfActi << 62 return fP1Manager->GetP1(id, warn, onlyIfActive); 132 } 63 } 133 64 134 //____________________________________________ 65 //_____________________________________________________________________________ 135 inline << 66 inline 136 tools::histo::p2d* G4ToolsAnalysisManager::Ge 67 tools::histo::p2d* G4ToolsAnalysisManager::GetP2(G4int id, G4bool warn, 137 << 68 G4bool onlyIfActive) const 138 { 69 { 139 return fP2Manager->GetT(id, warn, onlyIfActi << 70 return fP2Manager->GetP2(id, warn, onlyIfActive); 140 } 71 } 141 72 142 //____________________________________________ 73 //_____________________________________________________________________________ 143 inline 74 inline 144 std::vector<tools::histo::h1d*>::iterator G4To 75 std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::BeginH1() 145 { 76 { 146 return fH1Manager->BeginT(); << 77 return fH1Manager->BeginH1(); 147 } << 78 } 148 79 149 //____________________________________________ 80 //_____________________________________________________________________________ 150 inline 81 inline 151 std::vector<tools::histo::h1d*>::iterator G4To 82 std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::EndH1() 152 { 83 { 153 return fH1Manager->EndT(); << 84 return fH1Manager->EndH1(); 154 } << 85 } 155 86 156 //____________________________________________ 87 //_____________________________________________________________________________ 157 inline 88 inline 158 std::vector<tools::histo::h1d*>::const_iterato << 89 std::vector<tools::histo::h1d*>::const_iterator 159 G4ToolsAnalysisManager::BeginConstH1() const 90 G4ToolsAnalysisManager::BeginConstH1() const 160 { 91 { 161 return fH1Manager->BeginConstT(); << 92 return fH1Manager->BeginConstH1(); 162 } << 93 } 163 94 164 //____________________________________________ 95 //_____________________________________________________________________________ 165 inline 96 inline 166 std::vector<tools::histo::h1d*>::const_iterato << 97 std::vector<tools::histo::h1d*>::const_iterator 167 G4ToolsAnalysisManager::EndConstH1() const 98 G4ToolsAnalysisManager::EndConstH1() const 168 { 99 { 169 return fH1Manager->EndConstT(); << 100 return fH1Manager->EndConstH1(); 170 } << 101 } 171 102 172 //____________________________________________ 103 //_____________________________________________________________________________ 173 inline 104 inline 174 std::vector<tools::histo::h2d*>::iterator G4To 105 std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::BeginH2() 175 { 106 { 176 return fH2Manager->BeginT(); << 107 return fH2Manager->BeginH2(); 177 } << 108 } 178 109 179 //____________________________________________ 110 //_____________________________________________________________________________ 180 inline 111 inline 181 std::vector<tools::histo::h2d*>::iterator G4To 112 std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::EndH2() 182 { 113 { 183 return fH2Manager->EndT(); << 114 return fH2Manager->EndH2(); 184 } << 115 } 185 116 186 //____________________________________________ 117 //_____________________________________________________________________________ 187 inline 118 inline 188 std::vector<tools::histo::h2d*>::const_iterato << 119 std::vector<tools::histo::h2d*>::const_iterator 189 G4ToolsAnalysisManager::BeginConstH2() const 120 G4ToolsAnalysisManager::BeginConstH2() const 190 { 121 { 191 return fH2Manager->BeginConstT(); << 122 return fH2Manager->BeginConstH2(); 192 } << 123 } 193 124 194 //____________________________________________ 125 //_____________________________________________________________________________ 195 inline 126 inline 196 std::vector<tools::histo::h2d*>::const_iterato << 127 std::vector<tools::histo::h2d*>::const_iterator 197 G4ToolsAnalysisManager::EndConstH2() const 128 G4ToolsAnalysisManager::EndConstH2() const 198 { 129 { 199 return fH2Manager->EndConstT(); << 130 return fH2Manager->EndConstH2(); 200 } << 131 } 201 132 202 //____________________________________________ 133 //_____________________________________________________________________________ 203 inline 134 inline 204 std::vector<tools::histo::h3d*>::iterator G4To 135 std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::BeginH3() 205 { 136 { 206 return fH3Manager->BeginT(); << 137 return fH3Manager->BeginH3(); 207 } << 138 } 208 139 209 //____________________________________________ 140 //_____________________________________________________________________________ 210 inline 141 inline 211 std::vector<tools::histo::h3d*>::iterator G4To 142 std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::EndH3() 212 { 143 { 213 return fH3Manager->EndT(); << 144 return fH3Manager->EndH3(); 214 } << 145 } 215 146 216 //____________________________________________ 147 //_____________________________________________________________________________ 217 inline 148 inline 218 std::vector<tools::histo::h3d*>::const_iterato << 149 std::vector<tools::histo::h3d*>::const_iterator 219 G4ToolsAnalysisManager::BeginConstH3() const 150 G4ToolsAnalysisManager::BeginConstH3() const 220 { 151 { 221 return fH3Manager->BeginConstT(); << 152 return fH3Manager->BeginConstH3(); 222 } << 153 } 223 154 224 //____________________________________________ 155 //_____________________________________________________________________________ 225 inline 156 inline 226 std::vector<tools::histo::h3d*>::const_iterato << 157 std::vector<tools::histo::h3d*>::const_iterator 227 G4ToolsAnalysisManager::EndConstH3() const 158 G4ToolsAnalysisManager::EndConstH3() const 228 { 159 { 229 return fH3Manager->EndConstT(); << 160 return fH3Manager->EndConstH3(); 230 } << 161 } 231 162 232 //____________________________________________ 163 //_____________________________________________________________________________ 233 inline 164 inline 234 std::vector<tools::histo::p1d*>::iterator G4To 165 std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::BeginP1() 235 { 166 { 236 return fP1Manager->BeginT(); << 167 return fP1Manager->BeginP1(); 237 } << 168 } 238 169 239 //____________________________________________ 170 //_____________________________________________________________________________ 240 inline 171 inline 241 std::vector<tools::histo::p1d*>::iterator G4To 172 std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::EndP1() 242 { 173 { 243 return fP1Manager->EndT(); << 174 return fP1Manager->EndP1(); 244 } << 175 } 245 176 246 //____________________________________________ 177 //_____________________________________________________________________________ 247 inline 178 inline 248 std::vector<tools::histo::p1d*>::const_iterato << 179 std::vector<tools::histo::p1d*>::const_iterator 249 G4ToolsAnalysisManager::BeginConstP1() const 180 G4ToolsAnalysisManager::BeginConstP1() const 250 { 181 { 251 return fP1Manager->BeginConstT(); << 182 return fP1Manager->BeginConstP1(); 252 } << 183 } 253 184 254 //____________________________________________ 185 //_____________________________________________________________________________ 255 inline 186 inline 256 std::vector<tools::histo::p1d*>::const_iterato << 187 std::vector<tools::histo::p1d*>::const_iterator 257 G4ToolsAnalysisManager::EndConstP1() const 188 G4ToolsAnalysisManager::EndConstP1() const 258 { 189 { 259 return fP1Manager->EndConstT(); << 190 return fP1Manager->EndConstP1(); 260 } << 191 } 261 192 262 //____________________________________________ 193 //_____________________________________________________________________________ 263 inline 194 inline 264 std::vector<tools::histo::p2d*>::iterator G4To 195 std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::BeginP2() 265 { 196 { 266 return fP2Manager->BeginT(); << 197 return fP2Manager->BeginP2(); 267 } << 198 } 268 199 269 //____________________________________________ 200 //_____________________________________________________________________________ 270 inline 201 inline 271 std::vector<tools::histo::p2d*>::iterator G4To 202 std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::EndP2() 272 { 203 { 273 return fP2Manager->EndT(); << 204 return fP2Manager->EndP2(); 274 } << 205 } 275 206 276 //____________________________________________ 207 //_____________________________________________________________________________ 277 inline 208 inline 278 std::vector<tools::histo::p2d*>::const_iterato << 209 std::vector<tools::histo::p2d*>::const_iterator 279 G4ToolsAnalysisManager::BeginConstP2() const 210 G4ToolsAnalysisManager::BeginConstP2() const 280 { 211 { 281 return fP2Manager->BeginConstT(); << 212 return fP2Manager->BeginConstP2(); 282 } << 213 } 283 214 284 //____________________________________________ 215 //_____________________________________________________________________________ 285 inline 216 inline 286 std::vector<tools::histo::p2d*>::const_iterato << 217 std::vector<tools::histo::p2d*>::const_iterator 287 G4ToolsAnalysisManager::EndConstP2() const 218 G4ToolsAnalysisManager::EndConstP2() const 288 { 219 { 289 return fP2Manager->EndConstT(); << 220 return fP2Manager->EndConstP2(); 290 } << 221 } >> 222 291 223