#include <G4RootAnalysisManager.hh>
Inheritance diagram for G4RootAnalysisManager:
Public Member Functions | |
G4RootAnalysisManager () | |
virtual | ~G4RootAnalysisManager () |
virtual G4bool | OpenFile (const G4String &fileName) |
virtual G4bool | Write () |
virtual G4bool | CloseFile () |
virtual G4int | CreateH1 (const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none") |
virtual G4int | CreateH2 (const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none") |
virtual G4bool | SetH1 (G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none") |
virtual G4bool | SetH2 (G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none") |
virtual G4bool | ScaleH1 (G4int id, G4double factor) |
virtual G4bool | ScaleH2 (G4int id, G4double factor) |
virtual void | CreateNtuple (const G4String &name, const G4String &title) |
virtual G4int | CreateNtupleIColumn (const G4String &name) |
virtual G4int | CreateNtupleFColumn (const G4String &name) |
virtual G4int | CreateNtupleDColumn (const G4String &name) |
virtual void | FinishNtuple () |
virtual G4bool | FillH1 (G4int id, G4double value, G4double weight=1.0) |
virtual G4bool | FillH2 (G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0) |
virtual G4bool | FillNtupleIColumn (G4int id, G4int value) |
virtual G4bool | FillNtupleFColumn (G4int id, G4float value) |
virtual G4bool | FillNtupleDColumn (G4int id, G4double value) |
virtual G4bool | AddNtupleRow () |
virtual tools::histo::h1d * | GetH1 (G4int id, G4bool warn=true, G4bool onlyIfActive=true) const |
virtual tools::histo::h2d * | GetH2 (G4int id, G4bool warn=true, G4bool onlyIfActive=true) const |
virtual tools::wroot::ntuple * | GetNtuple () const |
virtual G4int | GetH1Id (const G4String &name, G4bool warn=true) const |
virtual G4int | GetH2Id (const G4String &name, G4bool warn=true) const |
virtual G4int | GetH1Nbins (G4int id) const |
virtual G4double | GetH1Xmin (G4int id) const |
virtual G4double | GetH1Xmax (G4int id) const |
virtual G4double | GetH1Width (G4int id) const |
virtual G4int | GetH2Nxbins (G4int id) const |
virtual G4double | GetH2Xmin (G4int id) const |
virtual G4double | GetH2Xmax (G4int id) const |
virtual G4double | GetH2XWidth (G4int id) const |
virtual G4int | GetH2Nybins (G4int id) const |
virtual G4double | GetH2Ymin (G4int id) const |
virtual G4double | GetH2Ymax (G4int id) const |
virtual G4double | GetH2YWidth (G4int id) const |
virtual G4bool | SetH1Title (G4int id, const G4String &title) |
virtual G4bool | SetH1XAxisTitle (G4int id, const G4String &title) |
virtual G4bool | SetH1YAxisTitle (G4int id, const G4String &title) |
virtual G4bool | SetH2Title (G4int id, const G4String &title) |
virtual G4bool | SetH2XAxisTitle (G4int id, const G4String &title) |
virtual G4bool | SetH2YAxisTitle (G4int id, const G4String &title) |
virtual G4bool | SetH2ZAxisTitle (G4int id, const G4String &title) |
virtual G4String | GetH1Title (G4int id) const |
virtual G4String | GetH1XAxisTitle (G4int id) const |
virtual G4String | GetH1YAxisTitle (G4int id) const |
virtual G4String | GetH2Title (G4int id) const |
virtual G4String | GetH2XAxisTitle (G4int id) const |
virtual G4String | GetH2YAxisTitle (G4int id) const |
virtual G4String | GetH2ZAxisTitle (G4int id) const |
Static Public Member Functions | |
static G4RootAnalysisManager * | Instance () |
Protected Member Functions | |
virtual G4bool | WriteOnAscii (std::ofstream &output) |
Definition at line 46 of file G4RootAnalysisManager.hh.
G4RootAnalysisManager::G4RootAnalysisManager | ( | ) |
Definition at line 48 of file G4RootAnalysisManager.cc.
References FatalException, and G4Exception().
Referenced by Instance().
00049 : G4VAnalysisManager("Root"), 00050 fFile(0), 00051 fHistoDirectory(0), 00052 fNtupleDirectory(0), 00053 fH1Vector(), 00054 fH2Vector(), 00055 fH1NameIdMap(), 00056 fH2NameIdMap(), 00057 fNtuple(0), 00058 fNtupleBooking(0), 00059 fNtupleIColumnMap(), 00060 fNtupleFColumnMap(), 00061 fNtupleDColumnMap() 00062 { 00063 if ( fgInstance ) { 00064 G4ExceptionDescription description; 00065 description << " " 00066 << "G4RootAnalysisManager already exists." 00067 << "Cannot create another instance."; 00068 G4Exception("G4RootAnalysisManager::G4RootAnalysisManager()", 00069 "Analysis_F001", FatalException, description); 00070 } 00071 00072 fgInstance = this; 00073 }
G4RootAnalysisManager::~G4RootAnalysisManager | ( | ) | [virtual] |
Definition at line 76 of file G4RootAnalysisManager.cc.
00077 { 00078 std::vector<tools::histo::h1d*>::iterator it; 00079 for (it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) { 00080 delete (*it); 00081 } 00082 00083 std::vector<tools::histo::h2d*>::iterator it2; 00084 for (it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) { 00085 delete (*it2); 00086 } 00087 00088 delete fNtuple; 00089 delete fNtupleBooking; 00090 delete fFile; 00091 00092 fgInstance = 0; 00093 }
G4bool G4RootAnalysisManager::AddNtupleRow | ( | ) | [virtual] |
Implements G4VAnalysisManager.
Definition at line 987 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fpVerboseL4, G4Exception(), JustWarning, and G4AnalysisVerbose::Message().
00988 { 00989 #ifdef G4VERBOSE 00990 if ( fpVerboseL4 ) 00991 fpVerboseL4->Message("add", "ntuple row", ""); 00992 #endif 00993 00994 if ( ! fNtuple ) { 00995 G4ExceptionDescription description; 00996 description << " " << "ntuple does not exist. "; 00997 G4Exception("G4RootAnalysisManager::AddNtupleRow()", 00998 "Analysis_W008", JustWarning, description); 00999 return false; 01000 } 01001 01002 G4bool result =fNtuple->add_row(); 01003 if ( ! result ) { 01004 G4ExceptionDescription description; 01005 description << " " << "adding row has failed."; 01006 G4Exception("G4RootAnalysisManager::AddNtupleRow()", 01007 "Analysis_W004", JustWarning, description); 01008 } 01009 #ifdef G4VERBOSE 01010 if ( fpVerboseL4 ) 01011 fpVerboseL4->Message("add", "ntuple row", "", result); 01012 #endif 01013 01014 return result; 01015 }
G4bool G4RootAnalysisManager::CloseFile | ( | ) | [virtual] |
Implements G4VAnalysisManager.
Definition at line 506 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fLockFileName, G4VAnalysisManager::fpVerboseL1, G4VAnalysisManager::fpVerboseL4, G4Exception(), G4VAnalysisManager::GetFullFileName(), JustWarning, and G4AnalysisVerbose::Message().
00507 { 00508 G4bool result = true; 00509 00510 #ifdef G4VERBOSE 00511 if ( fpVerboseL4 ) 00512 fpVerboseL4->Message("close", "file", GetFullFileName()); 00513 #endif 00514 00515 // reset data 00516 result = Reset(); 00517 if ( ! result ) { 00518 G4ExceptionDescription description; 00519 description << " " << "Resetting data failed"; 00520 G4Exception("G4RootAnalysisManager::Write()", 00521 "Analysis_W002", JustWarning, description); 00522 result = false; 00523 } 00524 00525 // close file 00526 fFile->close(); 00527 fLockFileName = false; 00528 00529 #ifdef G4VERBOSE 00530 if ( fpVerboseL1 ) 00531 fpVerboseL1->Message("close", "file", GetFullFileName()); 00532 #endif 00533 00534 return result; 00535 }
G4int G4RootAnalysisManager::CreateH1 | ( | const G4String & | name, | |
const G4String & | title, | |||
G4int | nbins, | |||
G4double | xmin, | |||
G4double | xmax, | |||
const G4String & | unitName = "none" , |
|||
const G4String & | fcnName = "none" | |||
) | [virtual] |
Implements G4VAnalysisManager.
Definition at line 538 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::AddH1Information(), G4VAnalysisManager::fLockFirstHistoId, G4VAnalysisManager::fpVerboseL2, G4VAnalysisManager::fpVerboseL4, G4VAnalysisManager::GetFunction(), G4VAnalysisManager::GetUnitValue(), and G4AnalysisVerbose::Message().
00541 { 00542 #ifdef G4VERBOSE 00543 if ( fpVerboseL4 ) 00544 fpVerboseL4->Message("create", "H1", name); 00545 #endif 00546 G4int index = fH1Vector.size(); 00547 G4double unit = GetUnitValue(unitName); 00548 G4Fcn fcn = GetFunction(fcnName); 00549 tools::histo::h1d* h1 00550 = new tools::histo::h1d(title, nbins, fcn(xmin), fcn(xmax)); 00551 // h1 objects are deleted in destructor and reset when 00552 // closing a file. 00553 00554 G4String axisTitle; 00555 UpdateTitle(axisTitle,unitName, fcnName); 00556 h1->add_annotation(tools::histo::key_axis_x_title(), axisTitle); 00557 00558 fH1Vector.push_back(h1); 00559 AddH1Information(name, unitName, fcnName, unit, fcn); 00560 00561 fLockFirstHistoId = true; 00562 #ifdef G4VERBOSE 00563 if ( fpVerboseL2 ) 00564 fpVerboseL2->Message("create", "H1", name); 00565 #endif 00566 fH1NameIdMap[name] = index + fFirstHistoId; 00567 return index + fFirstHistoId; 00568 }
G4int G4RootAnalysisManager::CreateH2 | ( | const G4String & | name, | |
const G4String & | title, | |||
G4int | nxbins, | |||
G4double | xmin, | |||
G4double | xmax, | |||
G4int | nybins, | |||
G4double | ymin, | |||
G4double | ymax, | |||
const G4String & | xunitName = "none" , |
|||
const G4String & | yunitName = "none" , |
|||
const G4String & | xfcnName = "none" , |
|||
const G4String & | yfcnName = "none" | |||
) | [virtual] |
Implements G4VAnalysisManager.
Definition at line 571 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::AddH2Information(), G4VAnalysisManager::fLockFirstHistoId, G4VAnalysisManager::fpVerboseL2, G4VAnalysisManager::fpVerboseL4, G4VAnalysisManager::GetFunction(), G4VAnalysisManager::GetUnitValue(), and G4AnalysisVerbose::Message().
00577 { 00578 #ifdef G4VERBOSE 00579 if ( fpVerboseL4 ) 00580 fpVerboseL4->Message("create", "H2", name); 00581 #endif 00582 G4int index = fH2Vector.size(); 00583 G4double xunit = GetUnitValue(xunitName); 00584 G4double yunit = GetUnitValue(yunitName); 00585 G4Fcn xfcn = GetFunction(xfcnName); 00586 G4Fcn yfcn = GetFunction(yfcnName); 00587 tools::histo::h2d* h2 00588 = new tools::histo::h2d(title, 00589 nxbins, xfcn(xmin), xfcn(xmax), 00590 nybins, yfcn(ymin), yfcn(ymax)); 00591 // h2 objects are deleted in destructor and reset when 00592 // closing a file. 00593 00594 G4String xaxisTitle; 00595 G4String yaxisTitle; 00596 UpdateTitle(xaxisTitle, xunitName, xfcnName); 00597 UpdateTitle(yaxisTitle, yunitName, yfcnName); 00598 h2->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle); 00599 h2->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle); 00600 00601 fH2Vector.push_back(h2); 00602 AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName, 00603 xunit, yunit, xfcn, yfcn); 00604 00605 fLockFirstHistoId = true; 00606 #ifdef G4VERBOSE 00607 if ( fpVerboseL2 ) 00608 fpVerboseL2->Message("create", "H2", name); 00609 #endif 00610 fH2NameIdMap[name] = index + fFirstHistoId; 00611 return index + fFirstHistoId; 00612 }
void G4RootAnalysisManager::CreateNtuple | ( | const G4String & | name, | |
const G4String & | title | |||
) | [virtual] |
Implements G4VAnalysisManager.
Definition at line 710 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fpVerboseL2, G4VAnalysisManager::fpVerboseL4, G4Exception(), JustWarning, and G4AnalysisVerbose::Message().
00712 { 00713 if ( fNtupleBooking ) { 00714 G4ExceptionDescription description; 00715 description << " " 00716 << "Ntuple already exists. " 00717 << "(Only one ntuple is currently supported.)"; 00718 G4Exception("G4RootAnalysisManager::CreateNtuple()", 00719 "Analysis_W006", JustWarning, description); 00720 return; 00721 } 00722 00723 // Create a directory if file is open 00724 if ( fFile && ( ! fNtupleDirectory ) ) { 00725 if ( ! CreateNtupleDirectory() ) return; 00726 } 00727 00728 #ifdef G4VERBOSE 00729 if ( fpVerboseL4 ) 00730 fpVerboseL4->Message("create", "ntuple", name); 00731 #endif 00732 00733 // Create ntuple booking 00734 fNtupleBooking = new tools::ntuple_booking(); 00735 fNtupleBooking->m_name = name; 00736 fNtupleBooking->m_title = title; 00737 // ntuple booking object is deleted in destructor 00738 00739 // Create ntuple if the file is open 00740 if ( fFile ) { 00741 fNtuple = new tools::wroot::ntuple(*fNtupleDirectory, name, title); 00742 // ntuple object is deleted automatically when closing a file 00743 } 00744 00745 #ifdef G4VERBOSE 00746 if ( fpVerboseL2 ) 00747 fpVerboseL2->Message("create", "ntuple", name); 00748 #endif 00749 }
Implements G4VAnalysisManager.
Definition at line 829 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fFirstNtupleColumnId, G4VAnalysisManager::fLockFirstNtupleColumnId, G4VAnalysisManager::fpVerboseL2, G4VAnalysisManager::fpVerboseL4, G4Exception(), JustWarning, and G4AnalysisVerbose::Message().
00830 { 00831 #ifdef G4VERBOSE 00832 if ( fpVerboseL4 ) 00833 fpVerboseL4->Message("create", "ntuple D column", name); 00834 #endif 00835 00836 if ( ! fNtupleBooking ) { 00837 G4ExceptionDescription description; 00838 description << " " 00839 << "Ntuple has to be created first. "; 00840 G4Exception("G4RootAnalysisManager::CreateNtupleDColumn()", 00841 "Analysis_W005", JustWarning, description); 00842 return -1; 00843 } 00844 00845 // Save column info in booking 00846 G4int index = fNtupleBooking->m_columns.size(); 00847 fNtupleBooking->add_column<double>(name); 00848 00849 // Create column if ntuple already exists 00850 if ( fNtuple ) { 00851 tools::wroot::ntuple::column<double>* column 00852 = fNtuple->create_column<double>(name); 00853 fNtupleDColumnMap[index] = column; 00854 } 00855 00856 fLockFirstNtupleColumnId = true; 00857 00858 #ifdef G4VERBOSE 00859 if ( fpVerboseL2 ) 00860 fpVerboseL2->Message("create", "ntuple D column", name); 00861 #endif 00862 00863 return index + fFirstNtupleColumnId; 00864 }
Implements G4VAnalysisManager.
Definition at line 790 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fFirstNtupleColumnId, G4VAnalysisManager::fLockFirstNtupleColumnId, G4VAnalysisManager::fpVerboseL2, G4VAnalysisManager::fpVerboseL4, G4Exception(), JustWarning, and G4AnalysisVerbose::Message().
00791 { 00792 #ifdef G4VERBOSE 00793 if ( fpVerboseL4 ) 00794 fpVerboseL4->Message("create", "ntuple F column", name); 00795 #endif 00796 00797 if ( ! fNtupleBooking ) { 00798 G4ExceptionDescription description; 00799 description << " " 00800 << "Ntuple has to be created first. "; 00801 G4Exception("G4RootAnalysisManager::CreateNtupleFColumn()", 00802 "Analysis_W005", JustWarning, description); 00803 return -1; 00804 } 00805 00806 // Save column info in booking 00807 G4int index = fNtupleBooking->m_columns.size(); 00808 fNtupleBooking->add_column<float>(name); 00809 00810 // Create column if ntuple already exists 00811 if ( fNtuple ) { 00812 tools::wroot::ntuple::column<float>* column 00813 = fNtuple->create_column<float>(name); 00814 fNtupleFColumnMap[index] = column; 00815 } 00816 00817 fLockFirstNtupleColumnId = true; 00818 00819 #ifdef G4VERBOSE 00820 if ( fpVerboseL2 ) 00821 fpVerboseL2->Message("create", "ntuple F column", name); 00822 #endif 00823 00824 return index + fFirstNtupleColumnId; 00825 }
Implements G4VAnalysisManager.
Definition at line 752 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fFirstNtupleColumnId, G4VAnalysisManager::fLockFirstNtupleColumnId, G4VAnalysisManager::fpVerboseL2, G4VAnalysisManager::fpVerboseL4, G4Exception(), JustWarning, and G4AnalysisVerbose::Message().
00753 { 00754 #ifdef G4VERBOSE 00755 if ( fpVerboseL4 ) 00756 fpVerboseL4->Message("create", "ntuple I column", name); 00757 #endif 00758 00759 if ( ! fNtupleBooking ) { 00760 G4ExceptionDescription description; 00761 description << " " 00762 << "Ntuple has to be created first. "; 00763 G4Exception("G4RootAnalysisManager::CreateNtupleIColumn()", 00764 "Analysis_W005", JustWarning, description); 00765 return -1; 00766 } 00767 00768 // Save column info in booking 00769 G4int index = fNtupleBooking->m_columns.size(); 00770 fNtupleBooking->add_column<int>(name); 00771 00772 // Create column if ntuple already exists 00773 if ( fNtuple ) { 00774 tools::wroot::ntuple::column<int>* column 00775 = fNtuple->create_column<int>(name); 00776 fNtupleIColumnMap[index] = column; 00777 } 00778 00779 fLockFirstNtupleColumnId = true; 00780 00781 #ifdef G4VERBOSE 00782 if ( fpVerboseL2 ) 00783 fpVerboseL2->Message("create", "ntuple I column", name); 00784 #endif 00785 00786 return index + fFirstNtupleColumnId; 00787 }
Implements G4VAnalysisManager.
Definition at line 873 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fActivation, G4VAnalysisManager::fpVerboseL4, G4HnInformation::fXFcn, G4HnInformation::fXUnit, G4VAnalysisManager::GetActivation(), G4VAnalysisManager::GetInformation(), G4VAnalysisManager::kH1, and G4AnalysisVerbose::Message().
00874 { 00875 tools::histo::h1d* h1d = GetH1InFunction(id, "FillH1", true, false); 00876 if ( ! h1d ) return false; 00877 00878 if ( fActivation && ( ! GetActivation(kH1, id) ) ) { 00879 //G4cout << "Skipping FillH1 for " << id << G4endl; 00880 return false; 00881 } 00882 00883 G4HnInformation* info = GetInformation(kH1, id); 00884 h1d->fill(info->fXFcn(value/info->fXUnit), weight); 00885 #ifdef G4VERBOSE 00886 if ( fpVerboseL4 ) { 00887 G4ExceptionDescription description; 00888 description << " id " << id << " value " << value; 00889 fpVerboseL4->Message("fill", "H1", description); 00890 } 00891 #endif 00892 return true; 00893 }
G4bool G4RootAnalysisManager::FillH2 | ( | G4int | id, | |
G4double | xvalue, | |||
G4double | yvalue, | |||
G4double | weight = 1.0 | |||
) | [virtual] |
Implements G4VAnalysisManager.
Definition at line 896 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fActivation, G4VAnalysisManager::fpVerboseL4, G4HnInformation::fXFcn, G4HnInformation::fXUnit, G4HnInformation::fYFcn, G4HnInformation::fYUnit, G4VAnalysisManager::GetActivation(), G4VAnalysisManager::GetInformation(), G4VAnalysisManager::kH2, and G4AnalysisVerbose::Message().
00899 { 00900 tools::histo::h2d* h2d = GetH2InFunction(id, "FillH2", true, false); 00901 if ( ! h2d ) return false; 00902 00903 if ( fActivation && ( ! GetActivation(kH2, id) ) ) return false; 00904 00905 G4HnInformation* info = GetInformation(kH2, id); 00906 h2d->fill(info->fXFcn(xvalue/info->fXUnit), 00907 info->fYFcn(yvalue/info->fYUnit), weight); 00908 #ifdef G4VERBOSE 00909 if ( fpVerboseL4 ) { 00910 G4ExceptionDescription description; 00911 description << " id " << id 00912 << " xvalue " << xvalue << " yvalue " << yvalue; 00913 fpVerboseL4->Message("fill", "H2", description); 00914 } 00915 #endif 00916 return true; 00917 }
Implements G4VAnalysisManager.
Definition at line 964 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fpVerboseL4, G4Exception(), JustWarning, and G4AnalysisVerbose::Message().
00965 { 00966 tools::wroot::ntuple::column<double>* column = GetNtupleDColumn(id); 00967 if ( ! column ) { 00968 G4ExceptionDescription description; 00969 description << " " << "column " << id << " does not exist."; 00970 G4Exception("G4RootAnalysisManager::FillNtupleDColumn()", 00971 "Analysis_W009", JustWarning, description); 00972 return false; 00973 } 00974 00975 column->fill(value); 00976 #ifdef G4VERBOSE 00977 if ( fpVerboseL4 ) { 00978 G4ExceptionDescription description; 00979 description << " id " << id << " value " << value; 00980 fpVerboseL4->Message("fill", "ntuple D column", description); 00981 } 00982 #endif 00983 return true; 00984 }
Implements G4VAnalysisManager.
Definition at line 942 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fpVerboseL4, G4Exception(), JustWarning, and G4AnalysisVerbose::Message().
00943 { 00944 tools::wroot::ntuple::column<float>* column = GetNtupleFColumn(id); 00945 if ( ! column ) { 00946 G4ExceptionDescription description; 00947 description << " " << "column " << id << " does not exist."; 00948 G4Exception("G4RootAnalysisManager::FillNtupleFColumn()", 00949 "Analysis_W009", JustWarning, description); 00950 return false; 00951 } 00952 00953 column->fill(value); 00954 #ifdef G4VERBOSE 00955 if ( fpVerboseL4 ) { 00956 G4ExceptionDescription description; 00957 description << " id " << id << " value " << value; 00958 fpVerboseL4->Message("fill", "ntuple F column", description); 00959 } 00960 #endif 00961 return true; 00962 }
Implements G4VAnalysisManager.
Definition at line 920 of file G4RootAnalysisManager.cc.
References G4VAnalysisManager::fpVerboseL4, G4Exception(), JustWarning, and G4AnalysisVerbose::Message().
00921 { 00922 tools::wroot::ntuple::column<int>* column = GetNtupleIColumn(id); 00923 if ( ! column ) { 00924 G4ExceptionDescription description; 00925 description << " " << "column " << id << " does not exist."; 00926 G4Exception("G4RootAnalysisManager::FillNtupleIColumn()", 00927 "Analysis_W009", JustWarning, description); 00928 return false; 00929 } 00930 00931 column->fill(value); 00932 #ifdef G4VERBOSE 00933 if ( fpVerboseL4 ) { 00934 G4ExceptionDescription description; 00935 description << " id " << id << " value " << value; 00936 fpVerboseL4->Message("fill", "ntuple I column", description); 00937 } 00938 #endif 00939 return true; 00940 }
void G4RootAnalysisManager::FinishNtuple | ( | ) | [virtual] |
tools::histo::h1d * G4RootAnalysisManager::GetH1 | ( | G4int | id, | |
G4bool | warn = true , |
|||
G4bool | onlyIfActive = true | |||
) | const [virtual] |
Definition at line 1032 of file G4RootAnalysisManager.cc.
References G4Exception(), and JustWarning.
01033 { 01034 std::map<G4String, G4int>::const_iterator it = fH1NameIdMap.find(name); 01035 if ( it == fH1NameIdMap.end() ) { 01036 if ( warn) { 01037 G4String inFunction = "G4RootAnalysisManager::GetH1Id"; 01038 G4ExceptionDescription description; 01039 description << " " << "histogram " << name << " does not exist."; 01040 G4Exception(inFunction, "Analysis_W007", JustWarning, description); 01041 } 01042 return -1; 01043 } 01044 return it->second; 01045 }
Implements G4VAnalysisManager.
Definition at line 1070 of file G4RootAnalysisManager.cc.
01071 { 01072 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Nbins"); 01073 if ( ! h1d ) return 0; 01074 01075 return h1d->axis().bins(); 01076 }
Implements G4VAnalysisManager.
Definition at line 1291 of file G4RootAnalysisManager.cc.
01292 { 01293 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Title"); 01294 if ( ! h1d ) return ""; 01295 01296 return h1d->title(); 01297 }
Implements G4VAnalysisManager.
Definition at line 1101 of file G4RootAnalysisManager.cc.
References G4HnInformation::fXFcn, G4HnInformation::fXUnit, G4Exception(), G4VAnalysisManager::GetInformation(), JustWarning, and G4VAnalysisManager::kH1.
01102 { 01103 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1XWidth", true, false); 01104 if ( ! h1d ) return 0; 01105 01106 G4int nbins = h1d->axis().bins(); 01107 if ( ! nbins ) { 01108 G4ExceptionDescription description; 01109 description << " nbins = 0 (for h1 id = " << id << ")."; 01110 G4Exception("G4RootAnalysisManager::GetH1Width", 01111 "Analysis_W014", JustWarning, description); 01112 return 0; 01113 } 01114 01115 G4HnInformation* info = GetInformation(kH1, id); 01116 return ( info->fXFcn(h1d->axis().upper_edge()) 01117 - info->fXFcn(h1d->axis().lower_edge()))*info->fXUnit/nbins; 01118 }
Implements G4VAnalysisManager.
Definition at line 1301 of file G4RootAnalysisManager.cc.
References G4Exception(), and JustWarning.
01302 { 01303 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1XAxisTitle"); 01304 if ( ! h1d ) return ""; 01305 01306 G4String title; 01307 G4bool result = h1d->annotation(tools::histo::key_axis_x_title(), title); 01308 if ( ! result ) { 01309 G4ExceptionDescription description; 01310 description << " Failed to get x_axis title for h1 id = " << id << ")."; 01311 G4Exception("G4RootAnalysisManager::GetH1XAxisTitle", 01312 "Analysis_W014", JustWarning, description); 01313 return ""; 01314 } 01315 01316 return title; 01317 }
Implements G4VAnalysisManager.
Definition at line 1091 of file G4RootAnalysisManager.cc.
References G4HnInformation::fXFcn, G4HnInformation::fXUnit, G4VAnalysisManager::GetInformation(), and G4VAnalysisManager::kH1.
01092 { 01093 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Xmax"); 01094 if ( ! h1d ) return 0; 01095 01096 G4HnInformation* info = GetInformation(kH1, id); 01097 return info->fXFcn(h1d->axis().upper_edge()*info->fXUnit); 01098 }
Implements G4VAnalysisManager.
Definition at line 1079 of file G4RootAnalysisManager.cc.
References G4HnInformation::fXFcn, G4HnInformation::fXUnit, G4VAnalysisManager::GetInformation(), and G4VAnalysisManager::kH1.
01080 { 01081 // Returns xmin value with applied unit and histogram function 01082 01083 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Xmin"); 01084 if ( ! h1d ) return 0; 01085 01086 G4HnInformation* info = GetInformation(kH1, id); 01087 return info->fXFcn(h1d->axis().lower_edge()*info->fXUnit); 01088 }
Implements G4VAnalysisManager.
Definition at line 1320 of file G4RootAnalysisManager.cc.
References G4Exception(), and JustWarning.
01321 { 01322 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1YAxisTitle"); 01323 if ( ! h1d ) return ""; 01324 01325 G4String title; 01326 G4bool result = h1d->annotation(tools::histo::key_axis_y_title(), title); 01327 if ( ! result ) { 01328 G4ExceptionDescription description; 01329 description << " Failed to get y_axis title for h1 id = " << id << ")."; 01330 G4Exception("G4RootAnalysisManager::GetH1YAxisTitle", 01331 "Analysis_W014", JustWarning, description); 01332 return ""; 01333 } 01334 01335 return title; 01336 }
tools::histo::h2d * G4RootAnalysisManager::GetH2 | ( | G4int | id, | |
G4bool | warn = true , |
|||
G4bool | onlyIfActive = true | |||
) | const [virtual] |
Definition at line 1048 of file G4RootAnalysisManager.cc.
References G4Exception(), and JustWarning.
01049 { 01050 std::map<G4String, G4int>::const_iterator it = fH2NameIdMap.find(name); 01051 if ( it == fH2NameIdMap.end() ) { 01052 if ( warn) { 01053 G4String inFunction = "G4RootAnalysisManager::GetH2Id"; 01054 G4ExceptionDescription description; 01055 description << " " << "histogram " << name << " does not exist."; 01056 G4Exception(inFunction, "Analysis_W007", JustWarning, description); 01057 } 01058 return -1; 01059 } 01060 return it->second; 01061 }
Implements G4VAnalysisManager.
Definition at line 1121 of file G4RootAnalysisManager.cc.
01122 { 01123 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2NXbins"); 01124 if ( ! h2d ) return 0; 01125 01126 return h2d->axis_x().bins(); 01127 }
Implements G4VAnalysisManager.
Definition at line 1172 of file G4RootAnalysisManager.cc.
01173 { 01174 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2NYbins"); 01175 if ( ! h2d ) return 0; 01176 01177 return h2d->axis_y().bins(); 01178 }
Implements G4VAnalysisManager.
Definition at line 1339 of file G4RootAnalysisManager.cc.
01340 { 01341 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Title"); 01342 if ( ! h2d ) return ""; 01343 01344 return h2d->title(); 01345 }
Implements G4VAnalysisManager.
Definition at line 1348 of file G4RootAnalysisManager.cc.
References G4Exception(), and JustWarning.
01349 { 01350 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2XAxisTitle"); 01351 if ( ! h2d ) return ""; 01352 01353 G4String title; 01354 G4bool result = h2d->annotation(tools::histo::key_axis_x_title(), title); 01355 if ( ! result ) { 01356 G4ExceptionDescription description; 01357 description << " Failed to get x_axis title for h2 id = " << id << ")."; 01358 G4Exception("G4RootAnalysisManager::GetH2XAxisTitle", 01359 "Analysis_W014", JustWarning, description); 01360 return ""; 01361 } 01362 01363 return title; 01364 }
Implements G4VAnalysisManager.
Definition at line 1142 of file G4RootAnalysisManager.cc.
References G4HnInformation::fXFcn, G4HnInformation::fXUnit, G4VAnalysisManager::GetInformation(), and G4VAnalysisManager::kH2.
01143 { 01144 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Xmax"); 01145 if ( ! h2d ) return 0; 01146 01147 G4HnInformation* info = GetInformation(kH2, id); 01148 return info->fXFcn(h2d->axis_x().upper_edge()*info->fXUnit); 01149 }
Implements G4VAnalysisManager.
Definition at line 1130 of file G4RootAnalysisManager.cc.
References G4HnInformation::fXFcn, G4HnInformation::fXUnit, G4VAnalysisManager::GetInformation(), and G4VAnalysisManager::kH2.
01131 { 01132 // Returns xmin value with applied unit and histogram function 01133 01134 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Xmin"); 01135 if ( ! h2d ) return 0; 01136 01137 G4HnInformation* info = GetInformation(kH2, id); 01138 return info->fXFcn(h2d->axis_x().lower_edge()*info->fXUnit); 01139 }
Implements G4VAnalysisManager.
Definition at line 1152 of file G4RootAnalysisManager.cc.
References G4HnInformation::fXFcn, G4HnInformation::fXUnit, G4Exception(), G4VAnalysisManager::GetInformation(), JustWarning, and G4VAnalysisManager::kH2.
01153 { 01154 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2XWidth", true, false); 01155 if ( ! h2d ) return 0; 01156 01157 G4int nbins = h2d->axis_x().bins(); 01158 if ( ! nbins ) { 01159 G4ExceptionDescription description; 01160 description << " nbins = 0 (for h1 id = " << id << ")."; 01161 G4Exception("G4RootAnalysisManager::GetH2Width", 01162 "Analysis_W014", JustWarning, description); 01163 return 0; 01164 } 01165 01166 G4HnInformation* info = GetInformation(kH2, id); 01167 return ( info->fXFcn(h2d->axis_x().upper_edge()) 01168 - info->fXFcn(h2d->axis_x().lower_edge()))*info->fXUnit/nbins; 01169 }
Implements G4VAnalysisManager.
Definition at line 1367 of file G4RootAnalysisManager.cc.
References G4Exception(), and JustWarning.
01368 { 01369 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2YAxisTitle"); 01370 if ( ! h2d ) return ""; 01371 01372 G4String title; 01373 G4bool result = h2d->annotation(tools::histo::key_axis_y_title(), title); 01374 if ( ! result ) { 01375 G4ExceptionDescription description; 01376 description << " Failed to get y_axis title for h2 id = " << id << ")."; 01377 G4Exception("G4RootAnalysisManager::GetH2YAxisTitle", 01378 "Analysis_W014", JustWarning, description); 01379 return ""; 01380 } 01381 01382 return title; 01383 }
Implements G4VAnalysisManager.
Definition at line 1193 of file G4RootAnalysisManager.cc.
References G4HnInformation::fYFcn, G4HnInformation::fYUnit, G4VAnalysisManager::GetInformation(), and G4VAnalysisManager::kH2.
01194 { 01195 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Ymax"); 01196 if ( ! h2d ) return 0; 01197 01198 G4HnInformation* info = GetInformation(kH2, id); 01199 return info->fYFcn(h2d->axis_y().upper_edge()*info->fYUnit); 01200 }
Implements G4VAnalysisManager.
Definition at line 1181 of file G4RootAnalysisManager.cc.
References G4HnInformation::fYFcn, G4HnInformation::fYUnit, G4VAnalysisManager::GetInformation(), and G4VAnalysisManager::kH2.
01182 { 01183 // Returns xmin value with applied unit and histogram function 01184 01185 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Ymin"); 01186 if ( ! h2d ) return 0; 01187 01188 G4HnInformation* info = GetInformation(kH2, id); 01189 return info->fYFcn(h2d->axis_y().lower_edge()*info->fYUnit); 01190 }
Implements G4VAnalysisManager.
Definition at line 1203 of file G4RootAnalysisManager.cc.
References G4HnInformation::fYFcn, G4HnInformation::fYUnit, G4Exception(), G4VAnalysisManager::GetInformation(), JustWarning, and G4VAnalysisManager::kH2.
01204 { 01205 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2YWidth", true, false); 01206 if ( ! h2d ) return 0; 01207 01208 G4int nbins = h2d->axis_y().bins(); 01209 if ( ! nbins ) { 01210 G4ExceptionDescription description; 01211 description << " nbins = 0 (for h1 id = " << id << ")."; 01212 G4Exception("G4RootAnalysisManager::GetH2Width", 01213 "Analysis_W014", JustWarning, description); 01214 return 0; 01215 } 01216 01217 G4HnInformation* info = GetInformation(kH2, id); 01218 return ( info->fYFcn(h2d->axis_y().upper_edge()) 01219 - info->fYFcn(h2d->axis_y().lower_edge()))*info->fYUnit/nbins; 01220 }
Implements G4VAnalysisManager.
Definition at line 1386 of file G4RootAnalysisManager.cc.
References G4Exception(), and JustWarning.
01387 { 01388 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2ZAxisTitle"); 01389 if ( ! h2d ) return ""; 01390 01391 G4String title; 01392 G4bool result = h2d->annotation(tools::histo::key_axis_z_title(), title); 01393 if ( ! result ) { 01394 G4ExceptionDescription description; 01395 description << " Failed to get z_axis title for h2 id = " << id << ")."; 01396 G4Exception("G4RootAnalysisManager::GetH2ZAxisTitle", 01397 "Analysis_W014", JustWarning, description); 01398 return ""; 01399 } 01400 01401 return title; 01402 }
tools::wroot::ntuple * G4RootAnalysisManager::GetNtuple | ( | ) | const [virtual] |
G4RootAnalysisManager * G4RootAnalysisManager::Instance | ( | ) | [static] |
Definition at line 38 of file G4RootAnalysisManager.cc.
References G4RootAnalysisManager().
00039 { 00040 if ( fgInstance == 0 ) { 00041 fgInstance = new G4RootAnalysisManager(); 00042 } 00043 00044 return fgInstance; 00045 }
Implements G4VAnalysisManager.
Definition at line 387 of file G4RootAnalysisManager.cc.
References G4String::append(), G4VAnalysisManager::fFileName, G4VAnalysisManager::fLockFileName, G4VAnalysisManager::fLockHistoDirectoryName, G4VAnalysisManager::fLockNtupleDirectoryName, G4VAnalysisManager::fpVerboseL1, G4VAnalysisManager::fpVerboseL4, G4Exception(), G4VAnalysisManager::GetFileType(), JustWarning, and G4AnalysisVerbose::Message().
00388 { 00389 // Keep file name 00390 fFileName = fileName; 00391 00392 // Add file extension .root if no extension is given 00393 G4String name(fileName); 00394 if ( name.find(".") == std::string::npos ) { 00395 name.append("."); 00396 name.append(GetFileType()); 00397 } 00398 00399 #ifdef G4VERBOSE 00400 if ( fpVerboseL4 ) 00401 fpVerboseL4->Message("open", "analysis file", name); 00402 #endif 00403 00404 // delete previous file if exists 00405 if ( fFile ) delete fFile; 00406 00407 fFile = new tools::wroot::file(std::cout, name); 00408 if ( ! fFile->is_open() ) { 00409 G4ExceptionDescription description; 00410 description << " " << "Cannot open file " << fileName; 00411 G4Exception("G4RootAnalysisManager::OpenFile()", 00412 "Analysis_W001", JustWarning, description); 00413 return false; 00414 } 00415 00416 // Create directories 00417 if ( ! CreateHistoDirectory() ) return false; 00418 if ( ! CreateNtupleDirectory() ) return false; 00419 00420 // Create ntuple if it is booked 00421 if ( fNtupleBooking && ( ! fNtuple ) ) 00422 CreateNtupleFromBooking(); 00423 00424 fLockFileName = true; 00425 fLockHistoDirectoryName = true; 00426 fLockNtupleDirectoryName = true; 00427 00428 #ifdef G4VERBOSE 00429 if ( fpVerboseL1 ) 00430 fpVerboseL1->Message("open", "analysis file", name); 00431 #endif 00432 00433 return true; 00434 }
Implements G4VAnalysisManager.
Definition at line 692 of file G4RootAnalysisManager.cc.
00693 { 00694 tools::histo::h1d* h1d = GetH1InFunction(id, "ScaleH1", false, false); 00695 if ( ! h1d ) return false; 00696 00697 return h1d->scale(factor); 00698 }
Implements G4VAnalysisManager.
Definition at line 701 of file G4RootAnalysisManager.cc.
00702 { 00703 tools::histo::h2d* h2d = GetH2InFunction(id, "ScaleH2", false, false); 00704 if ( ! h2d ) return false; 00705 00706 return h2d->scale(factor); 00707 }
G4bool G4RootAnalysisManager::SetH1 | ( | G4int | id, | |
G4int | nbins, | |||
G4double | xmin, | |||
G4double | xmax, | |||
const G4String & | unitName = "none" , |
|||
const G4String & | fcnName = "none" | |||
) | [virtual] |
Implements G4VAnalysisManager.
Definition at line 615 of file G4RootAnalysisManager.cc.
References G4HnInformation::fName, G4VAnalysisManager::fpVerboseL4, G4HnInformation::fXFcn, G4HnInformation::fXFcnName, G4HnInformation::fXUnit, G4HnInformation::fXUnitName, G4HnInformation::fYFcn, G4HnInformation::fYFcnName, G4HnInformation::fYUnit, G4HnInformation::fYUnitName, G4VAnalysisManager::GetFunction(), G4VAnalysisManager::GetH1Information(), G4VAnalysisManager::GetUnitValue(), G4VAnalysisManager::kH1, G4AnalysisVerbose::Message(), and G4VAnalysisManager::SetActivation().
00618 { 00619 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1", false, false); 00620 if ( ! h1d ) return false; 00621 00622 G4HnInformation* info = GetH1Information(id); 00623 #ifdef G4VERBOSE 00624 if ( fpVerboseL4 ) 00625 fpVerboseL4->Message("configure", "H1", info->fName); 00626 #endif 00627 00628 G4double unit = GetUnitValue(unitName); 00629 G4Fcn fcn = GetFunction(fcnName); 00630 h1d->configure(nbins, fcn(xmin), fcn(xmax)); 00631 info->fXUnitName = unitName; 00632 info->fYUnitName = unitName; 00633 info->fXFcnName = fcnName; 00634 info->fYFcnName = fcnName; 00635 info->fXUnit = unit; 00636 info->fYUnit = unit; 00637 info->fXFcn = fcn; 00638 info->fYFcn = fcn; 00639 SetActivation(kH1, id, true); 00640 00641 G4String axisTitle; 00642 UpdateTitle(axisTitle,unitName, fcnName); 00643 h1d->add_annotation(tools::histo::key_axis_x_title(), axisTitle); 00644 00645 return true; 00646 }
Implements G4VAnalysisManager.
Definition at line 1223 of file G4RootAnalysisManager.cc.
01224 { 01225 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1Title"); 01226 if ( ! h1d ) return false; 01227 01228 return h1d->set_title(title); 01229 }
Implements G4VAnalysisManager.
Definition at line 1232 of file G4RootAnalysisManager.cc.
01233 { 01234 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1XAxisTitle"); 01235 if ( ! h1d ) return false; 01236 01237 h1d->add_annotation(tools::histo::key_axis_x_title(), title); 01238 return true; 01239 }
Implements G4VAnalysisManager.
Definition at line 1242 of file G4RootAnalysisManager.cc.
01243 { 01244 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1YAxisTitle"); 01245 if ( ! h1d ) return false; 01246 01247 h1d->add_annotation(tools::histo::key_axis_y_title(), title); 01248 return true; 01249 }
G4bool G4RootAnalysisManager::SetH2 | ( | G4int | id, | |
G4int | nxbins, | |||
G4double | xmin, | |||
G4double | xmax, | |||
G4int | nybins, | |||
G4double | ymin, | |||
G4double | ymax, | |||
const G4String & | xunitName = "none" , |
|||
const G4String & | yunitName = "none" , |
|||
const G4String & | xfcnName = "none" , |
|||
const G4String & | yfcnName = "none" | |||
) | [virtual] |
Implements G4VAnalysisManager.
Definition at line 649 of file G4RootAnalysisManager.cc.
References G4HnInformation::fName, G4VAnalysisManager::fpVerboseL4, G4HnInformation::fXFcn, G4HnInformation::fXFcnName, G4HnInformation::fXUnit, G4HnInformation::fXUnitName, G4HnInformation::fYFcn, G4HnInformation::fYFcnName, G4HnInformation::fYUnit, G4HnInformation::fYUnitName, G4VAnalysisManager::GetFunction(), G4VAnalysisManager::GetH2Information(), G4VAnalysisManager::GetUnitValue(), G4VAnalysisManager::kH2, G4AnalysisVerbose::Message(), and G4VAnalysisManager::SetActivation().
00654 { 00655 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2", false, false); 00656 if ( ! h2d ) return false; 00657 00658 G4HnInformation* info = GetH2Information(id); 00659 #ifdef G4VERBOSE 00660 if ( fpVerboseL4 ) 00661 fpVerboseL4->Message("configure", "H2", info->fName); 00662 #endif 00663 00664 G4double xunit = GetUnitValue(xunitName); 00665 G4double yunit = GetUnitValue(yunitName); 00666 G4Fcn xfcn = GetFunction(xfcnName); 00667 G4Fcn yfcn = GetFunction(yfcnName); 00668 h2d->configure(nxbins, xfcn(xmin), xfcn(xmax), 00669 nybins, yfcn(ymin), yfcn(ymax)); 00670 00671 info->fXUnitName = xunitName; 00672 info->fYUnitName = yunitName; 00673 info->fXFcnName = xfcnName; 00674 info->fYFcnName = yfcnName; 00675 info->fXUnit = xunit; 00676 info->fYUnit = yunit; 00677 info->fXFcn = xfcn; 00678 info->fYFcn = yfcn; 00679 SetActivation(kH2, id, true); 00680 00681 G4String xaxisTitle; 00682 G4String yaxisTitle; 00683 UpdateTitle(xaxisTitle, xunitName, xfcnName); 00684 UpdateTitle(yaxisTitle, yunitName, yfcnName); 00685 h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle); 00686 h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle); 00687 00688 return true; 00689 }
Implements G4VAnalysisManager.
Definition at line 1252 of file G4RootAnalysisManager.cc.
01253 { 01254 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2Title"); 01255 if ( ! h2d ) return false; 01256 01257 return h2d->set_title(title); 01258 }
Implements G4VAnalysisManager.
Definition at line 1261 of file G4RootAnalysisManager.cc.
01262 { 01263 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2XAxisTitle"); 01264 if ( ! h2d ) return false; 01265 01266 h2d->add_annotation(tools::histo::key_axis_x_title(), title); 01267 return true; 01268 }
Implements G4VAnalysisManager.
Definition at line 1271 of file G4RootAnalysisManager.cc.
01272 { 01273 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2YAxisTitle"); 01274 if ( ! h2d ) return false; 01275 01276 h2d->add_annotation(tools::histo::key_axis_x_title(), title); 01277 return true; 01278 }
Implements G4VAnalysisManager.
Definition at line 1281 of file G4RootAnalysisManager.cc.
01282 { 01283 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2ZAxisTitle"); 01284 if ( ! h2d ) return false; 01285 01286 h2d->add_annotation(tools::histo::key_axis_z_title(), title); 01287 return true; 01288 }
G4bool G4RootAnalysisManager::Write | ( | ) | [virtual] |
Implements G4VAnalysisManager.
Definition at line 437 of file G4RootAnalysisManager.cc.
References G4HnInformation::fActivation, G4VAnalysisManager::fActivation, G4HnInformation::fName, G4VAnalysisManager::fpVerboseL1, G4VAnalysisManager::fpVerboseL3, G4VAnalysisManager::fpVerboseL4, G4Exception(), G4VAnalysisManager::GetFullFileName(), G4VAnalysisManager::GetH1Information(), G4VAnalysisManager::GetH2Information(), G4VAnalysisManager::IsAscii(), JustWarning, G4AnalysisVerbose::Message(), CLHEP::detail::n, and G4VAnalysisManager::WriteAscii().
00438 { 00439 // h1 histograms 00440 for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) { 00441 G4int id = i + fFirstHistoId; 00442 G4HnInformation* info = GetH1Information(id); 00443 // skip writing if activation is enabled and H1 is inactivated 00444 if ( fActivation && ( ! info->fActivation ) ) continue; 00445 tools::histo::h1d* h1 = fH1Vector[i]; 00446 #ifdef G4VERBOSE 00447 if ( fpVerboseL3 ) 00448 fpVerboseL3->Message("write", "h1d", info->fName); 00449 #endif 00450 G4bool result 00451 = to(*fHistoDirectory,*h1,info->fName); 00452 if ( ! result ) { 00453 G4ExceptionDescription description; 00454 description << " " << "saving histogram " << info->fName << " failed"; 00455 G4Exception("G4RootAnalysisManager::Write()", 00456 "Analysis_W003", JustWarning, description); 00457 return false; 00458 } 00459 } 00460 00461 // h2 histograms 00462 for ( G4int i=0; i<G4int(fH2Vector.size()); ++i ) { 00463 G4int id = i + fFirstHistoId; 00464 G4HnInformation* info = GetH2Information(id); 00465 // skip writing if inactivated 00466 if ( fActivation && ( ! info->fActivation ) ) continue; 00467 tools::histo::h2d* h2 = fH2Vector[i]; 00468 #ifdef G4VERBOSE 00469 if ( fpVerboseL3 ) 00470 fpVerboseL3->Message("write", "h2d", info->fName); 00471 #endif 00472 G4bool result 00473 = to(*fHistoDirectory,*h2,info->fName); 00474 if ( ! result ) { 00475 G4ExceptionDescription description; 00476 description << " " << "saving histogram " << info->fName << " failed"; 00477 G4Exception("G4RootAnalysisManager::Write()", 00478 "Analysis_W003", JustWarning, description); 00479 return false; 00480 } 00481 } 00482 00483 #ifdef G4VERBOSE 00484 if ( fpVerboseL4 ) 00485 fpVerboseL4->Message("write", "file", GetFullFileName()); 00486 #endif 00487 00488 unsigned int n; 00489 G4bool result = fFile->write(n); 00490 00491 #ifdef G4VERBOSE 00492 if ( fpVerboseL1 ) 00493 fpVerboseL1->Message("write", "file", GetFullFileName(), result); 00494 #endif 00495 00496 // Write ASCII if activated 00497 if ( IsAscii() ) { 00498 G4bool result2 = WriteAscii(); 00499 result = result && result2; 00500 } 00501 00502 return result; 00503 }
G4bool G4RootAnalysisManager::WriteOnAscii | ( | std::ofstream & | output | ) | [protected, virtual] |
Implements G4VAnalysisManager.
Definition at line 299 of file G4RootAnalysisManager.cc.
References G4HnInformation::fAscii, G4VAnalysisManager::fFirstHistoId, G4HnInformation::fName, G4VAnalysisManager::fpVerboseL3, G4endl, G4VAnalysisManager::GetH1Information(), and G4AnalysisVerbose::Message().
00300 { 00301 // Write selected objects on ASCII file 00302 // (Only H1 implemented by now) 00303 // According to the implementation by Michel Maire, originally in 00304 // extended examples. 00305 00306 // h1 histograms 00307 for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) { 00308 G4int id = i + fFirstHistoId; 00309 G4HnInformation* info = GetH1Information(id); 00310 // skip writing if activation is enabled and H1 is inactivated 00311 if ( ! info->fAscii ) continue; 00312 tools::histo::h1d* h1 = fH1Vector[i]; 00313 00314 #ifdef G4VERBOSE 00315 if ( fpVerboseL3 ) 00316 fpVerboseL3->Message("write on ascii", "h1d", info->fName); 00317 #endif 00318 00319 output << "\n 1D histogram " << id << ": " << h1->title() 00320 << "\n \n \t X \t\t Y" << G4endl; 00321 00322 for (G4int j=0; j< G4int(h1->axis().bins()); ++j) { 00323 output << " " << j << "\t" 00324 << h1->axis().bin_center(j) << "\t" 00325 << h1->bin_height(i) << G4endl; 00326 } 00327 } 00328 00329 return true; 00330 }