38 #include "tools/ntuple_booking"
49 fNtupleDescriptionVector(),
57 std::vector<G4XmlNtupleDescription*>::iterator it;
68 tools::waxml::ntuple::column<int>*
73 if ( ! ntupleDecription )
return 0;
75 std::map<G4int, tools::waxml::ntuple::column<int>* >& ntupleIColumnMap
77 std::map<G4int, tools::waxml::ntuple::column<int>* >::const_iterator it
78 = ntupleIColumnMap.find(columnId);
79 if ( it == ntupleIColumnMap.end() ) {
81 description <<
" " <<
"ntupleId " << ntupleId
82 <<
" columnId " << columnId <<
" does not exist.";
83 G4Exception(
"G4XmlNtupleManager::GetNtupleIColumn()",
92 tools::waxml::ntuple::column<float>*
97 if ( ! ntupleDecription )
return 0;
99 std::map<G4int, tools::waxml::ntuple::column<float>* >& ntupleFColumnMap
101 std::map<G4int, tools::waxml::ntuple::column<float>* >::const_iterator it
102 = ntupleFColumnMap.find(columnId);
103 if ( it == ntupleFColumnMap.end() ) {
105 description <<
" " <<
"ntupleId " << ntupleId
106 <<
" columnId " << columnId <<
" does not exist.";
107 G4Exception(
"G4XmlNtupleManager::GetNtupleFColumn()",
116 tools::waxml::ntuple::column<double>*
121 if ( ! ntupleDecription )
return 0;
123 std::map<G4int, tools::waxml::ntuple::column<double>* >& ntupleDColumnMap
125 std::map<G4int, tools::waxml::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(
"G4XmlNtupleManager::GetNtupleFColumn()",
140 tools::waxml::ntuple::column<std::string>*
145 if ( ! ntupleDecription )
return 0;
147 std::map<G4int, tools::waxml::ntuple::column<std::string>* >& ntupleSColumnMap
149 std::map<G4int, tools::waxml::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(
"G4XmlNtupleManager::GetNtupleSColumn()",
171 G4String inFunction =
"G4XmlNtupleManager::";
172 inFunction += functionName;
174 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
193 std::vector<G4XmlNtupleDescription*>::iterator itn;
196 tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
197 if ( ! ntupleBooking )
continue;
203 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
211 =
new tools::waxml::ntuple(*((*itn)->fFile),
G4cerr, *ntupleBooking);
214 if ( ntupleBooking->columns().size() ) {
216 const std::vector<tools::column_booking>& columns
217 = ntupleBooking->columns();
218 std::vector<tools::column_booking>::const_iterator it;
220 for ( it = columns.begin(); it!=columns.end(); ++it) {
221 if ( it->cls_id() == tools::_cid(
int(0) ) ) {
222 (*itn)->fNtupleIColumnMap[index++]
223 = (*itn)->fNtuple->find_column<
int>(it->name());
225 else if( it->cls_id() == tools::_cid(
float(0) ) ) {
226 (*itn)->fNtupleFColumnMap[index++]
227 = (*itn)->fNtuple->find_column<
float>(it->name());
229 else if(it->cls_id()== tools::_cid(
double(0))) {
230 (*itn)->fNtupleDColumnMap[index++]
231 = (*itn)->fNtuple->find_column<
double>(it->name());
233 else if(it->cls_id()== tools::_cid(std::string(
""))) {
234 (*itn)->fNtupleSColumnMap[index++]
235 = (*itn)->fNtuple->find_column<std::string>(it->name());
240 <<
"Unsupported column type " << it->name();
241 G4Exception(
"G4XmlNtupleManager::CreateNtuplesFromBooking()",
250 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
266 std::vector<G4XmlNtupleDescription*>::iterator it;
268 delete (*it)->fNtuple;
288 if ( ! ntupleDescription )
return 0;
290 return ntupleDescription->
fNtuple;
310 =
new tools::ntuple_booking(name, title);
317 =
new tools::waxml::ntuple(*(ntupleDescription->
fFile));
328 description << name <<
" ntupleId " << index +
fFirstId;
338 std::vector<int>* vector)
346 std::vector<float>* vector)
354 std::vector<double>* vector)
377 std::vector<int>* vector)
382 description << name <<
" ntupleId " << ntupleId;
391 tools::ntuple_booking* ntupleBooking
394 if ( ! ntupleBooking ) {
397 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
398 G4Exception(
"G4XmlNtupleManager::CreateNtupleIColumn()",
404 G4int index = ntupleBooking->columns().size();
406 ntupleBooking->add_column<
int>(
name);
408 ntupleBooking->add_column<
int>(
name, *vector);
411 if ( ntupleDescription->
fNtuple ) {
413 tools::waxml::ntuple::column<int>* column
414 = ntupleDescription->
fNtuple->create_column<
int>(
name);
418 ntupleDescription->
fNtuple->create_column<
int>(
name, *vector);
427 description << name <<
" ntupleId " << ntupleId;
438 std::vector<float>* vector)
443 description << name <<
" ntupleId " << ntupleId;
452 tools::ntuple_booking* ntupleBooking
455 if ( ! ntupleBooking ) {
458 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
459 G4Exception(
"G4XmlNtupleManager::CreateNtupleFColumn()",
465 G4int index = ntupleBooking->columns().size();
467 ntupleBooking->add_column<
float>(
name);
469 ntupleBooking->add_column<
float>(
name, *vector);
472 if ( ntupleDescription->
fNtuple ) {
474 tools::waxml::ntuple::column<float>* column
475 = ntupleDescription->
fNtuple->create_column<
float>(
name);
479 ntupleDescription->
fNtuple->create_column<
float>(
name, *vector);
488 description << name <<
" ntupleId " << ntupleId;
499 std::vector<double>* vector)
504 description << name <<
" ntupleId " << ntupleId;
513 tools::ntuple_booking* ntupleBooking
516 if ( ! ntupleBooking ) {
519 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
520 G4Exception(
"G4XmlNtupleManager::CreateNtupleDColumn()",
526 G4int index = ntupleBooking->columns().size();
528 ntupleBooking->add_column<
double>(
name);
530 ntupleBooking->add_column<
double>(
name, *vector);
533 if ( ntupleDescription->
fNtuple ) {
535 tools::waxml::ntuple::column<double>* column
536 = ntupleDescription->
fNtuple->create_column<
double>(
name);
540 ntupleDescription->
fNtuple->create_column<
double>(
name, *vector);
549 description << name <<
" ntupleId " << ntupleId;
564 description << name <<
" ntupleId " << ntupleId;
573 tools::ntuple_booking* ntupleBooking
576 if ( ! ntupleBooking ) {
579 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
580 G4Exception(
"G4XmlNtupleManager::CreateNtupleSColumn()",
586 G4int index = ntupleBooking->columns().size();
587 ntupleBooking->add_column<std::string>(
name);
590 if ( ntupleDescription->
fNtuple ) {
591 tools::waxml::ntuple::column<std::string>* column
592 = ntupleDescription->
fNtuple->create_column<std::string>(
name);
601 description << name <<
" ntupleId " << ntupleId;
614 tools::ntuple_booking* ntupleBooking = 0;
615 if ( ntupleDescription ) {
619 if ( ( ! ntupleDescription ) || ( ! ntupleBooking ) ) {
622 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
623 G4Exception(
"G4XmlNtupleManager::CreateNtupleDColumn()",
631 description << ntupleBooking->name() <<
" ntupleId " << ntupleId;
637 if ( ntupleDescription->
fNtuple ) {
641 ->write_header(path, ntupleBooking->name(), ntupleBooking->title());
648 description << ntupleBooking->name() <<
" ntupleId " << ntupleId;
682 tools::waxml::ntuple::column<int>* column
686 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
687 G4Exception(
"G4XmlNtupleManager::FillNtupleIColumn()",
696 description <<
" ntupleId " << ntupleId
697 <<
" columnId " << columnId <<
" value " << value;
707 tools::waxml::ntuple::column<float>* column
711 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
712 G4Exception(
"G4XmlNtupleManager::FillNtupleFColumn()",
721 description <<
" ntupleId " << ntupleId
722 <<
" columnId " << columnId <<
" value " << value;
733 tools::waxml::ntuple::column<double>* column
737 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
738 G4Exception(
"G4XmlNtupleManager::FillNtupleDColumn()",
747 description <<
" ntupleId " << ntupleId
748 <<
" columnId " << columnId <<
" value " << value;
759 tools::waxml::ntuple::column<std::string>* column
763 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
764 G4Exception(
"G4XmlNtupleManager::FillNtupleSColumn()",
773 description <<
" ntupleId " << ntupleId
774 <<
" columnId " << columnId <<
" value " << value;
793 description <<
" ntupleId " << ntupleId;
800 if ( ! ntupleDescription )
return false;
802 if ( ! ntupleDescription->
fNtuple ) {
804 description <<
" " <<
"ntuple does not exist. ";
810 ntupleDescription->
fNtuple->add_row();
814 description <<
" ntupleId " << ntupleId;
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
virtual G4int CreateNtupleFColumn(const G4String &name, std::vector< float > *vector)
virtual G4int CreateNtupleDColumn(const G4String &name, std::vector< double > *vector)
std::map< G4int, tools::waxml::ntuple::column< int > * > fNtupleIColumnMap
std::ostringstream G4ExceptionDescription
std::map< G4int, tools::waxml::ntuple::column< double > * > fNtupleDColumnMap
std::map< G4int, tools::waxml::ntuple::column< float > * > fNtupleFColumnMap
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value)
std::map< G4int, tools::waxml::ntuple::column< std::string > * > fNtupleSColumnMap
tools::waxml::ntuple * fNtuple
std::vector< tools::waxml::ntuple * > fNtupleVector
tools::ntuple_booking * fNtupleBooking
virtual G4bool AddNtupleRow()
std::vector< G4XmlNtupleDescription * > fNtupleDescriptionVector
G4bool CreateNtupleFile(G4XmlNtupleDescription *ntupleDescription)
virtual G4bool FillNtupleSColumn(G4int columnId, const G4String &value)
G4XmlFileManager * fFileManager
const G4AnalysisVerbose * GetVerboseL2() const
void LockNtupleDirectoryName()
G4String GetNtupleDirectoryName() const
const G4AnalysisVerbose * GetVerboseL3() const
const G4AnalysisVerbose * GetVerboseL4() const
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value)
virtual void FinishNtuple()
virtual G4int CreateNtupleIColumn(const G4String &name, std::vector< int > *vector)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
tools::waxml::ntuple::column< float > * GetNtupleFColumn(G4int ntupleId, G4int columnId) const
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
virtual G4int CreateNtupleSColumn(const G4String &name)
G4String & append(const G4String &)
void CreateNtuplesFromBooking()
virtual G4XmlNtupleDescription * GetNtupleInFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
tools::waxml::ntuple::column< std::string > * GetNtupleSColumn(G4int ntupleId, G4int columnId) const
tools::waxml::ntuple * GetNtuple() const
G4bool fLockFirstNtupleColumnId
G4int fFirstNtupleColumnId
G4XmlNtupleManager(const G4AnalysisManagerState &state)
tools::waxml::ntuple::column< int > * GetNtupleIColumn(G4int ntupleId, G4int columnId) const
G4String GetFileName() const
virtual G4int CreateNtuple(const G4String &name, const G4String &title)
tools::waxml::ntuple::column< double > * GetNtupleDColumn(G4int ntupleId, G4int columnId) const
const G4AnalysisManagerState & fState
G4GLOB_DLL std::ostream G4cerr