Belle II Software development
CDCPropSpeeds.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 <vector>
11#include <iostream>
12#include <fstream>
13#include <iomanip>
14#include <TObject.h>
15
16namespace Belle2 {
25 class CDCPropSpeeds: public TObject {
26 public:
27
31 enum {c_nSlayers = 56};
37
43 void setSpeed(unsigned short iCLayer, float speed)
44 {
45 m_speeds.at(iCLayer) = speed;
46 }
47
53 void addSpeed(unsigned short iCLayer, float delta)
54 {
55 m_speeds.at(iCLayer) += delta;
56 }
57
61 unsigned short getEntries() const
62 {
63 return m_speeds.size();
64 }
65
69 std::vector<float> getSpeeds() const
70 {
71 return m_speeds;
72 }
73
79 float getSpeed(unsigned short iCLayer) const
80 {
81 return m_speeds[iCLayer];
82 }
83
87 void dump() const
88 {
89 std::cout << " " << std::endl;
90 std::cout << "PropSpeed list" << std::endl;
91 std::cout << "#entries= " << m_speeds.size() << std::endl;
92 std::cout << "in order of clayer and speed (cm/ns)" << std::endl;
93
94 for (unsigned short iCL = 0; iCL < m_speeds.size(); ++iCL) {
95 std::cout << iCL << " " << m_speeds[iCL] << std::endl;
96 }
97 }
98
102 void outputToFile(std::string fileName) const
103 {
104 std::ofstream fout(fileName);
105
106 if (fout.bad()) {
107 B2ERROR("Specified output file could not be opened!");
108 } else {
109 for (unsigned short iCL = 0; iCL < m_speeds.size(); ++iCL) {
110 fout << std::setw(2) << std::right << iCL << " " << std::setw(15) << std::scientific << std::setprecision(
111 8) << m_speeds[iCL] << std::endl;
112 }
113 fout.close();
114 }
115 }
116
117 private:
118 // std::vector<float> m_speeds; /**< list of speed*/
119 std::vector<float> m_speeds = std::vector<float>(c_nSlayers);
121 };
122
124} // end namespace Belle2
Database object for signal propagation speed along the wire.
Definition: CDCPropSpeeds.h:25
void setSpeed(unsigned short iCLayer, float speed)
Set the speed in the list.
Definition: CDCPropSpeeds.h:43
void outputToFile(std::string fileName) const
Output the contents in text file format.
std::vector< float > getSpeeds() const
Get the whole list.
Definition: CDCPropSpeeds.h:69
CDCPropSpeeds()
Default constructor.
Definition: CDCPropSpeeds.h:36
void addSpeed(unsigned short iCLayer, float delta)
Update the speed in the list.
Definition: CDCPropSpeeds.h:53
unsigned short getEntries() const
Get the no.
Definition: CDCPropSpeeds.h:61
std::vector< float > m_speeds
list of speed
float getSpeed(unsigned short iCLayer) const
Get the speed for the specified layer.
Definition: CDCPropSpeeds.h:79
ClassDef(CDCPropSpeeds, 1)
ClassDef.
void dump() const
Print out contents.
Definition: CDCPropSpeeds.h:87
Abstract base class for different kinds of events.