1 #ifndef NPSTAT_NTNTUPLEFILL_HH_
2 #define NPSTAT_NTNTUPLEFILL_HH_
24 template <
class Ntuple>
28 typedef Ntuple ntuple_type;
44 const std::vector<unsigned long>& columnMap)
49 const unsigned long nCols = dest_->nColumns();
50 if (!nCols)
throw std::invalid_argument(
51 "In npstat::NtNtupleFill constructor: "
52 "can not fill zero-column ntuples");
53 const unsigned long mapLen = coordCols_.size();
54 if (mapLen != 0 && mapLen != nCols)
throw std::invalid_argument(
55 "In npstat::NtNtupleFill constructor: "
56 "incompatible number of elements in the column map");
57 buffer_.resize(nCols);
64 std::vector<unsigned long> coordCols_;
65 mutable std::vector<typename Ntuple::value_type> buffer_;
69 inline void accumulate(
const T* rowContents,
70 const unsigned long nCols)
const
72 const unsigned long dim = buffer_.size();
73 typename Ntuple::value_type * c = &buffer_[0];
74 if (coordCols_.empty())
76 if (nCols < dim)
throw std::invalid_argument(
77 "In npstat::NtNtupleFill::accumulate: "
78 "insufficient number of columns in the source ntuple");
79 for (
unsigned long i=0; i<dim; ++i)
80 c[i] =
static_cast<typename Ntuple::value_type
>(
85 const unsigned long* idx = &coordCols_[0];
86 for (
unsigned long i=0; i<dim; ++i)
87 c[i] =
static_cast<typename Ntuple::value_type
>(
96 template <
typename Ntuple>
99 const std::vector<unsigned long>& columnMap)
104 template <
typename Ntuple>
107 std::vector<unsigned long> dummyMap;
108 return NtNtupleFill<Ntuple>(&destination, dummyMap);
Definition: NtNtupleFill.hh:26
NtNtupleFill(Ntuple *destination, const std::vector< unsigned long > &columnMap)
Definition: NtNtupleFill.hh:43
Definition: AbsArrayProjector.hh:14
NtNtupleFill< Ntuple > make_NtNtupleFill(Ntuple &destination, const std::vector< unsigned long > &columnMap)
Definition: NtNtupleFill.hh:97