Belle II Software  release-05-01-25
CDCDedxMomentumCor.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jake Bennett *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/logging/Logger.h>
14 
15 #include <TObject.h>
16 #include <cmath>
17 
18 namespace Belle2 {
28  class CDCDedxMomentumCor: public TObject {
29 
30  public:
31 
36 
40  explicit CDCDedxMomentumCor(const std::vector<double>& momcor): m_momcor(momcor) {};
41 
46 
51  {
52  if (m_momcor.size() != rhs.getSize()) {
53  B2WARNING("Momentum correction parameters do not match, cannot merge!");
54  return *this;
55  }
56  std::vector<double> rhsgains = rhs.getMomCor();
57  for (unsigned int bin = 0; bin < m_momcor.size(); ++bin) {
58  m_momcor[bin] *= rhsgains[bin];
59  }
60  return *this;
61  }
62 
65  unsigned int getSize() const { return m_momcor.size(); };
66 
69  std::vector<double> getMomCor() const {return m_momcor; };
70 
74  double getMean(unsigned int bin) const
75  {
76  if (bin > m_momcor.size()) return 1.0;
77  else return m_momcor[bin];
78  }
79 
83  double getMean(double mom) const
84  {
85  if (std::abs(mom) > 10.0) return 0;
86 
87  // gains are stored at the center of the bins
88  // find the bin center immediately preceding this value of mom
89  double binsize = 10.0 / m_momcor.size();
90  int bin = std::floor(mom / binsize);
91 
92  return m_momcor[bin];
93  };
94 
95  private:
96 
97  std::vector<double> m_momcor;
100  };
102 } // end namespace Belle2
Belle2::CDCDedxMomentumCor::ClassDef
ClassDef(CDCDedxMomentumCor, 5)
ClassDef.
Belle2::CDCDedxMomentumCor::~CDCDedxMomentumCor
~CDCDedxMomentumCor()
Destructor.
Definition: CDCDedxMomentumCor.h:53
Belle2::CDCDedxMomentumCor::operator*=
CDCDedxMomentumCor & operator*=(CDCDedxMomentumCor const &rhs)
Combine payloads.
Definition: CDCDedxMomentumCor.h:58
Belle2::CDCDedxMomentumCor::getMean
double getMean(unsigned int bin) const
Return dE/dx mean value for given bin.
Definition: CDCDedxMomentumCor.h:82
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCDedxMomentumCor::CDCDedxMomentumCor
CDCDedxMomentumCor()
Default constructor.
Definition: CDCDedxMomentumCor.h:43
Belle2::CDCDedxMomentumCor
dE/dx wire gain calibration constants
Definition: CDCDedxMomentumCor.h:36
Belle2::CDCDedxMomentumCor::getMomCor
std::vector< double > getMomCor() const
Get the momentum correction.
Definition: CDCDedxMomentumCor.h:77
Belle2::CDCDedxMomentumCor::getSize
unsigned int getSize() const
Get the number of bins for the momentum correction.
Definition: CDCDedxMomentumCor.h:73
Belle2::CDCDedxMomentumCor::m_momcor
std::vector< double > m_momcor
dE/dx gains in momentum bins
Definition: CDCDedxMomentumCor.h:101