| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# HbookName.h File Reference

## 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.

`#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)
std::string | histoHbookName (const std::string &addr, const int maxLen=8)

## Define Documentation

#define GAUDIALG_HBOOKNAME_H 1

Definition at line 4 of file HbookName.h.

## Function Documentation

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

Definition at line 37 of file HbookName.h.

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

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

Definition at line 86 of file HbookName.h.

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