Logo ROOT  
Reference Guide
BatchHelpers.cxx
Go to the documentation of this file.
1// Author: Stephan Hageboeck, CERN 25 Feb 2019
2
3/*****************************************************************************
4 * RooFit
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2019, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17#include "BatchHelpers.h"
18
19namespace BatchHelpers {
20
21/**
22 * This function returns the minimum size of the non-zero-sized batches.
23 * \param[in] parameters Vector of spans to read sizes from.
24 * \return Smallest non-zero size found.
25 */
26size_t findSize(std::vector< RooSpan<const double> > parameters)
27{
28 size_t ret = std::numeric_limits<std::size_t>::max();
29 for (auto &param : parameters)
30 if (param.size()> 0 && param.size()<ret) ret=param.size();
31
32 return ret;
33}
34
35/* This function returns the minimum size of the non-zero-sized batches
36 * as well as the number of parameters that are batches, wrapped in a
37 * EvaluateInfo struct (see BatchHelpers.h). It will be used when the
38 * number of parameters is > 3 and the BracketAdapterWithMask will be used.
39 */
40EvaluateInfo getInfo(std::vector<const RooRealProxy*> parameters, size_t begin, size_t batchSize)
41{
42 EvaluateInfo ret = {SIZE_MAX, 0};
43 for (const auto par : parameters) {
44 RooSpan<const double> span = par->getValBatch(begin,batchSize);
45 if ( !span.empty() ) {
46 ret.nBatches++;
47 if (span.size() < ret.size) ret.size = span.size();
48 }
49 }
50 return ret;
51}
52
53};
A simple container to hold a batch of data values.
Definition: RooSpan.h:32
constexpr std::span< T >::index_type size() const noexcept
Definition: RooSpan.h:123
constexpr bool empty() const noexcept
Definition: RooSpan.h:127
size_t findSize(std::vector< RooSpan< const double > > parameters)
This function returns the minimum size of the non-zero-sized batches.
EvaluateInfo getInfo(std::vector< const RooRealProxy * > parameters, size_t begin, size_t batchSize)