Belle II Software development
CDCAlphaScaleFactorForAsymmetry.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <map>
11#include <iostream>
12#include <fstream>
13#include <iomanip>
14#include <TObject.h>
15
16namespace Belle2 {
21
25 class CDCAlphaScaleFactorForAsymmetry: public TObject {
26 public:
30 enum {c_nLayers = 56,
32 };
33
34
39
40
45 void setScaleFactors(const std::array<std::array<float, c_nAlphaBins>, c_nLayers>& inputScales)
46 {
47 m_Scales = inputScales;
48 }
49
53 unsigned short getEntries() const
54 {
55 return c_nLayers * c_nAlphaBins ;
56 }
57
61 std::array<std::array<float, c_nAlphaBins>, c_nLayers> getScaleFactors() const
62 {
63 return m_Scales;
64 }
65
71 std::array<float, c_nAlphaBins> getScaleFactors(unsigned short iCLayer) const
72 {
73 if (iCLayer >= c_nLayers)
74 B2FATAL("Required iCLayer is invalid ! Should be 0 to 55 .");
75 return m_Scales[iCLayer] ;
76 }
77
84 double getScaleFactor(unsigned short iCLayer, double alpha) const
85 {
86 if (alpha > (M_PI / 2)) alpha = alpha - M_PI;
87 if (alpha < -(M_PI / 2)) alpha = alpha + M_PI;
88 int alpha_bin = std::trunc(std::abs(alpha) / c_AlphaBinWidth);
89 if (alpha_bin > c_nAlphaBins) alpha_bin = c_nAlphaBins - 1 ;
90 return m_Scales[iCLayer][alpha_bin];
91 }
92
93
97 void dump() const
98 {
99 std::cout << " " << std::endl;
100 std::cout << "Scale factor list" << std::endl;
101 std::cout << "#entries= " << c_nLayers* c_nAlphaBins << std::endl;
102 std::cout << "the ratio of data to MC for the hit efficiency of positively charged tracks comparing to negitively charged tracks" <<
103 std::endl;
104
105 for (unsigned short iLayer = 0; iLayer < c_nLayers; iLayer++) {
106 std::cout << "Scale factors for Layer " << iLayer << " : " << std::endl;
107 for (unsigned short i = 0; i < c_nAlphaBins; ++i) {
108 std::cout << " Alpha in ( " << i * 0.01 << " , " << (i + 1) * 0.01 << " ), Scale factor: " << m_Scales[iLayer][i] << std::endl;
109 }
110 }
111 }
112
113 private:
114 std::array<std::array<float, c_nAlphaBins>, c_nLayers> m_Scales;
115 double c_AlphaBinWidth = 0.01;
117 };
118
120} // end namespace Belle2
ClassDef(CDCAlphaScaleFactorForAsymmetry, 1)
ClassDef.
std::array< std::array< float, c_nAlphaBins >, c_nLayers > m_Scales
scale factors
std::array< std::array< float, c_nAlphaBins >, c_nLayers > getScaleFactors() const
Get the whole list.
void setScaleFactors(const std::array< std::array< float, c_nAlphaBins >, c_nLayers > &inputScales)
Set the factors in the list.
std::array< float, c_nAlphaBins > getScaleFactors(unsigned short iCLayer) const
Get the factors for the iCLayer.
double getScaleFactor(unsigned short iCLayer, double alpha) const
Get the factor for one hit.
Abstract base class for different kinds of events.