Belle II Software  release-08-01-10
CDCFudgeFactorsForSigma.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 
16 namespace Belle2 {
25  class CDCFudgeFactorsForSigma: public TObject {
26  public:
27 
32 
37  void setGroupID(unsigned short mode)
38  {
39  m_groupID = mode;
40  }
41 
47  void setFactors(unsigned short id, const std::vector<float>& factors)
48  {
49  m_ffs.insert(std::pair<unsigned short, std::vector<float>>(id, factors));
50  }
51 
55  unsigned short getGroupID() const
56  {
57  return m_groupID;
58  }
59 
63  unsigned short getEntries() const
64  {
65  return m_ffs.size();
66  }
67 
71  std::map<unsigned short, std::vector<float>> getFactors() const
72  {
73  return m_ffs;
74  }
75 
81  const std::vector<float>& getFactors(unsigned short id) const
82  {
83  std::map<unsigned short, std::vector<float>>::const_iterator it = m_ffs.find(id);
84  if (it != m_ffs.end()) {
85  return it->second;
86  } else {
87  B2FATAL("Specified id not found in getFactors !");
88  }
89  }
90 
94  void dump() const
95  {
96  std::cout << " " << std::endl;
97  std::cout << "Fudge factor list" << std::endl;
98  std::cout << "#entries= " << m_ffs.size() << std::endl;
99  std::cout << "in order of id and factors" << std::endl;
100 
101  for (auto const& ent : m_ffs) {
102  std::cout << ent.first;
103  unsigned short np = (ent.second).size();
104  for (unsigned short i = 0; i < np; ++i) {
105  std::cout << " " << (ent.second)[i];
106  }
107  std::cout << std::endl;
108  }
109  }
110 
114  /*
115  void outputToFile(std::string fileName) const
116  {
117  std::ofstream fout(fileName);
118 
119  if (fout.bad()) {
120  B2ERROR("Specified output file could not be opened!");
121  } else {
122  fout << m_twParamMode << " " << m_nTwParams << std::endl;
123  for (auto const& ent : m_tws) {
124  fout << std::setw(3) << std::right << ent.first;
125  for (unsigned short i = 0; i < m_nTwParams; ++i) {
126  fout << " " << std::setw(15) << std::scientific << std::setprecision(8) << ent.second[i];
127  }
128  fout << std::endl;
129  }
130  fout.close();
131  }
132  }
133  */
134 
135  private:
136  unsigned short m_groupID = 0;
137  std::map<unsigned short, std::vector<float>> m_ffs;
140  };
141 
143 } // end namespace Belle2
144 
Database object for fudge factors for CDC space resol.
const std::vector< float > & getFactors(unsigned short id) const
Get the factors for the id.
void setGroupID(unsigned short mode)
Set group id (factors per group) id=0: all-wires; >=1: not ready.
std::map< unsigned short, std::vector< float > > m_ffs
cv list
ClassDef(CDCFudgeFactorsForSigma, 1)
ClassDef.
CDCFudgeFactorsForSigma()
Default constructor.
unsigned short getEntries() const
Get the no.
void setFactors(unsigned short id, const std::vector< float > &factors)
Set the factors in the list.
unsigned short m_groupID
Output the contents in text file format.
std::map< unsigned short, std::vector< float > > getFactors() const
Get the whole list.
void dump() const
Print all contents.
unsigned short getGroupID() const
Get group id.
Abstract base class for different kinds of events.