CMS 3D CMS Logo

Functions

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFunctions.h File Reference

#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <iostream>

Go to the source code of this file.

Functions

int factorial (int n)
 factorial function
bool hexStringToInt64 (const std::string &, std::vector< unsigned long long > &)
template<class T >
bool stringToNumber (T &tmpl, const std::string &str, std::ios_base &(*f)(std::ios_base &))

Function Documentation

int factorial ( int  n)
bool hexStringToInt64 ( const std::string &  ,
std::vector< unsigned long long > &   
)

convert a hex string to a vector of 64-bit integers, with the vector size depending on the string size return false in case of error

Definition at line 18 of file L1GlobalTriggerFunctions.cc.

References LogTrace.

Referenced by L1GtCorrelationCondition::evaluateCondition().

                                                 {

    int iVec = 0;
    size_t initialPos = 0;
    unsigned long long iValue = 0ULL;

    do {

        iValue = 0ULL;

        if (stringToNumber<unsigned long long> (iValue,
                hexString.substr(initialPos, 16), std::hex)) {

            LogTrace("L1GlobalTrigger") << "\n  String " << hexString.substr(
                    initialPos, 16) << " converted to hex value 0x" << std::hex
                    << iValue << std::dec << std::endl;

            vecInt64[iVec] = iValue;
        } else {
            LogTrace("L1GlobalTrigger")
                    << "\nstringToNumber failed to convert string "
                    << hexString.substr(initialPos, 16) << std::endl;

            return false;
        }

        initialPos = +16;
        iVec++;
    } while (hexString.size() >= (initialPos + 16));

    return true;
}
template<class T >
bool stringToNumber ( T tmpl,
const std::string &  str,
std::ios_base &(*)(std::ios_base &)  f 
)

convert a string to a integer-type number the third parameter of stringToNumber should be one of std::hex, std::dec or std::oct

Definition at line 23 of file L1GlobalTriggerFunctions.h.

References f, and cmsPerfPublish::fail().

                                         {

    std::istringstream iss(str);
    return !(iss >> f >> tmpl).fail();

}