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