41 bool to_vector(base_ntu& a_ntu,std::vector<T>& a_vec) {
43 const std::vector<base_col*>& cols = a_ntu.cols();
44 if(cols.empty())
return false;
45 base_col* _base_col = cols.front();
46 aida_col<T>* _col = safe_cast<base_col, aida_col<T> >(*_base_col);
47 if(!_col)
return false;
49 uint64 _rows = a_ntu.rows();
52 {
for(uint64 row=0;row<_rows;row++) {
53 if(!a_ntu.next()) {a_vec.clear();
return false;}
54 if(!_col->get_entry(v)) {a_vec.clear();
return false;}
71 std::vector<G4XmlRNtupleDescription*>::iterator it;
88 G4String inFunction =
"G4XmlRNtupleManager::";
89 inFunction += functionName;
91 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
115 std::vector<G4XmlRNtupleDescription*>::iterator it;
137 if ( ! rntupleDescription )
return nullptr;
139 return rntupleDescription->
fNtuple;
182 std::vector<G4int>& vector)
189 std::vector<G4float>& vector)
196 std::vector<G4double>& vector)
209 description <<
" ntupleId " << ntupleId <<
" " << columnName;
216 if ( ! ntupleDescription )
return false;
218 tools::ntuple_binding* ntupleBinding = ntupleDescription->
fNtupleBinding;
219 ntupleBinding->add_column(columnName, value);
224 description <<
" ntupleId " << ntupleId <<
" " << columnName;
240 description <<
" ntupleId " << ntupleId <<
" " << columnName;
247 if ( ! ntupleDescription )
return false;
249 tools::ntuple_binding* ntupleBinding = ntupleDescription->
fNtupleBinding;
250 ntupleBinding->add_column(columnName, value);
255 description <<
" ntupleId " << ntupleId <<
" " << columnName;
273 description <<
" ntupleId " << ntupleId <<
" " << columnName;
280 if ( ! ntupleDescription )
return false;
282 tools::ntuple_binding* ntupleBinding = ntupleDescription->
fNtupleBinding;
283 ntupleBinding->add_column(columnName, value);
288 description <<
" ntupleId " << ntupleId <<
" " << columnName;
306 description <<
" ntupleId " << ntupleId <<
" " << columnName;
313 if ( ! ntupleDescription )
return false;
315 tools::ntuple_binding* ntupleBinding = ntupleDescription->
fNtupleBinding;
316 ntupleBinding->add_column(columnName, value);
321 description <<
" ntupleId " << ntupleId <<
" " << columnName;
332 std::vector<G4int>& vector)
339 description <<
" ntupleId " << ntupleId <<
" " << columnName;
346 if ( ! ntupleDescription )
return false;
352 tools::aida::ntuple* subNtuple =
new tools::aida::ntuple(
G4cout, columnName);
354 tools::ntuple_binding* ntupleBinding = ntupleDescription->
fNtupleBinding;
355 ntupleBinding->add_column(columnName, *subNtuple);
360 description <<
" ntupleId " << ntupleId <<
" " << columnName;
371 std::vector<G4float>& vector)
378 description <<
" ntupleId " << ntupleId <<
" " << columnName;
385 if ( ! ntupleDescription )
return false;
391 tools::aida::ntuple* subNtuple =
new tools::aida::ntuple(
G4cout, columnName);
393 tools::ntuple_binding* ntupleBinding = ntupleDescription->
fNtupleBinding;
394 ntupleBinding->add_column(columnName, *subNtuple);
399 description <<
" ntupleId " << ntupleId <<
" " << columnName;
410 std::vector<G4double>& vector)
417 description <<
" ntupleId " << ntupleId <<
" " << columnName;
424 if ( ! ntupleDescription )
return false;
430 tools::aida::ntuple* subNtuple =
new tools::aida::ntuple(
G4cout, columnName);
432 tools::ntuple_binding* ntupleBinding = ntupleDescription->
fNtupleBinding;
433 ntupleBinding->add_column(columnName, *subNtuple);
438 description <<
" ntupleId " << ntupleId <<
" " << columnName;
458 description <<
" ntupleId " << ntupleId;
465 if ( ! ntupleDescription )
return false;
467 tools::aida::ntuple* ntuple = ntupleDescription->
fNtuple;
470 if ( ! isInitialized ) {
471 tools::ntuple_binding* ntupleBinding = ntupleDescription->
fNtupleBinding;
472 if ( ! ntuple->set_binding(std::cout, *ntupleBinding) ) {
476 <<
"Ntuple initialization failed !!";
485 G4bool next = ntuple->next();
487 if ( ! ntuple->get_row() ) {
491 <<
"Ntuple get_row() failed !!";
499 {std::map<tools::aida::ntuple*, std::vector<int>* >::iterator it;
502 tools::aida::to_vector<int>(*(it->first), *(it->second));
504 {std::map<tools::aida::ntuple*, std::vector<float>* >::iterator it;
507 tools::aida::to_vector<float>(*(it->first), *(it->second));
509 {std::map<tools::aida::ntuple*, std::vector<double>* >::iterator it;
512 tools::aida::to_vector<double>(*(it->first), *(it->second));
519 description <<
" ntupleId " << ntupleId;
std::map< tools::aida::ntuple *, std::vector< double > * > fDVectorBindingMap
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
tools::ntuple_binding * fNtupleBinding
std::ostringstream G4ExceptionDescription
virtual G4bool SetNtupleDColumn(const G4String &columnName, G4double &value)
std::map< tools::aida::ntuple *, std::vector< int > * > fIVectorBindingMap
const G4AnalysisVerbose * GetVerboseL2() const
G4GLOB_DLL std::ostream G4cout
const G4AnalysisVerbose * GetVerboseL4() const
virtual G4bool SetNtupleIColumn(const G4String &columnName, G4int &value)
virtual G4bool SetNtupleSColumn(const G4String &columnName, G4String &value)
tools::aida::ntuple * GetNtuple() const
virtual G4bool SetNtupleFColumn(const G4String &columnName, G4float &value)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4XmlRNtupleManager(const G4AnalysisManagerState &state)
tools::aida::ntuple * fNtuple
std::vector< G4XmlRNtupleDescription * > fNtupleVector
G4XmlRNtupleDescription * GetNtupleInFunction(G4int id, G4String function, G4bool warn=true) const
std::map< tools::aida::ntuple *, std::vector< float > * > fFVectorBindingMap
G4int SetNtuple(G4XmlRNtupleDescription *rntupleDescription)
virtual G4bool GetNtupleRow()
virtual ~G4XmlRNtupleManager()
G4bool isInitialized()
Check if the generator is initialized.
const G4AnalysisManagerState & fState