36 #include "tools/ntuple_booking"
52 std::vector<G4XmlNtupleDescription*>::iterator it;
63 tools::waxml::ntuple::column<int>*
68 if ( ! ntupleDecription )
return 0;
70 std::map<G4int, tools::waxml::ntuple::column<int>* >& ntupleIColumnMap
72 std::map<G4int, tools::waxml::ntuple::column<int>* >::const_iterator it
73 = ntupleIColumnMap.find(columnId);
74 if ( it == ntupleIColumnMap.end() ) {
76 description <<
" " <<
"ntupleId " << ntupleId
77 <<
"column " << columnId <<
" does not exist.";
78 G4Exception(
"G4XmlNtupleManager::GetNtupleIColumn()",
87 tools::waxml::ntuple::column<float>*
92 if ( ! ntupleDecription )
return 0;
94 std::map<G4int, tools::waxml::ntuple::column<float>* >& ntupleFColumnMap
96 std::map<G4int, tools::waxml::ntuple::column<float>* >::const_iterator it
97 = ntupleFColumnMap.find(columnId);
98 if ( it == ntupleFColumnMap.end() ) {
100 description <<
" " <<
"ntupleId " << ntupleId
101 <<
"column " << columnId <<
" does not exist.";
102 G4Exception(
"G4XmlNtupleManager::GetNtupleFColumn()",
111 tools::waxml::ntuple::column<double>*
116 if ( ! ntupleDecription )
return 0;
118 std::map<G4int, tools::waxml::ntuple::column<double>* >& ntupleDColumnMap
120 std::map<G4int, tools::waxml::ntuple::column<double>* >::const_iterator it
121 = ntupleDColumnMap.find(columnId);
122 if ( it == ntupleDColumnMap.end() ) {
124 description <<
" " <<
"ntupleId " << ntupleId
125 <<
"column " << columnId <<
" does not exist.";
126 G4Exception(
"G4XmlNtupleManager::GetNtupleFColumn()",
142 G4String inFunction =
"G4XmlNtupleManager::";
143 inFunction += functionName;
145 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
166 std::vector<G4XmlNtupleDescription*>::iterator itn;
169 tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
170 if ( ! ntupleBooking )
continue;
176 ->
Message(
"create from booking",
"ntuple", ntupleBooking->m_name);
184 =
new tools::waxml::ntuple(*((*itn)->fFile),
G4cerr, *ntupleBooking);
186 if ( ntupleBooking->m_columns.size() ) {
188 const std::vector<tools::ntuple_booking::col_t>& columns
189 = ntupleBooking->m_columns;
190 std::vector<tools::ntuple_booking::col_t>::const_iterator it;
192 for ( it = columns.begin(); it!=columns.end(); ++it) {
193 if ( (*it).second == tools::_cid(
int(0) ) ) {
194 (*itn)->fNtupleIColumnMap[index++]
195 = (*itn)->fNtuple->find_column<
int>((*it).first);
197 else if( (*it).second == tools::_cid(
float(0) ) ) {
198 (*itn)->fNtupleFColumnMap[index++]
199 = (*itn)->fNtuple->find_column<
float>((*it).first);
201 else if((*it).second== tools::_cid(
double(0))) {
202 (*itn)->fNtupleDColumnMap[index++]
203 = (*itn)->fNtuple->find_column<
double>((*it).first);
208 <<
"Unsupported column type " << (*it).first;
209 G4Exception(
"G4XmlNtupleManager::CreateNtuplesFromBooking()",
218 ->
Message(
"create from booking",
"ntuple", ntupleBooking->m_name);
234 std::vector<G4XmlNtupleDescription*>::iterator it;
236 delete (*it)->fNtuple;
255 return ntupleDescription->
fNtuple;
283 =
new tools::waxml::ntuple(*(ntupleDescription->
fFile));
293 description << name <<
" ntupleId " << index +
fFirstId;
335 description << name <<
" ntupleId " << ntupleId;
342 tools::ntuple_booking* ntupleBooking
345 if ( ! ntupleBooking ) {
348 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
349 G4Exception(
"G4XmlNtupleManager::CreateNtupleIColumn()",
355 G4int index = ntupleBooking->m_columns.size();
356 ntupleBooking->add_column<
int>(
name);
359 if ( ntupleDescription->
fNtuple ) {
360 tools::waxml::ntuple::column<int>* column
361 = ntupleDescription->
fNtuple->create_column<
int>(
name);
370 description << name <<
" ntupleId " << ntupleId;
384 description << name <<
" ntupleId " << ntupleId;
391 tools::ntuple_booking* ntupleBooking
394 if ( ! ntupleBooking ) {
397 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
398 G4Exception(
"G4XmlNtupleManager::CreateNtupleFColumn()",
404 G4int index = ntupleBooking->m_columns.size();
405 ntupleBooking->add_column<
float>(
name);
408 if ( ntupleDescription->
fNtuple ) {
409 tools::waxml::ntuple::column<float>* column
410 = ntupleDescription->
fNtuple->create_column<
float>(
name);
419 description << name <<
" ntupleId " << ntupleId;
433 description << name <<
" ntupleId " << ntupleId;
440 tools::ntuple_booking* ntupleBooking
443 if ( ! ntupleBooking ) {
446 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
447 G4Exception(
"G4XmlNtupleManager::CreateNtupleDColumn()",
453 G4int index = ntupleBooking->m_columns.size();
454 ntupleBooking->add_column<
double>(
name);
457 if ( ntupleDescription->
fNtuple ) {
458 tools::waxml::ntuple::column<double>* column
459 = ntupleDescription->
fNtuple->create_column<
double>(
name);
468 description << name <<
" ntupleId " << ntupleId;
481 tools::ntuple_booking* ntupleBooking
484 if ( ! ntupleBooking ) {
487 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
488 G4Exception(
"G4XmlNtupleManager::CreateNtupleDColumn()",
496 description << ntupleBooking->m_name <<
" ntupleId " << ntupleId;
502 if ( ntupleDescription->
fNtuple ) {
506 ->write_header(path, ntupleBooking->m_name, ntupleBooking->m_title);
514 description << ntupleBooking->m_name <<
" ntupleId " << ntupleId;
542 tools::waxml::ntuple::column<int>* column
546 description <<
" " <<
"column " << columnId <<
" does not exist.";
547 G4Exception(
"G4XmlNtupleManager::FillNtupleIColumn()",
556 description <<
" ntupleId " << ntupleId
557 <<
" columnId " << columnId <<
" value " << value;
567 tools::waxml::ntuple::column<float>* column
571 description <<
" " <<
"column " << columnId <<
" does not exist.";
572 G4Exception(
"G4XmlNtupleManager::FillNtupleFColumn()",
581 description <<
" ntupleId " << ntupleId
582 <<
" columnId " << columnId <<
" value " << value;
593 tools::waxml::ntuple::column<double>* column
597 description <<
" " <<
"column " << columnId <<
" does not exist.";
598 G4Exception(
"G4XmlNtupleManager::FillNtupleDColumn()",
607 description <<
" ntupleId " << ntupleId
608 <<
" columnId " << columnId <<
" value " << value;
627 description <<
" ntupleId " << ntupleId;
635 if ( ! ntupleDescription || ! ntupleDescription->
fNtuple ) {
637 description <<
" " <<
"ntuple does not exist. ";
643 ntupleDescription->
fNtuple->add_row();
647 description <<
" ntupleId " << ntupleId;
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
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)
void LockNtupleDirectoryName()
tools::waxml::ntuple * fNtuple
tools::ntuple_booking * fNtupleBooking
virtual G4bool AddNtupleRow()
G4bool CreateNtupleFile(G4XmlNtupleDescription *ntupleDescription)
virtual G4int CreateNtupleFColumn(const G4String &name)
G4XmlFileManager * fFileManager
const G4AnalysisVerbose * GetVerboseL2() const
G4String GetNtupleDirectoryName() const
const G4AnalysisVerbose * GetVerboseL3() const
virtual G4int CreateNtupleDColumn(const G4String &name)
const G4AnalysisVerbose * GetVerboseL4() const
G4String GetFileName() const
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value)
virtual void FinishNtuple()
virtual G4int CreateNtupleIColumn(const G4String &name)
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)
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 * GetNtuple() const
G4bool fLockFirstNtupleColumnId
G4int fFirstNtupleColumnId
G4XmlNtupleManager(const G4AnalysisManagerState &state)
tools::waxml::ntuple::column< int > * GetNtupleIColumn(G4int ntupleId, G4int columnId) const
std::vector< G4XmlNtupleDescription * > fNtupleVector
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