Belle II Software  release-05-01-25
CDCDedx1DCell.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, Jitendra *
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 #include <TMath.h>
18 
19 namespace Belle2 {
29  class CDCDedx1DCell: public TObject {
30 
31  public:
32 
37 
41  CDCDedx1DCell(short version, const std::vector<std::vector<double>>& onedgains): m_version(version), m_onedgains(onedgains) {};
42 
46  ~CDCDedx1DCell() {};
47 
52  {
53  if (m_version != rhs.getVersion()) {
54  B2WARNING("1D cell gain parameters do not match, cannot merge!");
55  return *this;
56  }
57  for (unsigned int layer = 0; layer < getSize(); ++layer) {
58  double tempLayer = -1; //out of bound layer
59  if (getSize() == 2)tempLayer = layer * 20; // 20 to make <8 and >=8 difference
60  else if (getSize() == 56)tempLayer = layer;
61  else B2ERROR("ERROR! Wrong # of constants vector array");
62  for (unsigned int bin = 0; bin < getNBins(layer); ++bin) {
63  m_onedgains[layer][bin] *= rhs.getMean(tempLayer, bin);
64  }
65  }
66  return *this;
67  }
68 
71  short getVersion() const { return m_version; };
72 
75  unsigned int getSize() const { return m_onedgains.size(); };
76 
79  unsigned int getNBins(unsigned int layer) const
80  {
81  if (m_onedgains.size() == 0) {
82  B2ERROR("ERROR!");
83  return 0;
84  }
85 
86  if (m_onedgains.size() == 2) {
87  if (layer == 0) return m_onedgains[0].size();
88  else if (layer == 1) return m_onedgains[1].size();
89  else {
90  B2ERROR("ERROR! const vector not found");
91  return 0;
92  }
93  } else if (m_onedgains.size() == 56) {
94  return m_onedgains[layer].size();
95  } else {
96  B2ERROR("ERROR! Wrong # of constants vector array: getNBins()");
97  return 0;
98  }
99  return 0;
100  };
101 
106  double getMean(unsigned int layer, unsigned int bin) const
107  {
108  int mylayer = 0;
109  if (layer >= 8 && m_onedgains.size() == 2) mylayer = 1;
110  else if (m_onedgains.size() == 56) mylayer = layer;
111 
112  if (bin < m_onedgains[mylayer].size())
113  return m_onedgains[mylayer][bin];
114  else return 1.0;
115  };
116 
122  void setMean(unsigned int layer, unsigned int bin, double value)
123  {
124  int mylayer = 0;
125  if (layer >= 8 && m_onedgains.size() == 2) mylayer = 1;
126  else if (m_onedgains.size() == 56) mylayer = layer;
127 
128  if (bin < m_onedgains[mylayer].size()) m_onedgains[mylayer][bin] = value;
129  else m_onedgains[mylayer][bin] = 1.0;
130  };
131 
136  double getMean(unsigned int layer, double enta) const
137  {
138  if (layer > 56) {
139  B2ERROR("No such layer!");
140  return 0;
141  }
142 
143  int mylayer = 0;
144  if (layer >= 8 && m_onedgains.size() == 2) mylayer = 1;
145  else if (m_onedgains.size() == 56) mylayer = layer;
146 
147  double piby2 = TMath::Pi() / 2.0;
148  // assume rotational symmetry
149  if (enta < -piby2) enta += piby2;
150  if (enta > piby2) enta -= piby2;
151 
152  double binsize = (m_onedgains[mylayer].size() != 0) ? 2.0 * piby2 / m_onedgains[mylayer].size() : 0.0;
153  int bin = (binsize != 0.0) ? std::floor((enta + piby2) / binsize) : -1;
154  if (bin < 0 || (unsigned)bin >= m_onedgains[mylayer].size()) {
155  B2WARNING("Problem with CDC dE/dx 1D binning!");
156  return 1.0;
157  }
158 
159  return m_onedgains[mylayer][bin];
160  };
161 
162  private:
166  short m_version;
167  std::vector<std::vector<double>> m_onedgains;
169  ClassDef(CDCDedx1DCell, 5);
170  };
172 } // end namespace Belle2
Belle2::CDCDedx1DCell::ClassDef
ClassDef(CDCDedx1DCell, 5)
ClassDef.
Belle2::CDCDedx1DCell::getSize
unsigned int getSize() const
Get the number of bins for the entrance angle correction.
Definition: CDCDedx1DCell.h:83
Belle2::CDCDedx1DCell::setMean
void setMean(unsigned int layer, unsigned int bin, double value)
Reset dE/dx mean value for the given bin.
Definition: CDCDedx1DCell.h:130
Belle2::CDCDedx1DCell::getNBins
unsigned int getNBins(unsigned int layer) const
Get the number of bins for the entrance angle correction.
Definition: CDCDedx1DCell.h:87
Belle2::CDCDedx1DCell::m_version
short m_version
dE/dx cleanup correction versus entrance angle may be different for different layers,...
Definition: CDCDedx1DCell.h:168
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCDedx1DCell::m_onedgains
std::vector< std::vector< double > > m_onedgains
dE/dx means in entrance angle bins
Definition: CDCDedx1DCell.h:175
Belle2::CDCDedx1DCell::~CDCDedx1DCell
~CDCDedx1DCell()
Destructor.
Definition: CDCDedx1DCell.h:54
Belle2::CDCDedx1DCell::getVersion
short getVersion() const
Get the version for the 1D cleanup.
Definition: CDCDedx1DCell.h:79
Belle2::CDCDedx1DCell::CDCDedx1DCell
CDCDedx1DCell()
Default constructor.
Definition: CDCDedx1DCell.h:44
Belle2::CDCDedx1DCell::getMean
double getMean(unsigned int layer, unsigned int bin) const
Return dE/dx mean value for the given bin.
Definition: CDCDedx1DCell.h:114
Belle2::CDCDedx1DCell::operator*=
CDCDedx1DCell & operator*=(CDCDedx1DCell const &rhs)
Combine payloads.
Definition: CDCDedx1DCell.h:59