ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCalib::RtDataFromFile Class Reference

Manages the I/O of the Rt realtions from/to file. More...

#include <RtDataFromFile.h>

Collaboration diagram for MuonCalib::RtDataFromFile:

Public Types

typedef RtData_t_r_reso RtRelation
typedef std::vector< RtRelation * > RtRelations

Public Member Functions

 RtDataFromFile ()
 ~RtDataFromFile ()=default
unsigned int nRts () const
 return number of rt relations
RtRelationgetRt (unsigned int regionId) const
 retrieve rt-relation for a give regionId
void setNRts (unsigned int nrts)
 set total number of regions
bool addRt (int regionId, RtRelation *rt)
 RtDataFromFile takes ownership of rt.
bool addRt (int regionId, RtRelation *rt, const RtFullInfo *info)
std::istream & read (std::istream &is)
std::ostream & write (std::ostream &os, int region) const
std::ostream & write (std::ostream &os) const
void write_forDB (FILE *frt, FILE *frtt, FILE *frtr, FILE *frts, int region) const
void write_forDB (FILE *frt, FILE *frtt, FILE *frtr, FILE *frts) const
void setVersion (int major, int minor)

Private Attributes

unsigned int m_rts
 total number of regions
RtRelations m_rtRelations
 rt relations
std::vector< const RtFullInfo * > m_fullInfo
int m_major_version
 format version
int m_minor_version

Detailed Description

Manages the I/O of the Rt realtions from/to file.

Definition at line 21 of file RtDataFromFile.h.

Member Typedef Documentation

◆ RtRelation

◆ RtRelations

Definition at line 24 of file RtDataFromFile.h.

Constructor & Destructor Documentation

◆ RtDataFromFile()

MuonCalib::RtDataFromFile::RtDataFromFile ( )
inline

Definition at line 27 of file RtDataFromFile.h.

int m_major_version
format version
unsigned int m_rts
total number of regions

◆ ~RtDataFromFile()

MuonCalib::RtDataFromFile::~RtDataFromFile ( )
default

Member Function Documentation

◆ addRt() [1/2]

bool MuonCalib::RtDataFromFile::addRt ( int regionId,
RtRelation * rt )
inline

RtDataFromFile takes ownership of rt.

Definition at line 51 of file RtDataFromFile.h.

51 {
52 if (regionId < 0 || regionId >= (int)m_rts) {
53 MsgStream log(Athena::getMessageSvc(), "RtDataFromFile");
54 log << MSG::WARNING << "addRt() <regionId out of range> " << regionId << " size " << m_rts << endmsg;
55 return false;
56 }
57 if (m_rtRelations[regionId] != 0) {
58 MsgStream log(Athena::getMessageSvc(), "RtDataFromFile");
59 log << MSG::WARNING << "addRt() <rt already set>" << endmsg;
60 return false;
61 }
62
63 m_rtRelations[regionId] = rt;
64
65 return true;
66 }
#define endmsg
RtRelations m_rtRelations
rt relations
IMessageSvc * getMessageSvc(bool quiet=false)

◆ addRt() [2/2]

bool MuonCalib::RtDataFromFile::addRt ( int regionId,
RtRelation * rt,
const RtFullInfo * info )
inline

Definition at line 67 of file RtDataFromFile.h.

67 {
68 bool result = addRt(regionId, rt);
69 if (result) { m_fullInfo[regionId] = info; }
70 return result;
71 }
bool addRt(int regionId, RtRelation *rt)
RtDataFromFile takes ownership of rt.
std::vector< const RtFullInfo * > m_fullInfo

◆ getRt()

RtRelation * MuonCalib::RtDataFromFile::getRt ( unsigned int regionId) const
inline

retrieve rt-relation for a give regionId

Definition at line 34 of file RtDataFromFile.h.

34 {
35 if (regionId >= (unsigned int)m_rts) {
36 MsgStream log(Athena::getMessageSvc(), "RtDataFromFile");
37 log << MSG::WARNING << "getRt() <regionId out of range> " << regionId << " size " << m_rts << endmsg;
38 return 0;
39 }
40 return m_rtRelations[regionId];
41 }

◆ nRts()

unsigned int MuonCalib::RtDataFromFile::nRts ( ) const
inline

return number of rt relations

Definition at line 31 of file RtDataFromFile.h.

31{ return m_rts; }

◆ read()

std::istream & MuonCalib::RtDataFromFile::read ( std::istream & is)

Definition at line 18 of file RtDataFromFile.cxx.

18 {
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 }

◆ setNRts()

void MuonCalib::RtDataFromFile::setNRts ( unsigned int nrts)
inline

set total number of regions

Definition at line 44 of file RtDataFromFile.h.

44 {
45 m_rts = nrts;
46 m_rtRelations.resize(nrts);
47 m_fullInfo.resize(nrts);
48 }

◆ setVersion()

void MuonCalib::RtDataFromFile::setVersion ( int major,
int minor )
inline

Definition at line 77 of file RtDataFromFile.h.

77 {
78 m_major_version = major;
79 m_minor_version = minor;
80 }

◆ write() [1/2]

std::ostream & MuonCalib::RtDataFromFile::write ( std::ostream & os) const

Definition at line 71 of file RtDataFromFile.cxx.

71 {
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 }

◆ write() [2/2]

std::ostream & MuonCalib::RtDataFromFile::write ( std::ostream & os,
int region ) const

Definition at line 55 of file RtDataFromFile.cxx.

55 {
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 }

◆ write_forDB() [1/2]

void MuonCalib::RtDataFromFile::write_forDB ( FILE * frt,
FILE * frtt,
FILE * frtr,
FILE * frts ) const

Definition at line 100 of file RtDataFromFile.cxx.

100 {
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 }
void write_forDB(FILE *frt, FILE *frtt, FILE *frtr, FILE *frts, int region) const

◆ write_forDB() [2/2]

void MuonCalib::RtDataFromFile::write_forDB ( FILE * frt,
FILE * frtt,
FILE * frtr,
FILE * frts,
int region ) const

Definition at line 86 of file RtDataFromFile.cxx.

86 {
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 }

Member Data Documentation

◆ m_fullInfo

std::vector<const RtFullInfo*> MuonCalib::RtDataFromFile::m_fullInfo
private

Definition at line 88 of file RtDataFromFile.h.

◆ m_major_version

int MuonCalib::RtDataFromFile::m_major_version
private

format version

Definition at line 90 of file RtDataFromFile.h.

◆ m_minor_version

int MuonCalib::RtDataFromFile::m_minor_version
private

Definition at line 90 of file RtDataFromFile.h.

◆ m_rtRelations

RtRelations MuonCalib::RtDataFromFile::m_rtRelations
private

rt relations

Definition at line 87 of file RtDataFromFile.h.

◆ m_rts

unsigned int MuonCalib::RtDataFromFile::m_rts
private

total number of regions

Definition at line 84 of file RtDataFromFile.h.


The documentation for this class was generated from the following files: