| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# HbookName.h File Reference

few useful function to construct names of Hbook histograms and directories functions are imported from Tools/LoKi and Calo/CaloUtils packages More...

`#include <string>`
`#include <algorithm>`

Include dependency graph for HbookName.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | GAUDIALG_HBOOKNAME_H 1
## Functions
std::string | dirHbookName (const std::string &addr, const int maxLen=16)
| Simple function to convert any valid Gaudi address (name in Transient Store) to address, which is simultaneously valid for Hbook directory.
std::string | histoHbookName (const std::string &addr, const int maxLen=8)
| Simple function to convert any valid Gaudi address(name in Transient Store) to address, which is simultaneously valid for Hbook histogram.

## Detailed Description

few useful function to construct names of Hbook histograms and directories functions are imported from Tools/LoKi and Calo/CaloUtils packages

Author:
  Vanya BELYAEV Ivan.Belyaev@itep.ru

Date:
  2002-07-25

Definition in file HbookName.h.

## Define Documentation

#define GAUDIALG_HBOOKNAME_H 1

Definition at line 4 of file HbookName.h.

## Function Documentation

std::string @32::dirHbookName | ( | const std::string & | addr,
|  | const int | maxLen = `16` |
| ) |  |  | `[inline, static]`

Simple function to convert any valid Gaudi address (name in Transient Store) to address, which is simultaneously valid for Hbook directory.

examples: "verylongname" --> "verylong/name"

Parameters:

  | old | old address
  | maxLen | maximum allowed length of directory name (16 for Hbook)

Returns:
  new address

Author:
  Vanya BELYAEV Ivan.Belyaev@itep.ru

Date:
  06/07/2001

Definition at line 35 of file HbookName.h.

    00037   {
    00038     // ignore empty locations
    00039     if( addr.empty() ) { return std::string(); }
    00040     //
    00041     std::string old( addr );
    00042     // remove long names
    00043     if( 0 < maxLen &&  maxLen < (int) old.size() )
    00044     {
    00045       std::string::iterator p1,p2;
    00046       p1 = old.begin();
    00047       const char sep('/');
    00048       while( old.end() != p1 )
    00049       {
    00050         p1 =
    00051           std::find_if( p1        ,
    00052                         old.end() ,
    00053                         std::bind2nd(std::not_equal_to<char>(),sep));
    00054         p2 = std::find( p1 , old.end() , sep ) ;
    00055         if( ( p2 - p1 ) <= (int) maxLen  ) { p1 = p2 ; continue ; }
    00056         old.insert( p1 + maxLen , sep ) ;
    00057         p1 = old.begin() ;
    00058       }
    00059     }
    00061     return old;
    00062   }

std::string @32::histoHbookName | ( | const std::string & | addr,
|  | const int | maxLen = `8` |
| ) |  |  | `[inline, static]`

Simple function to convert any valid Gaudi address(name in Transient Store) to address, which is simultaneously valid for Hbook histogram.

examples: "verylongname/116" --> "verylong/name/116" "verylongname" --> "verylong/name/1" "somename/here/" --> "somename/here/1" "directory/object" --> "director/y/object/1"

Parameters:

  | old | old address
  | maxLen | maximum allowed length of directory name (8 for Hbook)

Returns:
  new address

Author:
  Vanya BELYAEV Ivan.Belyaev@itep.ru

Date:
  06/07/2001

Definition at line 82 of file HbookName.h.

    00084   {
    00085     // ignore empty locations
    00086     if( addr.empty() ) { return std::string(); }
    00087     //
    00088     std::string old( addr );
    00089     { // make valid histogram ID (integer)
    00090       std::string::size_type pos
    00091         = old.find_last_of( '/' );
    00092       if      ( std::string::npos == pos ) { old += "/1" ; }
    00093       else if ( old.size() - 1    == pos ) { old += '1'  ; }
    00094       else
    00095       {
    00096         const int id =
    00097           atoi( std::string( old , pos + 1 , std::string::npos ).c_str() );
    00098         if( 0 == id ) { old+="/1"; }
    00099       }
    00100     }
    00101     // remove long names
    00102     if( 0 < maxLen &&  maxLen < (int) old.size() )
    00103     {
    00104       std::string::iterator p1,p2;
    00105       p1 = old.begin();
    00106       const char sep('/');
    00107       while( old.end() != p1 )
    00108       {
    00109         p1 =
    00110           std::find_if( p1        ,
    00111                         old.end() ,
    00112                         std::bind2nd(std::not_equal_to<char>(),sep));
    00113         p2 = std::find( p1 , old.end() , sep ) ;
    00114         if( ( p2 - p1 ) <= (int) maxLen  ) { p1 = p2 ; continue ; }
    00115         old.insert( p1 + maxLen , sep ) ;
    00116         p1 = old.begin() ;
    00117       }
    00118     }
    00119     //
    00120     return old;
    00121   }