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.";
195 G4cout <<
"Do not create ntuples on master thread" <<
G4endl;
200 std::vector<G4XmlNtupleDescription*>::iterator itn;
203 tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
204 if ( ! ntupleBooking )
continue;
210 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
218 =
new tools::waxml::ntuple(*((*itn)->fFile),
G4cerr, *ntupleBooking);
221 if ( ntupleBooking->columns().size() ) {
223 const std::vector<tools::column_booking>& columns
224 = ntupleBooking->columns();
225 std::vector<tools::column_booking>::const_iterator it;
227 for ( it = columns.begin(); it!=columns.end(); ++it) {
228 if ( it->cls_id() == tools::_cid(
int(0) ) ) {
229 (*itn)->fNtupleIColumnMap[index++]
230 = (*itn)->fNtuple->find_column<
int>(it->name());
232 else if( it->cls_id() == tools::_cid(
float(0) ) ) {
233 (*itn)->fNtupleFColumnMap[index++]
234 = (*itn)->fNtuple->find_column<
float>(it->name());
236 else if(it->cls_id()== tools::_cid(
double(0))) {
237 (*itn)->fNtupleDColumnMap[index++]
238 = (*itn)->fNtuple->find_column<
double>(it->name());
240 else if(it->cls_id()== tools::_cid(std::string(
""))) {
241 (*itn)->fNtupleSColumnMap[index++]
242 = (*itn)->fNtuple->find_column<std::string>(it->name());
247 <<
"Unsupported column type " << it->name();
248 G4Exception(
"G4XmlNtupleManager::CreateNtuplesFromBooking()",
257 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
273 std::vector<G4XmlNtupleDescription*>::iterator it;
275 delete (*it)->fNtuple;
295 if ( ! ntupleDescription )
return 0;
297 return ntupleDescription->
fNtuple;
317 =
new tools::ntuple_booking(name, title);
324 =
new tools::waxml::ntuple(*(ntupleDescription->
fFile));
335 description << name <<
" ntupleId " << index +
fFirstId;
345 std::vector<int>* vector)
353 std::vector<float>* vector)
361 std::vector<double>* vector)
384 std::vector<int>* vector)
389 description << name <<
" ntupleId " << ntupleId;
398 tools::ntuple_booking* ntupleBooking
401 if ( ! ntupleBooking ) {
404 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
405 G4Exception(
"G4XmlNtupleManager::CreateNtupleIColumn()",
411 G4int index = ntupleBooking->columns().size();
413 ntupleBooking->add_column<
int>(
name);
415 ntupleBooking->add_column<
int>(
name, *vector);
418 if ( ntupleDescription->
fNtuple ) {
420 tools::waxml::ntuple::column<int>* column
421 = ntupleDescription->
fNtuple->create_column<
int>(
name);
425 ntupleDescription->
fNtuple->create_column<
int>(
name, *vector);
434 description << name <<
" ntupleId " << ntupleId;
445 std::vector<float>* vector)
450 description << name <<
" ntupleId " << ntupleId;
459 tools::ntuple_booking* ntupleBooking
462 if ( ! ntupleBooking ) {
465 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
466 G4Exception(
"G4XmlNtupleManager::CreateNtupleFColumn()",
472 G4int index = ntupleBooking->columns().size();
474 ntupleBooking->add_column<
float>(
name);
476 ntupleBooking->add_column<
float>(
name, *vector);
479 if ( ntupleDescription->
fNtuple ) {
481 tools::waxml::ntuple::column<float>* column
482 = ntupleDescription->
fNtuple->create_column<
float>(
name);
486 ntupleDescription->
fNtuple->create_column<
float>(
name, *vector);
495 description << name <<
" ntupleId " << ntupleId;
506 std::vector<double>* vector)
511 description << name <<
" ntupleId " << ntupleId;
520 tools::ntuple_booking* ntupleBooking
523 if ( ! ntupleBooking ) {
526 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
527 G4Exception(
"G4XmlNtupleManager::CreateNtupleDColumn()",
533 G4int index = ntupleBooking->columns().size();
535 ntupleBooking->add_column<
double>(
name);
537 ntupleBooking->add_column<
double>(
name, *vector);
540 if ( ntupleDescription->
fNtuple ) {
542 tools::waxml::ntuple::column<double>* column
543 = ntupleDescription->
fNtuple->create_column<
double>(
name);
547 ntupleDescription->
fNtuple->create_column<
double>(
name, *vector);
556 description << name <<
" ntupleId " << ntupleId;
571 description << name <<
" ntupleId " << ntupleId;
580 tools::ntuple_booking* ntupleBooking
583 if ( ! ntupleBooking ) {
586 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
587 G4Exception(
"G4XmlNtupleManager::CreateNtupleSColumn()",
593 G4int index = ntupleBooking->columns().size();
594 ntupleBooking->add_column<std::string>(
name);
597 if ( ntupleDescription->
fNtuple ) {
598 tools::waxml::ntuple::column<std::string>* column
599 = ntupleDescription->
fNtuple->create_column<std::string>(
name);
608 description << name <<
" ntupleId " << ntupleId;
621 tools::ntuple_booking* ntupleBooking = 0;
622 if ( ntupleDescription ) {
626 if ( ( ! ntupleDescription ) || ( ! ntupleBooking ) ) {
629 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
630 G4Exception(
"G4XmlNtupleManager::CreateNtupleDColumn()",
638 description << ntupleBooking->name() <<
" ntupleId " << ntupleId;
644 if ( ntupleDescription->
fNtuple ) {
648 ->write_header(path, ntupleBooking->name(), ntupleBooking->title());
655 description << ntupleBooking->name() <<
" ntupleId " << ntupleId;
689 tools::waxml::ntuple::column<int>* column
693 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
694 G4Exception(
"G4XmlNtupleManager::FillNtupleIColumn()",
703 description <<
" ntupleId " << ntupleId
704 <<
" columnId " << columnId <<
" value " << value;
714 tools::waxml::ntuple::column<float>* column
718 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
719 G4Exception(
"G4XmlNtupleManager::FillNtupleFColumn()",
728 description <<
" ntupleId " << ntupleId
729 <<
" columnId " << columnId <<
" value " << value;
740 tools::waxml::ntuple::column<double>* column
744 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
745 G4Exception(
"G4XmlNtupleManager::FillNtupleDColumn()",
754 description <<
" ntupleId " << ntupleId
755 <<
" columnId " << columnId <<
" value " << value;
766 tools::waxml::ntuple::column<std::string>* column
770 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
771 G4Exception(
"G4XmlNtupleManager::FillNtupleSColumn()",
780 description <<
" ntupleId " << ntupleId
781 <<
" columnId " << columnId <<
" value " << value;
800 description <<
" ntupleId " << ntupleId;
807 if ( ! ntupleDescription )
return false;
809 if ( ! ntupleDescription->
fNtuple ) {
811 description <<
" " <<
"ntuple does not exist. ";
817 ntupleDescription->
fNtuple->add_row();
821 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
G4GLOB_DLL std::ostream G4cout
const G4AnalysisVerbose * GetVerboseL4() const
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value)
virtual void FinishNtuple()
G4bool IsMultithreadedApplication()
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()
G4bool GetIsMaster() const
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