Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
JTransmittances.hh
Go to the documentation of this file.
1#ifndef __JCALIBRATE_JTRANSMITTANCES__
2#define __JCALIBRATE_JTRANSMITTANCES__
3
4#include <istream>
5#include <ostream>
6#include <iomanip>
7#include <array>
8#include <map>
9
11#include "JLang/JManip.hh"
12
13#include "JFitK40.hh"
14
15
16/**
17 * \author mdejong
18 */
19
20namespace JCALIBRATE {}
21namespace JPP { using namespace JCALIBRATE; }
22
23namespace JCALIBRATE {
24
26
27 /**
28 * Auxiliary data structure for I/O of transmittances of optical module.
29 */
31 public std::array<double, NUMBER_OF_RINGS>
32 {
33 /**
34 * Default constructor.
35 */
37 {
38 for (int i = 0; i != NUMBER_OF_RINGS; ++i) {
39 (*this)[i] = 1.0;
40 }
41 }
42
43
44 /**
45 * Copy constructor.
46 *
47 * \param transmittance model transmittances
48 */
50 {
51 for (int i = 0; i != NUMBER_OF_RINGS; ++i) {
52 (*this)[i] = transmittance[i];
53 }
54 }
55
56
57 /**
58 * Read transmittances from input stream.
59 *
60 * \param in input stream
61 * \param transmittance transmittances
62 * \return input stream
63 */
64 friend inline std::istream& operator>>(std::istream& in, transmittance_type& transmittance)
65 {
66 for (int i = 0; i != NUMBER_OF_RINGS; ++i) {
67 in >> transmittance[i];
68 }
69
70 return in;
71 }
72
73
74 /**
75 * Write transmittances to output stream.
76 *
77 * \param out output stream
78 * \param transmittance transmittances
79 * \return output stream
80 */
81 friend inline std::ostream& operator<<(std::ostream& out, const transmittance_type& transmittance)
82 {
83 for (int i = 0; i != NUMBER_OF_RINGS; ++i) {
84 out << (i != 0 ? " " : "") << FIXED(7,3) << transmittance[i];
85 }
86 return out;
87 }
88 };
89
90
91 /**
92 * Auxiliary data structure for I/O of transmittances of optical modules in detector.
93 */
95 public std::map<int, transmittance_type>,
96 public JObjectStreamIO<transmittances_type>
97 {
98 using std::map<int, transmittance_type>::operator[];
99
100 /**
101 * Get transmittances of given optical module.
102 *
103 * In the absence of a module identifier, default values are returned.
104 *
105 * \param id module identifier
106 * \return transmittances
107 */
108 transmittance_type operator[](const int id) const
109 {
110 const_iterator p = find(id);
111
112 if (p != this->end())
113 return p->second;
114 else
115 return transmittance_type();
116 }
117
118
119 /**
120 * Read transmittances from input stream.
121 *
122 * \param in input stream
123 * \param transmittances transmittances
124 * \return input stream
125 */
126 friend inline std::istream& operator>>(std::istream& in, transmittances_type& transmittances)
127 {
128 int id;
129 transmittance_type transmittance;
130
131 while (in >> id >> transmittance) {
132 transmittances[id] = transmittance;
133 }
134
135 return in;
136 }
137
138
139 /**
140 * Write transmittances to output stream.
141 *
142 * \param out output stream
143 * \param transmittances transmittances
144 * \return output stream
145 */
146 friend inline std::ostream& operator<<(std::ostream& out, const transmittances_type& transmittances)
147 {
148 using namespace std;
149
150 for (const auto& i : transmittances) {
151 out << i.first << ' ' << i.second << endl;
152 }
153
154 return out;
155 }
156 };
157}
158
159#endif
I/O manipulators.
Auxiliary classes and methods for PMT calibration.
static const int NUMBER_OF_RINGS
number of rings in optical module.
Definition JFitK40.hh:63
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Auxiliary data structure to handle transmittance of glass sphere due to sedimentation.
Definition JFitK40.hh:1016
Auxiliary data structure for I/O of transmittances of optical module.
friend std::istream & operator>>(std::istream &in, transmittance_type &transmittance)
Read transmittances from input stream.
transmittance_type(const JTransmittance_t &transmittance)
Copy constructor.
transmittance_type()
Default constructor.
friend std::ostream & operator<<(std::ostream &out, const transmittance_type &transmittance)
Write transmittances to output stream.
Auxiliary data structure for I/O of transmittances of optical modules in detector.
friend std::ostream & operator<<(std::ostream &out, const transmittances_type &transmittances)
Write transmittances to output stream.
transmittance_type operator[](const int id) const
Get transmittances of given optical module.
friend std::istream & operator>>(std::istream &in, transmittances_type &transmittances)
Read transmittances from input stream.
Auxiliary base class for storing and loading a single object to and from an ASCII file,...