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 "G4VAnalysisManager.hh" 30 #include "G4AnalysisMessenger.hh" 31 #include "G4HnManager.hh" 32 #include "G4VNtupleManager.hh" 33 #include "G4VNtupleFileManager.hh" 34 #include "G4VFileManager.hh" 35 #include "G4NtupleBookingManager.hh" 36 #include "G4Threading.hh" 37 #include "G4AutoLock.hh" 38 39 using namespace G4Analysis; 40 41 namespace { 42 //Mutex to lock master manager when merging 43 G4Mutex registerWorkerMutex = G4MUTEX_INITIA 44 } 45 46 namespace { 47 48 //____________________________________________ 49 void NtupleMergingWarning(std::string_view cla 50 std::string_view fun 51 const G4String& outp 52 { 53 G4Analysis::Warn( 54 "Ntuple merging is not available with " + 55 "Setting is ignored.", className, function 56 } 57 58 } 59 60 // 61 // ctor/dtor 62 // 63 64 //____________________________________________ 65 G4VAnalysisManager::G4VAnalysisManager(const G 66 : fState(type, ! G4Threading::IsWorkerThread( 67 { 68 fMessenger = std::make_unique<G4AnalysisMess 69 fNtupleBookingManager = std::make_shared<G4N 70 71 // Set master/worker instances 72 // used only in "FromUI" functions 73 if ( ! G4Threading::IsWorkerThread() ) { 74 fgMasterInstance = this; 75 } 76 else { 77 if (fgMasterInstance != nullptr) { 78 G4AutoLock lock(®isterWorkerMutex); 79 fgMasterInstance->fWorkerManagers.push_b 80 lock.unlock(); 81 } 82 } 83 } 84 85 //____________________________________________ 86 G4VAnalysisManager::~G4VAnalysisManager() = de 87 88 // 89 // private methods 90 // 91 92 //____________________________________________ 93 G4bool G4VAnalysisManager::WriteFromUI() 94 { 95 // Write is performed on workers first, then o 96 97 if (! fState.GetIsMaster() ) return true; 98 99 auto result = true; 100 101 // Process first all workers 102 for (auto workerManger : fWorkerManagers) { 103 // Update G4Threading 104 auto g4ThreadingValue = G4Threading::G4Get 105 G4Threading::G4SetThreadId(workerManger->f 106 107 result &= workerManger->Write(); 108 109 // Set G4Threading back 110 G4Threading::G4SetThreadId(g4ThreadingValu 111 } 112 113 // Process write on master 114 result &= Write(); 115 116 return result; 117 } 118 119 //____________________________________________ 120 G4bool G4VAnalysisManager::CloseFileFromUI(G4b 121 { 122 // Close file is performed on workers first, t 123 124 if (! fState.GetIsMaster() ) return true; 125 126 auto result = true; 127 128 // Process first all workers 129 for (auto workerManger : fWorkerManagers) { 130 // Update G4Threading 131 auto g4ThreadingValue = G4Threading::G4Get 132 G4Threading::G4SetThreadId(workerManger->f 133 134 result &= workerManger->CloseFile(reset); 135 136 // Set G4Threading back 137 G4Threading::G4SetThreadId(g4ThreadingValu 138 } 139 140 // Process write on master 141 result &= CloseFile(reset); 142 143 return result; 144 } 145 146 //____________________________________________ 147 G4bool G4VAnalysisManager::ResetFromUI() 148 { 149 // Reset file is performed on workers first, t 150 151 if (! fState.GetIsMaster() ) return true; 152 153 auto result = true; 154 155 // Process first all workers 156 for (auto workerManger : fWorkerManagers) { 157 // Update G4Threading 158 auto g4ThreadingValue = G4Threading::G4Get 159 G4Threading::G4SetThreadId(workerManger->f 160 161 result &= workerManger->Reset(); 162 163 // Set G4Threading back 164 G4Threading::G4SetThreadId(g4ThreadingValu 165 } 166 167 // Process write on master 168 result &= Reset(); 169 170 return result; 171 } 172 173 // 174 // protected methods 175 // 176 177 //____________________________________________ 178 void G4VAnalysisManager::SetDefaultFileTypeImp 179 { 180 if ( (! GetType().empty()) && (GetFileType() 181 // If not generic analysis manager (which 182 // the file type cannot be different from 183 Warn("Cannot set default file type " + val 184 " different than the analysis manager ty 185 fkClass, "SetDefault"); 186 return; 187 } 188 189 fH1HnManager->SetDefaultFileType(value); 190 fH2HnManager->SetDefaultFileType(value); 191 fH3HnManager->SetDefaultFileType(value); 192 fP1HnManager->SetDefaultFileType(value); 193 fP2HnManager->SetDefaultFileType(value); 194 } 195 196 //____________________________________________ 197 G4String G4VAnalysisManager::GetDefaultFileTyp 198 { 199 return GetFileType(); 200 } 201 202 //____________________________________________ 203 void G4VAnalysisManager::SetH1Manager(G4VTBase 204 { 205 fVH1Manager.reset(h1Manager); 206 fH1HnManager = h1Manager->GetHnManager(); 207 if (fVFileManager != nullptr ) fH1HnManager- 208 if (! GetFileType().empty() ) fH1HnManager-> 209 } 210 211 //____________________________________________ 212 void G4VAnalysisManager::SetH2Manager(G4VTBase 213 { 214 fVH2Manager.reset(h2Manager); 215 fH2HnManager = h2Manager->GetHnManager(); 216 if (fVFileManager != nullptr ) fH2HnManager- 217 if (! GetFileType().empty() ) fH2HnManager-> 218 } 219 220 //____________________________________________ 221 void G4VAnalysisManager::SetH3Manager(G4VTBase 222 { 223 fVH3Manager.reset(h3Manager); 224 fH3HnManager = h3Manager->GetHnManager(); 225 if (fVFileManager != nullptr ) fH3HnManager- 226 if (! GetFileType().empty() ) fH3HnManager-> 227 } 228 229 //____________________________________________ 230 void G4VAnalysisManager::SetP1Manager(G4VTBase 231 { 232 fVP1Manager.reset(p1Manager); 233 fP1HnManager = p1Manager->GetHnManager(); 234 if (fVFileManager != nullptr ) fP1HnManager- 235 if (! GetFileType().empty() ) fP1HnManager-> 236 } 237 238 //____________________________________________ 239 void G4VAnalysisManager::SetP2Manager(G4VTBase 240 { 241 fVP2Manager.reset(p2Manager); 242 fP2HnManager = p2Manager->GetHnManager(); 243 if (fVFileManager != nullptr ) fP2HnManager- 244 if (! GetFileType().empty() ) fP2HnManager-> 245 } 246 247 //____________________________________________ 248 void G4VAnalysisManager::SetNtupleManager(std: 249 { 250 fVNtupleManager = std::move(ntupleManager); 251 fVNtupleManager->SetFirstId(fNtupleBookingMa 252 fVNtupleManager->SetFirstNtupleColumnId(fNtu 253 } 254 255 //____________________________________________ 256 void G4VAnalysisManager::SetNtupleFileManager( 257 std::shared_ptr<G4VNtupleFileManager> ntuple 258 { 259 fVNtupleFileManager = std::move(ntupleFileMa 260 } 261 262 //____________________________________________ 263 void G4VAnalysisManager::SetFileManager(std::s 264 { 265 fVFileManager = fileManager; 266 267 if ( fH1HnManager != nullptr ) fH1HnManager- 268 if ( fH2HnManager != nullptr ) fH2HnManager- 269 if ( fH3HnManager != nullptr ) fH3HnManager- 270 if ( fP1HnManager != nullptr ) fP1HnManager- 271 if ( fP2HnManager != nullptr ) fP2HnManager- 272 } 273 274 //____________________________________________ 275 G4bool G4VAnalysisManager::WriteAscii(const G4 276 { 277 // Do not write on workers 278 if ( ! fState.GetIsMaster() ) return true; 279 280 auto result = true; 281 282 // Replace or add file extension .ascii 283 G4String name(fileName); 284 if (name.find('.') != std::string::npos) { 285 name.erase(name.find('.'), name.length()); 286 } 287 name.append(".ascii"); 288 289 Message(kVL3, "write ASCII", "file", name); 290 291 std::ofstream output(name, std::ios::out); 292 if ( ! output ) { 293 Warn("Cannot open file. File name is not d 294 fkClass, "WriteAscii"); 295 return false; 296 } 297 output.setf( std::ios::scientific, std::ios: 298 299 result &= fVH1Manager->WriteOnAscii(output); 300 result &= fVH2Manager->WriteOnAscii(output); 301 result &= fVH3Manager->WriteOnAscii(output); 302 result &= fVP1Manager->WriteOnAscii(output); 303 result &= fVP2Manager->WriteOnAscii(output); 304 305 Message(kVL1, "write ASCII", "file", name, r 306 307 return result; 308 } 309 310 //____________________________________________ 311 std::shared_ptr<G4VFileManager> 312 G4VAnalysisManager::GetFileManager(const G4Str 313 { 314 // Check if file type corresponds the manage 315 G4String extension = GetExtension(fileName); 316 if ((extension.size() != 0u) && extension != 317 Warn( 318 "The file extension differs from " + Get 319 GetFileType() + " output type will be us 320 fkClass, "GetFileManager"); 321 } 322 323 return fVFileManager; 324 } 325 326 // 327 // public methods 328 // 329 330 //____________________________________________ 331 G4bool G4VAnalysisManager::OpenFile(const G4St 332 { 333 // Protection against opening file twice 334 // (Seems to happen when opening file via UI 335 if (IsOpenFile()) { 336 // G4cout << "Skipping OpenFile. File is a 337 return true; 338 } 339 340 if ( fileName != "" ) { 341 return OpenFileImpl(fileName); 342 } 343 if (fVFileManager->GetFileName() == "") { 344 Warn("Cannot open file. File name is not d 345 return false; 346 } 347 return OpenFileImpl(fVFileManager->GetFileNa 348 } 349 350 //____________________________________________ 351 G4bool G4VAnalysisManager::Write() 352 { 353 auto result = true; 354 355 result &= WriteImpl(); 356 if ( IsPlotting() ) { 357 result &= PlotImpl(); 358 } 359 360 // Increment cycle number 361 fState.IncrementCycle(); 362 363 return result; 364 } 365 366 //____________________________________________ 367 G4bool G4VAnalysisManager::CloseFile(G4bool re 368 { 369 auto result = CloseFileImpl(reset); 370 371 // Notify about new cycle 372 fState.ResetCycle(); 373 if (fVNtupleManager != nullptr) { 374 fVNtupleManager->SetNewCycle(false); 375 } 376 377 return result; 378 } 379 380 //____________________________________________ 381 G4bool G4VAnalysisManager::Reset() 382 { 383 // Notify about new cycle 384 // (as reset causes deleting ntuples) 385 if (fVNtupleManager != nullptr) { 386 fVNtupleManager->SetNewCycle(true); 387 } 388 389 return ResetImpl(); 390 } 391 392 //____________________________________________ 393 void G4VAnalysisManager::Clear() 394 { 395 Message(kVL4, "clear", "all data"); 396 397 // clear hntools objects 398 ClearImpl(); 399 400 // clear remaining data 401 fNtupleBookingManager->ClearData(); 402 if ( fVNtupleManager != nullptr ) fVNtupleMa 403 if ( fVFileManager != nullptr ) fVFileManage 404 405 Message(kVL1, "clear", "all data"); 406 } 407 408 //____________________________________________ 409 G4bool G4VAnalysisManager::Merge(tools::histo: 410 { 411 return MergeImpl(hmpi); 412 } 413 414 //____________________________________________ 415 G4bool G4VAnalysisManager::Plot() 416 { 417 return PlotImpl(); 418 } 419 420 //____________________________________________ 421 G4bool G4VAnalysisManager::IsOpenFile() const 422 { 423 return IsOpenFileImpl(); 424 } 425 426 //____________________________________________ 427 void G4VAnalysisManager::SetDefaultFileType(co 428 { 429 SetDefaultFileTypeImpl(value); 430 } 431 432 //____________________________________________ 433 G4String G4VAnalysisManager::GetDefaultFileTyp 434 { 435 return GetDefaultFileTypeImpl(); 436 } 437 438 //____________________________________________ 439 G4bool G4VAnalysisManager::SetFileName(const G 440 { 441 return fVFileManager->SetFileName(fileName); 442 } 443 444 //____________________________________________ 445 G4bool G4VAnalysisManager::SetHistoDirectoryNa 446 { 447 return fVFileManager->SetHistoDirectoryName( 448 } 449 450 //____________________________________________ 451 G4bool G4VAnalysisManager::SetNtupleDirectoryN 452 { 453 return fVFileManager->SetNtupleDirectoryName 454 } 455 456 //____________________________________________ 457 void G4VAnalysisManager::SetCompressionLevel(G 458 { 459 fVFileManager->SetCompressionLevel(level); 460 } 461 462 //____________________________________________ 463 G4String G4VAnalysisManager::GetFileName() con 464 { 465 return fVFileManager->GetFileName(); 466 } 467 468 //____________________________________________ 469 G4String G4VAnalysisManager::GetHistoDirectory 470 { 471 return fVFileManager->GetHistoDirectoryName( 472 } 473 474 //____________________________________________ 475 G4String G4VAnalysisManager::GetNtupleDirector 476 { 477 return fVFileManager->GetNtupleDirectoryName 478 } 479 480 //____________________________________________ 481 G4int G4VAnalysisManager::GetCompressionLevel( 482 { 483 return fVFileManager->GetCompressionLevel(); 484 } 485 486 //____________________________________________ 487 G4int G4VAnalysisManager::CreateH1(const G4Str 488 G4int nbins, G4 489 const G4String& 490 const G4String& 491 { 492 std::array<G4HnDimension, kDim1> bins = { 493 G4HnDimension(nbins, xmin, xmax)}; 494 std::array<G4HnDimensionInformation, kDim1> 495 G4HnDimensionInformation(unitName, fcnName 496 497 return fVH1Manager->Create(name, title, bins 498 } 499 500 //____________________________________________ 501 G4int G4VAnalysisManager::CreateH1(const G4Str 502 const std::vect 503 const G4String& 504 { 505 std::array<G4HnDimension, kDim1> bins = { 506 G4HnDimension(edges)}; 507 std::array<G4HnDimensionInformation, kDim1> 508 G4HnDimensionInformation(unitName, fcnName 509 510 return fVH1Manager->Create(name, title, bins 511 } 512 513 //____________________________________________ 514 G4int G4VAnalysisManager::CreateH2(const G4Str 515 G4int nxbins, G 516 G4int nybins, G 517 const G4String& 518 const G4String& 519 const G4String& 520 const G4String& 521 522 { 523 std::array<G4HnDimension, kDim2> bins = { 524 G4HnDimension(nxbins, xmin, xmax), 525 G4HnDimension(nybins, ymin, ymax) }; 526 std::array<G4HnDimensionInformation, kDim2> 527 G4HnDimensionInformation(xunitName, xfcnNa 528 G4HnDimensionInformation(yunitName, yfcnNa 529 530 return fVH2Manager->Create(name, title, bins 531 } 532 533 //____________________________________________ 534 G4int G4VAnalysisManager::CreateH2(const G4Str 535 const std::vect 536 const std::vect 537 const G4String& 538 const G4String& 539 540 { 541 std::array<G4HnDimension, kDim2> bins = { 542 G4HnDimension(xedges), G4HnDimension(yedge 543 std::array<G4HnDimensionInformation, kDim2> 544 G4HnDimensionInformation(xunitName, xfcnNa 545 G4HnDimensionInformation(yunitName, yfcnNa 546 547 return fVH2Manager->Create(name, title, bins 548 } 549 550 //____________________________________________ 551 G4int G4VAnalysisManager::CreateH3(const G4Str 552 G4int nxbins, G 553 G4int nybins, G 554 G4int nzbins, G 555 const G4String& 556 const G4String& 557 const G4String& 558 const G4String& 559 const G4String& 560 const G4String& 561 const G4String& 562 563 { 564 std::array<G4HnDimension, kDim3> bins = { 565 G4HnDimension(nxbins, xmin, xmax), 566 G4HnDimension(nybins, ymin, ymax), 567 G4HnDimension(nzbins, zmin, zmax)}; 568 std::array<G4HnDimensionInformation, kDim3> 569 G4HnDimensionInformation(xunitName, xfcnNa 570 G4HnDimensionInformation(yunitName, yfcnNa 571 G4HnDimensionInformation(zunitName, zfcnNa 572 573 return fVH3Manager->Create(name, title, bins 574 } 575 576 //____________________________________________ 577 G4int G4VAnalysisManager::CreateH3(const G4Str 578 const std::vect 579 const std::vect 580 const std::vect 581 const G4String& 582 const G4String& 583 const G4String& 584 const G4String& 585 586 { 587 std::array<G4HnDimension, kDim3> bins = { 588 G4HnDimension(xedges), G4HnDimension(yedg 589 std::array<G4HnDimensionInformation, kDim3> 590 G4HnDimensionInformation(xunitName, xfcnNa 591 G4HnDimensionInformation(yunitName, yfcnNa 592 G4HnDimensionInformation(zunitName, zfcnNa 593 594 return fVH3Manager->Create(name, title, bins 595 } 596 597 //____________________________________________ 598 G4bool G4VAnalysisManager::SetH1(G4int id, 599 G4int nbins, G 600 const G4String 601 const G4String 602 { 603 std::array<G4HnDimension, kDim1> bins = { 604 G4HnDimension(nbins, xmin, xmax)}; 605 std::array<G4HnDimensionInformation, kDim1> 606 G4HnDimensionInformation(unitName, fcnName 607 608 return fVH1Manager->Set(id, bins, info); 609 } 610 611 //____________________________________________ 612 G4bool G4VAnalysisManager::SetH1(G4int id, 613 const std::vec 614 const G4String 615 { 616 std::array<G4HnDimension, kDim1> bins = { 617 G4HnDimension(edges)}; 618 std::array<G4HnDimensionInformation, kDim1> 619 G4HnDimensionInformation(unitName, fcnName 620 621 return fVH1Manager->Set(id, bins, info); 622 } 623 624 //____________________________________________ 625 G4bool G4VAnalysisManager::SetH2(G4int id, 626 G4int nxbins, 627 G4int nybins, 628 const G4String 629 const G4String 630 const G4String 631 const G4String 632 { 633 std::array<G4HnDimension, kDim2> bins = { 634 G4HnDimension(nxbins, xmin, xmax), 635 G4HnDimension(nybins, ymin, ymax) }; 636 std::array<G4HnDimensionInformation, kDim2> 637 G4HnDimensionInformation(xunitName, xfcnNa 638 G4HnDimensionInformation(yunitName, yfcnNa 639 640 return fVH2Manager->Set(id, bins, info); 641 } 642 643 //____________________________________________ 644 G4bool G4VAnalysisManager::SetH2(G4int id, 645 const std::vec 646 const std::vec 647 const G4String 648 const G4String 649 { 650 std::array<G4HnDimension, kDim2> bins = { 651 G4HnDimension(xedges), G4HnDimension(yedge 652 std::array<G4HnDimensionInformation, kDim2> 653 G4HnDimensionInformation(xunitName, xfcnNa 654 G4HnDimensionInformation(yunitName, yfcnNa 655 656 return fVH2Manager->Set(id, bins, info); 657 } 658 659 //____________________________________________ 660 G4bool G4VAnalysisManager::SetH3(G4int id, 661 G4int nxbins, 662 G4int nybins, 663 G4int nzbins, 664 const G4String 665 const G4String 666 const G4String 667 const G4String 668 const G4String 669 const G4String 670 const G4String 671 { 672 std::array<G4HnDimension, kDim3> bins = { 673 G4HnDimension(nxbins, xmin, xmax), 674 G4HnDimension(nybins, ymin, ymax), 675 G4HnDimension(nzbins, zmin, zmax)}; 676 std::array<G4HnDimensionInformation, kDim3> 677 G4HnDimensionInformation(xunitName, xfcnNa 678 G4HnDimensionInformation(yunitName, yfcnNa 679 G4HnDimensionInformation(zunitName, zfcnNa 680 681 return fVH3Manager->Set(id, bins, info); 682 } 683 684 //____________________________________________ 685 G4bool G4VAnalysisManager::SetH3(G4int id, 686 const std::vec 687 const std::vec 688 const std::vec 689 const G4String 690 const G4String 691 const G4String 692 const G4String 693 { 694 std::array<G4HnDimension, kDim3> bins = { 695 G4HnDimension(xedges), G4HnDimension(yedge 696 std::array<G4HnDimensionInformation, kDim3> 697 G4HnDimensionInformation(xunitName, xfcnNa 698 G4HnDimensionInformation(yunitName, yfcnNa 699 G4HnDimensionInformation(zunitName, zfcnNa 700 701 return fVH3Manager->Set(id, bins, info); 702 } 703 704 //____________________________________________ 705 G4bool G4VAnalysisManager::ScaleH1(G4int id, G 706 { 707 return fVH1Manager->Scale(id, factor); 708 } 709 710 //____________________________________________ 711 G4bool G4VAnalysisManager::ScaleH2(G4int id, G 712 { 713 return fVH2Manager->Scale(id, factor); 714 } 715 716 //____________________________________________ 717 G4bool G4VAnalysisManager::ScaleH3(G4int id, G 718 { 719 return fVH3Manager->Scale(id, factor); 720 } 721 722 //____________________________________________ 723 G4int G4VAnalysisManager::CreateP1(const G4Str 724 G4int nbins, G4 725 G4double ymin, 726 const G4String& 727 const G4String& 728 const G4String& 729 { 730 std::array<G4HnDimension, kDim2> bins = { 731 G4HnDimension(nbins, xmin, xmax), 732 G4HnDimension(0, ymin, ymax) }; 733 std::array<G4HnDimensionInformation, kDim2> 734 G4HnDimensionInformation(xunitName, xfcnNa 735 G4HnDimensionInformation(yunitName, yfcnNa 736 737 return fVP1Manager->Create(name, title, bins 738 } 739 740 //____________________________________________ 741 G4int G4VAnalysisManager::CreateP1(const G4Str 742 const std::vect 743 G4double ymin, 744 const G4String& 745 const G4String& 746 { 747 std::array<G4HnDimension, kDim2> bins = { 748 G4HnDimension(edges), G4HnDimension(0, ymi 749 std::array<G4HnDimensionInformation, kDim2> 750 G4HnDimensionInformation(xunitName, xfcnNa 751 G4HnDimensionInformation(yunitName, yfcnNa 752 753 return fVP1Manager->Create(name, title, bins 754 } 755 756 //____________________________________________ 757 G4int G4VAnalysisManager::CreateP2(const G4Str 758 G4int nxbins, G4 759 G4int nybins, G4 760 G4double zmin, G 761 const G4String& 762 const G4String& 763 const G4String& 764 const G4String& 765 const G4String& 766 const G4String& 767 { 768 std::array<G4HnDimension, kDim3> bins = { 769 G4HnDimension(nxbins, xmin, xmax), 770 G4HnDimension(nybins, ymin, ymax), 771 G4HnDimension(0, zmin, zmax)}; 772 std::array<G4HnDimensionInformation, kDim3> 773 G4HnDimensionInformation(xunitName, xfcnNa 774 G4HnDimensionInformation(yunitName, yfcnNa 775 G4HnDimensionInformation(zunitName, zfcnNa 776 777 return fVP2Manager->Create(name, title, bins 778 } 779 780 //____________________________________________ 781 G4int G4VAnalysisManager::CreateP2(const G4Str 782 const std::vecto 783 const std::vecto 784 G4double zmin, G 785 const G4String& 786 const G4String& 787 const G4String& 788 const G4String& 789 { 790 std::array<G4HnDimension, kDim3> bins = { 791 G4HnDimension(xedges), G4HnDimension(yedg 792 std::array<G4HnDimensionInformation, kDim3> 793 G4HnDimensionInformation(xunitName, xfcnNa 794 G4HnDimensionInformation(yunitName, yfcnNa 795 G4HnDimensionInformation(zunitName, zfcnNa 796 797 return fVP2Manager->Create(name, title, bins 798 } 799 800 //____________________________________________ 801 G4bool G4VAnalysisManager::SetP1(G4int id, 802 G4int nbins, G 803 G4double ymin, 804 const G4String 805 const G4String 806 const G4String 807 { 808 std::array<G4HnDimension, kDim2> bins = { 809 G4HnDimension(nbins, xmin, xmax), 810 G4HnDimension(0, ymin, ymax) }; 811 std::array<G4HnDimensionInformation, kDim2> 812 G4HnDimensionInformation(xunitName, xfcnNa 813 G4HnDimensionInformation(yunitName, yfcnNa 814 815 return fVP1Manager->Set(id, bins, info); 816 } 817 818 //____________________________________________ 819 G4bool G4VAnalysisManager::SetP1(G4int id, 820 const std::vec 821 G4double ymin, 822 const G4String 823 const G4String 824 { 825 std::array<G4HnDimension, kDim2> bins = { 826 G4HnDimension(edges), G4HnDimension(0, ymi 827 std::array<G4HnDimensionInformation, kDim2> 828 G4HnDimensionInformation(xunitName, xfcnNa 829 G4HnDimensionInformation(yunitName, yfcnNa 830 831 return fVP1Manager->Set(id, bins, info); 832 } 833 834 //____________________________________________ 835 G4bool G4VAnalysisManager::SetP2(G4int id, 836 G4int nxbins, G4 837 G4int nybins, G4 838 G4double zmin, G 839 const G4String& 840 const G4String& 841 const G4String& 842 const G4String& 843 const G4String& 844 const G4String& 845 { 846 std::array<G4HnDimension, kDim3> bins = { 847 G4HnDimension(nxbins, xmin, xmax), 848 G4HnDimension(nybins, ymin, ymax), 849 G4HnDimension(0, zmin, zmax)}; 850 std::array<G4HnDimensionInformation, kDim3> 851 G4HnDimensionInformation(xunitName, xfcnNa 852 G4HnDimensionInformation(yunitName, yfcnNa 853 G4HnDimensionInformation(zunitName, zfcnNa 854 855 return fVP2Manager->Set(id, bins, info); 856 } 857 858 //____________________________________________ 859 G4bool G4VAnalysisManager::SetP2(G4int id, 860 const std::vecto 861 const std::vecto 862 G4double zmin, G 863 const G4String& 864 const G4String& 865 const G4String& 866 const G4String& 867 const G4String& 868 const G4String& 869 { 870 std::array<G4HnDimension, kDim3> bins = { 871 G4HnDimension(xedges), G4HnDimension(yedge 872 std::array<G4HnDimensionInformation, kDim3> 873 G4HnDimensionInformation(xunitName, xfcnNa 874 G4HnDimensionInformation(yunitName, yfcnNa 875 G4HnDimensionInformation(zunitName, zfcnNa 876 877 return fVP2Manager->Set(id, bins, info); 878 } 879 880 //____________________________________________ 881 G4bool G4VAnalysisManager::ScaleP1(G4int id, G 882 { 883 return fVP1Manager->Scale(id, factor); 884 } 885 886 //____________________________________________ 887 G4bool G4VAnalysisManager::ScaleP2(G4int id, G 888 { 889 return fVP2Manager->Scale(id, factor); 890 } 891 892 //____________________________________________ 893 G4int G4VAnalysisManager::CreateNtuple(const G 894 cons 895 { 896 return fNtupleBookingManager->CreateNtuple(n 897 } 898 899 //____________________________________________ 900 G4int G4VAnalysisManager::CreateNtupleIColumn( 901 { 902 return fNtupleBookingManager->CreateNtupleIC 903 } 904 905 //____________________________________________ 906 G4int G4VAnalysisManager::CreateNtupleFColumn( 907 { 908 return fNtupleBookingManager->CreateNtupleFC 909 } 910 911 //____________________________________________ 912 G4int G4VAnalysisManager::CreateNtupleDColumn( 913 { 914 return fNtupleBookingManager->CreateNtupleDC 915 } 916 917 //____________________________________________ 918 G4int G4VAnalysisManager::CreateNtupleSColumn( 919 { 920 return fNtupleBookingManager->CreateNtupleSC 921 } 922 923 //____________________________________________ 924 G4int G4VAnalysisManager::CreateNtupleIColumn( 925 926 { 927 return fNtupleBookingManager->CreateNtupleIC 928 } 929 930 //____________________________________________ 931 G4int G4VAnalysisManager::CreateNtupleFColumn( 932 933 { 934 return fNtupleBookingManager->CreateNtupleFC 935 } 936 937 //____________________________________________ 938 G4int G4VAnalysisManager::CreateNtupleDColumn( 939 940 { 941 return fNtupleBookingManager->CreateNtupleDC 942 } 943 944 //____________________________________________ 945 G4int G4VAnalysisManager::CreateNtupleSColumn( 946 947 { 948 return fNtupleBookingManager->CreateNtupleSC 949 } 950 951 //____________________________________________ 952 void G4VAnalysisManager::FinishNtuple() 953 { 954 auto ntupleBooking = fNtupleBookingManager-> 955 956 if ( fVNtupleManager ) { 957 fVNtupleManager->CreateNtuple(ntupleBookin 958 } 959 } 960 961 //____________________________________________ 962 void G4VAnalysisManager::SetNtupleMerging(G4bo 963 G4int /*nofReducedNtupleFil 964 { 965 // The function is overridden in the managers 966 // Here we give just a warning that the featur 967 968 NtupleMergingWarning(fkClass, "SetNtupleMerg 969 } 970 971 //____________________________________________ 972 void G4VAnalysisManager::SetNtupleRowWise(G4bo 973 G4bo 974 { 975 // The function is overridden in the managers 976 // Here we give just a warning that the featur 977 978 NtupleMergingWarning(fkClass, "SetNtupleRowW 979 } 980 981 //____________________________________________ 982 void G4VAnalysisManager::SetBasketSize(unsigne 983 { 984 // The function is overridden in the managers 985 // Here we give just a warning that the featur 986 987 NtupleMergingWarning(fkClass, "SetBasketSize 988 } 989 990 //____________________________________________ 991 void G4VAnalysisManager::SetBasketEntries(unsi 992 { 993 // The function is overridden in the managers 994 // Here we give just a warning that the featur 995 996 NtupleMergingWarning(fkClass, "SetBasketEntr 997 } 998 999 //____________________________________________ 1000 G4int G4VAnalysisManager::CreateNtupleIColumn 1001 1002 { 1003 return fNtupleBookingManager->CreateNtupleI 1004 } 1005 1006 //___________________________________________ 1007 G4int G4VAnalysisManager::CreateNtupleFColumn 1008 1009 { 1010 return fNtupleBookingManager->CreateNtupleF 1011 } 1012 1013 1014 //___________________________________________ 1015 G4int G4VAnalysisManager::CreateNtupleDColumn 1016 1017 { 1018 return fNtupleBookingManager->CreateNtupleD 1019 } 1020 1021 //___________________________________________ 1022 G4int G4VAnalysisManager::CreateNtupleSColumn 1023 1024 { 1025 return fNtupleBookingManager->CreateNtupleS 1026 } 1027 1028 //___________________________________________ 1029 G4int G4VAnalysisManager::CreateNtupleIColumn 1030 1031 1032 { 1033 return fNtupleBookingManager->CreateNtupleI 1034 } 1035 1036 //___________________________________________ 1037 G4int G4VAnalysisManager::CreateNtupleFColumn 1038 1039 1040 { 1041 return fNtupleBookingManager->CreateNtupleF 1042 } 1043 1044 //___________________________________________ 1045 G4int G4VAnalysisManager::CreateNtupleDColumn 1046 1047 1048 { 1049 return fNtupleBookingManager->CreateNtupleD 1050 } 1051 1052 //___________________________________________ 1053 G4int G4VAnalysisManager::CreateNtupleSColumn 1054 1055 1056 { 1057 return fNtupleBookingManager->CreateNtupleS 1058 } 1059 1060 //___________________________________________ 1061 void G4VAnalysisManager::FinishNtuple(G4int n 1062 { 1063 auto ntupleBooking = fNtupleBookingManager- 1064 1065 if ( fVNtupleManager ) { 1066 fVNtupleManager->CreateNtuple(ntupleBooki 1067 } 1068 } 1069 1070 //___________________________________________ 1071 G4bool G4VAnalysisManager::SetFirstHistoId(G4 1072 { 1073 auto result = true; 1074 1075 result &= SetFirstH1Id(firstId); 1076 result &= SetFirstH2Id(firstId); 1077 result &= SetFirstH3Id(firstId); 1078 1079 return result; 1080 } 1081 1082 //___________________________________________ 1083 G4bool G4VAnalysisManager::SetFirstH1Id(G4int 1084 { 1085 return fH1HnManager->SetFirstId(firstId); 1086 } 1087 1088 //___________________________________________ 1089 G4bool G4VAnalysisManager::SetFirstH2Id(G4int 1090 { 1091 return fH2HnManager->SetFirstId(firstId); 1092 } 1093 1094 //___________________________________________ 1095 G4bool G4VAnalysisManager::SetFirstH3Id(G4int 1096 { 1097 return fH3HnManager->SetFirstId(firstId); 1098 } 1099 1100 //___________________________________________ 1101 G4bool G4VAnalysisManager::SetFirstProfileId( 1102 { 1103 auto result = true; 1104 1105 result &= SetFirstP1Id(firstId); 1106 result &= SetFirstP2Id(firstId); 1107 1108 return result; 1109 } 1110 1111 //___________________________________________ 1112 G4bool G4VAnalysisManager::SetFirstP1Id(G4int 1113 { 1114 return fP1HnManager->SetFirstId(firstId); 1115 } 1116 1117 //___________________________________________ 1118 G4bool G4VAnalysisManager::SetFirstP2Id(G4int 1119 { 1120 return fP2HnManager->SetFirstId(firstId); 1121 } 1122 1123 //___________________________________________ 1124 G4bool G4VAnalysisManager::SetFirstNtupleId(G 1125 { 1126 auto result = true; 1127 1128 result &= fNtupleBookingManager->SetFirstId 1129 if ( fVNtupleManager ) { 1130 result &= fVNtupleManager->SetFirstId(fir 1131 } 1132 1133 return result; 1134 } 1135 1136 //___________________________________________ 1137 G4bool G4VAnalysisManager::SetFirstNtupleColu 1138 { 1139 auto result = true; 1140 1141 result &= fNtupleBookingManager->SetFirstNt 1142 if ( fVNtupleManager ) { 1143 result &= fVNtupleManager->SetFirstNtuple 1144 } 1145 1146 return result; 1147 } 1148 1149 // Fill methods in .icc 1150 1151 //___________________________________________ 1152 void G4VAnalysisManager::SetActivation(G4boo 1153 { 1154 fState.SetIsActivation(activation); 1155 } 1156 1157 // GetActivation() in .icc 1158 1159 //___________________________________________ 1160 G4bool G4VAnalysisManager::IsActive() const 1161 { 1162 // Return true if activation option is select 1163 // an activated object. 1164 1165 return fState.GetIsActivation() && 1166 ( fH1HnManager->IsActive() || 1167 fH2HnManager->IsActive() || 1168 fH3HnManager->IsActive() || 1169 fP1HnManager->IsActive() || 1170 fP2HnManager->IsActive() ); 1171 } 1172 1173 //___________________________________________ 1174 G4bool G4VAnalysisManager::IsAscii() const 1175 { 1176 // Return true any of managers has an object 1177 1178 return ( fH1HnManager->IsAscii() || 1179 fH2HnManager->IsAscii() || 1180 fH3HnManager->IsAscii() || 1181 fP1HnManager->IsAscii() || 1182 fP2HnManager->IsAscii() ); 1183 } 1184 1185 //___________________________________________ 1186 G4bool G4VAnalysisManager::IsPlotting() const 1187 { 1188 // Return true any of managers has an object 1189 1190 return ( fH1HnManager->IsPlotting() || 1191 fH2HnManager->IsPlotting() || 1192 fH3HnManager->IsPlotting() || 1193 fP1HnManager->IsPlotting() || 1194 fP2HnManager->IsPlotting() ); 1195 } 1196 1197 //___________________________________________ 1198 G4int G4VAnalysisManager::GetFirstH1Id() cons 1199 { 1200 // Return first H1 id 1201 1202 return fH1HnManager->GetFirstId(); 1203 } 1204 1205 //___________________________________________ 1206 G4int G4VAnalysisManager::GetFirstH2Id() cons 1207 { 1208 // Return first H2 id 1209 1210 return fH2HnManager->GetFirstId(); 1211 } 1212 1213 //___________________________________________ 1214 G4int G4VAnalysisManager::GetFirstH3Id() cons 1215 { 1216 // Return first H3 id 1217 1218 return fH3HnManager->GetFirstId(); 1219 } 1220 1221 //___________________________________________ 1222 G4int G4VAnalysisManager::GetFirstP1Id() cons 1223 { 1224 // Return first P1 id 1225 1226 return fP1HnManager->GetFirstId(); 1227 } 1228 1229 //___________________________________________ 1230 G4int G4VAnalysisManager::GetFirstP2Id() cons 1231 { 1232 // Return first P2 id 1233 1234 return fP2HnManager->GetFirstId(); 1235 } 1236 1237 //___________________________________________ 1238 G4int G4VAnalysisManager::GetFirstNtupleId() 1239 { 1240 // Return first Ntuple id 1241 1242 return fNtupleBookingManager->GetFirstId(); 1243 } 1244 1245 //___________________________________________ 1246 G4int G4VAnalysisManager::GetFirstNtupleColum 1247 { 1248 // Return first Ntuple column id 1249 1250 return fNtupleBookingManager->GetFirstNtupl 1251 } 1252 1253 //___________________________________________ 1254 G4int G4VAnalysisManager::GetNofH1s(G4bool on 1255 { 1256 return fVH1Manager->GetNofHns(onlyIfExist); 1257 } 1258 1259 //___________________________________________ 1260 G4int G4VAnalysisManager::GetNofH2s(G4bool on 1261 { 1262 return fVH2Manager->GetNofHns(onlyIfExist); 1263 } 1264 1265 //___________________________________________ 1266 G4int G4VAnalysisManager::GetNofH3s(G4bool on 1267 { 1268 return fVH3Manager->GetNofHns(onlyIfExist); 1269 } 1270 1271 //___________________________________________ 1272 G4int G4VAnalysisManager::GetNofP1s(G4bool on 1273 { 1274 return fVP1Manager->GetNofHns(onlyIfExist); 1275 } 1276 1277 //___________________________________________ 1278 G4int G4VAnalysisManager::GetNofP2s(G4bool on 1279 { 1280 return fVP2Manager->GetNofHns(onlyIfExist); 1281 } 1282 1283 //___________________________________________ 1284 G4int G4VAnalysisManager::GetNofNtuples(G4boo 1285 { 1286 return fNtupleBookingManager->GetNofNtuples 1287 } 1288 1289 // GetH1Id(), GetH2Id in .icc 1290 1291 //___________________________________________ 1292 G4bool G4VAnalysisManager::ListH1(G4bool only 1293 { 1294 return fVH1Manager->List(G4cout, onlyIfActi 1295 } 1296 1297 //___________________________________________ 1298 G4bool G4VAnalysisManager::ListH2(G4bool only 1299 { 1300 return fVH2Manager->List(G4cout, onlyIfActi 1301 } 1302 1303 //___________________________________________ 1304 G4bool G4VAnalysisManager::ListH3(G4bool only 1305 { 1306 return fVH3Manager->List(G4cout, onlyIfActi 1307 } 1308 1309 //___________________________________________ 1310 G4bool G4VAnalysisManager::ListP1(G4bool only 1311 { 1312 return fVP1Manager->List(G4cout, onlyIfActi 1313 } 1314 1315 //___________________________________________ 1316 G4bool G4VAnalysisManager::ListP2(G4bool only 1317 { 1318 return fVP2Manager->List(G4cout, onlyIfActi 1319 } 1320 1321 //___________________________________________ 1322 G4bool G4VAnalysisManager::ListNtuple(G4bool 1323 { 1324 return fNtupleBookingManager->List(G4cout, 1325 } 1326 1327 //___________________________________________ 1328 G4bool G4VAnalysisManager::List(G4bool onlyIf 1329 { 1330 auto result = true; 1331 result &= ListH1(onlyIfActive); 1332 result &= ListH2(onlyIfActive); 1333 result &= ListH3(onlyIfActive); 1334 result &= ListP1(onlyIfActive); 1335 result &= ListP2(onlyIfActive); 1336 result &= ListNtuple(onlyIfActive); 1337 1338 return result; 1339 } 1340 1341 //___________________________________________ 1342 void G4VAnalysisManager::SetH1Activation(G4i 1343 { 1344 // Set activation to a given H1 object 1345 1346 fH1HnManager->SetActivation(id, activation) 1347 } 1348 1349 //___________________________________________ 1350 void G4VAnalysisManager::SetH1Activation(G4b 1351 { 1352 // Set activation to all H1 objects 1353 1354 fH1HnManager->SetActivation(activation); 1355 } 1356 1357 //___________________________________________ 1358 void G4VAnalysisManager::SetH1Ascii(G4int id 1359 { 1360 fH1HnManager->SetAscii(id, ascii); 1361 } 1362 1363 //___________________________________________ 1364 void G4VAnalysisManager::SetH1Plotting(G4int 1365 { 1366 fH1HnManager->SetPlotting(id, plotting); 1367 } 1368 1369 //___________________________________________ 1370 void G4VAnalysisManager::SetH1FileName(G4int 1371 { 1372 fH1HnManager->SetFileName(id, fileName); 1373 } 1374 1375 //___________________________________________ 1376 void G4VAnalysisManager::SetH2Activation(G4i 1377 { 1378 // Set activation to a given H2 object 1379 1380 fH2HnManager->SetActivation(id, activation) 1381 } 1382 1383 //___________________________________________ 1384 void G4VAnalysisManager::SetH2Activation(G4b 1385 { 1386 // Set activation to all H2 objects 1387 1388 fH2HnManager->SetActivation(activation); 1389 } 1390 1391 //___________________________________________ 1392 void G4VAnalysisManager::SetH2Ascii(G4int id 1393 { 1394 fH2HnManager->SetAscii(id, ascii); 1395 } 1396 1397 //___________________________________________ 1398 void G4VAnalysisManager::SetH2Plotting(G4int 1399 { 1400 fH2HnManager->SetPlotting(id, plotting); 1401 } 1402 1403 //___________________________________________ 1404 void G4VAnalysisManager::SetH2FileName(G4int 1405 { 1406 fH2HnManager->SetFileName(id, fileName); 1407 } 1408 1409 //___________________________________________ 1410 void G4VAnalysisManager::SetH3Activation(G4i 1411 { 1412 // Set activation to a given H3 object 1413 1414 fH3HnManager->SetActivation(id, activation) 1415 } 1416 1417 //___________________________________________ 1418 void G4VAnalysisManager::SetH3Activation(G4b 1419 { 1420 // Set activation to all H3 objects 1421 1422 fH3HnManager->SetActivation(activation); 1423 } 1424 1425 //___________________________________________ 1426 void G4VAnalysisManager::SetH3Ascii(G4int id 1427 { 1428 fH3HnManager->SetAscii(id, ascii); 1429 } 1430 1431 //___________________________________________ 1432 void G4VAnalysisManager::SetH3Plotting(G4int 1433 { 1434 fH3HnManager->SetPlotting(id, plotting); 1435 } 1436 1437 //___________________________________________ 1438 void G4VAnalysisManager::SetH3FileName(G4int 1439 { 1440 fH3HnManager->SetFileName(id, fileName); 1441 } 1442 1443 //___________________________________________ 1444 void G4VAnalysisManager::SetP1Activation(G4i 1445 { 1446 // Set activation to a given P1 object 1447 1448 fP1HnManager->SetActivation(id, activation) 1449 } 1450 1451 //___________________________________________ 1452 void G4VAnalysisManager::SetP1Activation(G4b 1453 { 1454 // Set activation to all P1 objects 1455 1456 fP1HnManager->SetActivation(activation); 1457 } 1458 1459 //___________________________________________ 1460 void G4VAnalysisManager::SetP1Ascii(G4int id 1461 { 1462 fP1HnManager->SetAscii(id, ascii); 1463 } 1464 1465 //___________________________________________ 1466 void G4VAnalysisManager::SetP1Plotting(G4int 1467 { 1468 fP1HnManager->SetPlotting(id, plotting); 1469 } 1470 1471 //___________________________________________ 1472 void G4VAnalysisManager::SetP1FileName(G4int 1473 { 1474 fP1HnManager->SetFileName(id, fileName); 1475 } 1476 1477 //___________________________________________ 1478 void G4VAnalysisManager::SetP2Activation(G4i 1479 { 1480 // Set activation to a given P2 object 1481 1482 fP2HnManager->SetActivation(id, activation) 1483 } 1484 1485 //___________________________________________ 1486 void G4VAnalysisManager::SetP2Activation(G4b 1487 { 1488 // Set activation to all P2 objects 1489 1490 fP2HnManager->SetActivation(activation); 1491 } 1492 1493 //___________________________________________ 1494 void G4VAnalysisManager::SetP2Ascii(G4int id 1495 { 1496 fP2HnManager->SetAscii(id, ascii); 1497 } 1498 1499 //___________________________________________ 1500 void G4VAnalysisManager::SetP2Plotting(G4int 1501 { 1502 fP2HnManager->SetPlotting(id, plotting); 1503 } 1504 1505 //___________________________________________ 1506 void G4VAnalysisManager::SetP2FileName(G4int 1507 { 1508 fP2HnManager->SetFileName(id, fileName); 1509 } 1510 1511 //___________________________________________ 1512 void G4VAnalysisManager::SetNtupleActivation 1513 { 1514 // Set activation to a given ntuple object 1515 1516 fNtupleBookingManager->SetActivation(id, ac 1517 if ( fVNtupleManager ) { 1518 fVNtupleManager->SetActivation(id, activa 1519 } 1520 } 1521 1522 //___________________________________________ 1523 void G4VAnalysisManager::SetNtupleActivation 1524 { 1525 // Set activation to all ntuple objects 1526 1527 fNtupleBookingManager->SetActivation(activa 1528 if ( fVNtupleManager ) { 1529 fVNtupleManager->SetActivation(activation 1530 } 1531 } 1532 1533 //___________________________________________ 1534 void G4VAnalysisManager::SetNtupleFileName(G 1535 { 1536 // Set activation to a given P2 object 1537 1538 fNtupleBookingManager->SetFileName(id, file 1539 } 1540 1541 //___________________________________________ 1542 void G4VAnalysisManager::SetNtupleFileName(c 1543 { 1544 // Set activation to all P2 objects 1545 1546 fNtupleBookingManager->SetFileName(fileName 1547 } 1548 1549 //___________________________________________ 1550 G4bool G4VAnalysisManager::DeleteH1(G4int id 1551 { 1552 return fVH1Manager->Delete(id, keepSetting) 1553 } 1554 1555 //___________________________________________ 1556 G4bool G4VAnalysisManager::DeleteH2(G4int id 1557 { 1558 return fVH2Manager->Delete(id, keepSetting) 1559 } 1560 1561 //___________________________________________ 1562 G4bool G4VAnalysisManager::DeleteH3(G4int id 1563 { 1564 return fVH3Manager->Delete(id, keepSetting) 1565 } 1566 1567 //___________________________________________ 1568 G4bool G4VAnalysisManager::DeleteP1(G4int id 1569 { 1570 return fVP1Manager->Delete(id, keepSetting) 1571 } 1572 1573 //___________________________________________ 1574 G4bool G4VAnalysisManager::DeleteP2(G4int id 1575 { 1576 return fVP2Manager->Delete(id, keepSetting) 1577 } 1578 1579 //___________________________________________ 1580 G4bool G4VAnalysisManager::DeleteNtuple(G4in 1581 { 1582 auto result = fNtupleBookingManager->Delete 1583 1584 if (fVNtupleManager != nullptr) { 1585 result &= fVNtupleManager->Delete(id); 1586 } 1587 1588 return result; 1589 } 1590 1591 // Access methods in .icc 1592 1593 //___________________________________________ 1594 void G4VAnalysisManager::SetVerboseLevel(G4in 1595 { 1596 fState.SetVerboseLevel(verboseLevel); 1597 } 1598 1599 // GetVerboseLevel() in .icc 1600 1601