48 std::vector<G4CsvNtupleDescription*>::iterator it;
59 tools::wcsv::ntuple::column<int>*
64 if ( ! ntupleDecription ) {
69 std::map<G4int, tools::wcsv::ntuple::column<int>* >& ntupleIColumnMap
71 std::map<G4int, tools::wcsv::ntuple::column<int>* >::const_iterator it
72 = ntupleIColumnMap.find(columnId);
73 if ( it == ntupleIColumnMap.end() ) {
75 description <<
" " <<
"ntupleId " << ntupleId
76 <<
"column " << columnId <<
" does not exist.";
77 G4Exception(
"G4CsvNtupleManager::GetNtupleIColumn()",
86 tools::wcsv::ntuple::column<float>*
91 if ( ! ntupleDecription ) {
96 std::map<G4int, tools::wcsv::ntuple::column<float>* >& ntupleFColumnMap
98 std::map<G4int, tools::wcsv::ntuple::column<float>* >::const_iterator it
99 = ntupleFColumnMap.find(columnId);
100 if ( it == ntupleFColumnMap.end() ) {
102 description <<
" " <<
"ntupleId " << ntupleId
103 <<
"column " << columnId <<
" does not exist.";
104 G4Exception(
"G4CsvNtupleManager::GetNtupleFColumn()",
114 tools::wcsv::ntuple::column<double>*
119 if ( ! ntupleDecription ) {
124 std::map<G4int, tools::wcsv::ntuple::column<double>* >& ntupleDColumnMap
126 std::map<G4int, tools::wcsv::ntuple::column<double>* >::const_iterator it
127 = ntupleDColumnMap.find(columnId);
128 if ( it == ntupleDColumnMap.end() ) {
130 description <<
" " <<
"ntupleId " << ntupleId
131 <<
"column " << columnId <<
" does not exist.";
132 G4Exception(
"G4CsvNtupleManager::GetNtupleDColumn()",
148 G4String inFunction =
"G4CsvNtupleManager::";
149 inFunction += functionName;
151 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
172 std::vector<G4CsvNtupleDescription*>::iterator itn;
175 tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
176 if ( ! ntupleBooking )
continue;
181 ->
Message(
"create from booking",
"ntuple", ntupleBooking->m_name);
189 =
new tools::wcsv::ntuple(*((*itn)->fFile),
G4cerr, *ntupleBooking);
191 if ( ntupleBooking->m_columns.size() ) {
193 const std::vector<tools::ntuple_booking::col_t>& columns
194 = ntupleBooking->m_columns;
195 std::vector<tools::ntuple_booking::col_t>::const_iterator it;
197 for ( it = columns.begin(); it!=columns.end(); ++it) {
198 if ( (*it).second == tools::_cid(
int(0) ) ) {
199 (*itn)->fNtupleIColumnMap[index++]
200 = (*itn)->fNtuple->find_column<
int>((*it).first);
202 else if ( (*it).second == tools::_cid(
float(0) ) ) {
203 (*itn)->fNtupleFColumnMap[index++]
204 = (*itn)->fNtuple->find_column<
float>((*it).first);
206 else if ( (*it).second== tools::_cid(
double(0))) {
207 (*itn)->fNtupleDColumnMap[index++]
208 = (*itn)->fNtuple->find_column<
double>((*it).first);
213 <<
"Unsupported column type " << (*it).first;
214 G4Exception(
"G4CsvNtupleManager::CreateNtupleFromBooking()",
222 ->
Message(
"create from booking",
"ntuple", ntupleBooking->m_name);
236 std::vector<G4CsvNtupleDescription*>::iterator it;
238 delete (*it)->fNtuple;
257 return ntupleDescription->
fNtuple;
286 =
new tools::wcsv::ntuple(*(ntupleDescription->
fFile));
296 description << name <<
" ntupleId " << index +
fFirstId;
337 description << name <<
" ntupleId " << ntupleId;
344 tools::ntuple_booking* ntupleBooking
347 if ( ! ntupleBooking ) {
350 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
351 G4Exception(
"G4CsvNtupleManager::CreateNtupleIColumn()",
357 G4int index = ntupleBooking->m_columns.size();
358 ntupleBooking->add_column<
int>(
name);
361 if ( ntupleDescription->
fNtuple ) {
362 tools::wcsv::ntuple::column<int>* column
363 = ntupleDescription->
fNtuple->create_column<
int>(
name);
372 description << name <<
" ntupleId " << ntupleId;
386 description << name <<
" ntupleId " << ntupleId;
393 tools::ntuple_booking* ntupleBooking
396 if ( ! ntupleBooking ) {
399 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
400 G4Exception(
"G4CsvNtupleManager::CreateNtupleFColumn()",
406 G4int index = ntupleBooking->m_columns.size();
407 ntupleBooking->add_column<
float>(
name);
410 if ( ntupleDescription->
fNtuple ) {
411 tools::wcsv::ntuple::column<float>* column
412 = ntupleDescription->
fNtuple->create_column<
float>(
name);
421 description << name <<
" ntupleId " << ntupleId;
435 description << name <<
" ntupleId " << ntupleId;
442 tools::ntuple_booking* ntupleBooking
445 if ( ! ntupleBooking ) {
448 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
449 G4Exception(
"G4CsvNtupleManager::CreateNtupleDColumn()",
455 G4int index = ntupleBooking->m_columns.size();
456 ntupleBooking->add_column<
double>(
name);
459 if ( ntupleDescription->
fNtuple ) {
460 tools::wcsv::ntuple::column<double>* column
461 = ntupleDescription->
fNtuple->create_column<
double>(
name);
470 description << name <<
" ntupleId " << ntupleId;
512 tools::wcsv::ntuple::column<int>* column
516 description <<
" " <<
"ntupleId " << ntupleId
517 <<
"column " << columnId <<
" does not exist.";
518 G4Exception(
"G4CsvNtupleManager::FillNtupleIColumn()",
527 description <<
" ntupleId " << ntupleId
528 <<
" columnId " << columnId <<
" value " << value;
538 tools::wcsv::ntuple::column<float>* column
542 description <<
" " <<
"ntupleId " << ntupleId
543 <<
"column " << columnId <<
" does not exist.";
544 G4Exception(
"G4CsvNtupleManager::FillNtupleFColumn()",
553 description <<
" ntupleId " << ntupleId
554 <<
" columnId " << columnId <<
" value " << value;
565 tools::wcsv::ntuple::column<double>* column
569 description <<
" " <<
"ntupleId " << ntupleId
570 <<
"column " << columnId <<
" does not exist.";
571 G4Exception(
"G4CsvNtupleManager::FillNtupleDColumn()",
580 description <<
" ntupleId " << ntupleId
581 <<
" columnId " << columnId <<
" value " << value;
594 description <<
" ntupleId " << ntupleId;
602 if ( ! ntupleDescription || ! ntupleDescription->
fNtuple ) {
604 description <<
" " <<
"ntuple does not exist. ";
610 ntupleDescription->
fNtuple->add_row();
614 description <<
" ntupleId " << ntupleId;
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
std::ostringstream G4ExceptionDescription
G4CsvFileManager * fFileManager
virtual G4int CreateNtuple(const G4String &name, const G4String &title)
G4CsvNtupleManager(const G4AnalysisManagerState &state)
void CreateNtuplesFromBooking()
const G4AnalysisVerbose * GetVerboseL2() const
tools::wcsv::ntuple * GetNtuple() const
virtual G4CsvNtupleDescription * GetNtupleInFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
tools::wcsv::ntuple::column< float > * GetNtupleFColumn(G4int ntupleId, G4int columnId) const
G4CsvFileManager * fFileManager
const G4AnalysisVerbose * GetVerboseL3() const
virtual void FinishNtuple()
std::map< G4int, tools::wcsv::ntuple::column< float > * > fNtupleFColumnMap
const G4AnalysisVerbose * GetVerboseL4() const
G4String GetFileName() const
tools::wcsv::ntuple::column< double > * GetNtupleDColumn(G4int ntupleId, G4int columnId) const
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value)
virtual G4int CreateNtupleFColumn(const G4String &name)
tools::ntuple_booking * fNtupleBooking
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual G4int CreateNtupleDColumn(const G4String &name)
G4bool CreateNtupleFile(G4CsvNtupleDescription *ntupleDescription)
tools::wcsv::ntuple * fNtuple
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value)
std::map< G4int, tools::wcsv::ntuple::column< double > * > fNtupleDColumnMap
G4bool GetIsMaster() const
tools::wcsv::ntuple::column< int > * GetNtupleIColumn(G4int ntupleId, G4int columnId) const
G4bool fLockFirstNtupleColumnId
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
std::map< G4int, tools::wcsv::ntuple::column< int > * > fNtupleIColumnMap
G4int fFirstNtupleColumnId
std::vector< G4CsvNtupleDescription * > fNtupleVector
virtual G4int CreateNtupleIColumn(const G4String &name)
const G4AnalysisManagerState & fState
virtual G4bool AddNtupleRow()
G4GLOB_DLL std::ostream G4cerr