36 #include "tools/ntuple_booking"
52 std::vector<G4XmlNtupleDescription*>::iterator it;
53 for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
63 tools::waxml::ntuple::column<int>*
64 G4XmlNtupleManager::GetNtupleIColumn(
G4int ntupleId,
G4int columnId)
const
67 = GetNtupleInFunction(ntupleId,
"GetNtupleIColumn");
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>*
88 G4XmlNtupleManager::GetNtupleFColumn(
G4int ntupleId,
G4int columnId)
const
91 = GetNtupleInFunction(ntupleId,
"GetNtupleFColumn");
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>*
112 G4XmlNtupleManager::GetNtupleDColumn(
G4int ntupleId,
G4int columnId)
const
115 = GetNtupleInFunction(ntupleId,
"GetNtupleDColumn");
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()",
140 if ( index < 0 || index >=
G4int(fNtupleVector.size()) ) {
142 G4String inFunction =
"G4XmlNtupleManager::";
143 inFunction += functionName;
145 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
151 return fNtupleVector[
index];
166 std::vector<G4XmlNtupleDescription*>::iterator itn;
167 for (itn = fNtupleVector.begin(); itn != fNtupleVector.end(); itn++ ) {
169 tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
170 if ( ! ntupleBooking )
continue;
176 ->
Message(
"create from booking",
"ntuple", ntupleBooking->m_name);
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);
226 return ! fNtupleVector.size();
234 std::vector<G4XmlNtupleDescription*>::iterator it;
235 for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
236 delete (*it)->fNtuple;
253 = GetNtupleInFunction(ntupleId,
"GetNtuple");
255 return ntupleDescription->
fNtuple;
268 G4int index = fNtupleVector.size();
271 fNtupleVector.push_back(ntupleDescription);
293 description << name <<
" ntupleId " << index +
fFirstId;
304 G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
311 G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
318 G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
325 G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
335 description << name <<
" ntupleId " << ntupleId;
341 = GetNtupleInFunction(ntupleId,
"CreateNtupleIColumn");
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;
390 = GetNtupleInFunction(ntupleId,
"CreateNtupleFColumn");
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;
439 = GetNtupleInFunction(ntupleId,
"CreateNtupleDColumn");
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;
480 = GetNtupleInFunction(ntupleId,
"FinishNtuple");
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
543 = GetNtupleIColumn(ntupleId, columnId);
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
568 = GetNtupleFColumn(ntupleId, columnId);
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
594 = GetNtupleDColumn(ntupleId, columnId);
597 description <<
" " <<
"column " << columnId <<
" does not exist.";
598 G4Exception(
"G4XmlNtupleManager::FillNtupleDColumn()",
607 description <<
" ntupleId " << ntupleId
608 <<
" columnId " << columnId <<
" value " <<
value;
627 description <<
" ntupleId " << ntupleId;
633 = GetNtupleInFunction(ntupleId,
"AddNtupleRow");
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)
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)
subroutine title(NA, NB, NCA, NCB)
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
G4String & append(const G4String &)
void CreateNtuplesFromBooking()
G4bool GetIsMaster() const
tools::waxml::ntuple * GetNtuple() const
const XML_Char int const XML_Char * value
G4bool fLockFirstNtupleColumnId
G4int fFirstNtupleColumnId
G4XmlNtupleManager(const G4AnalysisManagerState &state)
virtual G4int CreateNtuple(const G4String &name, const G4String &title)
const G4AnalysisManagerState & fState
G4GLOB_DLL std::ostream G4cerr