39bool to_vector(base_ntu& a_ntu,std::vector<T>& a_vec) {
41 const std::vector<base_col*>& cols = a_ntu.cols();
42 if(cols.empty())
return false;
43 base_col* _base_col = cols.front();
44 aida_col<T>* _col = safe_cast<base_col, aida_col<T> >(*_base_col);
45 if(!_col)
return false;
47 uint64 _rows = a_ntu.rows();
50 {
for(uint64 row=0;row<_rows;row++) {
51 if(!a_ntu.next()) {a_vec.clear();
return false;}
52 if(!_col->get_entry(v)) {a_vec.clear();
return false;}
75 std::vector<G4int>& vector)
82 description <<
" ntupleId " << ntupleId <<
" " << columnName;
88 if ( ! ntupleDescription )
return false;
94 auto subNtuple =
new tools::aida::ntuple(
G4cout, columnName);
95 ntupleDescription->fIVectorBindingMap[subNtuple] = &vector;
96 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
97 ntupleBinding->add_column_cid(columnName, *subNtuple);
102 description <<
" ntupleId " << ntupleId <<
" " << columnName;
113 std::vector<G4float>& vector)
120 description <<
" ntupleId " << ntupleId <<
" " << columnName;
126 if ( ! ntupleDescription )
return false;
132 auto subNtuple =
new tools::aida::ntuple(
G4cout, columnName);
133 ntupleDescription->fFVectorBindingMap[subNtuple] = &vector;
134 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
135 ntupleBinding->add_column_cid(columnName, *subNtuple);
140 description <<
" ntupleId " << ntupleId <<
" " << columnName;
151 std::vector<G4double>& vector)
158 description <<
" ntupleId " << ntupleId <<
" " << columnName;
164 if ( ! ntupleDescription )
return false;
170 auto subNtuple =
new tools::aida::ntuple(
G4cout, columnName);
171 ntupleDescription->fDVectorBindingMap[subNtuple] = &vector;
172 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
173 ntupleBinding->add_column_cid(columnName, *subNtuple);
178 description <<
" ntupleId " << ntupleId <<
" " << columnName;
187G4bool G4XmlRNtupleManager::GetTNtupleRow(
190 auto ntuple = ntupleDescription->
fNtuple;
193 if ( ! isInitialized ) {
194 tools::ntuple_binding* ntupleBinding = ntupleDescription->
fNtupleBinding;
195 if ( ! ntuple->set_binding(std::cout, *ntupleBinding) ) {
199 <<
"Ntuple initialization failed !!";
208 G4bool next = ntuple->next();
210 if ( ! ntuple->get_row() ) {
214 <<
"Ntuple get_row() failed !!";
222 {std::map<tools::aida::ntuple*, std::vector<int>* >::iterator it;
225 tools::aida::to_vector<int>(*(it->first), *(it->second));
227 {std::map<tools::aida::ntuple*, std::vector<float>* >::iterator it;
230 tools::aida::to_vector<float>(*(it->first), *(it->second));
232 {std::map<tools::aida::ntuple*, std::vector<double>* >::iterator it;
235 tools::aida::to_vector<double>(*(it->first), *(it->second));
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
const G4AnalysisVerbose * GetVerboseL2() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState
G4TRNtupleDescription< tools::aida::ntuple > * GetNtupleDescriptionInFunction(G4int id, G4String function, G4bool warn=true) const
G4XmlRNtupleManager(const G4AnalysisManagerState &state)
virtual G4bool SetNtupleIColumn(G4int ntupleId, const G4String &columnName, std::vector< G4int > &vector) final
virtual G4bool SetNtupleFColumn(G4int ntupleId, const G4String &columnName, std::vector< G4float > &vector) final
virtual G4bool SetNtupleDColumn(G4int ntupleId, const G4String &columnName, std::vector< G4double > &vector) final
virtual ~G4XmlRNtupleManager()
tools::ntuple_binding * fNtupleBinding
std::map< TNTUPLE *, std::vector< double > * > fDVectorBindingMap
std::map< TNTUPLE *, std::vector< int > * > fIVectorBindingMap
std::map< TNTUPLE *, std::vector< float > * > fFVectorBindingMap