17 : batchSize_(
batchSize), sizes_(sizes), lastPadding_(lastPadding) {
24 auto pos = rule.find(
":");
25 if (
pos == std::string::npos) {
26 throw cms::Exception(
"InvalidBatchRule") <<
"invalid batch rule format: " << ruleString;
29 rule = rule.substr(
pos + 1);
32 std::vector<size_t> sizes;
34 while (!rule.empty()) {
36 sizes.push_back(std::stoi(rule.substr(0,
pos)));
37 sumSizes += sizes.back();
38 rule =
pos == std::string::npos ?
"" : rule.substr(
pos + 1);
44 <<
"sum of composite batch sizes is smaller than target batch size: " << ruleString;
57 throw cms::Exception(
"EmptySizes") <<
"no batch sizes provided for stitching";
64 <<
"padding " <<
lastPadding_ <<
" must be smaller than last size " << lastSize;
69 for (
const size_t&
s :
sizes_) {
74 <<
"padding " <<
lastPadding_ <<
" must not be larger than sum of sizes " << sizeSum;
81 <<
"batch size " <<
batchSize_ <<
" does not match sum of sizes - padding " << sizeSum;
95 for (
size_t i = 0;
i < rule.
nSizes();
i++) {
102 std::vector<size_t> sizes;
103 size_t lastPadding = 0;
108 if (
std::find(availableBatchSizes.begin(), availableBatchSizes.end(),
batchSize) != availableBatchSizes.end()) {
111 size_t smallestBatchSize = *std::min_element(availableBatchSizes.begin(), availableBatchSizes.end());
114 lastPadding =
rest == 0 ? 0 : (smallestBatchSize -
rest);
115 sizes.resize(
n, smallestBatchSize);
const BatchRule & getRule(size_t batchSize) const
void setRule(const BatchRule &rule)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
BatchRule(size_t batchSize, const std::vector< size_t > &sizes, size_t lastPadding=0)
size_t getLastPadding() const
size_t getBatchSize() const
std::ostream & operator<<(std::ostream &out, const BatchRule &rule)
const std::vector< size_t > & getSizes() const
std::vector< size_t > sizes_
std::map< size_t, BatchRule > rules_
void setDefaultRule(size_t batchSize, const std::vector< size_t > &availableBatchSizes)