33#include "tools/waxml/begend"
34#include "tools/waxml/histos"
43 if ( fgInstance == 0 ) {
63 <<
"G4CsvAnalysisManager already exists."
64 <<
"Cannot create another instance.";
65 G4Exception(
"G4CsvAnalysisManager::G4CsvAnalysisManager()",
76 delete fNtupleBooking;
87tools::wcsv::ntuple::column<int>*
88G4CsvAnalysisManager::GetNtupleIColumn(
G4int id)
const
90 std::map<G4int, tools::wcsv::ntuple::column<int>* >::const_iterator it
91 = fNtupleIColumnMap.find(
id);
92 if ( it == fNtupleIColumnMap.end() ) {
94 description <<
" " <<
"column " <<
id <<
" does not exist.";
95 G4Exception(
"G4CsvAnalysisManager::GetNtupleIColumn()",
104tools::wcsv::ntuple::column<float>*
105G4CsvAnalysisManager::GetNtupleFColumn(
G4int id)
const
107 std::map<G4int, tools::wcsv::ntuple::column<float>* >::const_iterator it
108 = fNtupleFColumnMap.find(
id);
109 if ( it == fNtupleFColumnMap.end() ) {
111 description <<
" " <<
"column " <<
id <<
" does not exist.";
112 G4Exception(
"G4CsvAnalysisManager::GetNtupleFColumn()",
122tools::wcsv::ntuple::column<double>*
123G4CsvAnalysisManager::GetNtupleDColumn(
G4int id)
const
125 std::map<G4int, tools::wcsv::ntuple::column<double>* >::const_iterator it
126 = fNtupleDColumnMap.find(
id);
127 if ( it == fNtupleDColumnMap.end() ) {
129 description <<
" " <<
"column " <<
id <<
" does not exist.";
130 G4Exception(
"G4CsvAnalysisManager::GetNtupleDColumn()",
139G4bool G4CsvAnalysisManager::Reset()
148void G4CsvAnalysisManager::ExceptionForHistograms(
151 G4String inFunction =
"G4CsvAnalysisManager::";
152 inFunction += functionName;
155 <<
"Histograms are not supported." ;
184 if ( name.find(
".") == std::string::npos ) {
195 if ( fFile )
delete fFile;
197 fFile =
new std::ofstream(name);
198 if ( fFile->fail() ) {
200 description <<
" " <<
"Cannot open file " << fileName;
207 if ( fNtupleBooking && ( ! fNtuple ) ) {
212 fNtuple =
new tools::wcsv::ntuple(*fFile,
G4cerr, *fNtupleBooking);
213 if ( fNtupleBooking->m_columns.size() ) {
215 const std::vector<tools::ntuple_booking::col_t>& columns
216 = fNtupleBooking->m_columns;
217 std::vector<tools::ntuple_booking::col_t>::const_iterator it;
219 for ( it = columns.begin(); it!=columns.end(); ++it) {
220 if ( (*it).second == tools::_cid(
int(0) ) ) {
221 G4cout <<
"adding int " << fNtuple->find_column<
int>((*it).first) <<
G4endl;
222 fNtupleIColumnMap[index++] = fNtuple->find_column<
int>((*it).first);
224 else if( (*it).second == tools::_cid(
float(0) ) ) {
225 fNtupleFColumnMap[index++] = fNtuple->find_column<
float>((*it).first);
227 else if((*it).second== tools::_cid(
double(0))) {
228 fNtupleDColumnMap[index++] = fNtuple->find_column<
double>((*it).first);
233 <<
"Unsupported column type " << (*it).first;
279 description <<
" " <<
"Resetting data failed";
305 ExceptionForHistograms(
"CreateH1");
321 ExceptionForHistograms(
"CreateH2");
332 ExceptionForHistograms(
"SetH1");
347 ExceptionForHistograms(
"SetH2");
354 ExceptionForHistograms(
"ScaleH1");
361 ExceptionForHistograms(
"ScaleH2");
369 if ( fNtupleBooking ) {
372 <<
"Ntuple already exists. "
373 <<
"(Only one ntuple is currently supported.)";
374 G4Exception(
"G4CsvAnalysisManager::CreateNtuple()",
385 fNtupleBooking =
new tools::ntuple_booking();
386 fNtupleBooking->m_name = name;
387 fNtupleBooking->m_title = title;
392 fNtuple =
new tools::wcsv::ntuple(*fFile);
410 if ( ! fNtupleBooking ) {
413 <<
"Ntuple has to be created first. ";
414 G4Exception(
"G4CsvAnalysisManager::CreateNtupleIColumn()",
420 G4int index = fNtupleBooking->m_columns.size();
421 fNtupleBooking->add_column<
int>(name);
425 tools::wcsv::ntuple::column<int>* column
426 = fNtuple->create_column<
int>(name);
427 fNtupleIColumnMap[index] = column;
448 if ( ! fNtupleBooking ) {
451 <<
"Ntuple has to be created first. ";
452 G4Exception(
"G4CsvAnalysisManager::CreateNtupleFColumn()",
458 G4int index = fNtupleBooking->m_columns.size();
459 fNtupleBooking->add_column<
float>(name);
463 tools::wcsv::ntuple::column<float>* column
464 = fNtuple->create_column<
float>(name);
465 fNtupleFColumnMap[index] = column;
486 if ( ! fNtupleBooking ) {
489 <<
"Ntuple has to be created first. ";
490 G4Exception(
"G4CsvAnalysisManager::CreateNtupleDColumn()",
496 G4int index = fNtupleBooking->m_columns.size();
497 fNtupleBooking->add_column<
double>(name);
501 tools::wcsv::ntuple::column<double>* column
502 = fNtuple->create_column<
double>(name);
503 fNtupleDColumnMap[index] = column;
529 <<
"Histograms are not supported." ;
542 <<
"Histograms are not supported." ;
551 tools::wcsv::ntuple::column<int>* column = GetNtupleIColumn(
id);
554 description <<
" " <<
"column " <<
id <<
" does not exist.";
555 G4Exception(
"G4CsvAnalysisManager::FillNtupleIColumn()",
564 description <<
" id " <<
id <<
" value " << value;
573 tools::wcsv::ntuple::column<float>* column = GetNtupleFColumn(
id);
576 description <<
" " <<
"column " <<
id <<
" does not exist.";
577 G4Exception(
"G4CsvAnalysisManager::FillNtupleFColumn()",
586 description <<
" id " <<
id <<
" value " << value;
596 tools::wcsv::ntuple::column<double>* column = GetNtupleDColumn(
id);
599 description <<
" " <<
"column " <<
id <<
" does not exist.";
600 G4Exception(
"G4CsvAnalysisManager::FillNtupleDColumn()",
609 description <<
" id " <<
id <<
" value " << value;
626 description <<
" " <<
"ntuple does not exist. ";
627 G4Exception(
"G4CsvAnalysisManager::AddNtupleRow()",
651 ExceptionForHistograms(
"GetH1Nbins");
658 ExceptionForHistograms(
"GetH1Xmin");
665 ExceptionForHistograms(
"GetH1Xmax");
672 ExceptionForHistograms(
"GetH1Xwidth");
679 ExceptionForHistograms(
"GetH2NXbins");
686 ExceptionForHistograms(
"GetH2Xmin");
693 ExceptionForHistograms(
"GetH2Xmin");
700 ExceptionForHistograms(
"GetH2XWidth");
707 ExceptionForHistograms(
"GetH2NYbins");
714 ExceptionForHistograms(
"GetH2Ymin");
721 ExceptionForHistograms(
"GetH2Ymax");
728 ExceptionForHistograms(
"GetH2YWidth");
736 ExceptionForHistograms(
"SetH1Title");
744 ExceptionForHistograms(
"SetH1XAxisTitle");
752 ExceptionForHistograms(
"SetH1YAxisTitle");
760 ExceptionForHistograms(
"SetH2Title");
768 ExceptionForHistograms(
"SetH2XAxisTitle");
776 ExceptionForHistograms(
"SetH2YAxisTitle");
784 ExceptionForHistograms(
"SetH2ZAxisTitle");
791 ExceptionForHistograms(
"GetH1XAxisTitle");
798 ExceptionForHistograms(
"GetH1Title");
805 ExceptionForHistograms(
"GetH1YAxisTitle");
813 ExceptionForHistograms(
"GetH2Title");
820 ExceptionForHistograms(
"GetH2XAxisTitle");
827 ExceptionForHistograms(
"GetH2YAxisTitle");
834 ExceptionForHistograms(
"GetH2ZAxisTitle");
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true)
virtual G4double GetH2Ymax(G4int id) const
virtual G4String GetH1XAxisTitle(G4int id) const
virtual G4int CreateNtupleDColumn(const G4String &name)
virtual void FinishNtuple()
virtual G4double GetH1Xmin(G4int id) const
virtual G4bool SetH1YAxisTitle(G4int id, const G4String &title)
virtual G4double GetH2YWidth(G4int id) const
virtual G4bool WriteOnAscii(std::ofstream &output)
virtual G4int GetH2Nxbins(G4int id) const
virtual G4bool FillNtupleDColumn(G4int id, G4double value)
virtual G4bool SetH2Title(G4int id, const G4String &title)
virtual tools::wcsv::ntuple * GetNtuple() const
virtual G4int GetH1Nbins(G4int id) const
virtual G4String GetH2ZAxisTitle(G4int id) const
virtual G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
virtual G4bool SetH2XAxisTitle(G4int id, const G4String &title)
virtual G4bool SetH1Title(G4int id, const G4String &title)
virtual void CreateNtuple(const G4String &name, const G4String &title)
virtual G4String GetH1YAxisTitle(G4int id) const
virtual G4int CreateNtupleFColumn(const G4String &name)
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")
static G4CsvAnalysisManager * Instance()
virtual G4String GetH2YAxisTitle(G4int id) const
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 G4double GetH2Xmin(G4int id) const
virtual G4int GetH2Nybins(G4int id) const
virtual G4double GetH1Xmax(G4int id) const
virtual G4bool SetH2YAxisTitle(G4int id, const G4String &title)
virtual G4double GetH2Ymin(G4int id) const
virtual G4bool AddNtupleRow()
virtual G4double GetH2Xmax(G4int id) const
virtual G4int CreateNtupleIColumn(const G4String &name)
virtual G4double GetH2XWidth(G4int id) const
virtual G4String GetH2XAxisTitle(G4int id) const
virtual G4bool FillNtupleIColumn(G4int id, G4int value)
virtual G4bool OpenFile()
virtual G4String GetH2Title(G4int id) const
virtual G4bool FillH2(G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0)
virtual G4bool SetH1XAxisTitle(G4int id, const G4String &title)
virtual G4bool CloseFile()
virtual G4bool ScaleH2(G4int id, G4double factor)
virtual G4double GetH1Width(G4int id) const
virtual G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none")
virtual G4bool FillNtupleFColumn(G4int id, G4float value)
virtual G4bool SetH2ZAxisTitle(G4int id, const G4String &title)
virtual G4bool ScaleH1(G4int id, G4double factor)
virtual G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none")
virtual G4String GetH1Title(G4int id) const
G4String & append(const G4String &)
G4int fFirstNtupleColumnId
G4AnalysisVerbose * fpVerboseL4
G4bool fLockFirstNtupleColumnId
G4AnalysisVerbose * fpVerboseL2
G4AnalysisVerbose * fpVerboseL1
G4String GetFileType() const
virtual G4String GetFullFileName() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostringstream G4ExceptionDescription