| # 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::HRWNTupleCnv Class Reference

`#include <HRWNTupleCnv.h>`

Inheritance diagram for HbookCnv::HRWNTupleCnv:

[legend]
Collaboration diagram for HbookCnv::HRWNTupleCnv:

[legend]
List of all members.

## Detailed Description

Row wise NTuple converter class definition.

Description: Definition of the converter for row wise Ntuples using HBOOK

Dependencies:

- Base class: HNTupleCnv.h

History :

          +---------+----------------------------------------------+--------+
          |    Date |                 Comment                      | Who    |
          +---------+----------------------------------------------+--------+
          | 21/10/99| Initial version.                             | MF     |
          +---------+----------------------------------------------+--------+

Author: M.Frank Version: 1.0

Definition at line 49 of file HRWNTupleCnv.h.

## Public Member Functions
| HRWNTupleCnv (ISvcLocator *svc)
| Standard constructor.
virtual | ~HRWNTupleCnv ()
| Standard destructor.
## Static Public Member Functions
static const CLID & | classID ()
| Inquire class type.
## Protected Member Functions
virtual StatusCode | load (long id, INTuple *&refpObject)
| Create the transient representation of an object.
virtual StatusCode | book (long idh, const std::string &loc, INTuple *pObject)
| Book the N tuple.
virtual StatusCode | writeData (long idh, INTuple *pObject)
| Write N tuple data.
virtual StatusCode | readData (long idh, INTuple *pObject, long ievt)
| Read N tuple data.
## Friends
class | CnvFactory< HRWNTupleCnv >
| Creator needs access to constructor/destructor.

## Constructor & Destructor Documentation

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

Standard constructor.

Definition at line 60 of file HRWNTupleCnv.h.

    00060                                       : HNTupleCnv(svc, classID())    {
    00061     }

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

Standard destructor.

Definition at line 63 of file HRWNTupleCnv.h.

    00063                               {
    00064     }

## Member Function Documentation

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

Inquire class type.

Definition at line 56 of file HRWNTupleCnv.h.

References CLID_RowWiseTuple.

    00056                                     {
    00057       return CLID_RowWiseTuple;
    00058     }

StatusCode HbookCnv::HRWNTupleCnv::load | ( | long | id,
|  | INTuple *& | refpObject |
| ) |  |  | `[protected, virtual]`

Create the transient representation of an object.

Implements HbookCnv::HNTupleCnv.

Definition at line 204 of file HRWNTupleCnv.cpp.

References DataTypeInfo::BOOL, DataTypeInfo::CHAR, CLID_RowWiseTuple, INTupleSvc::create(), CREATE_RWNTUPLE_COL, std::basic_string< _CharT, _Traits, _Alloc >::data(), dataTypePolicy(), MSG::DEBUG, DataTypeInfo::DOUBLE, endreq(), MSG::ERROR, StatusCode::FAILURE, DataTypeInfo::FLOAT, FORTRAN_STYLE, HGNF, HGNPAR, HUNGARIAN_STYLE, DataTypeInfo::INT, StatusCode::isSuccess(), std::basic_string< _CharT, _Traits, _Alloc >::length(), DataTypeInfo::LONG, HbookCnv::HNTupleCnv::m_ntupleSvc, Converter::msgSvc(), DataTypeInfo::OBJECT_ADDR, RWNT_INFO(), DataTypeInfo::SHORT, StatusCode::SUCCESS, toupper(), DataTypeInfo::UCHAR, DataTypeInfo::UINT, DataTypeInfo::ULONG, USE_DATA_TYPES, and DataTypeInfo::USHORT.

    00204                                                                       {
    00205   MsgStream log(msgSvc(), "HbookNTupleCnv");
    00206   NTUPLEINFO tags;
    00207
    00208   memset(&tags,0,sizeof(tags));
    00209   tags.id = idh;
    00210   StatusCode status = ::RWNT_INFO(tags);
    00211   if ( status.isSuccess() && tags.numEnt > 0 )     {
    00212     NTuple::Tuple* pObj = 0;
    00213     status = m_ntupleSvc->create(CLID_RowWiseTuple, tags.title, pObj);
    00214     INTuple* ntup = dynamic_cast<INTuple*>(pObj);
    00215     if ( status.isSuccess() && 0 != ntup)   {
    00216       long size = 0, istat = 0;
    00217       std::string typ = "NONE";
    00218       float buffer[512];
    00219       std::string call = "HRWNTupleCnv::load";
    00220       ::HGNPAR( idh, call.data(), call.length());
    00221       // Make info compatible with column wise N-tuples
    00222       for ( int i = 0; i < tags.numVar; i++ )   {
    00223         ::strcpy(tags.block[i],"AUTO_BLK");
    00224       }
    00225       if ( dataTypePolicy() == USE_DATA_TYPES )   {
    00226         ::HGNF(idh, 1, buffer, istat);
    00227       }
    00228       else if ( dataTypePolicy() == FORTRAN_STYLE )   {
    00229         for ( int i = 0; i < tags.numVar; i++ )   {
    00230           char c1 = ::toupper(tags.name[i][0]);
    00231           if ( c1 >= 'I' && c1 <= 'N' )
    00232             buffer[i] = DataTypeInfo::INT;
    00233           else
    00234             buffer[i] = DataTypeInfo::FLOAT;
    00235         }
    00236       }
    00237       else if ( dataTypePolicy() == HUNGARIAN_STYLE )   {
    00238         for ( int i = 0; i < tags.numVar; i++ )   {
    00239           char c1 = ::toupper(tags.name[i][0]);
    00240           char c2 = ::toupper(tags.name[i][1]);
    00241           switch(c1)    {
    00242           case 'B':   buffer[i] = DataTypeInfo::BOOL;             break;
    00243           case 'C':   buffer[i] = DataTypeInfo::CHAR;             break;
    00244           case 'S':   buffer[i] = DataTypeInfo::SHORT;            break;
    00245           case 'I':   buffer[i] = DataTypeInfo::INT;              break;
    00246           case 'L':   buffer[i] = DataTypeInfo::LONG;             break;
    00247           case 'F':   buffer[i] = DataTypeInfo::FLOAT;            break;
    00248           case 'D':   buffer[i] = DataTypeInfo::DOUBLE;           break;
    00249           case 'O':   buffer[i] = DataTypeInfo::OBJECT_ADDR;      break;
    00250           case 'U':
    00251             switch(c2)    {
    00252             case 'C':   buffer[i] = DataTypeInfo::UCHAR;          break;
    00253             case 'S':   buffer[i] = DataTypeInfo::USHORT;         break;
    00254             case 'I':   buffer[i] = DataTypeInfo::UINT;           break;
    00255             case 'L':   buffer[i] = DataTypeInfo::ULONG;          break;
    00256             default:
    00257             log << MSG::ERROR << "Cannot Create Item for Var[" << i << "]: "
    00258                               << " Name:" << tags.name[i]
    00259                               << " Unknown data type" << endreq;
    00260             return StatusCode::FAILURE;
    00261             }
    00262             break;
    00263           default:
    00264             log << MSG::ERROR << "Cannot Create Item for Var[" << i << "]: "
    00265                               << " Name:" << tags.name[i]
    00266                               << " Unknown data type" << endreq;
    00267             return StatusCode::FAILURE;
    00268           }
    00269         }
    00270       }
    00271       else    {
    00272         for ( int i = 0; i < tags.numVar; i++ )   {
    00273           buffer[i] = float(DataTypeInfo::FLOAT);
    00274         }
    00275       }
    00276       if ( istat == 0 )   {
    00277         for ( int i = 0; i < tags.numVar; i++ )   {
    00278           INTupleItem* item = 0;
    00279           switch( long(buffer[i]) )   {
    00280             case DataTypeInfo::BOOL:              // bool
    00281               CREATE_RWNTUPLE_COL(i,ntup, bool)
    00282               break;
    00283             case DataTypeInfo::CHAR:              // char
    00284               CREATE_RWNTUPLE_COL(i,ntup, char)
    00285               break;
    00286             case DataTypeInfo::SHORT:             // short
    00287               CREATE_RWNTUPLE_COL(i,ntup, short)
    00288               break;
    00289             case DataTypeInfo::INT:               // int
    00290               CREATE_RWNTUPLE_COL(i,ntup, int)
    00291               break;
    00292             case DataTypeInfo::LONG:              // long
    00293               CREATE_RWNTUPLE_COL(i,ntup, long)
    00294               break;
    00295             case DataTypeInfo::UCHAR:             // unsigned char
    00296               CREATE_RWNTUPLE_COL(i,ntup, unsigned char)
    00297               break;
    00298             case DataTypeInfo::USHORT:            // unsigned short
    00299               CREATE_RWNTUPLE_COL(i,ntup, unsigned short)
    00300               break;
    00301             case DataTypeInfo::UINT:              // unsigned int
    00302               CREATE_RWNTUPLE_COL(i,ntup, unsigned int)
    00303               break;
    00304             case DataTypeInfo::ULONG:             // unsigned long
    00305               CREATE_RWNTUPLE_COL(i,ntup, unsigned long)
    00306               break;
    00307             case DataTypeInfo::FLOAT:             // float
    00308               CREATE_RWNTUPLE_COL(i,ntup, float)
    00309               break;
    00310             case DataTypeInfo::DOUBLE:            // double
    00311               CREATE_RWNTUPLE_COL(i,ntup, double)
    00312               break;
    00313             case DataTypeInfo::OBJECT_ADDR:
    00314               //CREATE_RWNTUPLE_COL(i,ntup, IOpaqueAddress*)
    00315               break;
    00316             default:
    00317               break;
    00318           }
    00319           if ( item )    {
    00320             ntup->items().push_back(item);
    00321             log << MSG::DEBUG << "Create Var[" << i << "]: "
    00322                 << item->typeName() << "[1]"
    00323                 << " Name:" << tags.name[i]
    00324                 << "[" << tags.frange[i][0] << "," << tags.frange[i][1]
    00325                 << "]" << endreq;
    00326           }
    00327           else    {
    00328             log << MSG::ERROR << "Cannot Create Item for Var[" << i << "]: "
    00329                               << " Name:" << tags.name[i] << endreq;
    00330           }
    00331         }
    00332         log << MSG::DEBUG << "Total buffer size of NTuple: " << size << " Bytes." << endreq;
    00333         refpObject = ntup;
    00334         return StatusCode::SUCCESS;
    00335       }
    00336     }
    00337   }
    00338   return StatusCode::FAILURE;
    00339 }

StatusCode HbookCnv::HRWNTupleCnv::book | ( | long | idh,
|  | const std::string & | loc,
|  | INTuple * | pObject |
| ) |  |  | `[protected, virtual]`

Book the N tuple.

Implements HbookCnv::HNTupleCnv.

Definition at line 37 of file HRWNTupleCnv.cpp.

References dataTypePolicy(), MSG::DEBUG, endreq(), MSG::ERROR, StatusCode::FAILURE, HEXIST, HFN, HPRINT, MSG::INFO, MsgStream::isActive(), StatusCode::isSuccess(), std::basic_string< _CharT, _Traits, _Alloc >::length(), name, RWNT_BOOK(), std::vector< _Tp, _Alloc >::size(), StatusCode::SUCCESS, and USE_DATA_TYPES.

    00037                                                                                   {
    00038   MsgStream log(msgSvc(), "HbookRWNTupleCnv");
    00039   if ( !::HEXIST(idh) )    {
    00040     const INTuple::ItemContainer& items = nt->items();
    00041     NTUPLEINFO tags;
    00042     float buffer[512];
    00043     memset(&tags,0, sizeof(tags));
    00044     tags.id = idh;
    00045     tags.numVar = items.size();
    00046     strncpy(tags.rzdir, loc.data(), loc.length());
    00047     strncpy(tags.title, nt->title().data(), nt->title().length());
    00048     for (size_t length = items.size(), i = 0; i < length; i++ )    {
    00049       long len = items[i]->name().length();
    00050       long nam_len = (len > 8) ? 8 : len;
    00051       long pad_len=sizeof(tags.name[i])-nam_len-1;
    00052       ::strncpy(tags.name[i], items[i]->name().data(), nam_len);
    00053       ::memset(&tags.name[i][nam_len], ' ', pad_len);
    00054       buffer[i] = float(items[i]->type());
    00055     }
    00056     StatusCode status = ::RWNT_BOOK(tags);
    00057     if ( status.isSuccess() )   {
    00058       log << MSG::INFO << "Booked Row wise HBOOK N tuple with ID:" << idh
    00059           << " \"" << nt->title() << "\" in directory <" << loc << ">" << endreq;
    00060       if ( dataTypePolicy() == USE_DATA_TYPES )   {
    00061         ::HFN(idh, buffer);
    00062       }
    00063       log << MSG::DEBUG;
    00064       if ( log.isActive() ) ::HPRINT( idh );
    00065       return StatusCode::SUCCESS;
    00066     }
    00067     else    {
    00068       log << MSG::ERROR << "HBOOK N tuple " << idh
    00069           << "\"" << nt->title()
    00070           << "\" cannot be booked in directory <" << loc << ">" << endreq;
    00071     }
    00072   }
    00073   log << MSG::ERROR << "HBOOK N tuple " << idh << " \"" << nt->title()
    00074       << "\" already exists." << endreq;
    00075   return StatusCode::FAILURE;
    00076 }

StatusCode HbookCnv::HRWNTupleCnv::writeData | ( | long | idh,
|  | INTuple * | pObject |
| ) |  |  | `[protected, virtual]`

Write N tuple data.

Implements HbookCnv::HNTupleCnv.

Definition at line 80 of file HRWNTupleCnv.cpp.

References std::vector< _Tp, _Alloc >::begin(), DataTypeInfo::BOOL, DataTypeInfo::CHAR, DataTypeInfo::DOUBLE, std::vector< _Tp, _Alloc >::end(), DataTypeInfo::FLOAT, HFN, DataTypeInfo::INT, INTuple::items(), DataTypeInfo::LONG, DataTypeInfo::SHORT, StatusCode::SUCCESS, DataTypeInfo::UCHAR, DataTypeInfo::UINT, DataTypeInfo::ULONG, and DataTypeInfo::USHORT.

    00080                                                                   {
    00081   const INTuple::ItemContainer& items = nt->items();
    00082   INTuple::ItemContainer::const_iterator i;
    00083   float buffer[512], *buff = buffer;
    00084   for (i = items.begin(); i != items.end(); i++)    {
    00085     switch( (*i)->type() )   {
    00086     case DataTypeInfo::BOOL:              // bool
    00087       *buff++ = float( *(bool*)(*i)->buffer() );
    00088       break;
    00089     case DataTypeInfo::CHAR:              // char
    00090       *buff++ = float( *(char*)(*i)->buffer() );
    00091       break;
    00092     case DataTypeInfo::SHORT:             // short
    00093       *buff++ = float( *(short*)(*i)->buffer() );
    00094       break;
    00095     case DataTypeInfo::INT:               // int
    00096       *buff++ = float( *(int*)(*i)->buffer() );
    00097       break;
    00098     case DataTypeInfo::LONG:              // long
    00099       *buff++ = float( *(long*)(*i)->buffer() );
    00100       break;
    00101     case DataTypeInfo::UCHAR:             // unsigned char
    00102       *buff++ = float( *(unsigned char*)(*i)->buffer() );
    00103       break;
    00104     case DataTypeInfo::USHORT:            // unsigned short
    00105       *buff++ = float( *(unsigned short*)(*i)->buffer() );
    00106       break;
    00107     case DataTypeInfo::UINT:              // unsigned int
    00108       *buff++ = float( *(unsigned int*)(*i)->buffer() );
    00109       break;
    00110     case DataTypeInfo::ULONG:             // unsigned long
    00111       *buff++ = float( *(unsigned long*)(*i)->buffer() );
    00112       break;
    00113     case DataTypeInfo::FLOAT:             // float
    00114       *buff++ = *(float*)((*i)->buffer());
    00115       break;
    00116     case DataTypeInfo::DOUBLE:            // double
    00117       *buff++ = float( *(double*)(*i)->buffer() );
    00118       break;
    00119     default:
    00120       *buff++ = 0.0;
    00121       break;
    00122     }
    00123     (*i)->reset();
    00124   }
    00125   ::HFN(idh, buffer);
    00126   return StatusCode::SUCCESS;
    00127 }

StatusCode HbookCnv::HRWNTupleCnv::readData | ( | long | idh,
|  | INTuple * | pObject,
|  | long | ievt |
| ) |  |  | `[protected, virtual]`

Read N tuple data.

Implements HbookCnv::HNTupleCnv.

Definition at line 131 of file HRWNTupleCnv.cpp.

References std::vector< _Tp, _Alloc >::begin(), DataTypeInfo::BOOL, DataTypeInfo::CHAR, dataTypePolicy(), DataTypeInfo::DOUBLE, std::vector< _Tp, _Alloc >::end(), StatusCode::FAILURE, DataTypeInfo::FLOAT, HGN, HNOENT, DataTypeInfo::INT, INTuple::items(), DataTypeInfo::LONG, DataTypeInfo::OBJECT_ADDR, DataTypeInfo::SHORT, StatusCode::SUCCESS, DataTypeInfo::UCHAR, DataTypeInfo::UINT, DataTypeInfo::ULONG, USE_DATA_TYPES, and DataTypeInfo::USHORT.

    00131                                                                                  {
    00132   long istat = 0, numevt = 0, idn = 0;
    00133   float buffer[512], *buff = buffer;
    00134   StatusCode status = StatusCode::SUCCESS;
    00135   INTuple::ItemContainer& items = pObject->items();
    00136   ievt++;
    00137   if ( dataTypePolicy() == USE_DATA_TYPES )   {
    00138     ievt++;
    00139   }
    00140 //  ::HGNF(id, ievt, buffer, istat);
    00141   ::HGN(id, idn, ievt, buffer, istat);
    00142   ::HNOENT( id, numevt);
    00143   if ( istat == 0 && ievt <= numevt )   {
    00144     INTuple::ItemContainer::iterator i;
    00145     for (i = items.begin(); i != items.end(); i++)    {
    00146       try   {
    00147         long item_type = (*i)->type();
    00148         switch( item_type )   {
    00149         case DataTypeInfo::BOOL:              // bool
    00150           (dynamic_cast< NTuple::_Item<bool>* >(*i))->set((*buff++ < 0.000000001) ? false : true);
    00151           break;
    00152         case DataTypeInfo::CHAR:              // char
    00153           (dynamic_cast< NTuple::_Item<char>* >(*i))->set(char(*buff++));
    00154           break;
    00155         case DataTypeInfo::SHORT:             // short
    00156           (dynamic_cast< NTuple::_Item<short>* >(*i))->set(short(*buff++));
    00157           break;
    00158         case DataTypeInfo::INT:               // int
    00159           (dynamic_cast< NTuple::_Item<int>* >(*i))->set(int(*buff++));
    00160           break;
    00161         case DataTypeInfo::LONG:              // long
    00162           (dynamic_cast< NTuple::_Item<long>* >(*i))->set(long(*buff++));
    00163           break;
    00164         case DataTypeInfo::UCHAR:             // unsigned char
    00165           (dynamic_cast< NTuple::_Item<unsigned char>* >(*i))->set((unsigned char)(*buff++));
    00166           break;
    00167         case DataTypeInfo::USHORT:            // unsigned short
    00168           (dynamic_cast< NTuple::_Item<unsigned short>* >(*i))->set((unsigned short)(*buff++));
    00169           break;
    00170         case DataTypeInfo::UINT:              // unsigned int
    00171           (dynamic_cast< NTuple::_Item<unsigned int>* >(*i))->set((unsigned int)(*buff++));
    00172           break;
    00173         case DataTypeInfo::ULONG:             // unsigned long
    00174           (dynamic_cast< NTuple::_Item<unsigned long>* >(*i))->set((unsigned long)(*buff++));
    00175           break;
    00176         case DataTypeInfo::FLOAT:             // float
    00177           (dynamic_cast< NTuple::_Item<float>* >(*i))->set(float(*buff++));
    00178           break;
    00179         case DataTypeInfo::DOUBLE:            // double
    00180           (dynamic_cast< NTuple::_Item<double>* >(*i))->set(double(*buff++));
    00181           break;
    00182         case DataTypeInfo::OBJECT_ADDR:
    00183           (dynamic_cast< NTuple::_Item<IOpaqueAddress*>* >(*i))->set(0);
    00184           break;
    00185         default:
    00186           buff++;
    00187           break;
    00188         }
    00189       }
    00190       catch (...)     {
    00191         status = StatusCode::FAILURE;
    00192       }
    00193     }
    00194     return status;
    00195   }
    00196   return StatusCode::FAILURE;
    00197 }

## Friends And Related Function Documentation

friend class CnvFactory< HRWNTupleCnv >`[friend]`

Creator needs access to constructor/destructor.

Definition at line 52 of file HRWNTupleCnv.h.

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

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