Belle II Software  release-05-01-25
CDCFudgeFactorsForSigma.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: CDC group *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <map>
13 #include <iostream>
14 #include <fstream>
15 #include <iomanip>
16 #include <TObject.h>
17 
18 namespace Belle2 {
27  class CDCFudgeFactorsForSigma: public TObject {
28  public:
29 
34 
39  void setGroupID(unsigned short mode)
40  {
41  m_groupID = mode;
42  }
43 
49  void setFactors(unsigned short id, const std::vector<float>& factors)
50  {
51  m_ffs.insert(std::pair<unsigned short, std::vector<float>>(id, factors));
52  }
53 
57  unsigned short getGroupID() const
58  {
59  return m_groupID;
60  }
61 
65  unsigned short getEntries() const
66  {
67  return m_ffs.size();
68  }
69 
73  std::map<unsigned short, std::vector<float>> getFactors() const
74  {
75  return m_ffs;
76  }
77 
83  const std::vector<float>& getFactors(unsigned short id) const
84  {
85  std::map<unsigned short, std::vector<float>>::const_iterator it = m_ffs.find(id);
86  if (it != m_ffs.end()) {
87  return it->second;
88  } else {
89  B2FATAL("Specified id not found in getFactors !");
90  }
91  }
92 
96  void dump() const
97  {
98  std::cout << " " << std::endl;
99  std::cout << "Fudge factor list" << std::endl;
100  std::cout << "#entries= " << m_ffs.size() << std::endl;
101  std::cout << "in order of id and factors" << std::endl;
102 
103  for (auto const& ent : m_ffs) {
104  std::cout << ent.first;
105  unsigned short np = (ent.second).size();
106  for (unsigned short i = 0; i < np; ++i) {
107  std::cout << " " << (ent.second)[i];
108  }
109  std::cout << std::endl;
110  }
111  }
112 
116  /*
117  void outputToFile(std::string fileName) const
118  {
119  std::ofstream fout(fileName);
120 
121  if (fout.bad()) {
122  B2ERROR("Specified output file could not be opened!");
123  } else {
124  fout << m_twParamMode << " " << m_nTwParams << std::endl;
125  for (auto const& ent : m_tws) {
126  fout << std::setw(3) << std::right << ent.first;
127  for (unsigned short i = 0; i < m_nTwParams; ++i) {
128  fout << " " << std::setw(15) << std::scientific << std::setprecision(8) << ent.second[i];
129  }
130  fout << std::endl;
131  }
132  fout.close();
133  }
134  }
135  */
136 
137  private:
138  unsigned short m_groupID = 0;
139  std::map<unsigned short, std::vector<float>> m_ffs;
142  };
143 
145 } // end namespace Belle2
146 
Belle2::CDCFudgeFactorsForSigma::getFactors
std::map< unsigned short, std::vector< float > > getFactors() const
Get the whole list.
Definition: CDCFudgeFactorsForSigma.h:81
Belle2::CDCFudgeFactorsForSigma::getGroupID
unsigned short getGroupID() const
Get group id.
Definition: CDCFudgeFactorsForSigma.h:65
Belle2::CDCFudgeFactorsForSigma::m_groupID
unsigned short m_groupID
Output the contents in text file format.
Definition: CDCFudgeFactorsForSigma.h:146
Belle2::CDCFudgeFactorsForSigma::setFactors
void setFactors(unsigned short id, const std::vector< float > &factors)
Set the factors in the list.
Definition: CDCFudgeFactorsForSigma.h:57
Belle2::CDCFudgeFactorsForSigma::dump
void dump() const
Print all contents.
Definition: CDCFudgeFactorsForSigma.h:104
Belle2::CDCFudgeFactorsForSigma::CDCFudgeFactorsForSigma
CDCFudgeFactorsForSigma()
Default constructor.
Definition: CDCFudgeFactorsForSigma.h:41
Belle2::CDCFudgeFactorsForSigma::getEntries
unsigned short getEntries() const
Get the no.
Definition: CDCFudgeFactorsForSigma.h:73
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCFudgeFactorsForSigma::ClassDef
ClassDef(CDCFudgeFactorsForSigma, 1)
ClassDef.
Belle2::CDCFudgeFactorsForSigma::m_ffs
std::map< unsigned short, std::vector< float > > m_ffs
cv list
Definition: CDCFudgeFactorsForSigma.h:147
Belle2::CDCFudgeFactorsForSigma::setGroupID
void setGroupID(unsigned short mode)
Set group id (factors per group) id=0: all-wires; >=1: not ready.
Definition: CDCFudgeFactorsForSigma.h:47