35 #include "tools/wroot/file"
43 fNtupleDescriptionVector(),
51 std::vector<G4RootNtupleDescription*>::iterator it;
62 tools::wroot::ntuple::column<int>*
67 if ( ! ntupleDecription )
return 0;
69 std::map<G4int, tools::wroot::ntuple::column<int>* >& ntupleIColumnMap
71 std::map<G4int, tools::wroot::ntuple::column<int>* >::const_iterator it
72 = ntupleIColumnMap.find(columnId);
74 if ( it == ntupleIColumnMap.end() ) {
76 description <<
" " <<
"ntupleId " << ntupleId
77 <<
" columnId " << columnId <<
" does not exist.";
78 G4Exception(
"G4RootNtupleManager::GetNtupleIColumn()",
87 tools::wroot::ntuple::column<float>*
92 if ( ! ntupleDecription )
return 0;
94 std::map<G4int, tools::wroot::ntuple::column<float>* >& ntupleFColumnMap
96 std::map<G4int, tools::wroot::ntuple::column<float>* >::const_iterator it
97 = ntupleFColumnMap.find(columnId);
99 if ( it == ntupleFColumnMap.end() ) {
101 description <<
" " <<
"ntupleId " << ntupleId
102 <<
" columnId " << columnId <<
" does not exist.";
103 G4Exception(
"G4RootNtupleManager::GetNtupleFColumn()",
113 tools::wroot::ntuple::column<double>*
118 if ( ! ntupleDecription )
return 0;
120 std::map<G4int, tools::wroot::ntuple::column<double>* >& ntupleDColumnMap
122 std::map<G4int, tools::wroot::ntuple::column<double>* >::const_iterator it
123 = ntupleDColumnMap.find(columnId);
125 if ( it == ntupleDColumnMap.end() ) {
127 description <<
" " <<
"ntupleId " << ntupleId
128 <<
" columnId " << columnId <<
" does not exist.";
129 G4Exception(
"G4RootNtupleManager::GetNtupleDColumn()",
138 tools::wroot::ntuple::column_string*
143 if ( ! ntupleDecription )
return 0;
145 std::map<G4int, tools::wroot::ntuple::column_string* >& ntupleSColumnMap
147 std::map<G4int, tools::wroot::ntuple::column_string* >::const_iterator it
148 = ntupleSColumnMap.find(columnId);
150 if ( it == ntupleSColumnMap.end() ) {
152 description <<
" " <<
"ntupleId " << ntupleId
153 <<
" columnId " << columnId <<
" does not exist.";
154 G4Exception(
"G4RootNtupleManager::GetNtupleSColumn()",
170 G4String inFunction =
"G4RootNtupleManager::";
171 inFunction += functionName;
173 description <<
" " <<
"ntuple " <<
id <<
" does not exist.";
193 std::vector<G4RootNtupleDescription*>::iterator itn;
196 tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
197 if ( ! ntupleBooking )
continue;
202 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
209 if ( ntupleBooking->columns().size() ) {
211 const std::vector<tools::column_booking>& columns
212 = ntupleBooking->columns();
213 std::vector<tools::column_booking>::const_iterator it;
215 for ( it = columns.begin(); it!=columns.end(); ++it) {
216 if ( it->cls_id() == tools::_cid(
int(0) ) ) {
217 (*itn)->fNtupleIColumnMap[index++]
218 = (*itn)->fNtuple->find_column<
int>(it->name());
220 else if ( it->cls_id() == tools::_cid(
float(0) ) ) {
221 (*itn)->fNtupleFColumnMap[index++]
222 = (*itn)->fNtuple->find_column<
float>(it->name());
224 else if ( it->cls_id()== tools::_cid(
double(0))) {
225 (*itn)->fNtupleDColumnMap[index++]
226 = (*itn)->fNtuple->find_column<
double>(it->name());
228 else if ( it->cls_id()== tools::_cid(std::string(
""))) {
229 (*itn)->fNtupleSColumnMap[index++]
230 = (*itn)->fNtuple->find_column_string(it->name());
235 <<
"Unsupported column type " << it->name();
236 G4Exception(
"G4RootNtupleManager::CreateNtupleFromBooking()",
244 ->
Message(
"create from booking",
"ntuple", ntupleBooking->name());
260 std::vector<G4RootNtupleDescription*>::iterator it;
283 if ( ! ntupleDescription )
return 0;
285 return ntupleDescription->
fNtuple;
305 =
new tools::ntuple_booking(name, title);
321 description << name <<
" ntupleId " << index +
fFirstId;
331 std::vector<int>* vector)
339 std::vector<float>* vector)
347 std::vector<double>* vector)
369 std::vector<int>* vector)
374 description << name <<
" ntupleId " << ntupleId;
383 tools::ntuple_booking* ntupleBooking
385 if ( ! ntupleBooking ) {
388 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
389 G4Exception(
"G4RootNtupleManager::CreateNtupleIColumn()",
395 G4int index = ntupleBooking->columns().size();
397 ntupleBooking->add_column<
int>(
name);
399 ntupleBooking->add_column<
int>(
name, *vector);
403 if ( ntupleDescription->
fNtuple ) {
405 tools::wroot::ntuple::column<int>* column
406 = ntupleDescription->
fNtuple->create_column<
int>(
name);
410 ntupleDescription->
fNtuple->create_column<
int>(
name, *vector);
419 description << name <<
" ntupleId " << ntupleId;
430 std::vector<float>* vector)
435 description << name <<
" ntupleId " << ntupleId;
444 tools::ntuple_booking* ntupleBooking
447 if ( ! ntupleBooking ) {
450 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
451 G4Exception(
"G4RootNtupleManager::CreateNtupleFColumn()",
457 G4int index = ntupleBooking->columns().size();
459 ntupleBooking->add_column<
float>(
name);
461 ntupleBooking->add_column<
float>(
name, *vector);
465 if ( ntupleDescription->
fNtuple ) {
467 tools::wroot::ntuple::column<float>* column
468 = ntupleDescription->
fNtuple->create_column<
float>(
name);
472 ntupleDescription->
fNtuple->create_column<
float>(
name, *vector);
481 description << name <<
" ntupleId " << ntupleId;
493 std::vector<double>* vector)
498 description << name <<
" ntupleId " << ntupleId;
507 tools::ntuple_booking* ntupleBooking
510 if ( ! ntupleBooking ) {
513 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
514 G4Exception(
"G4RootNtupleManager::CreateNtupleDColumn()",
520 G4int index = ntupleBooking->columns().size();
522 ntupleBooking->add_column<
double>(
name);
524 ntupleBooking->add_column<
double>(
name, *vector);
528 if ( ntupleDescription->
fNtuple ) {
530 tools::wroot::ntuple::column<double>* column
531 = ntupleDescription->
fNtuple->create_column<
double>(
name);
535 ntupleDescription->
fNtuple->create_column<
double>(
name, *vector);
544 description << name <<
" ntupleId " << ntupleId;
559 description << name <<
" ntupleId " << ntupleId;
568 tools::ntuple_booking* ntupleBooking
571 if ( ! ntupleBooking ) {
574 <<
"Ntuple " << ntupleId <<
" has to be created first. ";
575 G4Exception(
"G4RootNtupleManager::CreateNtupleSColumn()",
581 G4int index = ntupleBooking->columns().size();
582 ntupleBooking->add_column<std::string>(
name);
585 if ( ntupleDescription->
fNtuple ) {
586 tools::wroot::ntuple::column_string* column
587 = ntupleDescription->
fNtuple->create_column_string(name);
596 description << name <<
" ntupleId " << ntupleId;
645 tools::wroot::ntuple::column<int>* column
649 description <<
" " <<
"ntupleId " << ntupleId
650 <<
" columnId " << columnId <<
" does not exist.";
651 G4Exception(
"G4RootNtupleManager::FillNtupleIColumn()",
660 description <<
" ntupleId " << ntupleId
661 <<
" columnId " << columnId <<
" value " << value;
671 tools::wroot::ntuple::column<float>* column
675 description <<
" " <<
"ntupleId " << ntupleId
676 <<
" columnId " << columnId <<
" does not exist.";
677 G4Exception(
"G4RootNtupleManager::FillNtupleFColumn()",
686 description <<
" ntupleId " << ntupleId
687 <<
" columnId " << columnId <<
" value " << value;
698 tools::wroot::ntuple::column<double>* column
702 description <<
" " <<
"ntupleId " << ntupleId
703 <<
" columnId " << columnId <<
" does not exist.";
704 G4Exception(
"G4RootNtupleManager::FillNtupleDColumn()",
713 description <<
" ntupleId " << ntupleId
714 <<
" columnId " << columnId <<
" value " << value;
725 tools::wroot::ntuple::column_string* column
729 description <<
" " <<
"ntupleId " << ntupleId
730 <<
" columnId " << columnId <<
" does not exist.";
731 G4Exception(
"G4RootNtupleManager::FillNtupleSColumn()",
740 description <<
" ntupleId " << ntupleId
741 <<
" columnId " << columnId <<
" value " << value;
753 description <<
" ntupleId " << ntupleId;
760 if ( ! ntupleDescription )
return false;
762 if ( ! ntupleDescription->
fNtuple ) {
764 description <<
" " <<
" ntupleId " << ntupleId
765 <<
" does not exist. ";
774 description <<
" " <<
" ntupleId " << ntupleId
775 <<
"adding row has failed.";
782 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)
std::map< G4int, tools::wroot::ntuple::column< float > * > fNtupleFColumnMap
std::ostringstream G4ExceptionDescription
virtual G4int CreateNtupleSColumn(const G4String &name)
tools::wroot::directory * fNtupleDirectory
std::map< G4int, tools::wroot::ntuple::column< int > * > fNtupleIColumnMap
virtual G4int CreateNtupleFColumn(const G4String &name, std::vector< float > *vector)
tools::wroot::ntuple::column< float > * GetNtupleFColumn(G4int ntupleId, G4int columnId) const
const G4AnalysisVerbose * GetVerboseL2() const
std::map< G4int, tools::wroot::ntuple::column_string * > fNtupleSColumnMap
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value)
std::vector< tools::wroot::ntuple * > fNtupleVector
void CreateNtuplesFromBooking()
std::vector< G4RootNtupleDescription * > fNtupleDescriptionVector
const G4AnalysisVerbose * GetVerboseL3() const
virtual ~G4RootNtupleManager()
const G4AnalysisVerbose * GetVerboseL4() const
std::map< G4int, tools::wroot::ntuple::column< double > * > fNtupleDColumnMap
tools::wroot::ntuple::column_string * GetNtupleSColumn(G4int ntupleId, G4int columnId) const
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 G4bool AddNtupleRow()
virtual G4bool FillNtupleSColumn(G4int columnId, const G4String &value)
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
virtual G4int CreateNtupleIColumn(const G4String &name, std::vector< int > *vector)
G4int fFirstNtupleColumnId
G4RootNtupleManager(const G4AnalysisManagerState &state)
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
virtual G4int CreateNtupleDColumn(const G4String &name, std::vector< double > *vector)
const G4AnalysisManagerState & fState