34 #include "tools/wroot/file"
47 std::vector<G4RootNtupleDescription*>::iterator it;
48 for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
58 tools::wroot::ntuple::column<int>*
59 G4RootNtupleManager::GetNtupleIColumn(
G4int ntupleId,
G4int columnId)
const
62 = GetNtupleInFunction(ntupleId,
"GetNtupleIColumn");
63 if ( ! ntupleDecription )
return 0;
65 std::map<G4int, tools::wroot::ntuple::column<int>* >& ntupleIColumnMap
67 std::map<G4int, tools::wroot::ntuple::column<int>* >::const_iterator it
68 = ntupleIColumnMap.find(columnId);
70 if ( it == ntupleIColumnMap.end() ) {
72 description <<
" " <<
"ntupleId " << ntupleId
73 <<
"column " << columnId <<
" does not exist.";
74 G4Exception(
"G4RootNtupleManager::GetNtupleIColumn()",
83 tools::wroot::ntuple::column<float>*
84 G4RootNtupleManager::GetNtupleFColumn(
G4int ntupleId,
G4int columnId)
const
87 = GetNtupleInFunction(ntupleId,
"GetNtupleIColumn");
88 if ( ! ntupleDecription )
return 0;
90 std::map<G4int, tools::wroot::ntuple::column<float>* >& ntupleFColumnMap
92 std::map<G4int, tools::wroot::ntuple::column<float>* >::const_iterator it
93 = ntupleFColumnMap.find(columnId);
95 if ( it == ntupleFColumnMap.end() ) {
97 description <<
" " <<
"ntupleId " << ntupleId
98 <<
"column " << columnId <<
" does not exist.";
99 G4Exception(
"G4RootNtupleManager::GetNtupleFColumn()",
109 tools::wroot::ntuple::column<double>*
110 G4RootNtupleManager::GetNtupleDColumn(
G4int ntupleId,
G4int columnId)
const
113 = GetNtupleInFunction(ntupleId,
"GetNtupleIColumn");
114 if ( ! ntupleDecription )
return 0;
116 std::map<G4int, tools::wroot::ntuple::column<double>* >& ntupleDColumnMap
118 std::map<G4int, tools::wroot::ntuple::column<double>* >::const_iterator it
119 = ntupleDColumnMap.find(columnId);
121 if ( it == ntupleDColumnMap.end() ) {
123 description <<
" " <<
"ntupleId " << ntupleId
124 <<
"column " << columnId <<
" does not exist.";
125 G4Exception(
"G4RootNtupleManager::GetNtupleDColumn()",
139 if ( index < 0 || index >=
G4int(fNtupleVector.size()) ) {
141 G4String inFunction =
"G4RootNtupleManager::";
142 inFunction += functionName;
144 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
150 return fNtupleVector[
index];
162 if ( ! fNtupleVector.size() )
return;
164 std::vector<G4RootNtupleDescription*>::iterator itn;
165 for (itn = fNtupleVector.begin(); itn != fNtupleVector.end(); itn++ ) {
167 tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
168 if ( ! ntupleBooking )
continue;
173 ->
Message(
"create from booking",
"ntuple", ntupleBooking->m_name);
179 if ( ntupleBooking->m_columns.size() ) {
181 const std::vector<tools::ntuple_booking::col_t>& columns
182 = ntupleBooking->m_columns;
183 std::vector<tools::ntuple_booking::col_t>::const_iterator it;
185 for ( it = columns.begin(); it!=columns.end(); ++it) {
186 if ( (*it).second == tools::_cid(
int(0) ) ) {
187 (*itn)->fNtupleIColumnMap[index++]
188 = (*itn)->fNtuple->find_column<
int>((*it).first);
190 else if ( (*it).second == tools::_cid(
float(0) ) ) {
191 (*itn)->fNtupleFColumnMap[index++]
192 = (*itn)->fNtuple->find_column<
float>((*it).first);
194 else if ( (*it).second== tools::_cid(
double(0))) {
195 (*itn)->fNtupleDColumnMap[index++]
196 = (*itn)->fNtuple->find_column<
double>((*it).first);
201 <<
"Unsupported column type " << (*it).first;
202 G4Exception(
"G4RootNtupleManager::CreateNtupleFromBooking()",
210 ->
Message(
"create from booking",
"ntuple", ntupleBooking->m_name);
218 return ! fNtupleVector.size();
226 std::vector<G4RootNtupleDescription*>::iterator it;
227 for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
246 = GetNtupleInFunction(ntupleId,
"GetNtuple");
248 return ntupleDescription->
fNtuple;
261 G4int index = fNtupleVector.size();
264 fNtupleVector.push_back(ntupleDescription);
273 if ( fNtupleDirectory ) {
284 description << name <<
" ntupleId " << index +
fFirstId;
295 G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
302 G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
309 G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
326 description << name <<
" ntupleId " << ntupleId;
332 = GetNtupleInFunction(ntupleId,
"CreateNtupleIColumn");
333 tools::ntuple_booking* ntupleBooking
336 if ( ! ntupleBooking ) {
339 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
340 G4Exception(
"G4RootNtupleManager::CreateNtupleIColumn()",
346 G4int index = ntupleBooking->m_columns.size();
347 ntupleBooking->add_column<
int>(
name);
350 if ( ntupleDescription->
fNtuple ) {
351 tools::wroot::ntuple::column<int>* column
352 = ntupleDescription->
fNtuple->create_column<
int>(
name);
361 description << name <<
" ntupleId " << ntupleId;
375 description << name <<
" ntupleId " << ntupleId;
381 = GetNtupleInFunction(ntupleId,
"CreateNtupleFColumn");
382 tools::ntuple_booking* ntupleBooking
385 if ( ! ntupleBooking ) {
388 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
389 G4Exception(
"G4RootNtupleManager::CreateNtupleFColumn()",
395 G4int index = ntupleBooking->m_columns.size();
396 ntupleBooking->add_column<
float>(
name);
399 if ( ntupleDescription->
fNtuple ) {
400 tools::wroot::ntuple::column<float>* column
401 = ntupleDescription->
fNtuple->create_column<
float>(
name);
410 description << name <<
" ntupleId " << ntupleId;
425 description << name <<
" ntupleId " << ntupleId;
431 = GetNtupleInFunction(ntupleId,
"CreateNtupleDColumn");
432 tools::ntuple_booking* ntupleBooking
435 if ( ! ntupleBooking ) {
438 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
439 G4Exception(
"G4RootNtupleManager::CreateNtupleDColumn()",
445 G4int index = ntupleBooking->m_columns.size();
446 ntupleBooking->add_column<
double>(
name);
449 if ( ntupleDescription->
fNtuple ) {
450 tools::wroot::ntuple::column<double>* column
451 = ntupleDescription->
fNtuple->create_column<
double>(
name);
460 description << name <<
" ntupleId " << ntupleId;
502 tools::wroot::ntuple::column<int>* column
503 = GetNtupleIColumn(ntupleId, columnId);
506 description <<
" " <<
"ntupleId " << ntupleId
507 <<
"column " << columnId <<
" does not exist.";
508 G4Exception(
"G4RootNtupleManager::FillNtupleIColumn()",
517 description <<
" ntupleId " << ntupleId
518 <<
" columnId " << columnId <<
" value " <<
value;
528 tools::wroot::ntuple::column<float>* column
529 = GetNtupleFColumn(ntupleId, columnId);
532 description <<
" " <<
"ntupleId " << ntupleId
533 <<
"column " << columnId <<
" does not exist.";
534 G4Exception(
"G4RootNtupleManager::FillNtupleFColumn()",
543 description <<
" ntupleId " << ntupleId
544 <<
" columnId " << columnId <<
" value " <<
value;
554 tools::wroot::ntuple::column<double>* column
555 = GetNtupleDColumn(ntupleId, columnId);
558 description <<
" " <<
"ntupleId " << ntupleId
559 <<
"column " << columnId <<
" does not exist.";
560 G4Exception(
"G4RootNtupleManager::FillNtupleDColumn()",
569 description <<
" ntupleId " << ntupleId
570 <<
" columnId " << columnId <<
" value " <<
value;
583 description <<
" ntupleId " << ntupleId;
589 = GetNtupleInFunction(ntupleId,
"AddNtupleRow");
591 if ( ! ntupleDescription || ! ntupleDescription->
fNtuple ) {
593 description <<
" " <<
" ntupleId " << ntupleId
594 <<
" does not exist. ";
603 description <<
" " <<
" ntupleId " << ntupleId
604 <<
"adding row has failed.";
611 description <<
" ntupleId " << ntupleId;
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value)
virtual G4int CreateNtupleFColumn(const G4String &name)
std::map< G4int, tools::wroot::ntuple::column< float > * > fNtupleFColumnMap
std::ostringstream G4ExceptionDescription
G4double G4NeutronHPJENDLHEData::G4double result
std::map< G4int, tools::wroot::ntuple::column< int > * > fNtupleIColumnMap
virtual G4int CreateNtupleDColumn(const G4String &name)
const G4AnalysisVerbose * GetVerboseL2() const
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value)
void CreateNtuplesFromBooking()
const G4AnalysisVerbose * GetVerboseL3() const
virtual ~G4RootNtupleManager()
const G4AnalysisVerbose * GetVerboseL4() const
std::map< G4int, tools::wroot::ntuple::column< double > * > fNtupleDColumnMap
virtual void FinishNtuple()
tools::wroot::ntuple * GetNtuple() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual G4int CreateNtupleIColumn(const G4String &name)
subroutine title(NA, NB, NCA, NCB)
virtual G4bool AddNtupleRow()
tools::wroot::ntuple * fNtuple
tools::ntuple_booking * fNtupleBooking
const XML_Char int const XML_Char * value
virtual G4int CreateNtuple(const G4String &name, const G4String &title)
G4bool fLockFirstNtupleColumnId
G4int fFirstNtupleColumnId
G4RootNtupleManager(const G4AnalysisManagerState &state)
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
const G4AnalysisManagerState & fState