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 "G4HnInformation.hh" 28 << 28 #include "G4H1ToolsManager.hh" 29 #include "G4THnToolsManager.hh" << 29 #include "G4H2ToolsManager.hh" >> 30 #include "G4H3ToolsManager.hh" >> 31 #include "G4P1ToolsManager.hh" >> 32 #include "G4P2ToolsManager.hh" 30 33 31 //____________________________________________ 34 //_____________________________________________________________________________ 32 template <typename HT> 35 template <typename HT> 33 inline 36 inline 34 G4bool G4ToolsAnalysisManager::WriteT( << 37 G4bool G4ToolsAnalysisManager::WriteT(const std::vector<HT*>& htVector, 35 const std::vector<std::pair<HT*, G4HnInforma << 38 const std::vector<G4HnInformation*>& hnVector) 36 { 39 { 37 auto result = true; 40 auto result = true; 38 41 39 for ( auto& [ht, info] : hnVector) { << 42 for ( G4int i=0; i<G4int(htVector.size()); ++i ) { >> 43 auto info = hnVector[i]; 40 auto activation = info->GetActivation(); 44 auto activation = info->GetActivation(); 41 << 42 // skip writing if activation is enabled a 45 // skip writing if activation is enabled and H1 is inactivated 43 // or if histogram was deleted << 46 if ( fState.GetIsActivation() && ( ! activation ) ) continue; 44 if ( ( fState.GetIsActivation() && ( ! act << 45 ( info->GetDeleted() ) ) continue; << 46 47 47 auto name = info->GetName(); 48 auto name = info->GetName(); >> 49 auto ht = htVector[i]; >> 50 48 auto fileName = info->GetFileName(); 51 auto fileName = info->GetFileName(); 49 auto fileManager = GetFileManager(fileName 52 auto fileManager = GetFileManager(fileName); 50 53 51 // skip writing if cannot get file manager 54 // skip writing if cannot get file manager (wrong file extension) 52 if ( ! fileManager ) { 55 if ( ! fileManager ) { 53 G4Analysis::Warn( 56 G4Analysis::Warn( 54 "Cannot get file manager for file " + 57 "Cannot get file manager for file " + fileName + ".\n" + 55 "Writing " + G4Analysis::GetHnType<HT> 58 "Writing " + G4Analysis::GetHnType<HT>() + " " + name + " will be skipped.", 56 fkClass, "WriteT"); 59 fkClass, "WriteT"); 57 continue; 60 continue; 58 } 61 } 59 62 60 auto fileKind = " in file "; 63 auto fileKind = " in file "; 61 if ( fileName != "" ) { 64 if ( fileName != "" ) { 62 fileKind = " in extra file "; 65 fileKind = " in extra file "; 63 } else { 66 } else { 64 fileName = fileManager->GetFullFileName( 67 fileName = fileManager->GetFullFileName(); 65 } 68 } 66 69 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 70 Message(G4Analysis::kVL4, "write", G4Analysis::GetHnType<HT>(), 73 name + fileKind + fileName); 71 name + fileKind + fileName); 74 72 75 if ( ! fileManager->template GetHnFileMana << 73 if ( ! fileManager->GetHnFileManager<HT>()->Write(ht, name, fileName) ) { 76 G4Analysis::Warn( 74 G4Analysis::Warn( 77 "Writing " + G4Analysis::GetHnType<HT> 75 "Writing " + G4Analysis::GetHnType<HT>() + " " + name + 78 " to file " + fileName + " failed.", 76 " to file " + fileName + " failed.", 79 fkClass, "WriteT"); 77 fkClass, "WriteT"); 80 result = false; 78 result = false; 81 } 79 } 82 80 83 if (result) { << 81 // notify that file has a written object 84 // notify that file has a written object << 82 fileManager->SetIsEmpty(fileName, false); 85 fileManager->SetIsEmpty(fileName, false) << 86 } << 87 83 88 Message(G4Analysis::kVL3, "write", G4Analy 84 Message(G4Analysis::kVL3, "write", G4Analysis::GetHnType<HT>(), 89 name + " in the " + fileKind + " file " 85 name + " in the " + fileKind + " file " + fileName); 90 } 86 } 91 87 92 return result; 88 return result; 93 } 89 } 94 90 95 //____________________________________________ 91 //_____________________________________________________________________________ 96 inline 92 inline 97 G4bool G4ToolsAnalysisManager::IsOpenFileImpl( << 98 { << 99 return fVFileManager->IsOpenFile(); << 100 } << 101 << 102 //____________________________________________ << 103 inline << 104 tools::histo::h1d* G4ToolsAnalysisManager::Ge 93 tools::histo::h1d* G4ToolsAnalysisManager::GetH1(G4int id, G4bool warn, 105 94 G4bool onlyIfActive) const 106 { 95 { 107 return fH1Manager->GetT(id, warn, onlyIfActi << 96 return fH1Manager->GetH1(id, warn, onlyIfActive); 108 } 97 } 109 98 110 //____________________________________________ 99 //_____________________________________________________________________________ 111 inline 100 inline 112 tools::histo::h2d* G4ToolsAnalysisManager::Ge 101 tools::histo::h2d* G4ToolsAnalysisManager::GetH2(G4int id, G4bool warn, 113 102 G4bool onlyIfActive) const 114 { 103 { 115 return fH2Manager->GetT(id, warn, onlyIfActi << 104 return fH2Manager->GetH2(id, warn, onlyIfActive); 116 } 105 } 117 106 118 //____________________________________________ 107 //_____________________________________________________________________________ 119 inline 108 inline 120 tools::histo::h3d* G4ToolsAnalysisManager::Ge 109 tools::histo::h3d* G4ToolsAnalysisManager::GetH3(G4int id, G4bool warn, 121 110 G4bool onlyIfActive) const 122 { 111 { 123 return fH3Manager->GetT(id, warn, onlyIfActi << 112 return fH3Manager->GetH3(id, warn, onlyIfActive); 124 } 113 } 125 114 126 //____________________________________________ 115 //_____________________________________________________________________________ 127 inline 116 inline 128 tools::histo::p1d* G4ToolsAnalysisManager::Ge 117 tools::histo::p1d* G4ToolsAnalysisManager::GetP1(G4int id, G4bool warn, 129 118 G4bool onlyIfActive) const 130 { 119 { 131 return fP1Manager->GetT(id, warn, onlyIfActi << 120 return fP1Manager->GetP1(id, warn, onlyIfActive); 132 } 121 } 133 122 134 //____________________________________________ 123 //_____________________________________________________________________________ 135 inline 124 inline 136 tools::histo::p2d* G4ToolsAnalysisManager::Ge 125 tools::histo::p2d* G4ToolsAnalysisManager::GetP2(G4int id, G4bool warn, 137 126 G4bool onlyIfActive) const 138 { 127 { 139 return fP2Manager->GetT(id, warn, onlyIfActi << 128 return fP2Manager->GetP2(id, warn, onlyIfActive); 140 } 129 } 141 130 142 //____________________________________________ 131 //_____________________________________________________________________________ 143 inline 132 inline 144 std::vector<tools::histo::h1d*>::iterator G4To 133 std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::BeginH1() 145 { 134 { 146 return fH1Manager->BeginT(); << 135 return fH1Manager->BeginH1(); 147 } 136 } 148 137 149 //____________________________________________ 138 //_____________________________________________________________________________ 150 inline 139 inline 151 std::vector<tools::histo::h1d*>::iterator G4To 140 std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::EndH1() 152 { 141 { 153 return fH1Manager->EndT(); << 142 return fH1Manager->EndH1(); 154 } 143 } 155 144 156 //____________________________________________ 145 //_____________________________________________________________________________ 157 inline 146 inline 158 std::vector<tools::histo::h1d*>::const_iterato 147 std::vector<tools::histo::h1d*>::const_iterator 159 G4ToolsAnalysisManager::BeginConstH1() const 148 G4ToolsAnalysisManager::BeginConstH1() const 160 { 149 { 161 return fH1Manager->BeginConstT(); << 150 return fH1Manager->BeginConstH1(); 162 } 151 } 163 152 164 //____________________________________________ 153 //_____________________________________________________________________________ 165 inline 154 inline 166 std::vector<tools::histo::h1d*>::const_iterato 155 std::vector<tools::histo::h1d*>::const_iterator 167 G4ToolsAnalysisManager::EndConstH1() const 156 G4ToolsAnalysisManager::EndConstH1() const 168 { 157 { 169 return fH1Manager->EndConstT(); << 158 return fH1Manager->EndConstH1(); 170 } 159 } 171 160 172 //____________________________________________ 161 //_____________________________________________________________________________ 173 inline 162 inline 174 std::vector<tools::histo::h2d*>::iterator G4To 163 std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::BeginH2() 175 { 164 { 176 return fH2Manager->BeginT(); << 165 return fH2Manager->BeginH2(); 177 } 166 } 178 167 179 //____________________________________________ 168 //_____________________________________________________________________________ 180 inline 169 inline 181 std::vector<tools::histo::h2d*>::iterator G4To 170 std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::EndH2() 182 { 171 { 183 return fH2Manager->EndT(); << 172 return fH2Manager->EndH2(); 184 } 173 } 185 174 186 //____________________________________________ 175 //_____________________________________________________________________________ 187 inline 176 inline 188 std::vector<tools::histo::h2d*>::const_iterato 177 std::vector<tools::histo::h2d*>::const_iterator 189 G4ToolsAnalysisManager::BeginConstH2() const 178 G4ToolsAnalysisManager::BeginConstH2() const 190 { 179 { 191 return fH2Manager->BeginConstT(); << 180 return fH2Manager->BeginConstH2(); 192 } 181 } 193 182 194 //____________________________________________ 183 //_____________________________________________________________________________ 195 inline 184 inline 196 std::vector<tools::histo::h2d*>::const_iterato 185 std::vector<tools::histo::h2d*>::const_iterator 197 G4ToolsAnalysisManager::EndConstH2() const 186 G4ToolsAnalysisManager::EndConstH2() const 198 { 187 { 199 return fH2Manager->EndConstT(); << 188 return fH2Manager->EndConstH2(); 200 } 189 } 201 190 202 //____________________________________________ 191 //_____________________________________________________________________________ 203 inline 192 inline 204 std::vector<tools::histo::h3d*>::iterator G4To 193 std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::BeginH3() 205 { 194 { 206 return fH3Manager->BeginT(); << 195 return fH3Manager->BeginH3(); 207 } 196 } 208 197 209 //____________________________________________ 198 //_____________________________________________________________________________ 210 inline 199 inline 211 std::vector<tools::histo::h3d*>::iterator G4To 200 std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::EndH3() 212 { 201 { 213 return fH3Manager->EndT(); << 202 return fH3Manager->EndH3(); 214 } 203 } 215 204 216 //____________________________________________ 205 //_____________________________________________________________________________ 217 inline 206 inline 218 std::vector<tools::histo::h3d*>::const_iterato 207 std::vector<tools::histo::h3d*>::const_iterator 219 G4ToolsAnalysisManager::BeginConstH3() const 208 G4ToolsAnalysisManager::BeginConstH3() const 220 { 209 { 221 return fH3Manager->BeginConstT(); << 210 return fH3Manager->BeginConstH3(); 222 } 211 } 223 212 224 //____________________________________________ 213 //_____________________________________________________________________________ 225 inline 214 inline 226 std::vector<tools::histo::h3d*>::const_iterato 215 std::vector<tools::histo::h3d*>::const_iterator 227 G4ToolsAnalysisManager::EndConstH3() const 216 G4ToolsAnalysisManager::EndConstH3() const 228 { 217 { 229 return fH3Manager->EndConstT(); << 218 return fH3Manager->EndConstH3(); 230 } 219 } 231 220 232 //____________________________________________ 221 //_____________________________________________________________________________ 233 inline 222 inline 234 std::vector<tools::histo::p1d*>::iterator G4To 223 std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::BeginP1() 235 { 224 { 236 return fP1Manager->BeginT(); << 225 return fP1Manager->BeginP1(); 237 } 226 } 238 227 239 //____________________________________________ 228 //_____________________________________________________________________________ 240 inline 229 inline 241 std::vector<tools::histo::p1d*>::iterator G4To 230 std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::EndP1() 242 { 231 { 243 return fP1Manager->EndT(); << 232 return fP1Manager->EndP1(); 244 } 233 } 245 234 246 //____________________________________________ 235 //_____________________________________________________________________________ 247 inline 236 inline 248 std::vector<tools::histo::p1d*>::const_iterato 237 std::vector<tools::histo::p1d*>::const_iterator 249 G4ToolsAnalysisManager::BeginConstP1() const 238 G4ToolsAnalysisManager::BeginConstP1() const 250 { 239 { 251 return fP1Manager->BeginConstT(); << 240 return fP1Manager->BeginConstP1(); 252 } 241 } 253 242 254 //____________________________________________ 243 //_____________________________________________________________________________ 255 inline 244 inline 256 std::vector<tools::histo::p1d*>::const_iterato 245 std::vector<tools::histo::p1d*>::const_iterator 257 G4ToolsAnalysisManager::EndConstP1() const 246 G4ToolsAnalysisManager::EndConstP1() const 258 { 247 { 259 return fP1Manager->EndConstT(); << 248 return fP1Manager->EndConstP1(); 260 } 249 } 261 250 262 //____________________________________________ 251 //_____________________________________________________________________________ 263 inline 252 inline 264 std::vector<tools::histo::p2d*>::iterator G4To 253 std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::BeginP2() 265 { 254 { 266 return fP2Manager->BeginT(); << 255 return fP2Manager->BeginP2(); 267 } 256 } 268 257 269 //____________________________________________ 258 //_____________________________________________________________________________ 270 inline 259 inline 271 std::vector<tools::histo::p2d*>::iterator G4To 260 std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::EndP2() 272 { 261 { 273 return fP2Manager->EndT(); << 262 return fP2Manager->EndP2(); 274 } 263 } 275 264 276 //____________________________________________ 265 //_____________________________________________________________________________ 277 inline 266 inline 278 std::vector<tools::histo::p2d*>::const_iterato 267 std::vector<tools::histo::p2d*>::const_iterator 279 G4ToolsAnalysisManager::BeginConstP2() const 268 G4ToolsAnalysisManager::BeginConstP2() const 280 { 269 { 281 return fP2Manager->BeginConstT(); << 270 return fP2Manager->BeginConstP2(); 282 } 271 } 283 272 284 //____________________________________________ 273 //_____________________________________________________________________________ 285 inline 274 inline 286 std::vector<tools::histo::p2d*>::const_iterato 275 std::vector<tools::histo::p2d*>::const_iterator 287 G4ToolsAnalysisManager::EndConstP2() const 276 G4ToolsAnalysisManager::EndConstP2() const 288 { 277 { 289 return fP2Manager->EndConstT(); << 278 return fP2Manager->EndConstP2(); 290 } 279 } >> 280 291 281