2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
11 template <std::size_t N>
12 void trimmedMeanAndVariance(
13 const PufitMultiGrid<N> &grid,
19 // Construct a list of sorted tower energies
20 std::vector<double> sorted;
21 sorted.reserve(grid.nTowers());
22 for (const typename PufitMultiGrid<N>::Tower &tower : grid)
24 double sumEt = tower.sumEt(type);
26 std::lower_bound(sorted.begin(), sorted.end(), sumEt),
29 trimmedMeanAndVariance(sorted, trimFraction, mean, variance);
32 template <std::size_t N>
33 void unmaskedMeanAndVariance(
34 const PufitMultiGrid<N> &grid, std::size_t type, double &mean, double &variance)
37 double squaredSum = 0;
39 for (const typename PufitMultiGrid<N>::Tower &tower : grid)
44 double sumEt = tower.sumEt(type);
46 squaredSum += sumEt * sumEt;
49 variance = squaredSum / n - mean * mean;
52 template <typename Grid>
53 GridDisplacement selectGrid(
54 const PufitMultiGridSet<Grid> &grids, std::size_t type)
56 GridDisplacement maximum = NoDisplacement;
58 for (std::size_t d = 0; d < 4; ++d)
61 for (const typename Grid::Tower &tower : grids[GridDisplacement(d)])
63 sum += tower.sumEt(type);
66 maximum = GridDisplacement(d);
72 } // namespace PufitUtils