Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 27 #include "G4HnInformation.hh" 28 29 #include "G4THnToolsManager.hh" 30 31 //____________________________________________ 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 95 //____________________________________________ 96 inline 97 G4bool G4ToolsAnalysisManager::IsOpenFileImpl( 98 { 99 return fVFileManager->IsOpenFile(); 100 } 101 102 //____________________________________________ 103 inline 104 tools::histo::h1d* G4ToolsAnalysisManager::Ge 105 106 { 107 return fH1Manager->GetT(id, warn, onlyIfActi 108 } 109 110 //____________________________________________ 111 inline 112 tools::histo::h2d* G4ToolsAnalysisManager::Ge 113 114 { 115 return fH2Manager->GetT(id, warn, onlyIfActi 116 } 117 118 //____________________________________________ 119 inline 120 tools::histo::h3d* G4ToolsAnalysisManager::Ge 121 122 { 123 return fH3Manager->GetT(id, warn, onlyIfActi 124 } 125 126 //____________________________________________ 127 inline 128 tools::histo::p1d* G4ToolsAnalysisManager::Ge 129 130 { 131 return fP1Manager->GetT(id, warn, onlyIfActi 132 } 133 134 //____________________________________________ 135 inline 136 tools::histo::p2d* G4ToolsAnalysisManager::Ge 137 138 { 139 return fP2Manager->GetT(id, warn, onlyIfActi 140 } 141 142 //____________________________________________ 143 inline 144 std::vector<tools::histo::h1d*>::iterator G4To 145 { 146 return fH1Manager->BeginT(); 147 } 148 149 //____________________________________________ 150 inline 151 std::vector<tools::histo::h1d*>::iterator G4To 152 { 153 return fH1Manager->EndT(); 154 } 155 156 //____________________________________________ 157 inline 158 std::vector<tools::histo::h1d*>::const_iterato 159 G4ToolsAnalysisManager::BeginConstH1() const 160 { 161 return fH1Manager->BeginConstT(); 162 } 163 164 //____________________________________________ 165 inline 166 std::vector<tools::histo::h1d*>::const_iterato 167 G4ToolsAnalysisManager::EndConstH1() const 168 { 169 return fH1Manager->EndConstT(); 170 } 171 172 //____________________________________________ 173 inline 174 std::vector<tools::histo::h2d*>::iterator G4To 175 { 176 return fH2Manager->BeginT(); 177 } 178 179 //____________________________________________ 180 inline 181 std::vector<tools::histo::h2d*>::iterator G4To 182 { 183 return fH2Manager->EndT(); 184 } 185 186 //____________________________________________ 187 inline 188 std::vector<tools::histo::h2d*>::const_iterato 189 G4ToolsAnalysisManager::BeginConstH2() const 190 { 191 return fH2Manager->BeginConstT(); 192 } 193 194 //____________________________________________ 195 inline 196 std::vector<tools::histo::h2d*>::const_iterato 197 G4ToolsAnalysisManager::EndConstH2() const 198 { 199 return fH2Manager->EndConstT(); 200 } 201 202 //____________________________________________ 203 inline 204 std::vector<tools::histo::h3d*>::iterator G4To 205 { 206 return fH3Manager->BeginT(); 207 } 208 209 //____________________________________________ 210 inline 211 std::vector<tools::histo::h3d*>::iterator G4To 212 { 213 return fH3Manager->EndT(); 214 } 215 216 //____________________________________________ 217 inline 218 std::vector<tools::histo::h3d*>::const_iterato 219 G4ToolsAnalysisManager::BeginConstH3() const 220 { 221 return fH3Manager->BeginConstT(); 222 } 223 224 //____________________________________________ 225 inline 226 std::vector<tools::histo::h3d*>::const_iterato 227 G4ToolsAnalysisManager::EndConstH3() const 228 { 229 return fH3Manager->EndConstT(); 230 } 231 232 //____________________________________________ 233 inline 234 std::vector<tools::histo::p1d*>::iterator G4To 235 { 236 return fP1Manager->BeginT(); 237 } 238 239 //____________________________________________ 240 inline 241 std::vector<tools::histo::p1d*>::iterator G4To 242 { 243 return fP1Manager->EndT(); 244 } 245 246 //____________________________________________ 247 inline 248 std::vector<tools::histo::p1d*>::const_iterato 249 G4ToolsAnalysisManager::BeginConstP1() const 250 { 251 return fP1Manager->BeginConstT(); 252 } 253 254 //____________________________________________ 255 inline 256 std::vector<tools::histo::p1d*>::const_iterato 257 G4ToolsAnalysisManager::EndConstP1() const 258 { 259 return fP1Manager->EndConstT(); 260 } 261 262 //____________________________________________ 263 inline 264 std::vector<tools::histo::p2d*>::iterator G4To 265 { 266 return fP2Manager->BeginT(); 267 } 268 269 //____________________________________________ 270 inline 271 std::vector<tools::histo::p2d*>::iterator G4To 272 { 273 return fP2Manager->EndT(); 274 } 275 276 //____________________________________________ 277 inline 278 std::vector<tools::histo::p2d*>::const_iterato 279 G4ToolsAnalysisManager::BeginConstP2() const 280 { 281 return fP2Manager->BeginConstT(); 282 } 283 284 //____________________________________________ 285 inline 286 std::vector<tools::histo::p2d*>::const_iterato 287 G4ToolsAnalysisManager::EndConstP2() const 288 { 289 return fP2Manager->EndConstT(); 290 } 291