ATLAS Offline Software
Loading...
Searching...
No Matches
CMAidentity.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <iomanip>
8#include <string>
9
10const char CMAidentity::CoverageTAG[3][5] = {{"even"}, {"odd"}, {""}};
11
12bool CMAidentity::coverage(const std::string& side, CMAcoverage& cov) {
13 for (int i = EvenSectors; i <= AllSectors; ++i) {
14 std::string tag(CoverageTAG[i]);
15 if (side == tag) {
16 cov = (CMAcoverage)i;
17 return true;
18 }
19 }
20 return false;
21}
22
23const std::string CMAidentity::name(const ViewType view, const CMAcoverage coverage) {
24 std::string cover(CMAidentity::covtag(coverage));
25 std::string side = view == ViewType::Eta ? "Eta" : (view == ViewType::Phi ? "Phi" : "NoView");
26 std::string v_name = cover + side + "CMA";
27 return v_name;
28}
30
32 m_params.view = view;
33 m_params.coverage = side;
34 m_params.seqNumber = number;
35 m_params.etaIndex = eta_index;
36 m_params.phiIndex = phi_index;
37 m_params.padIndex = PAD_index;
38 m_params.IxxIndex = Ixx_index;
39}
40
42 m_params.view = view;
43 m_params.coverage = side;
44 m_params.seqNumber = number;
45}
46
48 m_params.view = view;
49 m_params.coverage = side;
50 m_params.etaIndex = indexes.first;
51 m_params.phiIndex = indexes.second;
52}
53
54CMAidentity::CMAidentity(ViewType view, CMAcoverage side, int PAD, int Ixx) {
55 m_params.view = view;
56 m_params.coverage = side;
57 m_params.padIndex = PAD;
58 m_params.IxxIndex = Ixx;
59}
60
61bool CMAidentity::operator==(const CMAidentity& id) const {
62 if (m_params.view == id.type() && m_params.coverage == id.coverage()) {
63 if (number() >= 0)
64 if (number() == id.number()) return true;
65
66 if (m_params.etaIndex >= 0)
67 if (m_params.etaIndex == id.eta_index() && m_params.phiIndex == id.phi_index()) return true;
68
69 if (m_params.padIndex >= 0)
70 if (m_params.padIndex == id.PAD_index() && m_params.IxxIndex == id.Ixx_index()) return true;
71 }
72 return false;
73}
74
75bool CMAidentity::operator!=(const CMAidentity& id) const { return !(*this == id); }
76
77bool CMAidentity::operator<(const CMAidentity& id) const {
78 if (*this == id) return false;
79 if (m_params.view < id.type()) return true;
80 if (m_params.coverage < id.coverage()) return true;
81 int id1 = m_params.etaIndex * 10 + m_params.phiIndex;
82 int id2 = id.eta_index() * 10 + id.phi_index();
83 return id1 < id2;
84}
85
87 if (*this != id) return *this;
88 if (m_params.seqNumber == -1) m_params.seqNumber = id.number();
89 if (m_params.etaIndex == -1) m_params.etaIndex = id.eta_index();
90 if (m_params.phiIndex == -1) m_params.phiIndex = id.phi_index();
91 if (m_params.padIndex == -1) m_params.padIndex = id.PAD_index();
92 if (m_params.IxxIndex == -1) m_params.IxxIndex = id.Ixx_index();
93 return *this;
94}
95
96void CMAidentity::inversion() { m_params.IxxIndex = (m_params.IxxIndex == 0) ? 1 : 0; }
97
98std::ostream& operator<<(std::ostream& stream, const CMAidentity& id) {
99 char exttag[5] = {' ', ' ', ' ', ' ', '\0'};
100 const char* tag = CMAidentity::covtag(id.m_params.coverage);
101 for (int i = 0; i < 5; ++i) {
102 if (tag[i] == '\0') break;
103 exttag[i] = tag[i];
104 }
105
106 std::string covtag(exttag);
107
108 std::string type = (id.type() == Phi) ? " phi cma " + covtag : " eta cma " + covtag;
109 if (!covtag.empty()) type = type + " ";
110 stream << type << std::setw(2) << id.number() << ": Eta ";
111 stream << std::setw(2) << id.eta_index();
112 stream << " Phi " << std::setw(2) << id.phi_index();
113 stream << " PAD " << std::setw(2) << id.PAD_index();
114 stream << " Ixx " << std::setw(2) << id.Ixx_index();
115 return stream;
116}
117ViewType CMAidentity::type() const { return m_params.view; }
118CMAcoverage CMAidentity::coverage() const { return m_params.coverage; }
119int CMAidentity::number() const { return m_params.seqNumber; }
120int CMAidentity::eta_index() const { return m_params.etaIndex; }
121int CMAidentity::phi_index() const { return m_params.phiIndex; }
122int CMAidentity::PAD_index() const { return m_params.padIndex; }
123int CMAidentity::Ixx_index() const { return m_params.IxxIndex; }
std::ostream & operator<<(std::ostream &stream, const CMAidentity &id)
CMAcoverage
Definition CMAidentity.h:14
@ AllSectors
Definition CMAidentity.h:14
@ EvenSectors
Definition CMAidentity.h:14
HWIdentifier id2
ViewType
Definition RPCdef.h:8
@ Phi
Definition RPCdef.h:8
@ Eta
Definition RPCdef.h:8
CMAidentity(const defineParams &pars)
CMAidentity & operator+=(const CMAidentity &)
static const std::string name(const ViewType, const CMAcoverage)
static const char * covtag(const CMAcoverage co)
Definition CMAidentity.h:24
CMAcoverage coverage() const
int number() const
void inversion()
bool operator!=(const CMAidentity &) const
bool operator==(const CMAidentity &) const
ViewType type() const
int Ixx_index() const
bool operator<(const CMAidentity &) const
static const char CoverageTAG[3][5]
Definition CMAidentity.h:10
static bool coverage(const std::string &, CMAcoverage &)
int PAD_index() const
std::pair< int, int > Offline_indexes
Definition CMAidentity.h:18
int eta_index() const
int phi_index() const
defineParams m_params
Definition CMAidentity.h:43