File indexing completed on 2025-02-21 10:04:19
0001
0002 #include <algorithm>
0003 #include <map>
0004 #include <vector>
0005
0006 #ifndef _CHERENKOV_PID_
0007 #define _CHERENKOV_PID_
0008
0009 class CherenkovRadiator;
0010
0011 class RadiatorMassHypothesis {
0012 public:
0013 RadiatorMassHypothesis(): m_Npe(0.0), m_Weight(0.0) {};
0014 ~RadiatorMassHypothesis() {};
0015
0016 inline void IncrementWeight(double npe, double weight) {
0017 m_Npe += npe; m_Weight += weight;
0018 };
0019
0020 inline void Reset( void ) { m_Npe = m_Weight = 0.0; };
0021 double GetNpe ( void ) const { return m_Npe; };
0022 double GetWeight( void ) const { return m_Weight; };
0023
0024 private:
0025
0026 double m_Npe;
0027 double m_Weight;
0028 };
0029
0030 class MassHypothesis {
0031 public:
0032 MassHypothesis(double mass): m_Mass(mass) {};
0033 ~MassHypothesis() {};
0034
0035 double GetMass( void ) const { return m_Mass; };
0036 inline void IncrementWeight(CherenkovRadiator *radiator, double npe, double weight) {
0037 m_RadiatorBreakdown[radiator].IncrementWeight(npe, weight);
0038 };
0039
0040 void Reset( void ) {
0041 for(auto rhm: m_RadiatorBreakdown)
0042 rhm.second.Reset();
0043 };
0044 double GetNpe (CherenkovRadiator *radiator) {
0045 return m_RadiatorBreakdown[radiator].GetNpe();
0046 };
0047 double GetWeight(CherenkovRadiator *radiator) {
0048 return m_RadiatorBreakdown[radiator].GetWeight();
0049 };
0050
0051 private:
0052 double m_Mass;
0053
0054 std::map<CherenkovRadiator*, RadiatorMassHypothesis> m_RadiatorBreakdown;
0055 };
0056
0057 class CherenkovPID {
0058 public:
0059 CherenkovPID( void ) {};
0060 ~CherenkovPID() {
0061 std::for_each(m_Hypotheses.begin(), m_Hypotheses.end(), [](auto* h){ delete h; });
0062 };
0063
0064 void AddMassHypothesis(double mass) { m_Hypotheses.push_back(new MassHypothesis(mass)); };
0065 unsigned GetHypothesesCount( void ) const { return m_Hypotheses.size(); };
0066 MassHypothesis *GetHypothesis(unsigned id) {
0067 return (id < m_Hypotheses.size() ? m_Hypotheses[id] : 0);
0068 };
0069
0070 private:
0071
0072
0073 std::vector<MassHypothesis*> m_Hypotheses;
0074 };
0075
0076 #endif