| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# HbookCnv::H1DCnv Class Reference

`#include <H1DCnv.h>`

Inheritance diagram for HbookCnv::H1DCnv:

[legend]
Collaboration diagram for HbookCnv::H1DCnv:

[legend]
List of all members.

## Detailed Description

Definition at line 30 of file H1DCnv.h.

## Public Member Functions
virtual StatusCode | createObj (IOpaqueAddress *pAddr, DataObject *&pObj)
| Create the transient representation of an object.
virtual StatusCode | updateObj (IOpaqueAddress *pAddr, DataObject *pObj)
| Update the transient object from the other representation.
virtual StatusCode | updateRep (IOpaqueAddress *pAddr, DataObject *pObj)
| Update the converted representation of a transient object.
| H1DCnv (ISvcLocator *svc)
| Standard constructor.
| H1DCnv (const CLID &clid, ISvcLocator *svc)
| Standard constructor.
virtual | ~H1DCnv ()
| Standard destructor.
## Static Public Member Functions
static const CLID & | classID ()
| Inquire class type.
## Protected Member Functions
virtual StatusCode | book (IOpaqueAddress *pAddr, DataObject *pObj)
| Book 1 D histogram.
## Friends
class | CnvFactory< H1DCnv >

## Constructor & Destructor Documentation

HbookCnv::H1DCnv::H1DCnv | ( | ISvcLocator * | svc | ) | `[inline]`

Standard constructor.

Definition at line 45 of file H1DCnv.h.

References HbookCnv::HConverter::m_deleteAfterSave, and HbookCnv::HConverter::m_prefix.

    00045                                : HConverter( classID(), svc )  {
    00046       m_prefix = "/stat";
    00047       m_deleteAfterSave = true;
    00048     }

HbookCnv::H1DCnv::H1DCnv | ( | const CLID & | clid,
|  | ISvcLocator * | svc |
| ) |  |  | `[inline]`

Standard constructor.

Definition at line 50 of file H1DCnv.h.

References HbookCnv::HConverter::m_deleteAfterSave, and HbookCnv::HConverter::m_prefix.

    00050                                                  : HConverter( clid, svc )  {
    00051       m_prefix = "/stat";
    00052       m_deleteAfterSave = true;
    00053     }

virtual HbookCnv::H1DCnv::~H1DCnv | ( |  | ) | `[inline, virtual]`

Standard destructor.

Definition at line 55 of file H1DCnv.h.

    00055                        {
    00056     }

## Member Function Documentation

static const CLID& HbookCnv::H1DCnv::classID | ( |  | ) | `[inline, static]`

Inquire class type.

Definition at line 34 of file H1DCnv.h.

References CLID_H1D.

    00034                                      {
    00035       return CLID_H1D;
    00036     }

StatusCode HbookCnv::H1DCnv::createObj | ( | IOpaqueAddress * | pAddr,
|  | DataObject *& | pObj |
| ) |  |  | `[virtual]`

Create the transient representation of an object.

Reimplemented from Converter.

Definition at line 130 of file H1DCnv.cpp.

References IOpaqueAddress::addRef(), Converter::dataProvider(), StatusCode::FAILURE, HGIVE(), HIX, HKIND, IRegistry::identifier(), IOpaqueAddress::ipar(), std::vector< _Tp, _Alloc >::push_back(), HbookCnv::HConverter::readObject(), DataObject::registry(), IOpaqueAddress::registry(), IRegistry::setAddress(), and updateObj().

    00132 {
    00133   //MsgStream log(msgSvc(), "HHistoCnv");
    00134
    00135   IHistogramFactory* pFac = dynamic_cast<IHistogramFactory*>(dataProvider());
    00136   if ( 0 != pAddr && pFac ) {
    00137     std::string loc = pAddr->registry()->identifier();
    00138     long id = pAddr->ipar()[0];
    00139     if ( readObject(loc, id).isSuccess() )  {
    00140       std::string tit;
    00141       int nx, ny, nwt, lpaw;
    00142       float xmi, xma, ymi, yma;
    00143       ::HGIVE(id, tit, nx, xmi, xma, ny, ymi, yma, nwt, lpaw);
    00144       long kind[32];
    00145       ::HKIND(id, kind, "A", 1);
    00146
    00147       if ( 0 == kind[5] ) {
    00148         pAddr->addRef();
    00149         refpObj = dynamic_cast<DataObject*>(pFac->createHistogram1D(loc,tit,
    00150                                                                     nx,xmi,xma));
    00151       }
    00152       else {
    00153         std::vector<double> binEdges;
    00154         float val;
    00155         for ( int i = 1; i <= nx; ++i ) {
    00156           ::HIX(id, i, val);
    00157           binEdges.push_back(val);
    00158         }
    00159         binEdges.push_back(xma);
    00160         pAddr->addRef();
    00161         refpObj = dynamic_cast<DataObject*>(pFac->createHistogram1D(loc,tit,
    00162                                                                     binEdges));
    00163       }
    00164
    00165       refpObj->registry()->setAddress(pAddr);
    00166       StatusCode sc = updateObj(pAddr, refpObj);
    00167       pAddr->release();
    00168       return sc;
    00169     }
    00170   }
    00171   return StatusCode::FAILURE;
    00172 }

StatusCode HbookCnv::H1DCnv::updateObj | ( | IOpaqueAddress * | pAddr,
|  | DataObject * | pObj |
| ) |  |  | `[virtual]`

Update the transient object from the other representation.

Reimplemented from Converter.

Definition at line 175 of file H1DCnv.cpp.

References StatusCode::FAILURE, HDELET, HEXIST, HI, HIE, HSTATI(), IRegistry::identifier(), IOpaqueAddress::ipar(), HbookCnv::HConverter::readObject(), IOpaqueAddress::registry(), and StatusCode::SUCCESS.

Referenced by createObj().

    00176                                                           {
    00177   IHistogram1D* h = dynamic_cast<IHistogram1D*>(pObj);
    00178   if ( 0 != h && 0 != pAddr ) {
    00179     int    id  = pAddr->ipar()[0]; // Histogram ID
    00180     std::string loc = pAddr->registry()->identifier();
    00181     if ( !::HEXIST( id ) )  {
    00182       readObject(loc, id);
    00183     }
    00184     if ( ::HEXIST( id ) )  {
    00185       const  IAxis& x = h->axis();
    00186       int    nBinX    = x.bins();         // Number of bins
    00187       double xLow     = x.lowerEdge();    // Histogram lower edge
    00188       double xHigh    = x.upperEdge();    // Histogram upper edge
    00189       double x_uflow  = xLow  - 1.0;      // Underflow coordinate
    00190       double x_oflow  = xHigh + 1.0;      // Overflow coordinate
    00191       double height = 0, err = 0, mean = 0, rms = 0,
    00192             centre = 0, sumOfHeights = 0, equivEntries = 0;
    00193       h->reset();
    00194       for ( int i = 0; i < nBinX; i++ )  {
    00195         centre = h->binMean(i);
    00196         height = ::HI (id, i+1);
    00197         err    = ::HIE(id, i+1);
    00198         sumOfHeights += height;
    00199         // Unfortunately IHistogram1D does not support to set bins
    00200         // and bin errors....errors will be SQRT(height)
    00201         h->fill(centre, height);
    00202       }
    00203       // Underflow bins: also here no error filling possible
    00204     //centre = h->binMean(AIDA::IAxis::UNDERFLOW_BIN);
    00205       height = ::HI(id, 0);
    00206       sumOfHeights += height;
    00207       h->fill(x_uflow, height);
    00208       // Overflow bins: also here no error filling possible
    00209     //centre = h->binMean(AIDA::IAxis::OVERFLOW_BIN);
    00210       height = ::HI(id, nBinX+1);
    00211       sumOfHeights += height;
    00212       h->fill(x_oflow, height);
    00213       // Set the correct MEAN and RMS vales in the HBOOK histogram
    00214       mean = ::HSTATI(id, 1, " ", 0);
    00215       rms  = ::HSTATI(id, 2, " ", 0);
    00216       equivEntries = ::HSTATI(id, 3, " ", 0);
    00217       //h->SET_MEAN_RMS( id, mean, rms, sumOfHeights, equivEntries );
    00218       ::HDELET(id);
    00219       return StatusCode::SUCCESS;
    00220     }
    00221   }
    00222   return StatusCode::FAILURE;
    00223 }

StatusCode HbookCnv::H1DCnv::updateRep | ( | IOpaqueAddress * | pAddr,
|  | DataObject * | pObj |
| ) |  |  | `[virtual]`

Update the converted representation of a transient object.

Reimplemented from Converter.

Definition at line 67 of file H1DCnv.cpp.

References StatusCode::FAILURE, HFILL, HPAKE, IOpaqueAddress::ipar(), SET_MEAN_RMS(), and StatusCode::SUCCESS.

    00068                                                           {
    00069   IHistogram1D* h = dynamic_cast<IHistogram1D*>(pObj);
    00070   if ( 0 != h ) {
    00071     const  IAxis& x = h->axis();
    00072     int    histoID  = pAddr->ipar()[0]; // Histogram ID
    00073     int    nBinX    = x.bins();         // Number of bins
    00074     float  xLow     = float(x.lowerEdge());    // Histogram lower edge
    00075     float  xHigh    = float(x.upperEdge());    // Histogram upper edge
    00076     float  x_uflow  = xLow  - 1.0F;      // Underflow coordinate
    00077     float  x_oflow  = xHigh + 1.0F;      // Overflow coordinate
    00078
    00079     int    entries  = 0;                // Number of entries in a bin
    00080     float  height   = 0.;               // Height if a bin
    00081     float  centre   = 0.;               // Mean of a bin
    00082     float  weight   = 0.;               // height / entries
    00083     float *errs     = new float[nBinX]; // Array of bin errors
    00084     int    i, j     = 0;
    00085
    00086     // Fill the HBOOK 1D histogram (with fixed or variable binning)
    00087     for ( i = 0; i < nBinX; i++ )  {
    00088       errs[i] = float(h->binError(i));
    00089       height  = float(h->binHeight(i));
    00090       if( 0 != height ) {
    00091         centre  = float(h->binMean(i));
    00092         entries = h->binEntries(i);
    00093         weight  = height / entries;
    00094         for( j = 0; j < entries; j++ ) {
    00095           ::HFILL(histoID, centre, 0.0, weight);
    00096         }
    00097       }
    00098     }
    00099     ::HPAKE(histoID,errs);
    00100     delete [] errs;
    00101
    00102
    00103     // Underflow bins
    00104     entries          = h->binEntries( AIDA::IAxis::UNDERFLOW_BIN );
    00105     height           = float(h->binHeight( AIDA::IAxis::UNDERFLOW_BIN ));
    00106     weight  = height / entries;
    00107     for( j = 0; j < entries; j++ ) {
    00108       ::HFILL(histoID, x_uflow, 0.0, weight);
    00109     }
    00110     // Overflow bins
    00111     entries          = h->binEntries( AIDA::IAxis::OVERFLOW_BIN );
    00112     height           = float(h->binHeight( AIDA::IAxis::OVERFLOW_BIN ));
    00113     weight  = height / entries;
    00114     for( j = 0; j < entries; j++ ) {
    00115       ::HFILL(histoID, x_oflow, 0.0, weight);
    00116     }
    00117
    00118     // Set the correct MEAN and RMS vales in the HBOOK histogram
    00119     float mean          = (float) h->mean();
    00120     float rms           = (float) h->rms();
    00121     float sumOfHeights  = (float) h->sumBinHeights();
    00122     float equivEntries  = (float) h->equivalentBinEntries();
    00123     ::SET_MEAN_RMS( histoID, mean, rms, sumOfHeights, equivEntries );
    00124     return StatusCode::SUCCESS;
    00125   }
    00126   return StatusCode::FAILURE;
    00127 }

StatusCode HbookCnv::H1DCnv::book | ( | IOpaqueAddress * | pAddr,
|  | DataObject * | pObj |
| ) |  |  | `[protected, virtual]`

Book 1 D histogram.

Reimplemented from HbookCnv::HConverter.

Definition at line 40 of file H1DCnv.cpp.

References StatusCode::FAILURE, HBOOK1(), HBOOKB(), HIDOPT(), and StatusCode::SUCCESS.

    00040                                                                      {
    00041   IHistogram1D* h = dynamic_cast<IHistogram1D*>(pObj);
    00042   if ( 0 != h ) {
    00043     int idh = pAdd->ipar()[0];
    00044     const IAxis& x = h->axis();
    00045     int nBinX = x.bins();      // Number of bins in the axis X
    00046
    00047     if ( x.isFixedBinning() ) {
    00048       ::HBOOK1(idh, h->title(), nBinX, float(x.lowerEdge()), float(x.upperEdge()));
    00049       ::HIDOPT(idh, "STAT");
    00050     }
    00051     else {
    00052       float *edges = new float[nBinX+1];
    00053       for ( int i = 0; i < nBinX; i++ )
    00054         edges[i] = float(x.binLowerEdge(i));
    00055
    00056       edges[nBinX] = float(x.upperEdge());
    00057       ::HBOOKB(idh, h->title(), nBinX, edges);
    00058       delete [] edges;
    00059     }
    00060
    00061     return StatusCode::SUCCESS;
    00062   }
    00063   return StatusCode::FAILURE;
    00064 }

## Friends And Related Function Documentation

friend class CnvFactory< H1DCnv >`[friend]`

Definition at line 31 of file H1DCnv.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/HbookCnv/v14r13/src/H1DCnv.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/HbookCnv/v14r13/src/H1DCnv.cpp