|
||||
File indexing completed on 2025-01-18 09:57:34
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #ifndef GAUDIALG_HBOOKNAME_H 0012 #define GAUDIALG_HBOOKNAME_H 1 0013 // Include files 0014 #include <algorithm> 0015 #include <string> 0016 0017 /** @file 0018 * few useful function to construct names of Hbook histograms 0019 * and directories 0020 * functions are imported from 0021 * Tools/LoKi and Calo/CaloUtils packages 0022 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 0023 * @date 2002-07-25 0024 */ 0025 0026 namespace { 0027 /** Simple function to convert any valid Gaudi address 0028 * (name in Transient Store) 0029 * to address, which is simultaneously valid for Hbook directory 0030 * 0031 * examples: 0032 * "verylongname" --> "verylong/name" 0033 * 0034 * @param old old address 0035 * @param maxLen maximum allowed length of directory name (16 for Hbook) 0036 * @return new address 0037 * 0038 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 0039 * @date 06/07/2001 0040 */ 0041 inline std::string dirHbookName( const std::string& addr, const int maxLen = 16 ) { 0042 // ignore empty locations 0043 if ( addr.empty() ) { return std::string(); } 0044 // 0045 std::string old( addr ); 0046 // remove long names 0047 if ( 0 < maxLen && maxLen < (int)old.size() ) { 0048 auto p1 = old.begin(); 0049 const char sep( '/' ); 0050 while ( old.end() != p1 ) { 0051 p1 = std::find_if( p1, old.end(), [&]( const char& c ) { return c != sep; } ); 0052 auto p2 = std::find( p1, old.end(), sep ); 0053 if ( ( p2 - p1 ) <= (int)maxLen ) { 0054 p1 = p2; 0055 continue; 0056 } 0057 old.insert( p1 + maxLen, sep ); 0058 p1 = old.begin(); 0059 } 0060 } 0061 /// 0062 return old; 0063 } 0064 0065 } // end of anonymous namespace 0066 0067 // ============================================================================ 0068 // The END 0069 // ============================================================================ 0070 #endif // GAUDIALG_HBOOKNAME_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |