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 <<
" columnId " << 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 <<
" columnId " << 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 <<
" columnId " << 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 if ( ! ntupleDescription )
return -1;
344 tools::ntuple_booking* ntupleBooking
347 if ( ! ntupleBooking ) {
350 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
351 G4Exception(
"G4XmlNtupleManager::CreateNtupleIColumn()",
357 G4int index = ntupleBooking->m_columns.size();
358 ntupleBooking->add_column<
int>(
name);
361 if ( ntupleDescription->
fNtuple ) {
362 tools::waxml::ntuple::column<int>* column
363 = ntupleDescription->
fNtuple->create_column<
int>(
name);
372 description << name <<
" ntupleId " << ntupleId;
386 description << name <<
" ntupleId " << ntupleId;
393 if ( ! ntupleDescription )
return -1;
395 tools::ntuple_booking* ntupleBooking
398 if ( ! ntupleBooking ) {
401 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
402 G4Exception(
"G4XmlNtupleManager::CreateNtupleFColumn()",
408 G4int index = ntupleBooking->m_columns.size();
409 ntupleBooking->add_column<
float>(
name);
412 if ( ntupleDescription->
fNtuple ) {
413 tools::waxml::ntuple::column<float>* column
414 = ntupleDescription->
fNtuple->create_column<
float>(
name);
423 description << name <<
" ntupleId " << ntupleId;
437 description << name <<
" ntupleId " << ntupleId;
444 if ( ! ntupleDescription )
return -1;
446 tools::ntuple_booking* ntupleBooking
449 if ( ! ntupleBooking ) {
452 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
453 G4Exception(
"G4XmlNtupleManager::CreateNtupleDColumn()",
459 G4int index = ntupleBooking->m_columns.size();
460 ntupleBooking->add_column<
double>(
name);
463 if ( ntupleDescription->
fNtuple ) {
464 tools::waxml::ntuple::column<double>* column
465 = ntupleDescription->
fNtuple->create_column<
double>(
name);
474 description << name <<
" ntupleId " << ntupleId;
487 tools::ntuple_booking* ntupleBooking
490 if ( ! ntupleBooking ) {
493 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
494 G4Exception(
"G4XmlNtupleManager::CreateNtupleDColumn()",
502 description << ntupleBooking->m_name <<
" ntupleId " << ntupleId;
508 if ( ntupleDescription->
fNtuple ) {
512 ->write_header(path, ntupleBooking->m_name, ntupleBooking->m_title);
520 description << ntupleBooking->m_name <<
" ntupleId " << ntupleId;
548 tools::waxml::ntuple::column<int>* column
552 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
553 G4Exception(
"G4XmlNtupleManager::FillNtupleIColumn()",
562 description <<
" ntupleId " << ntupleId
563 <<
" columnId " << columnId <<
" value " << value;
573 tools::waxml::ntuple::column<float>* column
577 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
578 G4Exception(
"G4XmlNtupleManager::FillNtupleFColumn()",
587 description <<
" ntupleId " << ntupleId
588 <<
" columnId " << columnId <<
" value " << value;
599 tools::waxml::ntuple::column<double>* column
603 description <<
" " <<
" columnId " << columnId <<
" does not exist.";
604 G4Exception(
"G4XmlNtupleManager::FillNtupleDColumn()",
613 description <<
" ntupleId " << ntupleId
614 <<
" columnId " << columnId <<
" value " << value;
633 description <<
" ntupleId " << ntupleId;
640 if ( ! ntupleDescription )
return false;
642 if ( ! ntupleDescription->
fNtuple ) {
644 description <<
" " <<
"ntuple does not exist. ";
650 ntupleDescription->
fNtuple->add_row();
654 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