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();
217 std::vector<G4CsvNtupleDescription*>::iterator itn;
220 tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
221 if ( ! ntupleBooking )
continue;
224 if ( (*itn)->fNtuple )
continue;
229 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
237 =
new tools::wcsv::ntuple(*((*itn)->fFile),
G4cerr, *ntupleBooking);
244 <<
"Writing ntuple header has failed. ";
245 G4Exception(
"G4CsvNtupleManager::CreateNtupleFromBooking()",
249 if ( ntupleBooking->columns().size() ) {
251 const std::vector<tools::column_booking>& columns
252 = ntupleBooking->columns();
253 std::vector<tools::column_booking>::const_iterator it;
255 for ( it = columns.begin(); it!=columns.end(); ++it) {
256 if ( it->cls_id() == tools::_cid(
int(0) ) ) {
257 (*itn)->fNtupleIColumnMap[index++]
258 = (*itn)->fNtuple->find_column<
int>(it->name());
260 else if ( it->cls_id() == tools::_cid(
float(0) ) ) {
261 (*itn)->fNtupleFColumnMap[index++]
262 = (*itn)->fNtuple->find_column<
float>(it->name());
264 else if ( it->cls_id() == tools::_cid(
double(0))) {
265 (*itn)->fNtupleDColumnMap[index++]
266 = (*itn)->fNtuple->find_column<
double>(it->name());
268 else if ( it->cls_id() == tools::_cid(std::string(
""))) {
269 (*itn)->fNtupleSColumnMap[index++]
270 = (*itn)->fNtuple->find_column<std::string>(it->name());
275 <<
"Unsupported column type " << it->cls_id();
276 G4Exception(
"G4CsvNtupleManager::CreateNtupleFromBooking()",
284 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
298 std::vector<G4CsvNtupleDescription*>::iterator it;
300 delete (*it)->fNtuple;
320 if ( ! ntupleDescription )
return 0;
322 return ntupleDescription->
fNtuple;
342 =
new tools::ntuple_booking(name, title);
350 =
new tools::wcsv::ntuple(*(ntupleDescription->
fFile));
352 (ntupleDescription->
fNtuple)->set_title(title);
362 description << name <<
" ntupleId " << index +
fFirstId;
372 std::vector<int>* vector)
380 std::vector<float>* vector)
388 std::vector<double>* vector)
411 std::vector<int>* vector)
416 <<
"Ntuple columns of vector are not supported." ;
417 G4Exception(
"G4CsvAnalysisManager::CreateNtupleIColumn",
425 description << name <<
" ntupleId " << ntupleId;
434 tools::ntuple_booking* ntupleBooking
437 if ( ! ntupleBooking ) {
440 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
441 G4Exception(
"G4CsvNtupleManager::CreateNtupleIColumn()",
447 G4int index = ntupleBooking->columns().size();
448 ntupleBooking->add_column<
int>(
name);
451 if ( ntupleDescription->
fNtuple ) {
452 tools::wcsv::ntuple::column<int>* column
453 = ntupleDescription->
fNtuple->create_column<
int>(
name);
462 description << name <<
" ntupleId " << ntupleId;
473 std::vector<float>* vector)
478 <<
"Ntuple columns of vector are not supported." ;
479 G4Exception(
"G4CsvAnalysisManager::CreateNtupleFColumn",
487 description << name <<
" ntupleId " << ntupleId;
496 tools::ntuple_booking* ntupleBooking
499 if ( ! ntupleBooking ) {
502 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
503 G4Exception(
"G4CsvNtupleManager::CreateNtupleFColumn()",
509 G4int index = ntupleBooking->columns().size();
510 ntupleBooking->add_column<
float>(
name);
513 if ( ntupleDescription->
fNtuple ) {
514 tools::wcsv::ntuple::column<float>* column
515 = ntupleDescription->
fNtuple->create_column<
float>(
name);
524 description << name <<
" ntupleId " << ntupleId;
535 std::vector<double>* vector)
540 <<
"Ntuple columns of vector are not supported." ;
541 G4Exception(
"G4CsvAnalysisManager::CreateNtupleDColumn",
549 description << name <<
" ntupleId " << ntupleId;
558 tools::ntuple_booking* ntupleBooking
561 if ( ! ntupleBooking ) {
564 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
565 G4Exception(
"G4CsvNtupleManager::CreateNtupleDColumn()",
571 G4int index = ntupleBooking->columns().size();
572 ntupleBooking->add_column<
double>(
name);
575 if ( ntupleDescription->
fNtuple ) {
576 tools::wcsv::ntuple::column<double>* column
577 = ntupleDescription->
fNtuple->create_column<
double>(
name);
586 description << name <<
" ntupleId " << ntupleId;
611 description << name <<
" ntupleId " << ntupleId;
620 tools::ntuple_booking* ntupleBooking
623 if ( ! ntupleBooking ) {
626 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
627 G4Exception(
"G4CsvNtupleManager::CreateNtupleSColumn()",
633 G4int index = ntupleBooking->columns().size();
634 ntupleBooking->add_column<std::string>(
name);
637 if ( ntupleDescription->
fNtuple ) {
638 tools::wcsv::ntuple::column<std::string>* column
639 = ntupleDescription->
fNtuple->create_column<std::string>(
name);
648 description << name <<
" ntupleId " << ntupleId;
662 if ( ! ntupleDescription )
return;
665 if ( ntupleDescription->
fNtuple ) {
669 <<
"Writing ntuple header has failed. ";
711 tools::wcsv::ntuple::column<int>* column
715 description <<
" " <<
"ntupleId " << ntupleId
716 <<
" columnId " << columnId <<
" does not exist.";
717 G4Exception(
"G4CsvNtupleManager::FillNtupleIColumn()",
726 description <<
" ntupleId " << ntupleId
727 <<
" columnId " << columnId <<
" value " << value;
737 tools::wcsv::ntuple::column<float>* column
741 description <<
" " <<
"ntupleId " << ntupleId
742 <<
" columnId " << columnId <<
" does not exist.";
743 G4Exception(
"G4CsvNtupleManager::FillNtupleFColumn()",
752 description <<
" ntupleId " << ntupleId
753 <<
" columnId " << columnId <<
" value " << value;
764 tools::wcsv::ntuple::column<double>* column
768 description <<
" " <<
"ntupleId " << ntupleId
769 <<
" columnId " << columnId <<
" does not exist.";
770 G4Exception(
"G4CsvNtupleManager::FillNtupleDColumn()",
779 description <<
" ntupleId " << ntupleId
780 <<
" columnId " << columnId <<
" value " << value;
791 tools::wcsv::ntuple::column<std::string>* column
795 description <<
" " <<
"ntupleId " << ntupleId
796 <<
" columnId " << columnId <<
" does not exist.";
797 G4Exception(
"G4CsvNtupleManager::FillNtupleSColumn()",
806 description <<
" ntupleId " << ntupleId
807 <<
" columnId " << columnId <<
" value " << value;
820 description <<
" ntupleId " << ntupleId;
827 if ( ! ntupleDescription )
return false;
829 if ( ! ntupleDescription->
fNtuple ) {
831 description <<
" " <<
"ntuple does not exist. ";
837 ntupleDescription->
fNtuple->add_row();
841 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)
G4bool IsMultithreadedApplication()
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
G4bool GetIsMaster() const
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)