Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-29 07:06:06

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2024, Nathan Brei, Dmitry Kalinkin
0003 
0004 #pragma once
0005 
0006 #include <algorithms/logger.h>
0007 #include <boost/histogram.hpp>
0008 #include <string>
0009 #include <tuple>
0010 #include <vector>
0011 // IWYU pragma: no_include <boost/mp11/detail/mp_defer.hpp>
0012 
0013 namespace eicrecon {
0014 
0015 class PIDLookupTable : public algorithms::LoggerMixin {
0016 
0017 public:
0018     /// The histogram entry with access counter, where the probabilities are stored in metadata
0019     struct Entry : public boost::histogram::accumulators::count<unsigned char, false> {
0020         double prob_electron, prob_pion, prob_kaon, prob_proton;
0021     };
0022 
0023     struct Binning {
0024       std::vector<int> pdg_values;
0025       std::vector<int> charge_values;
0026       std::vector<double> momentum_edges;
0027       std::vector<double> polar_edges;
0028       std::vector<double> azimuthal_binning;
0029       bool azimuthal_bin_centers_in_lut;
0030       bool momentum_bin_centers_in_lut;
0031       bool polar_bin_centers_in_lut;
0032       bool use_radians;
0033       bool missing_electron_prob;
0034     };
0035 
0036 private:
0037     boost::histogram::histogram<
0038       std::tuple<
0039         boost::histogram::axis::category<int>,
0040         boost::histogram::axis::category<int>,
0041         boost::histogram::axis::variable<>,
0042         boost::histogram::axis::variable<>,
0043         boost::histogram::axis::circular<>
0044       >
0045       , boost::histogram::dense_storage<Entry>
0046     > m_hist;
0047     bool m_symmetrizing_charges;
0048 
0049 public:
0050 
0051     PIDLookupTable() : algorithms::LoggerMixin("PIDLookupTable") {};
0052 
0053     const Entry* Lookup(int pdg, int charge, double momentum, double theta_deg, double phi_deg) const;
0054 
0055     void load_file(const std::string& filename, const Binning &binning);
0056 };
0057 
0058 }