45 const G4int ExG4HbookH2Manager::fgkDefaultH2HbookIdOffset = 100;
 
   59 ExG4HbookH2Manager::~ExG4HbookH2Manager()
 
   65   std::vector<h2_booking*>::iterator it2;
 
   66   for ( it2 = fH2BookingVector.begin(); it2 != fH2BookingVector.end(); it2++ ) {
 
   76 void ExG4HbookH2Manager::SetH2HbookIdOffset()
 
   80   if ( fH2HbookIdOffset == -1 ) {
 
   86     if ( fH2HbookIdOffset > 0 ) {
 
   88       description << 
"H2 will be defined in HBOOK with ID = G4_firstHistoId + 1";
 
   89       G4Exception(
"ExG4HbookH2Manager::SetH1HbookIdOffset",
 
   96 void ExG4HbookH2Manager::CreateH2sFromBooking()
 
  102   if ( fH2Vector.size() || ( fH2BookingVector.size() == 0 ) ) 
return;       
 
  105   if ( fFileManager->GetHistoDirectoryName() != 
"" ) {
 
  106     G4String histoPath = 
"//PAWC/LUN1/";
 
  107     histoPath.
append(fFileManager->GetHistoDirectoryName().data());
 
  108     tools::hbook::CHCDIR(histoPath.
data(),
" ");
 
  113   std::vector<h2_booking*>::const_iterator it;
 
  114   for ( it = fH2BookingVector.begin(); it != fH2BookingVector.end(); ++it) {
 
  116     G4int id = index + fFirstId;    
 
  117     G4HnInformation* info = fHnManager->GetHnInformation(
id, 
"CreateH2FromBooking");
 
  119     G4int hbookIndex = fH2HbookIdOffset + index + fFirstId;
 
  123     if ( fState.GetVerboseL3() ) 
 
  124       fState.GetVerboseL3()->Message(
"create from booking", 
"h2", info->
fName);
 
  129       = 
new tools::hbook::h2(hbookIndex, (*it)->fTitle, 
 
  130                              (*it)->fNxbins, (*it)->fXmin, (*it)->fXmax,
 
  131                              (*it)->fNybins, (*it)->fYmin, (*it)->fYmax);
 
  132     fH2Vector.push_back(h2);
 
  135     if ( fState.GetVerboseL3() ) { 
 
  137       description << 
" name : " << info->
fName << 
" hbook index : " << hbookIndex; 
 
  138       fState.GetVerboseL3()->Message(
"create from booking", 
"h2", description);
 
  143   if ( fFileManager->GetHistoDirectoryName() != 
"" ) {
 
  145     tools::hbook::CHCDIR(
"//PAWC/LUN1",
" ");
 
  150 void ExG4HbookH2Manager::Reset()
 
  155   std::vector<tools::hbook::h2*>::iterator it2;
 
  156   for (it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) {
 
  165 h2_booking*  ExG4HbookH2Manager::GetH2Booking(
G4int id, 
G4bool warn)
 const  
  167   G4int index = 
id - fFirstId;
 
  168   if ( index < 0 || index >= 
G4int(fH2BookingVector.size()) ) {
 
  171       description << 
"      " << 
"histo " << 
id << 
" does not exist.";
 
  172       G4Exception(
"G4HbookAnalysisManager::GetH2Booking()",
 
  178   return fH2BookingVector[index];
 
  186 G4bool ExG4HbookH2Manager::WriteOnAscii(std::ofstream& )
 
  197 tools::hbook::h2*  ExG4HbookH2Manager::GetH2InFunction(
G4int id, 
 
  199                                       G4bool onlyIfActive)
 const 
  201   G4int index = 
id - fFirstId;
 
  202   if ( index < 0 || index >= 
G4int(fH2Vector.size()) ) {
 
  204       G4String inFunction = 
"ExG4HbookH2Manager::";
 
  205       inFunction += functionName;
 
  207       description << 
"      " << 
"histogram " << 
id << 
" does not exist.";
 
  214   if ( fState.GetIsActivation()  && onlyIfActive && ( ! fHnManager->GetActivation(
id) ) ) {
 
  218   return fH2Vector[index];
 
  236   if ( xbinSchemeName != 
"linear" || ybinSchemeName != 
"linear" ) {
 
  240       << 
"Logarithimc binning is not supported for H2.";
 
  246   if ( fState.GetVerboseL4() ) 
 
  247     fState.GetVerboseL4()->Message(
"create", 
"H2", name);
 
  251   G4int index = fH2BookingVector.size();
 
  262   h2_booking* h2Booking = 
new h2_booking(nxbins, xfcn(xmin), xfcn(xmax), 
 
  263                                          nybins, yfcn(ymin), yfcn(ymax)); 
 
  265   h2Booking->fTitle = newTitle;
 
  266   fH2BookingVector.push_back(h2Booking);
 
  268     ->AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName, 
 
  269                        xunit, yunit, xfcn, yfcn, xbinScheme, ybinScheme);
 
  272   SetH2HbookIdOffset();
 
  275   G4int hbookIndex = fH2HbookIdOffset + index + fFirstId;
 
  278   if ( fFileManager->IsFile() ) {
 
  280     G4String histoPath = 
"//PAWC/LUN1/";
 
  281     if ( fFileManager->GetHistoDirectoryName() != 
"" ) {
 
  282       histoPath.
append(fFileManager->GetHistoDirectoryName().data());
 
  284     tools::hbook::CHCDIR(histoPath.
data(),
" ");
 
  288       = 
new tools::hbook::h2(hbookIndex, title, 
 
  289                              nxbins, xfcn(xmin), xfcn(xmax), 
 
  290                              nybins, yfcn(ymin), yfcn(ymax));
 
  292     fH2Vector.push_back(h2);
 
  295     if ( fFileManager->GetHistoDirectoryName() != 
"" ) {
 
  296       tools::hbook::CHCDIR(
"//PAWC/LUN1",
" ");
 
  303     if ( fState.GetVerboseL2() ) {
 
  305       description << 
" name : " << name << 
" hbook index : " << hbookIndex; 
 
  306       fState.GetVerboseL2()->Message(
"create", 
"H2", description);
 
  310   fH2NameIdMap[
name] = index + fFirstId;
 
  311   return index + fFirstId;
 
  316                           const std::vector<G4double>& ,
 
  317                           const std::vector<G4double>& ,
 
  325     << 
"User defined binning is not supported for H2.";
 
  340   if ( xbinScheme != 
"linear" || ybinScheme != 
"linear" ) {
 
  344       << 
"Logarithimc binning is not supported for H2.";
 
  349   h2_booking* h2Booking = GetH2Booking(
id, 
false);
 
  352     description << 
"      " << 
"histogram " << 
id << 
" does not exist.";
 
  360   if ( fState.GetVerboseL4() ) 
 
  361     fState.GetVerboseL4()->Message(
"configure", 
"H2", info->
fName);
 
  370   h2Booking->fNxbins = nxbins;
 
  371   h2Booking->fXmin = xfcn(xmin);
 
  372   h2Booking->fXmax = xfcn(xmax);
 
  373   h2Booking->fNybins = nybins;
 
  374   h2Booking->fYmin = yfcn(ymin);
 
  375   h2Booking->fYmax = yfcn(ymax);
 
  385   fHnManager->SetActivation(
id, 
true); 
 
  387   G4String newTitle(h2Booking->fTitle);
 
  390   h2Booking->fTitle = newTitle;  
 
  393   if ( fH2Vector.size() ) {
 
  394     tools::hbook::h2* h2 = GetH2(
id);
 
  395     h2->configure(nxbins, xfcn(xmin), xfcn(xmax), 
 
  396                   nybins, yfcn(ymin), yfcn(ymax));
 
  404                             const std::vector<G4double>& ,
 
  405                             const std::vector<G4double>& ,
 
  413     << 
"User defined binning is not supported for H2.";
 
  423   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"ScaleH2", 
false, 
false);
 
  424   if ( ! h2 ) 
return false;
 
  426   return h2->scale(factor);
 
  434   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"FillH2", 
true, 
false);
 
  435   if ( ! h2 ) 
return false;
 
  437   if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(
id) ) ) 
return false; 
 
  443   if ( fState.GetVerboseL4() ) {
 
  445     description << 
" id " << 
id  
  446                 << 
" xvalue " << xvalue << 
" yvalue " << yvalue;
 
  447     fState.GetVerboseL4()->Message(
"fill", 
"H2", description);
 
  454 tools::hbook::h2*  ExG4HbookH2Manager::GetH2(
G4int id, 
G4bool warn,
 
  455                                                    G4bool onlyIfActive)
 const  
  457   return GetH2InFunction(
id, 
"GetH2", warn, onlyIfActive);
 
  463   std::map<G4String, G4int>::const_iterator it = fH2NameIdMap.find(name);
 
  464   if ( it ==  fH2NameIdMap.end() ) {  
 
  466       G4String inFunction = 
"ExG4HbookH2Manager::GetH2Id";
 
  468       description << 
"      " << 
"histogram " << name << 
" does not exist.";
 
  477 G4int ExG4HbookH2Manager::GetH2Nxbins(
G4int id)
 const 
  479   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2NXbins");
 
  480   if ( ! h2 ) 
return 0;
 
  482   return h2->axis_x().bins();
 
  490   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2Xmin");
 
  491   if ( ! h2 ) 
return 0;
 
  494   return info->
fXFcn(h2->axis_x().lower_edge()*info->
fXUnit);
 
  500   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2Xmax");
 
  501   if ( ! h2 ) 
return 0;
 
  504   return info->
fXFcn(h2->axis_x().upper_edge()*info->
fXUnit);
 
  510   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2XWidth", 
true, 
false);
 
  511   if ( ! h2 ) 
return 0;
 
  513   G4int nbins = h2->axis_x().bins();
 
  516     description << 
"    nbins = 0 (for h1 id = " << 
id << 
").";
 
  522   G4HnInformation* info = fHnManager->GetHnInformation(
id, 
"GetH2XWidth");
 
  523   return ( info->
fXFcn(h2->axis_x().upper_edge()) 
 
  524            - info->
fXFcn(h2->axis_x().lower_edge()))*info->
fXUnit/nbins;
 
  528 G4int ExG4HbookH2Manager::GetH2Nybins(
G4int id)
 const 
  530   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2NYbins");
 
  531   if ( ! h2 ) 
return 0;
 
  533   return h2->axis_y().bins();
 
  541   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2Ymin");
 
  542   if ( ! h2 ) 
return 0;
 
  545   return info->
fYFcn(h2->axis_y().lower_edge()*info->
fYUnit);
 
  551   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2Ymax");
 
  552   if ( ! h2 ) 
return 0;
 
  555   return info->
fYFcn(h2->axis_y().upper_edge()*info->
fYUnit);
 
  561   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2YWidth", 
true, 
false);
 
  562   if ( ! h2 ) 
return 0;
 
  564   G4int nbins = h2->axis_y().bins();
 
  567     description << 
"    nbins = 0 (for h1 id = " << 
id << 
").";
 
  573   G4HnInformation* info = fHnManager->GetHnInformation(
id, 
"GetH2YWidth");
 
  574   return ( info->
fYFcn(h2->axis_y().upper_edge()) 
 
  575            - info->
fYFcn(h2->axis_y().lower_edge()))*info->
fYUnit/nbins;
 
  581   h2_booking* h2Booking = GetH2Booking(
id, 
false);
 
  584     description << 
"      " << 
"histogram " << 
id << 
" does not exist.";
 
  585     G4Exception(
"G4HbookAnalysisManager::SetH2Title()",
 
  590   h2Booking->fTitle = title;
 
  597   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"SetH2XAxisTitle");
 
  598   if ( ! h2 ) 
return false;
 
  600   h2->add_annotation(tools::hbook::key_axis_x_title(), title);
 
  607   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"SetH2YAxisTitle");
 
  608   if ( ! h2 ) 
return false;
 
  610   h2->add_annotation(tools::hbook::key_axis_x_title(), title);
 
  617   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"SetH2ZAxisTitle");
 
  618   if ( ! h2 ) 
return false;
 
  620   h2->add_annotation(tools::hbook::key_axis_z_title(), title);
 
  627   h2_booking* h2Booking = GetH2Booking(
id, 
false);
 
  630     description << 
"      " << 
"histogram " << 
id << 
" does not exist.";
 
  631     G4Exception(
"G4HbookAnalysisManager::GetH2Title()",
 
  636   return h2Booking->fTitle;
 
  643   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2XAxisTitle");
 
  644   if ( ! h2 ) 
return "";
 
  647   G4bool result = h2->annotation(tools::hbook::key_axis_x_title(), title);
 
  650     description << 
"    Failed to get x_axis title for h2 id = " << 
id << 
").";
 
  662   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2YAxisTitle");
 
  663   if ( ! h2 ) 
return "";
 
  666   G4bool result = h2->annotation(tools::hbook::key_axis_y_title(), title);
 
  669     description << 
"    Failed to get y_axis title for h2 id = " << 
id << 
").";
 
  681   tools::hbook::h2* h2 = GetH2InFunction(
id, 
"GetH2ZAxisTitle");
 
  682   if ( ! h2 ) 
return "";
 
  685   G4bool result = h2->annotation(tools::hbook::key_axis_z_title(), title);
 
  688     description << 
"    Failed to get z_axis title for h2 id = " << 
id << 
").";
 
  698 G4bool ExG4HbookH2Manager::SetH2HbookIdOffset(
G4int offset) 
 
  700   if ( fH2Vector.size() ) {
 
  703       << 
"Cannot set H2HbookIdOffset as some H2 histogramms already exist.";
 
  704     G4Exception(
"G4HbookAnalysisManager::SetH2HbookIdOffset()",
 
  709   if ( fFirstId + offset < 1 ) {
 
  711     description << 
"The first histogram HBOOK id must be >= 1.";
 
  712     G4Exception(
"G4HbookAnalysisManager::SetH1HbookIdOffset()",
 
  717   fH2HbookIdOffset = offset;
 
std::ostringstream G4ExceptionDescription
 
G4double(* G4Fcn)(G4double)
 
void UpdateTitle(G4String &title, const G4String &unitName, const G4String &fcnName)
 
G4double GetUnitValue(const G4String &unit)
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
const char * data() const 
 
G4Fcn GetFunction(const G4String &fcnName)
 
G4String & append(const G4String &)
 
G4BinScheme GetBinScheme(const G4String &binSchemeName)
 
Definition of the ExG4HbookH2Manager class. 
 
Definition of the ExG4HbookFileManager class.