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 // Author: Ivana Hrivnacova, 09/07/2013 (ivan 28 29 #include "G4VAnalysisReader.hh" 30 #include "G4AnalysisUtilities.hh" 31 #include "G4HnManager.hh" 32 #include "G4VRNtupleManager.hh" 33 #include "G4VRFileManager.hh" 34 #include "G4Threading.hh" 35 36 using namespace G4Analysis; 37 38 //____________________________________________ 39 G4VAnalysisReader::G4VAnalysisReader(const G4S 40 : fState(type, ! G4Threading::IsWorkerThread( 41 {} 42 43 //____________________________________________ 44 G4VAnalysisReader::~G4VAnalysisReader() = defa 45 46 // 47 // protected methods 48 // 49 50 //____________________________________________ 51 void G4VAnalysisReader::SetH1Manager(G4VTBaseH 52 { 53 fVH1Manager.reset(h1Manager); 54 } 55 56 //____________________________________________ 57 void G4VAnalysisReader::SetH2Manager(G4VTBaseH 58 { 59 fVH2Manager.reset(h2Manager); 60 } 61 62 //____________________________________________ 63 void G4VAnalysisReader::SetH3Manager(G4VTBaseH 64 { 65 fVH3Manager.reset(h3Manager); 66 } 67 68 //____________________________________________ 69 void G4VAnalysisReader::SetP1Manager(G4VTBaseH 70 { 71 fVP1Manager.reset(p1Manager); 72 } 73 74 //____________________________________________ 75 void G4VAnalysisReader::SetP2Manager(G4VTBaseH 76 { 77 fVP2Manager.reset(p2Manager); 78 } 79 80 //____________________________________________ 81 void G4VAnalysisReader::SetNtupleManager(std:: 82 { 83 fVNtupleManager = std::move(ntupleManager); 84 } 85 86 //____________________________________________ 87 void G4VAnalysisReader::SetFileManager(std::sh 88 { 89 fVFileManager = std::move(fileManager); 90 } 91 92 // 93 // public methods 94 // 95 96 //____________________________________________ 97 G4bool G4VAnalysisReader::CloseFiles(G4bool re 98 { 99 return CloseFilesImpl(reset); 100 } 101 102 //____________________________________________ 103 void G4VAnalysisReader::SetFileName(const G4St 104 { 105 fVFileManager->SetFileName(fileName); 106 } 107 108 //____________________________________________ 109 G4String G4VAnalysisReader::GetFileName() cons 110 { 111 return fVFileManager->GetFileName(); 112 } 113 114 //____________________________________________ 115 G4int G4VAnalysisReader::ReadH1(const G4String 116 const G4String 117 const G4String 118 { 119 if ( fileName != "" ) { 120 return ReadH1Impl(h1Name, fileName, dirNam 121 } 122 if (fVFileManager->GetFileName() == "") { 123 Warn("Cannot get H1 " + h1Name + ". File n 124 return kInvalidId; 125 } 126 return ReadH1Impl(h1Name, fVFileManager->Get 127 } 128 129 //____________________________________________ 130 G4int G4VAnalysisReader::ReadH2(const G4String 131 const G4String 132 const G4String 133 { 134 if ( fileName != "" ) { 135 return ReadH2Impl(h2Name, fileName, dirNam 136 } 137 if (fVFileManager->GetFileName() == "") { 138 Warn("Cannot get H2 " + h2Name + ". File n 139 return kInvalidId; 140 } 141 return ReadH2Impl(h2Name, fVFileManager->Get 142 } 143 144 //____________________________________________ 145 G4int G4VAnalysisReader::ReadH3(const G4String 146 const G4String 147 const G4String 148 { 149 if ( fileName != "" ) { 150 return ReadH3Impl(h3Name, fileName, dirNam 151 } 152 if (fVFileManager->GetFileName() == "") { 153 Warn("Cannot get H3 " + h3Name + ". File n 154 return kInvalidId; 155 } 156 return ReadH3Impl(h3Name, fVFileManager->Get 157 } 158 159 //____________________________________________ 160 G4int G4VAnalysisReader::ReadP1(const G4String 161 const G4String 162 const G4String 163 { 164 if ( fileName != "" ) { 165 return ReadP1Impl(p1Name, fileName, dirNam 166 } 167 if (fVFileManager->GetFileName() == "") { 168 Warn("Cannot get P1 " + p1Name + ". File n 169 return kInvalidId; 170 } 171 return ReadP1Impl(p1Name, fVFileManager->Get 172 } 173 174 //____________________________________________ 175 G4int G4VAnalysisReader::ReadP2(const G4String 176 const G4String 177 const G4String 178 { 179 if ( fileName != "" ) { 180 return ReadP2Impl(p2Name, fileName, dirNam 181 } 182 if (fVFileManager->GetFileName() == "") { 183 Warn("Cannot get P2 " + p2Name + ". File n 184 return kInvalidId; 185 } 186 return ReadP2Impl(p2Name, fVFileManager->Get 187 } 188 189 //____________________________________________ 190 G4bool G4VAnalysisReader::SetFirstHistoId(G4in 191 { 192 auto result = true; 193 194 result &= SetFirstH1Id(firstId); 195 result &= SetFirstH2Id(firstId); 196 result &= SetFirstH3Id(firstId); 197 198 return result; 199 } 200 201 //____________________________________________ 202 G4bool G4VAnalysisReader::SetFirstH1Id(G4int f 203 { 204 return fVH1Manager->GetHnManager()->SetFirst 205 } 206 207 //____________________________________________ 208 G4bool G4VAnalysisReader::SetFirstH2Id(G4int f 209 { 210 return fVH2Manager->GetHnManager()->SetFirst 211 } 212 213 //____________________________________________ 214 G4bool G4VAnalysisReader::SetFirstH3Id(G4int f 215 { 216 return fVH3Manager->GetHnManager()->SetFirst 217 } 218 219 //____________________________________________ 220 G4bool G4VAnalysisReader::SetFirstProfileId(G4 221 { 222 auto result = true; 223 224 result &= SetFirstP1Id(firstId); 225 result &= SetFirstP2Id(firstId); 226 227 return result; 228 } 229 230 //____________________________________________ 231 G4bool G4VAnalysisReader::SetFirstP1Id(G4int f 232 { 233 return fVP1Manager->GetHnManager()->SetFirst 234 } 235 236 //____________________________________________ 237 G4bool G4VAnalysisReader::SetFirstP2Id(G4int f 238 { 239 return fVP2Manager->GetHnManager()->SetFirst 240 } 241 242 //____________________________________________ 243 G4bool G4VAnalysisReader::SetFirstNtupleId(G4i 244 { 245 return fVNtupleManager->SetFirstId(firstId); 246 } 247 248 //____________________________________________ 249 G4int G4VAnalysisReader::GetNtuple(const G4Str 250 const G4Str 251 const G4Str 252 { 253 if ( fileName != "" ) { 254 return fVNtupleManager->ReadNtupleImpl(ntu 255 } 256 // Check if fileName was set 257 if (fVFileManager->GetFileName() == "") { 258 Warn("Cannot read Ntuple " + ntupleName += 259 "ReadNtuple"); 260 return kInvalidId; 261 } 262 return fVNtupleManager->ReadNtupleImpl(ntupl 263 } 264 265 //____________________________________________ 266 G4bool G4VAnalysisReader::SetNtupleIColumn(con 267 G4 268 { 269 return fVNtupleManager->SetNtupleIColumn(col 270 } 271 272 //____________________________________________ 273 G4bool G4VAnalysisReader::SetNtupleFColumn(con 274 G4 275 { 276 return fVNtupleManager->SetNtupleFColumn(col 277 } 278 279 //____________________________________________ 280 G4bool G4VAnalysisReader::SetNtupleDColumn(con 281 G4 282 { 283 return fVNtupleManager->SetNtupleDColumn(col 284 } 285 286 //____________________________________________ 287 G4bool G4VAnalysisReader::SetNtupleSColumn(con 288 G4 289 { 290 return fVNtupleManager->SetNtupleSColumn(col 291 } 292 293 //____________________________________________ 294 G4bool G4VAnalysisReader::SetNtupleIColumn(con 295 st 296 { 297 return fVNtupleManager->SetNtupleIColumn(col 298 } 299 300 //____________________________________________ 301 G4bool G4VAnalysisReader::SetNtupleFColumn(con 302 st 303 { 304 return fVNtupleManager->SetNtupleFColumn(col 305 } 306 307 //____________________________________________ 308 G4bool G4VAnalysisReader::SetNtupleDColumn(con 309 st 310 { 311 return fVNtupleManager->SetNtupleDColumn(col 312 } 313 314 //____________________________________________ 315 G4bool G4VAnalysisReader::SetNtupleSColumn(con 316 st 317 { 318 return fVNtupleManager->SetNtupleSColumn(col 319 } 320 321 //____________________________________________ 322 G4bool G4VAnalysisReader::SetNtupleIColumn(G4i 323 co 324 G4 325 { 326 return fVNtupleManager->SetNtupleIColumn(ntu 327 } 328 329 //____________________________________________ 330 G4bool G4VAnalysisReader::SetNtupleFColumn(G4i 331 co 332 G4 333 { 334 return fVNtupleManager->SetNtupleFColumn(ntu 335 } 336 337 //____________________________________________ 338 G4bool G4VAnalysisReader::SetNtupleDColumn(G4i 339 co 340 G4 341 { 342 return fVNtupleManager->SetNtupleDColumn(ntu 343 } 344 345 //____________________________________________ 346 G4bool G4VAnalysisReader::SetNtupleSColumn(G4i 347 co 348 G4 349 { 350 return fVNtupleManager->SetNtupleSColumn(ntu 351 } 352 353 //____________________________________________ 354 G4bool G4VAnalysisReader::SetNtupleIColumn(G4i 355 co 356 st 357 { 358 return fVNtupleManager->SetNtupleIColumn(ntu 359 } 360 361 //____________________________________________ 362 G4bool G4VAnalysisReader::SetNtupleFColumn(G4i 363 co 364 st 365 { 366 return fVNtupleManager->SetNtupleFColumn(ntu 367 } 368 369 //____________________________________________ 370 G4bool G4VAnalysisReader::SetNtupleDColumn(G4i 371 co 372 st 373 { 374 return fVNtupleManager->SetNtupleDColumn(ntu 375 } 376 377 //____________________________________________ 378 G4bool G4VAnalysisReader::SetNtupleSColumn(G4i 379 co 380 st 381 { 382 return fVNtupleManager->SetNtupleSColumn(ntu 383 } 384 385 //____________________________________________ 386 G4bool G4VAnalysisReader::GetNtupleRow() 387 { 388 return fVNtupleManager->GetNtupleRow(); 389 } 390 391 392 //____________________________________________ 393 G4bool G4VAnalysisReader::GetNtupleRow(G4int n 394 { 395 return fVNtupleManager->GetNtupleRow(ntupleI 396 } 397 398 //____________________________________________ 399 G4int G4VAnalysisReader::GetNofH1s(G4bool only 400 { 401 return fVH1Manager->GetNofHns(onlyIfExist); 402 } 403 404 //____________________________________________ 405 G4int G4VAnalysisReader::GetNofH2s(G4bool only 406 { 407 return fVH2Manager->GetNofHns(onlyIfExist); 408 } 409 410 //____________________________________________ 411 G4int G4VAnalysisReader::GetNofH3s(G4bool only 412 { 413 return fVH3Manager->GetNofHns(onlyIfExist); 414 } 415 416 //____________________________________________ 417 G4int G4VAnalysisReader::GetNofP1s(G4bool only 418 { 419 return fVP1Manager->GetNofHns(onlyIfExist); 420 } 421 422 //____________________________________________ 423 G4int G4VAnalysisReader::GetNofP2s(G4bool only 424 { 425 return fVP2Manager->GetNofHns(onlyIfExist); 426 } 427 428 //____________________________________________ 429 G4int G4VAnalysisReader::GetNofNtuples() const 430 { 431 return fVNtupleManager->GetNofNtuples(); 432 } 433 434 // GetH1Id(), GetH2Id in .icc 435 436 // Access methods in .icc 437 438 //____________________________________________ 439 void G4VAnalysisReader::SetVerboseLevel(G4int 440 { 441 fState.SetVerboseLevel(verboseLevel); 442 } 443 444 // GetVerboseLevel() in .icc 445