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

Manages the I/O of the list of multilayers belonging to a calibration region. More...

#include <RegionDataFromFile.h>

Collaboration diagram for MuonCalib::RegionDataFromFile:

Public Types

typedef MultilayerId id_type
typedef std::vector< id_typeid_vec

Public Member Functions

id_vec getIdentifiers (int regionId) const
 returns a vector containing all identifiers for the given regionId, returns an empty vector if the regionId is out of range or the region is empty
unsigned int nregions () const
 returns the number of regions
void setNRegions (unsigned int nreg)
bool addRegion (int regionIndex, const id_vec &ids)
 returns false if the region was already present, nothing is added in that case
void clear ()
 clear entries
std::istream & read (std::istream &is)
std::ostream & write (std::ostream &os) const

Private Types

typedef std::vector< id_vecid_vec_vec

Private Attributes

unsigned int m_nregions
 map containing all identifiers for a given region id
id_vec_vec m_identifiersPerRegions

Detailed Description

Manages the I/O of the list of multilayers belonging to a calibration region.

Definition at line 28 of file RegionDataFromFile.h.

Member Typedef Documentation

◆ id_type

◆ id_vec

Definition at line 31 of file RegionDataFromFile.h.

◆ id_vec_vec

typedef std::vector<id_vec> MuonCalib::RegionDataFromFile::id_vec_vec
private

Definition at line 57 of file RegionDataFromFile.h.

Member Function Documentation

◆ addRegion()

bool MuonCalib::RegionDataFromFile::addRegion ( int regionIndex,
const id_vec & ids )

returns false if the region was already present, nothing is added in that case

Definition at line 26 of file RegionDataFromFile.cxx.

26 {
27 if (regionId >= 0 && regionId < (int)m_identifiersPerRegions.size()) {
28 m_identifiersPerRegions[regionId] = ids;
29 return true;
30 } else {
31 MsgStream log(Athena::getMessageSvc(), "RegionDataFromFile");
32 log << MSG::WARNING << "addRegion() <index out of range> " << regionId << " size " << m_identifiersPerRegions.size() << endmsg;
33 return false;
34 }
35 }
#define endmsg
IMessageSvc * getMessageSvc(bool quiet=false)

◆ clear()

void MuonCalib::RegionDataFromFile::clear ( )

clear entries

Definition at line 37 of file RegionDataFromFile.cxx.

37 {
38 m_nregions = 0;
40 }
unsigned int m_nregions
map containing all identifiers for a given region id

◆ getIdentifiers()

RegionDataFromFile::id_vec MuonCalib::RegionDataFromFile::getIdentifiers ( int regionId) const

returns a vector containing all identifiers for the given regionId, returns an empty vector if the regionId is out of range or the region is empty

Definition at line 15 of file RegionDataFromFile.cxx.

15 {
16 if (regionId >= 0 && regionId < (int)m_identifiersPerRegions.size()) {
17 return m_identifiersPerRegions[regionId];
18 } else {
19 MsgStream log(Athena::getMessageSvc(), "RegionDataFromFile");
20 log << MSG::WARNING << "getIdentifiers() <index out of range> " << regionId << " size " << m_identifiersPerRegions.size()
21 << endmsg;
22 return id_vec();
23 }
24 }
std::vector< id_type > id_vec

◆ nregions()

unsigned int MuonCalib::RegionDataFromFile::nregions ( ) const

returns the number of regions

◆ read()

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

Definition at line 42 of file RegionDataFromFile.cxx.

42 {
43 // clear vector before starting to read
45
46 std::string dummy;
47
48 // read header containing the total number of regions
49 is >> dummy >> m_nregions;
51 // loop over all regions in file
52 int regionId, nelements;
53 for (int i = 0; i < static_cast<int>(m_nregions); ++i) {
54 // read region header containing the region id and the number of identifiers
55 is >> dummy >> regionId >> nelements;
56 nelements = (nelements > MAX_VALUE) ? MAX_VALUE : nelements;
57 if (regionId != i) {
58 MsgStream log(Athena::getMessageSvc(), "RegionDataFromFile");
59 log << MSG::WARNING << "read() <read wrong regionId> " << regionId << " current " << i << ". Aborting reading" << endmsg;
60 clear();
61 return is;
62 }
63
64 id_vec ids;
65 ids.reserve(nelements);
66
67 // loop over identifiers in file
68 int s, e, p, m;
69 for (int j = 0; j < nelements; ++j) {
70 // read stName,eta,phi,ml
71 is >> s >> e >> p >> m;
72 ids.push_back(MultilayerId(s, e, p, m));
73 }
74
75 m_identifiersPerRegions.push_back(std::move(ids));
76 }
77
78 return is;
79 }
#define MAX_VALUE

◆ setNRegions()

void MuonCalib::RegionDataFromFile::setNRegions ( unsigned int nreg)
inline

Definition at line 41 of file RegionDataFromFile.h.

41 {
42 m_nregions = nreg;
43 m_identifiersPerRegions.resize(nreg);
44 }

◆ write()

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

Definition at line 81 of file RegionDataFromFile.cxx.

81 {
82 // write header
83 os << "Regions " << m_identifiersPerRegions.size() << std::endl;
84
85 // write regions
86 for (unsigned int i = 0; i < m_identifiersPerRegions.size(); ++i) {
87 unsigned int ids = m_identifiersPerRegions[i].size();
88 os << "RegionId " << i << " " << ids << std::endl;
89
90 // write ids
91 for (unsigned int j = 0; j < ids; ++j) {
92 MultilayerId id = m_identifiersPerRegions[i][j];
93 os << " " << id.stName << " " << id.eta << " " << id.phi << " " << id.ml << std::endl;
94 }
95 }
96 return os;
97 }

Member Data Documentation

◆ m_identifiersPerRegions

id_vec_vec MuonCalib::RegionDataFromFile::m_identifiersPerRegions
private

Definition at line 61 of file RegionDataFromFile.h.

◆ m_nregions

unsigned int MuonCalib::RegionDataFromFile::m_nregions
private

map containing all identifiers for a given region id

Definition at line 60 of file RegionDataFromFile.h.


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