File indexing completed on 2025-04-19 09:13:41
0001
0002
0003
0004
0005
0006 #ifndef YODA_Profile_h
0007 #define YODA_Profile_h
0008
0009 #include "YODA/BinnedDbn.h"
0010
0011 namespace YODA {
0012
0013
0014 template <typename AxisT>
0015 class BinnedDbn<2, AxisT>
0016 : public DbnStorage<2, AxisT>,
0017 public XAxisMixin<BinnedDbn<2, AxisT>, AxisT>,
0018 public XStatsMixin<BinnedDbn<2, AxisT>> {
0019 public:
0020
0021 using ProfileT = BinnedDbn<2, AxisT>;
0022 using BaseT = DbnStorage<2, AxisT>;
0023 using FillType = typename BaseT::FillType;
0024 using BinType = typename BaseT::BinT;
0025 using Ptr = std::shared_ptr<ProfileT>;
0026
0027
0028 using BaseT::BaseT;
0029
0030 BinnedDbn() = default;
0031 BinnedDbn(const ProfileT&) = default;
0032 BinnedDbn(ProfileT&&) = default;
0033 BinnedDbn& operator =(const ProfileT&) = default;
0034 BinnedDbn& operator =(ProfileT&&) = default;
0035 using AnalysisObject::operator =;
0036
0037
0038
0039
0040 BinnedDbn(const BaseT& other) : BaseT(other) {}
0041
0042 BinnedDbn(const ProfileT& other, const std::string& path) : BaseT(other, path) {}
0043
0044
0045 BinnedDbn(BaseT&& other) : BaseT(std::move(other)) {}
0046
0047 BinnedDbn(ProfileT&& other, const std::string& path) : BaseT(std::move(other), path) {}
0048
0049
0050
0051
0052
0053
0054
0055 template <typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT>>
0056 BinnedDbn(size_t nbins, double lower, double upper,
0057 const std::string& path = "", const std::string& title = "")
0058 : BaseT({nbins}, {{lower, upper}}, path, title) {}
0059
0060
0061 ProfileT clone() const noexcept {
0062 return ProfileT(*this);
0063 }
0064
0065
0066 ProfileT* newclone() const noexcept {
0067 return new ProfileT(*this);
0068 }
0069
0070
0071 virtual int fill(const AxisT valX, const double valY, const double weight = 1.0, const double fraction = 1.0) {
0072 return BaseT::fill({valX, valY}, weight, fraction);
0073 }
0074
0075
0076 virtual int fill(FillType&& coords, const double weight = 1.0, const double fraction = 1.0) {
0077 return BaseT::fill(std::move(coords), weight, fraction);
0078 }
0079
0080
0081 size_t indexAt(const AxisT xCoord) const noexcept {
0082 return BaseT::binAt( {xCoord} ).index();
0083 }
0084
0085
0086 void maskBinAt(const AxisT xCoord, const bool status = true) noexcept {
0087 return BaseT::maskBin({xCoord}, status);
0088 }
0089
0090 };
0091
0092
0093
0094 template <typename AxisT1, typename AxisT2>
0095 class BinnedDbn<3, AxisT1, AxisT2>
0096 : public DbnStorage<3, AxisT1, AxisT2>,
0097 public XAxisMixin<BinnedDbn<3, AxisT1, AxisT2>, AxisT1>,
0098 public XStatsMixin<BinnedDbn<3, AxisT1, AxisT2>>,
0099 public YAxisMixin<BinnedDbn<3, AxisT1, AxisT2>, AxisT2>,
0100 public YStatsMixin<BinnedDbn<3, AxisT1, AxisT2>> {
0101 public:
0102
0103 using ProfileT = BinnedDbn<3, AxisT1, AxisT2>;
0104 using BaseT = DbnStorage<3, AxisT1, AxisT2>;
0105 using FillType = typename BaseT::FillType;
0106 using BinType = typename BaseT::BinT;
0107 using Ptr = std::shared_ptr<ProfileT>;
0108
0109
0110 using BaseT::BaseT;
0111
0112 BinnedDbn() = default;
0113 BinnedDbn(const ProfileT&) = default;
0114 BinnedDbn(ProfileT&&) = default;
0115 BinnedDbn& operator =(const ProfileT&) = default;
0116 BinnedDbn& operator =(ProfileT&&) = default;
0117 using AnalysisObject::operator =;
0118
0119
0120
0121
0122 BinnedDbn(const BaseT& other) : BaseT(other) {}
0123
0124 BinnedDbn(const ProfileT& other, const std::string& path) : BaseT(other, path) {}
0125
0126
0127 BinnedDbn(BaseT&& other) : BaseT(std::move(other)) {}
0128
0129 BinnedDbn(ProfileT&& other, const std::string& path) : BaseT(std::move(other), path) {}
0130
0131
0132
0133
0134
0135
0136
0137 template <typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT1, AxisT2>>
0138 BinnedDbn(size_t nbinsX, double lowerX, double upperX,
0139 size_t nbinsY, double lowerY, double upperY,
0140 const std::string& path, const std::string& title = "")
0141 : BaseT({nbinsX, nbinsY}, {{lowerX, upperX}, {lowerY, upperY}}, path, title) {}
0142
0143
0144 ProfileT clone() const noexcept {
0145 return ProfileT(*this);
0146 }
0147
0148
0149 ProfileT* newclone() const noexcept {
0150 return new ProfileT(*this);
0151 }
0152
0153
0154 virtual int fill(const AxisT1 valX, const AxisT2 valY, const double valZ, const double weight = 1.0, const double fraction = 1.0) {
0155 return BaseT::fill({valX, valY, valZ}, weight, fraction);
0156 }
0157
0158
0159 virtual int fill(FillType&& coords, const double weight = 1.0, const double fraction = 1.0) {
0160 return BaseT::fill(std::move(coords), weight, fraction);
0161 }
0162
0163
0164 BinType& bin(const size_t index) noexcept {
0165 return BaseT::bin(index);
0166 }
0167
0168
0169 const BinType& bin(const size_t index) const noexcept {
0170 return BaseT::bin(index);
0171 }
0172
0173
0174 BinType& bin(const size_t localX, const size_t localY) noexcept {
0175 return BaseT::bin( {localX, localY} );
0176 }
0177
0178
0179 const BinType& bin(const size_t localX, const size_t localY) const noexcept {
0180 return BaseT::bin( {localX, localY} );
0181 }
0182
0183
0184 BinType& binAt(const AxisT1 xCoord, const AxisT2 yCoord) noexcept {
0185 return BaseT::binAt( {xCoord, yCoord} );
0186 }
0187
0188
0189 const BinType& binAt(const AxisT1 xCoord, const AxisT2 yCoord) const noexcept {
0190 return BaseT::binAt( {xCoord, yCoord} );
0191 }
0192
0193
0194 size_t indexAt(const AxisT1 xCoord, const AxisT2 yCoord) const noexcept {
0195 return BaseT::binAt( {xCoord, yCoord} ).index();
0196 }
0197
0198
0199 void maskBinAt(const AxisT1 xCoord, const AxisT2 yCoord, const bool status = true) noexcept {
0200 return BaseT::maskBin({xCoord, yCoord}, status);
0201 }
0202
0203 };
0204
0205
0206
0207
0208 template <typename AxisT1, typename AxisT2, typename AxisT3>
0209 class BinnedDbn<4, AxisT1, AxisT2, AxisT3>
0210 : public DbnStorage<4, AxisT1, AxisT2, AxisT3>,
0211 public XAxisMixin<BinnedDbn<4, AxisT1, AxisT2, AxisT3>, AxisT1>,
0212 public XStatsMixin<BinnedDbn<4, AxisT1, AxisT2, AxisT3>>,
0213 public YAxisMixin<BinnedDbn<4, AxisT1, AxisT2, AxisT3>, AxisT3>,
0214 public YStatsMixin<BinnedDbn<4, AxisT1, AxisT2, AxisT3>> {
0215 public:
0216
0217 using ProfileT = BinnedDbn<4, AxisT1, AxisT2, AxisT3>;
0218 using BaseT = DbnStorage<4, AxisT1, AxisT2, AxisT3>;
0219 using FillType = typename BaseT::FillType;
0220 using BinType = typename BaseT::BinT;
0221 using Ptr = std::shared_ptr<ProfileT>;
0222
0223
0224 using BaseT::BaseT;
0225
0226 BinnedDbn() = default;
0227 BinnedDbn(const ProfileT&) = default;
0228 BinnedDbn(ProfileT&&) = default;
0229 BinnedDbn& operator =(const ProfileT&) = default;
0230 BinnedDbn& operator= (ProfileT&&) = default;
0231 using AnalysisObject::operator =;
0232
0233
0234
0235
0236 BinnedDbn(const BaseT& other) : BaseT(other) {}
0237
0238 BinnedDbn(const ProfileT& other, const std::string& path) : BaseT(other, path) {}
0239
0240
0241 BinnedDbn(BaseT&& other) : BaseT(std::move(other)) {}
0242
0243 BinnedDbn(ProfileT&& other, const std::string& path) : BaseT(std::move(other), path) {}
0244
0245
0246
0247
0248
0249
0250
0251 template <typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT1, AxisT2, AxisT3>>
0252 BinnedDbn(size_t nbinsX, double lowerX, double upperX,
0253 size_t nbinsY, double lowerY, double upperY,
0254 size_t nbinsZ, double lowerZ, double upperZ,
0255 const std::string& path, const std::string& title = "")
0256 : BaseT({nbinsX, nbinsY, nbinsZ},
0257 {{lowerX, upperX}, {lowerY, upperY},
0258 {lowerZ, upperZ}}, path, title) {}
0259
0260
0261 ProfileT clone() const noexcept {
0262 return ProfileT(*this);
0263 }
0264
0265
0266 ProfileT* newclone() const noexcept {
0267 return new ProfileT(*this);
0268 }
0269
0270
0271 virtual int fill(const AxisT1 valX, const AxisT2 valY, const AxisT3 valZ, const double valZplus,
0272 const double weight = 1.0, const double fraction = 1.0) {
0273 return BaseT::fill({valX, valY, valZ, valZplus}, weight, fraction);
0274 }
0275
0276
0277 virtual int fill(FillType&& coords, const double weight = 1.0, const double fraction = 1.0) {
0278 return BaseT::fill(std::move(coords), weight, fraction);
0279 }
0280
0281
0282 BinType& bin(const size_t index) noexcept {
0283 return BaseT::bin(index);
0284 }
0285
0286
0287 const BinType& bin(const size_t index) const noexcept {
0288 return BaseT::bin(index);
0289 }
0290
0291
0292 BinType& bin(const size_t localX, const size_t localY, const size_t localZ) noexcept {
0293 return BaseT::bin( {localX, localY, localZ} );
0294 }
0295
0296
0297 const BinType& bin(const size_t localX, const size_t localY, const size_t localZ) const noexcept {
0298 return BaseT::bin( {localX, localY, localZ} );
0299 }
0300
0301
0302 BinType& binAt(const AxisT1 xCoord, const AxisT2 yCoord, const AxisT3 zCoord) noexcept {
0303 return BaseT::binAt( {xCoord, yCoord, zCoord} );
0304 }
0305
0306
0307 const BinType& binAt(const AxisT1 xCoord, const AxisT2 yCoord, const AxisT3 zCoord) const noexcept {
0308 return BaseT::binAt( {xCoord, yCoord, zCoord} );
0309 }
0310
0311
0312 size_t indexAt(const AxisT1 xCoord, const AxisT2 yCoord, const AxisT3 zCoord) const noexcept {
0313 return BaseT::binAt( {xCoord, yCoord, zCoord} ).index();
0314 }
0315
0316
0317 void maskBinAt(const AxisT1 xCoord, const AxisT2 yCoord, const AxisT3 zCoord, const bool status = true) noexcept {
0318 return BaseT::maskBin({xCoord, yCoord, zCoord}, status);
0319 }
0320
0321 };
0322
0323
0324
0325 template<typename A1>
0326 using BinnedProfile1D = BinnedProfile<A1>;
0327
0328 template <typename A1, typename A2>
0329 using BinnedProfile2D = BinnedProfile<A1, A2>;
0330
0331 template <typename A1, typename A2, typename A3>
0332 using BinnedProfile3D = BinnedProfile<A1, A2, A3>;
0333
0334
0335 namespace {
0336 template <class T>
0337 struct ProfileMaker;
0338
0339 template<size_t... Is>
0340 struct ProfileMaker<std::index_sequence<Is...>> {
0341 using type = BinnedProfile< std::decay_t<decltype((void)Is, std::declval<double>())>... >;
0342 };
0343 }
0344
0345
0346 template<size_t N>
0347 using ProfileND = typename ProfileMaker<std::make_index_sequence<N>>::type;
0348
0349
0350 using Profile1D = BinnedProfile<double>;
0351 using Profile2D = BinnedProfile<double,double>;
0352 using Profile3D = BinnedProfile<double,double,double>;
0353
0354 }
0355
0356 #endif
0357