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 <<
" columnId " << 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 <<
" columnId " << 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 <<
" columnId " << 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 if ( ! ntupleDescription )
return -1;
346 tools::ntuple_booking* ntupleBooking
349 if ( ! ntupleBooking ) {
352 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
353 G4Exception(
"G4CsvNtupleManager::CreateNtupleIColumn()",
359 G4int index = ntupleBooking->m_columns.size();
360 ntupleBooking->add_column<
int>(
name);
363 if ( ntupleDescription->
fNtuple ) {
364 tools::wcsv::ntuple::column<int>* column
365 = ntupleDescription->
fNtuple->create_column<
int>(
name);
374 description << name <<
" ntupleId " << ntupleId;
388 description << name <<
" ntupleId " << ntupleId;
395 if ( ! ntupleDescription )
return -1;
397 tools::ntuple_booking* ntupleBooking
400 if ( ! ntupleBooking ) {
403 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
404 G4Exception(
"G4CsvNtupleManager::CreateNtupleFColumn()",
410 G4int index = ntupleBooking->m_columns.size();
411 ntupleBooking->add_column<
float>(
name);
414 if ( ntupleDescription->
fNtuple ) {
415 tools::wcsv::ntuple::column<float>* column
416 = ntupleDescription->
fNtuple->create_column<
float>(
name);
425 description << name <<
" ntupleId " << ntupleId;
439 description << name <<
" ntupleId " << ntupleId;
446 if ( ! ntupleDescription )
return -1;
448 tools::ntuple_booking* ntupleBooking
451 if ( ! ntupleBooking ) {
454 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
455 G4Exception(
"G4CsvNtupleManager::CreateNtupleDColumn()",
461 G4int index = ntupleBooking->m_columns.size();
462 ntupleBooking->add_column<
double>(
name);
465 if ( ntupleDescription->
fNtuple ) {
466 tools::wcsv::ntuple::column<double>* column
467 = ntupleDescription->
fNtuple->create_column<
double>(
name);
476 description << name <<
" ntupleId " << ntupleId;
518 tools::wcsv::ntuple::column<int>* column
522 description <<
" " <<
"ntupleId " << ntupleId
523 <<
" columnId " << columnId <<
" does not exist.";
524 G4Exception(
"G4CsvNtupleManager::FillNtupleIColumn()",
533 description <<
" ntupleId " << ntupleId
534 <<
" columnId " << columnId <<
" value " << value;
544 tools::wcsv::ntuple::column<float>* column
548 description <<
" " <<
"ntupleId " << ntupleId
549 <<
" columnId " << columnId <<
" does not exist.";
550 G4Exception(
"G4CsvNtupleManager::FillNtupleFColumn()",
559 description <<
" ntupleId " << ntupleId
560 <<
" columnId " << columnId <<
" value " << value;
571 tools::wcsv::ntuple::column<double>* column
575 description <<
" " <<
"ntupleId " << ntupleId
576 <<
" columnId " << columnId <<
" does not exist.";
577 G4Exception(
"G4CsvNtupleManager::FillNtupleDColumn()",
586 description <<
" ntupleId " << ntupleId
587 <<
" columnId " << columnId <<
" value " << value;
600 description <<
" ntupleId " << ntupleId;
607 if ( ! ntupleDescription )
return false;
609 if ( ! ntupleDescription->
fNtuple ) {
611 description <<
" " <<
"ntuple does not exist. ";
617 ntupleDescription->
fNtuple->add_row();
621 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