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


C++ Trace::SetBaseline方法代码示例

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


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

示例1: Analyze

void WaveformAnalyzer::Analyze(Trace &trace, const ChannelConfiguration &cfg) {
    TraceAnalyzer::Analyze(trace, cfg);

    if (trace.IsSaturated() || trace.empty() || ignoredTypes_.find(cfg.GetType()) != ignoredTypes_.end()) {
        trace.SetHasValidAnalysis(false);
        EndAnalyze();
        return;
    }

    pair<unsigned int, unsigned int> range = cfg.GetWaveformBoundsInSamples();

    //First we calculate the position of the maximum.
    pair<unsigned int, double> max;
    try {
        max = TraceFunctions::FindMaximum(trace, cfg.GetTraceDelayInSamples());
    } catch (range_error &ex) {
        trace.SetHasValidAnalysis(false);
        cout << "WaveformAnalyzer::Analyze - " << ex.what() << endl;
        EndAnalyze();
        return;
    }

    //If the position of the maximum doesn't give us enough bins on the
    // baseline to calculate the average baseline then we're going to set
    // some of the variables to be used later to zero and end the analysis of
    // the waveform now.
    if (max.first - range.first < TraceFunctions::minimum_baseline_length) {
#ifdef VERBOSE
        cout << "WaveformAnalyzer::Analyze - The low bound for the trace overlaps with the minimum bins for the"
        "baseline." << endl;
#endif
        trace.SetHasValidAnalysis(false);
        EndAnalyze();
        return;
    }

    try {
        //Next we calculate the baseline and its standard deviation
        pair<double, double> baseline = TraceFunctions::CalculateBaseline(trace, make_pair(0, max.first - range.first));

        //For well behaved traces the standard deviation of the baseline
        // shouldn't ever be more than 1-3 ADC units. However, for traces
        // that are not captured properly, we can get really crazy values
        // here the SiPM often saw values as high as 20. We will put in a
        // hard limit of 50 as a cutoff since anything with a standard
        // deviation of this high will never be something we want to analyze.
        static const double extremeBaselineVariation = 50;
        if (baseline.second >= extremeBaselineVariation) {
            trace.SetHasValidAnalysis(false);
            EndAnalyze();
            return;
        }

        //Subtract the baseline from the maximum value.
        max.second -= baseline.first;

        vector<double> traceNoBaseline;
        for (unsigned int i = 0; i < trace.size(); i++)
            traceNoBaseline.push_back(trace[i] - baseline.first);

        //Finally, we calculate the QDC in the waveform range and subtract
        // the baseline from it.
        pair<unsigned int, unsigned int> waveformRange(max.first - range.first, max.first + range.second);
        double qdc = TraceFunctions::CalculateQdc(traceNoBaseline, waveformRange);

        //Now we are going to set all the different values into the trace.
        trace.SetQdc(qdc);
        trace.SetBaseline(baseline);
        trace.SetMax(max);
        trace.SetExtrapolatedMax(make_pair(max.first,
                                           TraceFunctions::ExtrapolateMaximum(trace, max).first - baseline.first));
        trace.SetTraceSansBaseline(traceNoBaseline);
        trace.SetWaveformRange(waveformRange);
        trace.SetHasValidAnalysis(true);
    } catch (range_error &ex) {
        trace.SetHasValidAnalysis(false);
        cout << "WaveformAnalyzer::Analyze - " << ex.what() << endl;
        EndAnalyze();
        return;
    }
}
开发者ID:spaulaus,项目名称:paass,代码行数:81,代码来源:WaveformAnalyzer.cpp


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