46 fNtupleDescriptionVector(),
48 fIsCommentedHeader(true),
56 std::vector<G4CsvNtupleDescription*>::iterator it;
67 tools::wcsv::ntuple::column<int>*
72 if ( ! ntupleDecription )
return 0;
74 std::map<G4int, tools::wcsv::ntuple::column<int>* >& ntupleIColumnMap
76 std::map<G4int, tools::wcsv::ntuple::column<int>* >::const_iterator it
77 = ntupleIColumnMap.find(columnId);
78 if ( it == ntupleIColumnMap.end() ) {
80 description <<
" " <<
"ntupleId " << ntupleId
81 <<
" columnId " << columnId <<
" does not exist.";
82 G4Exception(
"G4CsvNtupleManager::GetNtupleIColumn()",
91 tools::wcsv::ntuple::column<float>*
96 if ( ! ntupleDecription )
return 0;
98 std::map<G4int, tools::wcsv::ntuple::column<float>* >& ntupleFColumnMap
100 std::map<G4int, tools::wcsv::ntuple::column<float>* >::const_iterator it
101 = ntupleFColumnMap.find(columnId);
102 if ( it == ntupleFColumnMap.end() ) {
104 description <<
" " <<
"ntupleId " << ntupleId
105 <<
" columnId " << columnId <<
" does not exist.";
106 G4Exception(
"G4CsvNtupleManager::GetNtupleFColumn()",
116 tools::wcsv::ntuple::column<double>*
121 if ( ! ntupleDecription )
return 0;
123 std::map<G4int, tools::wcsv::ntuple::column<double>* >& ntupleDColumnMap
125 std::map<G4int, tools::wcsv::ntuple::column<double>* >::const_iterator it
126 = ntupleDColumnMap.find(columnId);
127 if ( it == ntupleDColumnMap.end() ) {
129 description <<
" " <<
"ntupleId " << ntupleId
130 <<
" columnId " << columnId <<
" does not exist.";
131 G4Exception(
"G4CsvNtupleManager::GetNtupleDColumn()",
140 tools::wcsv::ntuple::column<std::string>*
145 if ( ! ntupleDecription )
return 0;
147 std::map<G4int, tools::wcsv::ntuple::column<std::string>* >& ntupleSColumnMap
149 std::map<G4int, tools::wcsv::ntuple::column<std::string>* >::const_iterator it
150 = ntupleSColumnMap.find(columnId);
151 if ( it == ntupleSColumnMap.end() ) {
153 description <<
" " <<
"ntupleId " << ntupleId
154 <<
" columnId " << columnId <<
" does not exist.";
155 G4Exception(
"G4CsvNtupleManager::GetNtupleSColumn()",
171 G4String inFunction =
"G4CsvNtupleManager::";
172 inFunction += functionName;
174 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
192 return ntuple->write_commented_header(
G4cout);
197 ntuple->write_hippo_header();
213 std::vector<G4CsvNtupleDescription*>::iterator itn;
216 tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
217 if ( ! ntupleBooking )
continue;
220 if ( (*itn)->fNtuple )
continue;
225 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
233 =
new tools::wcsv::ntuple(*((*itn)->fFile),
G4cerr, *ntupleBooking);
240 <<
"Writing ntuple header has failed. ";
241 G4Exception(
"G4CsvNtupleManager::CreateNtupleFromBooking()",
245 if ( ntupleBooking->columns().size() ) {
247 const std::vector<tools::column_booking>& columns
248 = ntupleBooking->columns();
249 std::vector<tools::column_booking>::const_iterator it;
251 for ( it = columns.begin(); it!=columns.end(); ++it) {
252 if ( it->cls_id() == tools::_cid(
int(0) ) ) {
253 (*itn)->fNtupleIColumnMap[index++]
254 = (*itn)->fNtuple->find_column<
int>(it->name());
256 else if ( it->cls_id() == tools::_cid(
float(0) ) ) {
257 (*itn)->fNtupleFColumnMap[index++]
258 = (*itn)->fNtuple->find_column<
float>(it->name());
260 else if ( it->cls_id() == tools::_cid(
double(0))) {
261 (*itn)->fNtupleDColumnMap[index++]
262 = (*itn)->fNtuple->find_column<
double>(it->name());
264 else if ( it->cls_id() == tools::_cid(std::string(
""))) {
265 (*itn)->fNtupleSColumnMap[index++]
266 = (*itn)->fNtuple->find_column<std::string>(it->name());
271 <<
"Unsupported column type " << it->cls_id();
272 G4Exception(
"G4CsvNtupleManager::CreateNtupleFromBooking()",
280 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
294 std::vector<G4CsvNtupleDescription*>::iterator it;
296 delete (*it)->fNtuple;
316 if ( ! ntupleDescription )
return 0;
318 return ntupleDescription->
fNtuple;
338 =
new tools::ntuple_booking(name, title);
346 =
new tools::wcsv::ntuple(*(ntupleDescription->
fFile));
348 (ntupleDescription->
fNtuple)->set_title(title);
358 description << name <<
" ntupleId " << index +
fFirstId;
368 std::vector<int>* vector)
376 std::vector<float>* vector)
384 std::vector<double>* vector)
407 std::vector<int>* vector)
412 <<
"Ntuple columns of vector are not supported." ;
413 G4Exception(
"G4CsvAnalysisManager::CreateNtupleIColumn",
421 description << name <<
" ntupleId " << ntupleId;
430 tools::ntuple_booking* ntupleBooking
433 if ( ! ntupleBooking ) {
436 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
437 G4Exception(
"G4CsvNtupleManager::CreateNtupleIColumn()",
443 G4int index = ntupleBooking->columns().size();
444 ntupleBooking->add_column<
int>(
name);
447 if ( ntupleDescription->
fNtuple ) {
448 tools::wcsv::ntuple::column<int>* column
449 = ntupleDescription->
fNtuple->create_column<
int>(
name);
458 description << name <<
" ntupleId " << ntupleId;
469 std::vector<float>* vector)
474 <<
"Ntuple columns of vector are not supported." ;
475 G4Exception(
"G4CsvAnalysisManager::CreateNtupleFColumn",
483 description << name <<
" ntupleId " << ntupleId;
492 tools::ntuple_booking* ntupleBooking
495 if ( ! ntupleBooking ) {
498 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
499 G4Exception(
"G4CsvNtupleManager::CreateNtupleFColumn()",
505 G4int index = ntupleBooking->columns().size();
506 ntupleBooking->add_column<
float>(
name);
509 if ( ntupleDescription->
fNtuple ) {
510 tools::wcsv::ntuple::column<float>* column
511 = ntupleDescription->
fNtuple->create_column<
float>(
name);
520 description << name <<
" ntupleId " << ntupleId;
531 std::vector<double>* vector)
536 <<
"Ntuple columns of vector are not supported." ;
537 G4Exception(
"G4CsvAnalysisManager::CreateNtupleDColumn",
545 description << name <<
" ntupleId " << ntupleId;
554 tools::ntuple_booking* ntupleBooking
557 if ( ! ntupleBooking ) {
560 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
561 G4Exception(
"G4CsvNtupleManager::CreateNtupleDColumn()",
567 G4int index = ntupleBooking->columns().size();
568 ntupleBooking->add_column<
double>(
name);
571 if ( ntupleDescription->
fNtuple ) {
572 tools::wcsv::ntuple::column<double>* column
573 = ntupleDescription->
fNtuple->create_column<
double>(
name);
582 description << name <<
" ntupleId " << ntupleId;
607 description << name <<
" ntupleId " << ntupleId;
616 tools::ntuple_booking* ntupleBooking
619 if ( ! ntupleBooking ) {
622 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
623 G4Exception(
"G4CsvNtupleManager::CreateNtupleSColumn()",
629 G4int index = ntupleBooking->columns().size();
630 ntupleBooking->add_column<std::string>(
name);
633 if ( ntupleDescription->
fNtuple ) {
634 tools::wcsv::ntuple::column<std::string>* column
635 = ntupleDescription->
fNtuple->create_column<std::string>(
name);
644 description << name <<
" ntupleId " << ntupleId;
658 if ( ! ntupleDescription )
return;
661 if ( ntupleDescription->
fNtuple ) {
665 <<
"Writing ntuple header has failed. ";
707 tools::wcsv::ntuple::column<int>* column
711 description <<
" " <<
"ntupleId " << ntupleId
712 <<
" columnId " << columnId <<
" does not exist.";
713 G4Exception(
"G4CsvNtupleManager::FillNtupleIColumn()",
722 description <<
" ntupleId " << ntupleId
723 <<
" columnId " << columnId <<
" value " << value;
733 tools::wcsv::ntuple::column<float>* column
737 description <<
" " <<
"ntupleId " << ntupleId
738 <<
" columnId " << columnId <<
" does not exist.";
739 G4Exception(
"G4CsvNtupleManager::FillNtupleFColumn()",
748 description <<
" ntupleId " << ntupleId
749 <<
" columnId " << columnId <<
" value " << value;
760 tools::wcsv::ntuple::column<double>* column
764 description <<
" " <<
"ntupleId " << ntupleId
765 <<
" columnId " << columnId <<
" does not exist.";
766 G4Exception(
"G4CsvNtupleManager::FillNtupleDColumn()",
775 description <<
" ntupleId " << ntupleId
776 <<
" columnId " << columnId <<
" value " << value;
787 tools::wcsv::ntuple::column<std::string>* column
791 description <<
" " <<
"ntupleId " << ntupleId
792 <<
" columnId " << columnId <<
" does not exist.";
793 G4Exception(
"G4CsvNtupleManager::FillNtupleSColumn()",
802 description <<
" ntupleId " << ntupleId
803 <<
" columnId " << columnId <<
" value " << value;
816 description <<
" ntupleId " << ntupleId;
823 if ( ! ntupleDescription )
return false;
825 if ( ! ntupleDescription->
fNtuple ) {
827 description <<
" " <<
"ntuple does not exist. ";
833 ntupleDescription->
fNtuple->add_row();
837 description <<
" ntupleId " << ntupleId;
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
virtual G4int CreateNtupleDColumn(const G4String &name, std::vector< double > *vector)
std::ostringstream G4ExceptionDescription
std::vector< G4CsvNtupleDescription * > fNtupleDescriptionVector
virtual G4int CreateNtuple(const G4String &name, const G4String &title)
virtual G4int CreateNtupleFColumn(const G4String &name, std::vector< float > *vector)
std::map< G4int, tools::wcsv::ntuple::column< std::string > * > fNtupleSColumnMap
G4CsvNtupleManager(const G4AnalysisManagerState &state)
std::vector< tools::wcsv::ntuple * > fNtupleVector
void CreateNtuplesFromBooking()
const G4AnalysisVerbose * GetVerboseL2() const
tools::wcsv::ntuple * GetNtuple() const
virtual G4CsvNtupleDescription * GetNtupleInFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
tools::wcsv::ntuple::column< float > * GetNtupleFColumn(G4int ntupleId, G4int columnId) const
G4CsvFileManager * fFileManager
const G4AnalysisVerbose * GetVerboseL3() const
virtual void FinishNtuple()
G4GLOB_DLL std::ostream G4cout
std::map< G4int, tools::wcsv::ntuple::column< float > * > fNtupleFColumnMap
const G4AnalysisVerbose * GetVerboseL4() const
tools::wcsv::ntuple::column< double > * GetNtupleDColumn(G4int ntupleId, G4int columnId) const
G4bool fIsCommentedHeader
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value)
tools::ntuple_booking * fNtupleBooking
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual G4int CreateNtupleIColumn(const G4String &name, std::vector< int > *vector)
G4bool CreateNtupleFile(G4CsvNtupleDescription *ntupleDescription)
virtual G4int CreateNtupleSColumn(const G4String &name)
tools::wcsv::ntuple * fNtuple
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value)
std::map< G4int, tools::wcsv::ntuple::column< double > * > fNtupleDColumnMap
tools::wcsv::ntuple::column< int > * GetNtupleIColumn(G4int ntupleId, G4int columnId) const
G4bool fLockFirstNtupleColumnId
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
std::map< G4int, tools::wcsv::ntuple::column< int > * > fNtupleIColumnMap
tools::wcsv::ntuple::column< std::string > * GetNtupleSColumn(G4int ntupleId, G4int columnId) const
G4int fFirstNtupleColumnId
G4String GetFileName() const
G4bool WriteHeader(tools::wcsv::ntuple *ntuple) const
const G4AnalysisManagerState & fState
virtual G4bool AddNtupleRow()
G4GLOB_DLL std::ostream G4cerr
virtual G4bool FillNtupleSColumn(G4int columnId, const G4String &value)