当前位置: 首页>>代码示例>>C++>>正文


C++ Timing::convert2bool方法代码示例

本文整理汇总了C++中Timing::convert2bool方法的典型用法代码示例。如果您正苦于以下问题:C++ Timing::convert2bool方法的具体用法?C++ Timing::convert2bool怎么用?C++ Timing::convert2bool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timing的用法示例。


在下文中一共展示了Timing::convert2bool方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadAnalysisParametersHistograms

void ParameterLoaderAnaysis::loadAnalysisParametersHistograms(ifstream &inputFileStream, HistoSetup &hSetup){
    //Variable Declaration
    bool bExitSuccess;
    
    pair<string,string> pair_strParam;
    
    string strLine;
    
    vector<string> vec_strList;
    
    //Loop through the section
    while ( getlineNoSpaces(inputFileStream, strLine) ) {
        bExitSuccess = false;
        
	//Debugging
	//cout<<"loadAnalysisParametersHistograms (Base Level); strLine = " << strLine << endl;

        //Does the user want to comment out this line?
        if ( 0 == strLine.compare(0,1,"#") ) continue;
        
        //Has this section ended?
        if ( 0 == strLine.compare(strSecEnd_Uniformity_Hiso) ) break;
        
        //Get Parameter Pairing
        pair_strParam = Timing::getParsedLine(strLine, bExitSuccess);
        
        //transform field name to upper case
        transform(pair_strParam.first.begin(),pair_strParam.first.end(),pair_strParam.first.begin(),toupper);
        
        //Parse pair
        if (bExitSuccess) { //Case: Parameter Fetched Successfully
            if( 0 == pair_strParam.first.compare("HISTO_BINRANGE") ){
                //Get comma separated list
                vec_strList = Timing::getCharSeparatedList(pair_strParam.second,',');
                
                //Debugging
                //for(int i=0; i<vec_strList.size(); ++i){
                //	cout<<"vec_strList["<<i<<"] = " << vec_strList[i] << endl;
                //}
                
                if (vec_strList.size() >= 2) { //Case: at least 2 numbers
                    //Fetch
                    hSetup.fHisto_xLower = Timing::stofSafe(pair_strParam.first, vec_strList[0]);
                    hSetup.fHisto_xUpper = Timing::stofSafe(pair_strParam.first, vec_strList[1]);
                    
                    //Reset to ensure they are both correctly lower & upper values
                    hSetup.fHisto_xLower = std::min(hSetup.fHisto_xLower, hSetup.fHisto_xUpper);
                    hSetup.fHisto_xUpper = std::max(hSetup.fHisto_xLower, hSetup.fHisto_xUpper);
                    
                    //Tell the user they entered more than what was expected
                    if (vec_strList.size() > 2) { //Case: 3 or more numbers
                        printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ( "Sorry you entered 3 or more numbers for " + pair_strParam.first + "\n" ).c_str() );
                        printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", "\tI have only used the first two and ignored the rest:\n" );
                        printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ("\t" + getString( hSetup.fHisto_xLower ) ).c_str() );
                        printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ("\t" + getString( hSetup.fHisto_xUpper ) ).c_str() );
                    } //End Case: 3 or more numbers
                } //End Case: at least 2 numbers
                else{ //Case: Not enough numbers
                    if (vec_strList.size() == 1) { //Case: only 1 number entered
                        hSetup.fHisto_xUpper = Timing::stofSafe(pair_strParam.first, vec_strList[0]);
                    } //End Case: only 1 number entered
                    
                    //Reset to ensure they are both correctly lower & upper values
                    hSetup.fHisto_xLower = std::min(hSetup.fHisto_xLower, hSetup.fHisto_xUpper);
                    hSetup.fHisto_xUpper = std::max(hSetup.fHisto_xLower, hSetup.fHisto_xUpper);
                    
                    //Output to User
                    printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ( "Sorry I was expecting a comma separated list of 2 numbers for: " + pair_strParam.first + "\n" ).c_str() );
                    printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", "\tRight now I have set:\n" );
                    printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ("\t" + getString( hSetup.fHisto_xLower ) ).c_str() );
                    printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ("\t" + getString( hSetup.fHisto_xUpper ) ).c_str() );
                } //End Case: Not enough numbers
            } //End Case: Assign Histo Bin Range
            /*else if( 0 == pair_strParam.first.compare("HISTO_NAME") ) {
                hSetup.strHisto_Name = pair_strParam.second;
            }*/
            else if( 0 == pair_strParam.first.compare("HISTO_NUMBINS") ){
                hSetup.iHisto_nBins = Timing::stoiSafe(pair_strParam.first, pair_strParam.second);
            }
            else if( 0 == pair_strParam.first.compare("HISTO_XTITLE") ){
                hSetup.strHisto_Title_X = pair_strParam.second;
            }
            else if( 0 == pair_strParam.first.compare("HISTO_YTITLE") ){
                hSetup.strHisto_Title_Y = pair_strParam.second;
            }
            else if( 0 == pair_strParam.first.compare("PERFORM_FIT") ){
                hSetup.bFit = convert2bool(pair_strParam.second, bExitSuccess);
            }
            else{ //Case: Parameter not recognized
                printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms","Error!!! Parameter Not Recognized:\n");
                printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms",( "\tField = " + pair_strParam.first + "\n" ).c_str() );
                printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms",( "\tValue = " + pair_strParam.second + "\n" ).c_str() );

            } //End Case: Parameter not recognized
        } //End Case: Parameter Fetched Successfully
        else{ //Case: Parameter was NOT fetched Successfully
            printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms","Error!!!  I didn't parse parameter correctly\n");
            printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms",("\tCurrent line: " + strLine).c_str() );
        } //End Case: Parameter was NOT fetched Successfully
    } //End Loop through Section
//.........这里部分代码省略.........
开发者ID:jhallan,项目名称:CMS_GEM_Analysis_Framework,代码行数:101,代码来源:ParameterLoaderAnaysis.cpp


注:本文中的Timing::convert2bool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。