34 #include "tools/wroot/file"
47 std::vector<G4RootNtupleDescription*>::iterator it;
58 tools::wroot::ntuple::column<int>*
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 <<
" columnId " << columnId <<
" does not exist.";
74 G4Exception(
"G4RootNtupleManager::GetNtupleIColumn()",
83 tools::wroot::ntuple::column<float>*
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 <<
" columnId " << columnId <<
" does not exist.";
99 G4Exception(
"G4RootNtupleManager::GetNtupleFColumn()",
109 tools::wroot::ntuple::column<double>*
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 <<
" columnId " << columnId <<
" does not exist.";
125 G4Exception(
"G4RootNtupleManager::GetNtupleDColumn()",
141 G4String inFunction =
"G4RootNtupleManager::";
142 inFunction += functionName;
144 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
164 std::vector<G4RootNtupleDescription*>::iterator 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);
226 std::vector<G4RootNtupleDescription*>::iterator it;
248 return ntupleDescription->
fNtuple;
284 description << name <<
" ntupleId " << index +
fFirstId;
326 description << name <<
" ntupleId " << ntupleId;
333 if ( ! ntupleDescription )
return -1;
335 tools::ntuple_booking* ntupleBooking
337 if ( ! ntupleBooking ) {
340 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
341 G4Exception(
"G4RootNtupleManager::CreateNtupleIColumn()",
347 G4int index = ntupleBooking->m_columns.size();
348 ntupleBooking->add_column<
int>(
name);
351 if ( ntupleDescription->
fNtuple ) {
352 tools::wroot::ntuple::column<int>* column
353 = ntupleDescription->
fNtuple->create_column<
int>(
name);
362 description << name <<
" ntupleId " << ntupleId;
376 description << name <<
" ntupleId " << ntupleId;
383 if ( ! ntupleDescription )
return -1;
385 tools::ntuple_booking* ntupleBooking
388 if ( ! ntupleBooking ) {
391 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
392 G4Exception(
"G4RootNtupleManager::CreateNtupleFColumn()",
398 G4int index = ntupleBooking->m_columns.size();
399 ntupleBooking->add_column<
float>(
name);
402 if ( ntupleDescription->
fNtuple ) {
403 tools::wroot::ntuple::column<float>* column
404 = ntupleDescription->
fNtuple->create_column<
float>(
name);
413 description << name <<
" ntupleId " << ntupleId;
428 description << name <<
" ntupleId " << ntupleId;
435 if ( ! ntupleDescription )
return -1;
437 tools::ntuple_booking* ntupleBooking
440 if ( ! ntupleBooking ) {
443 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
444 G4Exception(
"G4RootNtupleManager::CreateNtupleDColumn()",
450 G4int index = ntupleBooking->m_columns.size();
451 ntupleBooking->add_column<
double>(
name);
454 if ( ntupleDescription->
fNtuple ) {
455 tools::wroot::ntuple::column<double>* column
456 = ntupleDescription->
fNtuple->create_column<
double>(
name);
465 description << name <<
" ntupleId " << ntupleId;
507 tools::wroot::ntuple::column<int>* column
511 description <<
" " <<
"ntupleId " << ntupleId
512 <<
" columnId " << columnId <<
" does not exist.";
513 G4Exception(
"G4RootNtupleManager::FillNtupleIColumn()",
522 description <<
" ntupleId " << ntupleId
523 <<
" columnId " << columnId <<
" value " << value;
533 tools::wroot::ntuple::column<float>* column
537 description <<
" " <<
"ntupleId " << ntupleId
538 <<
" columnId " << columnId <<
" does not exist.";
539 G4Exception(
"G4RootNtupleManager::FillNtupleFColumn()",
548 description <<
" ntupleId " << ntupleId
549 <<
" columnId " << columnId <<
" value " << value;
559 tools::wroot::ntuple::column<double>* column
563 description <<
" " <<
"ntupleId " << ntupleId
564 <<
" columnId " << columnId <<
" does not exist.";
565 G4Exception(
"G4RootNtupleManager::FillNtupleDColumn()",
574 description <<
" ntupleId " << ntupleId
575 <<
" columnId " << columnId <<
" value " << value;
588 description <<
" ntupleId " << ntupleId;
595 if ( ! ntupleDescription )
return false;
597 if ( ! ntupleDescription->
fNtuple ) {
599 description <<
" " <<
" ntupleId " << ntupleId
600 <<
" does not exist. ";
609 description <<
" " <<
" ntupleId " << ntupleId
610 <<
"adding row has failed.";
617 description <<
" ntupleId " << ntupleId;
tools::wroot::ntuple::column< int > * GetNtupleIColumn(G4int ntupleId, G4int columnId) const
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
tools::wroot::directory * fNtupleDirectory
std::map< G4int, tools::wroot::ntuple::column< int > * > fNtupleIColumnMap
virtual G4int CreateNtupleDColumn(const G4String &name)
tools::wroot::ntuple::column< float > * GetNtupleFColumn(G4int ntupleId, G4int columnId) const
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
std::vector< G4RootNtupleDescription * > fNtupleVector
virtual void FinishNtuple()
virtual G4RootNtupleDescription * GetNtupleInFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
tools::wroot::ntuple * GetNtuple() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual G4int CreateNtupleIColumn(const G4String &name)
virtual G4bool AddNtupleRow()
tools::wroot::ntuple * fNtuple
tools::ntuple_booking * fNtupleBooking
tools::wroot::ntuple::column< double > * GetNtupleDColumn(G4int ntupleId, G4int columnId) const
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