48    fNtupleHbookIdOffset(-1),
    49    fNtupleDescriptionVector(),
    55 ExG4HbookNtupleManager::~ExG4HbookNtupleManager()
    59   std::vector<ExG4HbookNtupleDescription*>::iterator it;  
    60   for (it = fNtupleDescriptionVector.begin(); it != fNtupleDescriptionVector.end(); it++ ) {
    70 void ExG4HbookNtupleManager::SetNtupleHbookIdOffset()
    74   if ( fNtupleHbookIdOffset == -1 ) {
    76       fNtupleHbookIdOffset = 0;
    78       fNtupleHbookIdOffset = 1;
    80     if ( fNtupleHbookIdOffset > 0 ) {
    82       description << 
"Ntuple will be defined in HBOOK with ID = G4_firstNtupleId + 1";
    83       G4Exception(
"ExG4HbookNtupleManager::SetNtupleHbookIdOffset()",
    90 void ExG4HbookNtupleManager::CreateNtuplesFromBooking()
    94   if ( ! fNtupleDescriptionVector.size() ) 
return;     
    97   SetNtupleHbookIdOffset();
   100   std::vector<ExG4HbookNtupleDescription*>::iterator itn;  
   101   for (itn = fNtupleDescriptionVector.begin(); itn != fNtupleDescriptionVector.end(); itn++ ) {
   103     tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
   104     if ( ! ntupleBooking ) 
continue;
   112         ->
Message(
"create from booking", 
"ntuple", ntupleBooking->name());
   116     fFileManager->CreateNtupleDirectory();
   117     G4int hbookIndex = fNtupleHbookIdOffset + index + fFirstId;
   122       = 
new tools::hbook::wntuple(hbookIndex, 
G4cout, *ntupleBooking);
   123     fNtupleVector.push_back((*itn)->fNtuple);  
   125     if ( ntupleBooking->columns().size() ) {
   127       const std::vector<tools::column_booking>& columns 
   128         = ntupleBooking->columns();
   129       std::vector<tools::column_booking>::const_iterator it;
   131       for ( it = columns.begin(); it!=columns.end(); ++it) {
   132         if ( it->cls_id() == tools::_cid(
int(0) ) ) {
   133           (*itn)->fNtupleIColumnMap[counter++] 
   134             = (*itn)->fNtuple->find_column<
int>(it->name());
   136         else if( it->cls_id() == tools::_cid(
float(0) ) ) {
   137           (*itn)->fNtupleFColumnMap[counter++] 
   138             = (*itn)->fNtuple->find_column<
float>(it->name());
   140         else if(it->cls_id()== tools::_cid(
double(0))) {
   141           (*itn)->fNtupleDColumnMap[counter++] 
   142             = (*itn)->fNtuple->find_column<
double>(it->name());
   147                       << 
"Unsupported column type " << it->name();
   148           G4Exception(
"G4HbookAnalysisManager::CreateNtupleFromBooking()",
   157       ->
Message(
"create from booking", 
"ntuple", ntupleBooking->name());
   163 tools::hbook::wntuple::column<int>*    
   164 ExG4HbookNtupleManager::GetNtupleIColumn(
G4int ntupleId, 
G4int columnId)
 const   166   ExG4HbookNtupleDescription* ntupleDecription
   167     = GetNtupleInFunction(ntupleId, 
"GetNtupleIColumn");
   168   if ( ! ntupleDecription ) 
return 0;
   170   std::map<G4int, tools::hbook::wntuple::column<int>* >& ntupleIColumnMap
   171     = ntupleDecription->fNtupleIColumnMap;
   172   std::map<G4int, tools::hbook::wntuple::column<int>* >::const_iterator it
   173     = ntupleIColumnMap.find(columnId);
   174   if ( it == ntupleIColumnMap.end() ) {
   176     description << 
"      "  << 
"ntupleId " << ntupleId
   177                 << 
"column " << columnId << 
" does not exist.";
   178     G4Exception(
"G4HbookAnalysisManager::GetNtupleIColumn()",
   187 tools::hbook::wntuple::column<float>*  
   188 ExG4HbookNtupleManager::GetNtupleFColumn(
G4int ntupleId, 
G4int columnId)
 const   190   ExG4HbookNtupleDescription* ntupleDecription
   191     = GetNtupleInFunction(ntupleId, 
"GetNtupleFColumn");
   192   if ( ! ntupleDecription ) 
return 0;
   194   std::map<G4int, tools::hbook::wntuple::column<float>* >& ntupleFColumnMap
   195     = ntupleDecription->fNtupleFColumnMap;
   196   std::map<G4int, tools::hbook::wntuple::column<float>* >::const_iterator it
   197     = ntupleFColumnMap.find(columnId);
   198   if ( it == ntupleFColumnMap.end() ) {
   200     description << 
"      "  << 
"ntupleId " << ntupleId
   201                 << 
"column " << columnId << 
" does not exist.";
   202     G4Exception(
"G4HbookAnalysisManager::GetNtupleFColumn()",
   211 tools::hbook::wntuple::column<double>* 
   212 ExG4HbookNtupleManager::GetNtupleDColumn(
G4int ntupleId, 
G4int columnId)
 const   214   ExG4HbookNtupleDescription* ntupleDecription
   215     = GetNtupleInFunction(ntupleId, 
"GetNtupleDColumn");
   216   if ( ! ntupleDecription ) 
return 0;
   218   std::map<G4int, tools::hbook::wntuple::column<double>* >& ntupleDColumnMap
   219     = ntupleDecription->fNtupleDColumnMap;
   220   std::map<G4int, tools::hbook::wntuple::column<double>* >::const_iterator it
   221     = ntupleDColumnMap.find(columnId);
   222   if ( it == ntupleDColumnMap.end() ) {
   224     description << 
"      "  << 
"ntupleId " << ntupleId
   225                 << 
"column " << columnId << 
" does not exist.";
   226     G4Exception(
"G4HbookAnalysisManager::GetNtupleDColumn()",
   239   std::vector<ExG4HbookNtupleDescription*>::iterator it3;  
   240   for (it3 = fNtupleDescriptionVector.begin(); it3 != fNtupleDescriptionVector.end(); it3++ ) {
   241     delete (*it3)->fNtuple;
   244   fNtupleVector.clear(); 
   252 ExG4HbookNtupleDescription* ExG4HbookNtupleManager::GetNtupleInFunction(
   257   G4int index = 
id - fFirstId;
   258   if ( index < 0 || index >= 
G4int(fNtupleDescriptionVector.size()) ) {
   260       G4String inFunction = 
"G4HbookAnalysisManager::";
   261       inFunction += functionName;
   263       description << 
"      " << 
"ntuple " << 
id << 
" does not exist.";
   269   return fNtupleDescriptionVector[
index];
   281   if ( fFileManager->IsFile() ) 
   282     fFileManager->CreateNtupleDirectory();
   290   G4int index = fNtupleDescriptionVector.size();
   291   ExG4HbookNtupleDescription* ntupleDescription
   292     = 
new ExG4HbookNtupleDescription();
   293   fNtupleDescriptionVector.push_back(ntupleDescription);  
   296   ntupleDescription->fNtupleBooking 
   297     = 
new tools::ntuple_booking(name, title);
   301   SetNtupleHbookIdOffset();
   305   if ( fFileManager->IsFile() ) {
   306     G4int hbookIndex = fNtupleHbookIdOffset + index + fFirstId;
   307     ntupleDescription->fNtuple 
   308       = 
new tools::hbook::wntuple(hbookIndex, name);
   310     fNtupleVector.push_back(ntupleDescription->fNtuple);       
   316     description << name << 
" ntupleId " << index + fFirstId; 
   321   return index + fFirstId;
   325 G4int ExG4HbookNtupleManager::CreateNtupleIColumn(
const G4String& name,
   326                                                   std::vector<int>* vector)
   328   G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
   329   return CreateNtupleIColumn(ntupleId, name, vector);
   333 G4int ExG4HbookNtupleManager::CreateNtupleFColumn(
const G4String& name,
   334                                                   std::vector<float>* vector)
   336   G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
   337   return CreateNtupleFColumn(ntupleId, name, vector);
   341 G4int ExG4HbookNtupleManager::CreateNtupleDColumn(
const G4String& name,
   342                                                   std::vector<double>* vector)
   344   G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
   345   return CreateNtupleDColumn(ntupleId, name, vector);
   349 G4int ExG4HbookNtupleManager::CreateNtupleSColumn(
const G4String& name)
   351   G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
   352   return CreateNtupleSColumn(ntupleId, name);
   356 void ExG4HbookNtupleManager::FinishNtuple()
   358   G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
   359   FinishNtuple(ntupleId);
   363 G4int ExG4HbookNtupleManager::CreateNtupleIColumn(
G4int ntupleId, 
   365                                                     std::vector<int>* vector)
   371       << 
"Vector columns are not supported in HBOOK."; 
   372     G4Exception(
"(ExG4HbookNtupleManager::CreateNtupleIColumn)",
   380     description << name << 
" ntupleId " << ntupleId; 
   385   ExG4HbookNtupleDescription* ntupleDescription
   386     = GetNtupleInFunction(ntupleId, 
"CreateNtupleIColumn");
   387   tools::ntuple_booking* ntupleBooking
   388     = ntupleDescription->fNtupleBooking;  
   390   if ( ! ntupleBooking ) {
   393                 << 
"Ntuple " << ntupleId << 
" has to be created first. ";
   394     G4Exception(
"G4HbookAnalysisManager::CreateNtupleIColumn()",
   400   G4int index = ntupleBooking->columns().size();
   401   ntupleBooking->add_column<
int>(
name);  
   404   if ( ntupleDescription->fNtuple ) {
   405     tools::hbook::wntuple::column<int>* column 
   406       = ntupleDescription->fNtuple->create_column<
int>(
name);  
   407     ntupleDescription->fNtupleIColumnMap[
index] = column;
   410   fLockFirstNtupleColumnId = 
true;
   415     description << name << 
" ntupleId " << ntupleId; 
   420   return index + fFirstNtupleColumnId;       
   424 G4int ExG4HbookNtupleManager::CreateNtupleFColumn(
G4int ntupleId, 
   426                                                   std::vector<float>* vector)
   432       << 
"Vector columns are not supported in HBOOK."; 
   433     G4Exception(
"(ExG4HbookNtupleManager::CreateNtupleFColumn)",
   441     description << name << 
" ntupleId " << ntupleId; 
   446   ExG4HbookNtupleDescription* ntupleDescription
   447     = GetNtupleInFunction(ntupleId, 
"CreateNtupleFColumn");
   448   tools::ntuple_booking* ntupleBooking
   449     = ntupleDescription->fNtupleBooking;  
   451   if ( ! ntupleBooking ) {
   454                 << 
"Ntuple " << ntupleId << 
" has to be created first. ";
   455     G4Exception(
"G4HbookAnalysisManager::CreateNtupleFColumn()",
   461   G4int index = ntupleBooking->columns().size();
   462   ntupleBooking->add_column<
float>(
name);  
   465   if ( ntupleDescription->fNtuple ) {
   466     tools::hbook::wntuple::column<float>* column 
   467       = ntupleDescription->fNtuple->create_column<
float>(
name);  
   468     ntupleDescription->fNtupleFColumnMap[
index] = column;
   471   fLockFirstNtupleColumnId = 
true;
   476     description << name << 
" ntupleId " << ntupleId; 
   481   return index + fFirstNtupleColumnId;       
   486 G4int ExG4HbookNtupleManager::CreateNtupleDColumn(
G4int ntupleId, 
   488                                                   std::vector<double>* vector)
   494       << 
"Vector columns are not supported in HBOOK."; 
   495     G4Exception(
"(ExG4HbookNtupleManager::CreateNtupleDColumn)",
   503     description << name << 
" ntupleId " << ntupleId; 
   508   ExG4HbookNtupleDescription* ntupleDescription
   509     = GetNtupleInFunction(ntupleId, 
"CreateNtupleDColumn");
   510   tools::ntuple_booking* ntupleBooking
   511     = ntupleDescription->fNtupleBooking;  
   513   if ( ! ntupleBooking ) {
   516                 << 
"Ntuple " << ntupleId << 
" has to be created first. ";
   517     G4Exception(
"G4HbookAnalysisManager::CreateNtupleDColumn()",
   523   G4int index = ntupleBooking->columns().size();
   524   ntupleBooking->add_column<
double>(
name);  
   527   if ( ntupleDescription->fNtuple ) {
   528     tools::hbook::wntuple::column<double>* column 
   529       = ntupleDescription->fNtuple->create_column<
double>(
name);  
   530     ntupleDescription->fNtupleDColumnMap[
index] = column;
   533   fLockFirstNtupleColumnId = 
true;
   538     description << name << 
" ntupleId " << ntupleId; 
   543   return index + fFirstNtupleColumnId;       
   547 G4int ExG4HbookNtupleManager::CreateNtupleSColumn(
G4int , 
   552     << 
"Columns of string type are not supported in HBOOK."; 
   553   G4Exception(
"(ExG4HbookNtupleManager::CreateNtupleDColumn)",
   559 void ExG4HbookNtupleManager::FinishNtuple(
G4int ntupleId)
   561   ExG4HbookNtupleDescription* ntupleDescription
   562     = GetNtupleInFunction(ntupleId, 
"CreateNtupleDColumn");
   563   tools::hbook::wntuple* 
ntuple = ntupleDescription->fNtuple;  
   565   if ( ! ntuple ) 
return;
   570       ->
Message(
"finish", 
"ntuple", ntupleDescription->fNtupleBooking->name());
   574   tools::hbook::CHCDIR(
"//PAWC/LUN1",
" ");
   580       ->
Message(
"finish", 
"ntuple", ntupleDescription->fNtupleBooking->name());
   585 G4bool ExG4HbookNtupleManager::FillNtupleIColumn(
G4int columnId, 
G4int value)
   587   return FillNtupleIColumn(fFirstId, columnId, value);
   593   return FillNtupleFColumn(fFirstId, columnId, value);
   599   return FillNtupleDColumn(fFirstId, columnId, value);
   603 G4bool ExG4HbookNtupleManager::FillNtupleSColumn(
G4int columnId, 
   606   return FillNtupleSColumn(fFirstId, columnId, value);
   610 G4bool ExG4HbookNtupleManager::AddNtupleRow()
   612   return AddNtupleRow(fFirstId);
   616 G4bool ExG4HbookNtupleManager::FillNtupleIColumn(
   625   tools::hbook::wntuple::column<int>* column 
   626     = GetNtupleIColumn(ntupleId, columnId);
   629     description << 
"      " << 
"ntupleId " <<  ntupleId
   630                 << 
"column " << columnId << 
" does not exist.";
   631     G4Exception(
"G4HbookAnalysisManager::FillNtupleIColumn()",
   640     description << 
" ntupleId " << ntupleId  
   641                 << 
" columnId " << columnId << 
" value " << value;
   648 G4bool ExG4HbookNtupleManager::FillNtupleFColumn(
   657   tools::hbook::wntuple::column<float>* column 
   658     = GetNtupleFColumn(ntupleId, columnId);
   661     description << 
"      " << 
"ntupleId " <<  ntupleId
   662                 << 
"column " << columnId << 
" does not exist.";
   663     G4Exception(
"G4HbookAnalysisManager::FillNtupleFColumn()",
   672     description << 
" ntupleId " << ntupleId  
   673                 << 
" columnId " << columnId << 
" value " << value;
   681 G4bool ExG4HbookNtupleManager::FillNtupleDColumn(
   690   tools::hbook::wntuple::column<double>* column 
   691     = GetNtupleDColumn(ntupleId, columnId);
   694     description << 
"      " << 
"ntupleId " <<  ntupleId
   695                 << 
"column " << columnId << 
" does not exist.";
   696     G4Exception(
"G4HbookAnalysisManager::FillNtupleDColumn()",
   705     description << 
" ntupleId " << ntupleId  
   706                 << 
" columnId " << columnId << 
" value " << value;
   714 G4bool ExG4HbookNtupleManager::FillNtupleSColumn(
   725     << 
"Columns of string type are not supported in HBOOK."; 
   726   G4Exception(
"(ExG4HbookNtupleManager::FillNtupleSColumn)",
   732 G4bool ExG4HbookNtupleManager::AddNtupleRow(
G4int ntupleId)
   742     description << 
" ntupleId " << ntupleId;  
   747   ExG4HbookNtupleDescription* ntupleDescription
   748     = GetNtupleInFunction(ntupleId, 
"AddNtupleRow");
   750   if ( ! ntupleDescription || ! ntupleDescription->fNtuple ) {
   752     description << 
"      " << 
" ntupleId " << ntupleId 
   753                 << 
" does not exist. ";
   754     G4Exception(
"G4HbookAnalysisManager::AddNtupleRow()",
   759   ntupleDescription->fNtuple->add_row();
   763     description << 
" ntupleId " << ntupleId;  
   771 tools::hbook::wntuple* ExG4HbookNtupleManager::GetNtuple()
 const   773   return GetNtuple(fFirstId);
   777 tools::hbook::wntuple* ExG4HbookNtupleManager::GetNtuple(
G4int ntupleId)
 const   779   ExG4HbookNtupleDescription* ntupleDescription
   780     = GetNtupleInFunction(ntupleId, 
"GetNtuple");
   782   return ntupleDescription->fNtuple;  
   786 G4bool ExG4HbookNtupleManager::SetNtupleHbookIdOffset(
G4int offset) 
   788   if ( fNtupleDescriptionVector.size() ) {
   791       << 
"Cannot set NtupleHbookIdOffset as some ntuples already exist.";
   792     G4Exception(
"G4HbookAnalysisManager::SetNtupleHbookIdOffset()",
   797   if ( fFirstId + offset < 1 ) {
   799     description << 
"The first ntuple HBOOK id must be >= 1.";
   800     G4Exception(
"G4HbookAnalysisManager::SetNtupleHbookIdOffset()",
   805   fNtupleHbookIdOffset = offset;
   812 void  ExG4HbookNtupleManager::SetActivation(
G4bool activation)
   814   std::vector<ExG4HbookNtupleDescription*>::iterator it;  
   815   for (it = fNtupleDescriptionVector.begin(); it != fNtupleDescriptionVector.end(); it++ ) {
   816     (*it)->fActivation = activation;
   821 void  ExG4HbookNtupleManager::SetActivation(
G4int ntupleId, 
G4bool activation)
   823   ExG4HbookNtupleDescription* ntupleDescription
   824     = GetNtupleInFunction(ntupleId, 
"SetActivation");
   825   if ( ! ntupleDescription ) 
return;
   827   ntupleDescription->fActivation = activation;
   831 G4bool  ExG4HbookNtupleManager::GetActivation(
G4int ntupleId)
 const   833   ExG4HbookNtupleDescription* ntupleDescription
   834     = GetNtupleInFunction(ntupleId, 
"GetActivation");
   835   if ( ! ntupleDescription ) 
return false;
   837   return ntupleDescription->fActivation;
 
std::ostringstream G4ExceptionDescription
 
const G4AnalysisVerbose * GetVerboseL2() const
 
const G4AnalysisManagerState & fState
 
G4bool GetIsActivation() const
 
G4GLOB_DLL std::ostream G4cout
 
Definition of the ExG4HbookNtupleManager class. 
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
ntupleExperimental Reset()
 
const G4AnalysisVerbose * GetVerboseL3() const
 
const G4AnalysisVerbose * GetVerboseL4() const
 
Definition of the ExG4HbookFileManager class. 
 
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const