ATLAS Offline Software
Loading...
Searching...
No Matches
RtDataFromFile.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <TString.h> // for Form
8
9#include <string>
10
11
12namespace {
13 constexpr int M_MAX_RTS = 100000;
14}
15
16namespace MuonCalib {
17
18 std::istream& RtDataFromFile::read(std::istream& is) {
19 std::string version;
20 std::string rts_str;
21
22 // read number of rts in file
23 is >> version >> rts_str;
24
25 unsigned long int pos = 0;
26 std::string::size_type start = rts_str.find_first_not_of(' ', pos);
27 if (start == std::string::npos)
28 throw std::runtime_error(
29 Form("File: %s, Line: %d\nRtDataFromFile::read() - problems extracting m_rts, exiting", __FILE__, __LINE__));
30
31 std::string::size_type stop = rts_str.find_first_of(' ', start + 1);
32 if (stop == std::string::npos) stop = rts_str.size();
33 m_rts = std::stoi(rts_str.substr(start, stop - start), nullptr);
34
35 m_rts = (m_rts > M_MAX_RTS) ? M_MAX_RTS : m_rts;
36 for (unsigned int i = 0; i < m_rts; ++i) {
37 if (version != "v0.0") {
38 // read in additional information
39 RtFullInfo fi;
40 is >> fi;
41 }
42 // create empty rt
43 RtRelation* rt = new RtRelation();
44
45 // read rt from file
46 is >> *rt;
47
48 // store rt
49 m_rtRelations.push_back(rt);
50 }
51
52 return is;
53 }
54
55 std::ostream& RtDataFromFile::write(std::ostream& os, int region) const {
56 if (m_rts != m_rtRelations.size()) {
57 MsgStream log(Athena::getMessageSvc(), "RtDataFromFile");
58 log << MSG::WARNING << "write() <inconsistent rt count>" << endmsg;
59 }
60 if (region >= static_cast<int>(m_rts)) {
61 MsgStream log(Athena::getMessageSvc(), "RtDataFromFile");
62 log << MSG::WARNING << "write() <requested not existent region>" << endmsg;
63 }
64 os << "v" << m_major_version << "." << m_minor_version << " 1"; // full info added
65
66 if (m_fullInfo[region]) os << *(m_fullInfo[region]);
67 if (m_rtRelations[region]) os << *(m_rtRelations[region]);
68 return os;
69 }
70
71 std::ostream& RtDataFromFile::write(std::ostream& os) const {
72 if (m_rts != m_rtRelations.size()) {
73 MsgStream log(Athena::getMessageSvc(), "RtDataFromFile");
74 log << MSG::WARNING << "write() <inconsistent rt count>" << endmsg;
75 }
76
77 os << "v1.0 " << m_rts; // full info added
78
79 for (unsigned int i = 0; i < m_rtRelations.size(); ++i) {
80 if (m_fullInfo[i]) os << *(m_fullInfo[i]);
81 if (m_rtRelations[i]) os << *(m_rtRelations[i]);
82 }
83 return os;
84 }
85
86 void RtDataFromFile::write_forDB(FILE* frt, FILE* frtt, FILE* frtr, FILE* frts, int region) const {
87 if (m_rts != m_rtRelations.size()) {
88 MsgStream log(Athena::getMessageSvc(), "RtDataFromFile");
89 log << MSG::WARNING << "write_forDB() <inconsistent rt count>" << endmsg;
90 }
91 if (region >= static_cast<int>(m_rts)) {
92 MsgStream log(Athena::getMessageSvc(), "RtDataFromFile");
93 log << MSG::WARNING << "write_forDB() <requested not existent region>" << endmsg;
94 }
95 if (m_fullInfo[region]) { (m_fullInfo[region])->write_forDB(frt); }
96 if (m_rtRelations[region]) { (m_rtRelations[region])->write_forDB(frtt, frtr, frts); }
97 return;
98 }
99
100 void RtDataFromFile::write_forDB(FILE* frt, FILE* frtt, FILE* frtr, FILE* frts) const {
101 if (m_rts != m_rtRelations.size()) {
102 MsgStream log(Athena::getMessageSvc(), "RtDataFromFile");
103 log << MSG::WARNING << "write_forDB() <inconsistent rt count>" << endmsg;
104 }
105
106 for (unsigned int i = 0; i < m_rtRelations.size(); ++i) {
107 if (m_rtRelations[i]) { (m_rtRelations[i])->write_forDB(frtt, frtr, frts); }
108 if (m_fullInfo[i]) { (m_fullInfo[i])->write_forDB(frt); }
109 }
110 return;
111 }
112
113} // namespace MuonCalib
114
115std::istream& operator>>(std::istream& is, MuonCalib::RtDataFromFile& data) { return data.read(is); }
116
117std::ostream& operator<<(std::ostream& os, const MuonCalib::RtDataFromFile& data) { return data.write(os); }
#define endmsg
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
std::ostream & operator<<(std::ostream &os, const MuonCalib::RtDataFromFile &data)
std::istream & operator>>(std::istream &is, MuonCalib::RtDataFromFile &data)
Manages the I/O of the Rt realtions from/to file.
void write_forDB(FILE *frt, FILE *frtt, FILE *frtr, FILE *frts, int region) const
std::ostream & write(std::ostream &os, int region) const
std::vector< const RtFullInfo * > m_fullInfo
int m_major_version
format version
std::istream & read(std::istream &is)
RtRelations m_rtRelations
rt relations
unsigned int m_rts
total number of regions
addiitonal information used in validation of a rt-relation
Definition RtFullInfo.h:15
IMessageSvc * getMessageSvc(bool quiet=false)
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.