ATLAS Offline Software
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
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 More...
 
unsigned int nregions () const
 returns the number of regions More...
 
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 More...
 
void clear ()
 clear entries More...
 
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 More...
 
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

Definition at line 30 of file RegionDataFromFile.h.

◆ 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 25 of file RegionDataFromFile.cxx.

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

◆ clear()

void MuonCalib::RegionDataFromFile::clear ( )

clear entries

Definition at line 36 of file RegionDataFromFile.cxx.

36  {
37  m_nregions = 0;
39  }

◆ 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 14 of file RegionDataFromFile.cxx.

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

◆ nregions()

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

returns the number of regions

◆ read()

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

Definition at line 41 of file RegionDataFromFile.cxx.

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

◆ 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 80 of file RegionDataFromFile.cxx.

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

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:
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
MuonCalib::RegionDataFromFile::id_vec
std::vector< id_type > id_vec
Definition: RegionDataFromFile.h:31
MuonCalib::RegionDataFromFile::m_identifiersPerRegions
id_vec_vec m_identifiersPerRegions
Definition: RegionDataFromFile.h:61
MuonCalib::RegionDataFromFile::m_nregions
unsigned int m_nregions
map containing all identifiers for a given region id
Definition: RegionDataFromFile.h:60
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::RegionDataFromFile::clear
void clear()
clear entries
Definition: RegionDataFromFile.cxx:36
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
python.xAODType.dummy
dummy
Definition: xAODType.py:4
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MAX_VALUE
#define MAX_VALUE
Definition: RegionDataFromFile.cxx:10