ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloCoolChannelId.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <sstream>
8#include <iostream>
9
27
28//==============================================================================
29// constructor
30//==============================================================================
38
39//==============================================================================
40// constructor
41//==============================================================================
46 L1CaloModuleType mType,
47 unsigned int module,
48 unsigned int submodule,
49 unsigned int channel,
50 bool logical)
51 : m_id(0)
52{
53 if(logical) this->setId(crate, mType, module, submodule, channel);
54 else {
55 unsigned int moduleIndex = this->physicalToLogicalModule(mType, module);
56 this->setId(crate, mType, moduleIndex, submodule, channel);
57 }
58}
59
60//==============================================================================
61// constructor
62//==============================================================================
67 : m_id(id)
68{
69}
70
71//==============================================================================
72// copy constructor
73//==============================================================================
81
82//==============================================================================
83// setId
84//==============================================================================
88void
90 L1CaloModuleType mType,
91 unsigned int module,
92 unsigned int submodule,
93 unsigned int channel)
94{
95 m_id = (crate & 0xff) << 24 | (module & 0x0f) << 16 |
96 (submodule & 0xff) << 8 | (channel & 0xff);
97 // We only have a limited number of module types that will
98 // provide conditions data, so convert module types here.
99 // Ignore any other module type.
100
101 m_id |= ((unsigned int)mType & 0x0f) << 20;
102
103// if (mType == L1CaloModuleType::Ppm) { m_id |= 0x00100000; }
104// else if (mType == L1CaloModuleType::Cpm) { m_id |= 0x00200000; }
105// else if (mType == L1CaloModuleType::Jem) { m_id |= 0x00300000; }
106// else if (mType == L1CaloModuleType::Cmm) { m_id |= 0x00400000; }
107// else if (mType == L1CaloModuleType::Tcm) { m_id |= 0x00500000; }
108// else if (mType == L1CaloModuleType::L1CaloRod) { m_id |= 0x00600000; }
109// else if (mType == L1CaloModuleType::Cam) { m_id |= 0x00700000; }
110}
111
112//==============================================================================
113// getModuleType
114//==============================================================================
121{
122 unsigned int mTypeId = (m_id & 0x00f00000) >> 20;
124}
125
127// * Convert a typeId to a L1CaloModuleType
128// * \return L1CaloModuleType
129// */
130//L1CaloModuleType
131//L1CaloCoolChannelId::moduleType(unsigned int mTypeId) const
132//{
133// L1CaloModuleType mType = L1CaloModuleType::None;
134// if (mTypeId == 1) { mType = L1CaloModuleType::Ppm; }
135// else if (mTypeId == 2) { mType = L1CaloModuleType::Cpm; }
136// else if (mTypeId == 3) { mType = L1CaloModuleType::Jem; }
137// else if (mTypeId == 4) { mType = L1CaloModuleType::Cmm; }
138// else if (mTypeId == 5) { mType = L1CaloModuleType::Tcm; }
139// else if (mTypeId == 6) { mType = L1CaloModuleType::L1CaloRod; }
140// else if (mTypeId == 7) { mType = L1CaloModuleType::Cam; }
141// return mType;
142//}
143//
145// * Convert a L1CaloModuleType to a typeId
146// * \return unsigned int
147// */
148//unsigned int
149//L1CaloCoolChannelId::moduleType(L1CaloModuleType mType) const
150//{
151// unsigned int mTypeId = 0;
152// if (mType == L1CaloModuleType::Ppm) { mTypeId = 1; }
153// else if (mType == L1CaloModuleType::Cpm) { mTypeId = 2; }
154// else if (mType == L1CaloModuleType::Jem) { mTypeId = 3; }
155// else if (mType == L1CaloModuleType::Cmm) { mTypeId = 4; }
156// else if (mType == L1CaloModuleType::Tcm) { mTypeId = 5; }
157// else if (mType == L1CaloModuleType::L1CaloRod) { mTypeId = 6; }
158// else if (mType == L1CaloModuleType::Cam) { mTypeId = 7; }
159// return mTypeId;
160//}
161
162unsigned int L1CaloCoolChannelId::module(bool logical) const {
163 unsigned int logicalIndex = (m_id & 0x000f0000) >> 16;
164 if(logical) {
165 return logicalIndex;
166 } else {
167 return this->logicalToPhysicalModule(this->moduleType(), logicalIndex);
168 }
169}
170
172 if (mType == L1CaloModuleType::Ppm) { return module + 5; } //Ppm
173 else if (mType == L1CaloModuleType::Cpm) { return module + 5; } //Cpm
174 else if (mType == L1CaloModuleType::Jem) { return module + 4; } //Jem
175 else {
176 std::cout<<"The physical position of module type: "<<mType.toString()<<" is not known. Returning the logical index instead !"<<std::endl;
177 return module;
178 }
179}
180
182 if (mType == L1CaloModuleType::Ppm) { return module - 5; } //Ppm
183 else if (mType == L1CaloModuleType::Cpm) { return module - 5; } //Cpm
184 else if (mType == L1CaloModuleType::Jem) { return module - 4; } //Jem
185 else {
186 std::cout<<"The physical position of module type: "<<mType.toString()<<" is not known. Returning the logical index instead !"<<std::endl;
187 return module;
188 }
189}
190
191
192//==============================================================================
193// operator=
194//==============================================================================
200{
201 if (this != &id) m_id = id.m_id;
202 return *this;
203}
204
206 return m_id<id.m_id;
207}
208
210 return m_id==id.m_id;
211}
212
213std::ostream& operator<<(std::ostream& output, const L1CaloCoolChannelId& r) {
214 output << "coolChannelId: 0x" << std::hex <<r.id() << std::dec <<"("<<r.id()<<"), crate: "<<r.crate()<<", module: "<<r.module()<<", submodule: "<<r.subModule()<<", channel: "<<r.channel();
215 return output;
216}
std::ostream & operator<<(std::ostream &output, const L1CaloCoolChannelId &r)
Encapsulates the ID of one channel of conditions data in COOL, ie the ID of a row in a table.
L1CaloModuleType moduleType() const
Return module type of this channel ID.
unsigned int physicalToLogicalModule(L1CaloModuleType mType, unsigned int module) const
unsigned int id() const
L1CaloCoolChannelId & operator=(const L1CaloCoolChannelId &id)
Copy a L1CaloCoolChannelId.
bool operator==(const L1CaloCoolChannelId &id) const
bool operator<(const L1CaloCoolChannelId &id) const
L1CaloCoolChannelId()
Create a L1CaloCoolChannelId from the integer ID field.
unsigned int module(bool logical=true) const
Convert a typeId to a L1CaloModuleType.
unsigned int crate() const
void setId(unsigned int crate, L1CaloModuleType mType, unsigned int module, unsigned int submodule, unsigned int channel)
Set the CoolChannelId value from its component fields.
unsigned int logicalToPhysicalModule(L1CaloModuleType mType, unsigned int module) const
unsigned int channel() const
Infrastructure class encapsulating our known module types.
const std::string toString() const
Compare with type value.
int r
Definition globals.cxx:22