ATLAS Offline Software
Loading...
Searching...
No Matches
RtData_t_r_reso.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <stdio.h>
8
10#include "GaudiKernel/MsgStream.h"
11
12#define M_MAX_PARS 1000
13
14namespace MuonCalib {
15
16 std::istream& RtData_t_r_reso::read(std::istream& is) {
17 std::string dummy;
18
19 double t(0), r(0), reso(0);
20
21 // read region id and number of points in rt
22 is >> dummy >> m_regionId >> m_npars;
24 // reseve space in vectors
25 m_timeVec.reserve(m_npars);
26 m_radiusVec.reserve(m_npars);
27 m_resoVec.reserve(m_npars);
28
29 // read data from file
30 for (unsigned int i = 0; i < m_npars; ++i) {
31 // check if eof reached before last entry was read
32 if (is.eof()) {
33 MsgStream log(Athena::getMessageSvc(), "RtData_t_r_reso");
34 log << MSG::WARNING << "read() <unexpected eof> -> exit after " << i - 1 << " entries out of " << m_npars
35 << " were read from file" << endmsg;
36 reset();
37 return is;
38 }
39
40 // read next entry
41 is >> r >> t >> reso;
42 m_timeVec.push_back(t);
43 m_radiusVec.push_back(r);
44 m_resoVec.push_back(reso);
45 }
46
47 // reading success, data valid
48 m_isValid = true;
49
50 return is;
51 }
52
53 std::ostream& RtData_t_r_reso::write(std::ostream& os) const {
54 if (m_isValid) {
55 os << " dummy " << m_regionId << " " << m_npars << std::endl;
56 for (unsigned int i = 0; i < m_npars; ++i) {
57 os << " " << m_radiusVec[i] << " " << m_timeVec[i] << " " << m_resoVec[i] << std::endl;
58 }
59 } else {
60 MsgStream log(Athena::getMessageSvc(), "RtData_t_r_reso");
61 log << MSG::WARNING << "write() <data not valid>" << endmsg;
62 }
63
64 return os;
65 }
66
67 void RtData_t_r_reso::write_forDB(FILE* frtt, FILE* frtr, FILE* frts) const {
68 if (m_isValid) {
69 fprintf(frtt, "%u", m_npars);
70 fprintf(frtr, "%u", m_npars);
71 fprintf(frts, "%u", m_npars);
72
73 // loop over data and write to std::ostream
74 for (unsigned int i = 0; i < m_npars; ++i) {
75 fprintf(frtt, ",%f", m_timeVec[i]);
76 fprintf(frtr, ",%f", m_radiusVec[i]);
77 fprintf(frts, ",%f", m_resoVec[i]);
78 }
79 fprintf(frtt, "\n");
80 fprintf(frtr, "\n");
81 fprintf(frts, "\n");
82 } else {
83 MsgStream log(Athena::getMessageSvc(), "RtData_t_r_reso");
84 log << MSG::WARNING << "write_forDB() <data not valid>" << endmsg;
85 }
86
87 return;
88 }
89
91 m_isValid = false;
92 m_timeVec.clear();
93 m_radiusVec.clear();
94 m_resoVec.clear();
95 }
96
97 std::istream& operator>>(std::istream& is, RtData_t_r_reso& data) { return data.read(is); }
98
99 std::ostream& operator<<(std::ostream& os, const RtData_t_r_reso& data) { return data.write(os); }
100
101} // namespace MuonCalib
#define endmsg
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define M_MAX_PARS
Represents an Rt relation in the form of a set of (time,radius,resolution) points.
std::ostream & write(std::ostream &os) const
void write_forDB(FILE *frtt, FILE *frtr, FILE *frts) const
std::istream & read(std::istream &is)
singleton-like access to IMessageSvc via open function and helper
int r
Definition globals.cxx:22
IMessageSvc * getMessageSvc(bool quiet=false)
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
std::istream & operator>>(std::istream &is, RtFullInfo &data)
std::ostream & operator<<(std::ostream &os, const RtFullInfo &data)