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 // $Id: G4ToolsAnalysisManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $ 26 27 27 #include "G4HnInformation.hh" << 28 #include "G4H1ToolsManager.hh" 28 << 29 #include "G4H2ToolsManager.hh" 29 #include "G4THnToolsManager.hh" << 30 #include "G4H3ToolsManager.hh" 30 << 31 #include "G4P1ToolsManager.hh" 31 //____________________________________________ << 32 #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 33 95 //____________________________________________ 34 //_____________________________________________________________________________ 96 inline << 35 inline 97 G4bool G4ToolsAnalysisManager::IsOpenFileImpl( << 98 { << 99 return fVFileManager->IsOpenFile(); << 100 } << 101 << 102 //____________________________________________ << 103 inline << 104 tools::histo::h1d* G4ToolsAnalysisManager::Ge 36 tools::histo::h1d* G4ToolsAnalysisManager::GetH1(G4int id, G4bool warn, 105 << 37 G4bool onlyIfActive) const 106 { 38 { 107 return fH1Manager->GetT(id, warn, onlyIfActi << 39 return fH1Manager->GetH1(id, warn, onlyIfActive); 108 } 40 } 109 41 110 //____________________________________________ 42 //_____________________________________________________________________________ 111 inline << 43 inline 112 tools::histo::h2d* G4ToolsAnalysisManager::Ge 44 tools::histo::h2d* G4ToolsAnalysisManager::GetH2(G4int id, G4bool warn, 113 << 45 G4bool onlyIfActive) const 114 { 46 { 115 return fH2Manager->GetT(id, warn, onlyIfActi << 47 return fH2Manager->GetH2(id, warn, onlyIfActive); 116 } 48 } 117 49 118 //____________________________________________ 50 //_____________________________________________________________________________ 119 inline << 51 inline 120 tools::histo::h3d* G4ToolsAnalysisManager::Ge 52 tools::histo::h3d* G4ToolsAnalysisManager::GetH3(G4int id, G4bool warn, 121 << 53 G4bool onlyIfActive) const 122 { 54 { 123 return fH3Manager->GetT(id, warn, onlyIfActi << 55 return fH3Manager->GetH3(id, warn, onlyIfActive); 124 } 56 } 125 57 126 //____________________________________________ 58 //_____________________________________________________________________________ 127 inline << 59 inline 128 tools::histo::p1d* G4ToolsAnalysisManager::Ge 60 tools::histo::p1d* G4ToolsAnalysisManager::GetP1(G4int id, G4bool warn, 129 << 61 G4bool onlyIfActive) const 130 { 62 { 131 return fP1Manager->GetT(id, warn, onlyIfActi << 63 return fP1Manager->GetP1(id, warn, onlyIfActive); 132 } 64 } 133 65 134 //____________________________________________ 66 //_____________________________________________________________________________ 135 inline << 67 inline 136 tools::histo::p2d* G4ToolsAnalysisManager::Ge 68 tools::histo::p2d* G4ToolsAnalysisManager::GetP2(G4int id, G4bool warn, 137 << 69 G4bool onlyIfActive) const 138 { 70 { 139 return fP2Manager->GetT(id, warn, onlyIfActi << 71 return fP2Manager->GetP2(id, warn, onlyIfActive); 140 } 72 } 141 73 142 //____________________________________________ 74 //_____________________________________________________________________________ 143 inline 75 inline 144 std::vector<tools::histo::h1d*>::iterator G4To 76 std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::BeginH1() 145 { 77 { 146 return fH1Manager->BeginT(); << 78 return fH1Manager->BeginH1(); 147 } << 79 } 148 80 149 //____________________________________________ 81 //_____________________________________________________________________________ 150 inline 82 inline 151 std::vector<tools::histo::h1d*>::iterator G4To 83 std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::EndH1() 152 { 84 { 153 return fH1Manager->EndT(); << 85 return fH1Manager->EndH1(); 154 } << 86 } 155 87 156 //____________________________________________ 88 //_____________________________________________________________________________ 157 inline 89 inline 158 std::vector<tools::histo::h1d*>::const_iterato << 90 std::vector<tools::histo::h1d*>::const_iterator 159 G4ToolsAnalysisManager::BeginConstH1() const 91 G4ToolsAnalysisManager::BeginConstH1() const 160 { 92 { 161 return fH1Manager->BeginConstT(); << 93 return fH1Manager->BeginConstH1(); 162 } << 94 } 163 95 164 //____________________________________________ 96 //_____________________________________________________________________________ 165 inline 97 inline 166 std::vector<tools::histo::h1d*>::const_iterato << 98 std::vector<tools::histo::h1d*>::const_iterator 167 G4ToolsAnalysisManager::EndConstH1() const 99 G4ToolsAnalysisManager::EndConstH1() const 168 { 100 { 169 return fH1Manager->EndConstT(); << 101 return fH1Manager->EndConstH1(); 170 } << 102 } 171 103 172 //____________________________________________ 104 //_____________________________________________________________________________ 173 inline 105 inline 174 std::vector<tools::histo::h2d*>::iterator G4To 106 std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::BeginH2() 175 { 107 { 176 return fH2Manager->BeginT(); << 108 return fH2Manager->BeginH2(); 177 } << 109 } 178 110 179 //____________________________________________ 111 //_____________________________________________________________________________ 180 inline 112 inline 181 std::vector<tools::histo::h2d*>::iterator G4To 113 std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::EndH2() 182 { 114 { 183 return fH2Manager->EndT(); << 115 return fH2Manager->EndH2(); 184 } << 116 } 185 117 186 //____________________________________________ 118 //_____________________________________________________________________________ 187 inline 119 inline 188 std::vector<tools::histo::h2d*>::const_iterato << 120 std::vector<tools::histo::h2d*>::const_iterator 189 G4ToolsAnalysisManager::BeginConstH2() const 121 G4ToolsAnalysisManager::BeginConstH2() const 190 { 122 { 191 return fH2Manager->BeginConstT(); << 123 return fH2Manager->BeginConstH2(); 192 } << 124 } 193 125 194 //____________________________________________ 126 //_____________________________________________________________________________ 195 inline 127 inline 196 std::vector<tools::histo::h2d*>::const_iterato << 128 std::vector<tools::histo::h2d*>::const_iterator 197 G4ToolsAnalysisManager::EndConstH2() const 129 G4ToolsAnalysisManager::EndConstH2() const 198 { 130 { 199 return fH2Manager->EndConstT(); << 131 return fH2Manager->EndConstH2(); 200 } << 132 } 201 133 202 //____________________________________________ 134 //_____________________________________________________________________________ 203 inline 135 inline 204 std::vector<tools::histo::h3d*>::iterator G4To 136 std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::BeginH3() 205 { 137 { 206 return fH3Manager->BeginT(); << 138 return fH3Manager->BeginH3(); 207 } << 139 } 208 140 209 //____________________________________________ 141 //_____________________________________________________________________________ 210 inline 142 inline 211 std::vector<tools::histo::h3d*>::iterator G4To 143 std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::EndH3() 212 { 144 { 213 return fH3Manager->EndT(); << 145 return fH3Manager->EndH3(); 214 } << 146 } 215 147 216 //____________________________________________ 148 //_____________________________________________________________________________ 217 inline 149 inline 218 std::vector<tools::histo::h3d*>::const_iterato << 150 std::vector<tools::histo::h3d*>::const_iterator 219 G4ToolsAnalysisManager::BeginConstH3() const 151 G4ToolsAnalysisManager::BeginConstH3() const 220 { 152 { 221 return fH3Manager->BeginConstT(); << 153 return fH3Manager->BeginConstH3(); 222 } << 154 } 223 155 224 //____________________________________________ 156 //_____________________________________________________________________________ 225 inline 157 inline 226 std::vector<tools::histo::h3d*>::const_iterato << 158 std::vector<tools::histo::h3d*>::const_iterator 227 G4ToolsAnalysisManager::EndConstH3() const 159 G4ToolsAnalysisManager::EndConstH3() const 228 { 160 { 229 return fH3Manager->EndConstT(); << 161 return fH3Manager->EndConstH3(); 230 } << 162 } 231 163 232 //____________________________________________ 164 //_____________________________________________________________________________ 233 inline 165 inline 234 std::vector<tools::histo::p1d*>::iterator G4To 166 std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::BeginP1() 235 { 167 { 236 return fP1Manager->BeginT(); << 168 return fP1Manager->BeginP1(); 237 } << 169 } 238 170 239 //____________________________________________ 171 //_____________________________________________________________________________ 240 inline 172 inline 241 std::vector<tools::histo::p1d*>::iterator G4To 173 std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::EndP1() 242 { 174 { 243 return fP1Manager->EndT(); << 175 return fP1Manager->EndP1(); 244 } << 176 } 245 177 246 //____________________________________________ 178 //_____________________________________________________________________________ 247 inline 179 inline 248 std::vector<tools::histo::p1d*>::const_iterato << 180 std::vector<tools::histo::p1d*>::const_iterator 249 G4ToolsAnalysisManager::BeginConstP1() const 181 G4ToolsAnalysisManager::BeginConstP1() const 250 { 182 { 251 return fP1Manager->BeginConstT(); << 183 return fP1Manager->BeginConstP1(); 252 } << 184 } 253 185 254 //____________________________________________ 186 //_____________________________________________________________________________ 255 inline 187 inline 256 std::vector<tools::histo::p1d*>::const_iterato << 188 std::vector<tools::histo::p1d*>::const_iterator 257 G4ToolsAnalysisManager::EndConstP1() const 189 G4ToolsAnalysisManager::EndConstP1() const 258 { 190 { 259 return fP1Manager->EndConstT(); << 191 return fP1Manager->EndConstP1(); 260 } << 192 } 261 193 262 //____________________________________________ 194 //_____________________________________________________________________________ 263 inline 195 inline 264 std::vector<tools::histo::p2d*>::iterator G4To 196 std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::BeginP2() 265 { 197 { 266 return fP2Manager->BeginT(); << 198 return fP2Manager->BeginP2(); 267 } << 199 } 268 200 269 //____________________________________________ 201 //_____________________________________________________________________________ 270 inline 202 inline 271 std::vector<tools::histo::p2d*>::iterator G4To 203 std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::EndP2() 272 { 204 { 273 return fP2Manager->EndT(); << 205 return fP2Manager->EndP2(); 274 } << 206 } 275 207 276 //____________________________________________ 208 //_____________________________________________________________________________ 277 inline 209 inline 278 std::vector<tools::histo::p2d*>::const_iterato << 210 std::vector<tools::histo::p2d*>::const_iterator 279 G4ToolsAnalysisManager::BeginConstP2() const 211 G4ToolsAnalysisManager::BeginConstP2() const 280 { 212 { 281 return fP2Manager->BeginConstT(); << 213 return fP2Manager->BeginConstP2(); 282 } << 214 } 283 215 284 //____________________________________________ 216 //_____________________________________________________________________________ 285 inline 217 inline 286 std::vector<tools::histo::p2d*>::const_iterato << 218 std::vector<tools::histo::p2d*>::const_iterator 287 G4ToolsAnalysisManager::EndConstP2() const 219 G4ToolsAnalysisManager::EndConstP2() const 288 { 220 { 289 return fP2Manager->EndConstT(); << 221 return fP2Manager->EndConstP2(); 290 } << 222 } >> 223 291 224