Belle II Software  release-05-01-25
CDCEDepToADCConversions.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 CDCEDepToADCConversions: public TObject {
28  public:
29 
34 
38  void setParamMode(unsigned short mode)
39  {
40  m_paramMode = mode;
41  }
42 
47  void setGroupID(unsigned short mode)
48  {
49  m_groupID = mode;
50  }
51 
57  void setParams(unsigned short id, const std::vector<float>& params)
58  {
59  m_cvs.insert(std::pair<unsigned short, std::vector<float>>(id, params));
60  }
61 
65  unsigned short getParamMode() const
66  {
67  return m_paramMode;
68  }
69 
73  unsigned short getGroupID() const
74  {
75  return m_groupID;
76  }
77 
81  unsigned short getEntries() const
82  {
83  return m_cvs.size();
84  }
85 
89  std::map<unsigned short, std::vector<float>> getParams() const
90  {
91  return m_cvs;
92  }
93 
99  const std::vector<float>& getParams(unsigned short id) const
100  {
101  std::map<unsigned short, std::vector<float>>::const_iterator it = m_cvs.find(id);
102  if (it != m_cvs.end()) {
103  return it->second;
104  } else {
105  B2FATAL("Specified id not found in getParams !");
106  }
107  }
108 
112  void dump() const
113  {
114  std::cout << " " << std::endl;
115  std::cout << "Edep-to-ADC conversion list" << std::endl;
116  std::cout << "#entries= " << m_cvs.size() << std::endl;
117  std::cout << m_paramMode << std::endl;
118  std::cout << "in order of id and parameters" << std::endl;
119 
120  for (auto const& ent : m_cvs) {
121  std::cout << ent.first;
122  unsigned short np = (ent.second).size();
123  for (unsigned short i = 0; i < np; ++i) {
124  std::cout << " " << (ent.second)[i];
125  }
126  std::cout << std::endl;
127  }
128  }
129 
133  /*
134  void outputToFile(std::string fileName) const
135  {
136  std::ofstream fout(fileName);
137 
138  if (fout.bad()) {
139  B2ERROR("Specified output file could not be opened!");
140  } else {
141  fout << m_twParamMode << " " << m_nTwParams << std::endl;
142  for (auto const& ent : m_tws) {
143  fout << std::setw(3) << std::right << ent.first;
144  for (unsigned short i = 0; i < m_nTwParams; ++i) {
145  fout << " " << std::setw(15) << std::scientific << std::setprecision(8) << ent.second[i];
146  }
147  fout << std::endl;
148  }
149  fout.close();
150  }
151  }
152  */
153 
154  private:
155  unsigned short m_paramMode = 0;
156  unsigned short m_groupID = 0;
157  std::map<unsigned short, std::vector<float>> m_cvs;
160  };
161 
163 } // end namespace Belle2
Belle2::CDCEDepToADCConversions::setGroupID
void setGroupID(unsigned short mode)
Set group id (parameterized per group) id=0: superLayerID; =1: layerID; =1: wireID.
Definition: CDCEDepToADCConversions.h:55
Belle2::CDCEDepToADCConversions::setParams
void setParams(unsigned short id, const std::vector< float > &params)
Set the conv.
Definition: CDCEDepToADCConversions.h:65
Belle2::CDCEDepToADCConversions::getParamMode
unsigned short getParamMode() const
Get mode of conversion parameterization.
Definition: CDCEDepToADCConversions.h:73
Belle2::CDCEDepToADCConversions::ClassDef
ClassDef(CDCEDepToADCConversions, 2)
ClassDef.
Belle2::CDCEDepToADCConversions::m_paramMode
unsigned short m_paramMode
Output the contents in text file format.
Definition: CDCEDepToADCConversions.h:163
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCEDepToADCConversions::getParams
std::map< unsigned short, std::vector< float > > getParams() const
Get the whole list.
Definition: CDCEDepToADCConversions.h:97
Belle2::CDCEDepToADCConversions::m_cvs
std::map< unsigned short, std::vector< float > > m_cvs
cv list
Definition: CDCEDepToADCConversions.h:165
Belle2::CDCEDepToADCConversions::CDCEDepToADCConversions
CDCEDepToADCConversions()
Default constructor.
Definition: CDCEDepToADCConversions.h:41
Belle2::CDCEDepToADCConversions::getGroupID
unsigned short getGroupID() const
Get group id.
Definition: CDCEDepToADCConversions.h:81
Belle2::CDCEDepToADCConversions::m_groupID
unsigned short m_groupID
Group id (parameterized per group)
Definition: CDCEDepToADCConversions.h:164
Belle2::CDCEDepToADCConversions::getEntries
unsigned short getEntries() const
Get the no.
Definition: CDCEDepToADCConversions.h:89
Belle2::CDCEDepToADCConversions::dump
void dump() const
Print all contents.
Definition: CDCEDepToADCConversions.h:120
Belle2::CDCEDepToADCConversions::setParamMode
void setParamMode(unsigned short mode)
Set conversion parameterization mode.
Definition: CDCEDepToADCConversions.h:46