CMS 3D CMS Logo

RPCCompDetId.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: src
4 // Class : RPCCompDetId
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Author: Marcello Maggi
10 // Created: Wed Nov 2 12:09:10 CET 2011
11 #include <iostream>
12 #include <sstream>
13 #include <iomanip>
16 
17 RPCCompDetId::RPCCompDetId() : DetId(DetId::Muon, MuonSubdetId::RPC), _dbname(""), _type(0) {}
18 
19 RPCCompDetId::RPCCompDetId(uint32_t id) : DetId(id), _dbname(""), _type(0) {
20  if (det() != DetId::Muon || subdetId() != MuonSubdetId::RPC) {
21  throw cms::Exception("InvalidDetId") << "RPCCompDetId ctor:"
22  << " det: " << det() << " subdet: " << subdetId() << " is not a valid RPC id";
23  }
24 }
25 
26 RPCCompDetId::RPCCompDetId(DetId id) : DetId(id), _dbname(""), _type(0) {
27  if (det() != DetId::Muon || subdetId() != MuonSubdetId::RPC) {
28  throw cms::Exception("InvalidDetId") << "RPCCompDetId ctor:"
29  << " det: " << det() << " subdet: " << subdetId() << " is not a valid RPC id";
30  }
31 }
32 
33 RPCCompDetId::RPCCompDetId(int region, int ring, int station, int sector, int layer, int subsector, int type)
34  : DetId(DetId::Muon, MuonSubdetId::RPC), _dbname(""), _type(type) {
35  this->init(region, ring, station, sector, layer, subsector);
36 }
37 
39  : DetId(DetId::Muon, MuonSubdetId::RPC), _dbname(name), _type(type) {
40  this->init();
41 }
42 
43 bool RPCCompDetId::operator<(const RPCCompDetId& r) const { return this->dbname() < r.dbname(); }
44 
46 
47 int RPCCompDetId::ring() const { return int((id_ >> RingStartBit_) & RingMask_) + allRingId; }
48 
49 int RPCCompDetId::wheel() const {
50  int w = allRingId;
51  if (this->region() == 0)
52  w = this->ring();
53  return w;
54 }
55 
57 
58 int RPCCompDetId::disk() const {
59  int d = allStationId;
60  if (this->region() != 0)
61  d = this->station();
62  return d;
63 }
64 
66 
68 
70 
71 int RPCCompDetId::type() const { return _type; }
72 
75  if (a.empty()) {
76  if (this->type() == 0) {
77  a = this->gasDBname();
78  }
79  }
80  return a;
81 }
82 
83 void RPCCompDetId::init(int region, int ring, int station, int sector, int layer, int subsector) {
85  if (!region) {
87  }
88 
89  if (region < allRegionId || region > maxRegionId || ring < allRingId || ring > maxRing || station < allStationId ||
90  station > maxStationId || sector < allSectorId || sector > maxSectorId || layer < allLayerId ||
91  layer > maxLayerId || subsector < allSubSectorId || subsector > maxSubSectorId) {
92  throw cms::Exception("InvalidDetId") << "RPCDetId ctor:"
93  << " Invalid parameters: "
94  << " region " << region << " ring " << ring << " station " << station
95  << " sector " << sector << " layer " << layer << " subsector " << subsector
96  << std::endl;
97  }
98  int regionInBits = region - allRegionId;
99  int ringInBits = ring - allRingId;
100  int stationInBits = station - allStationId;
101  int sectorInBits = sector - allSectorId;
102  int layerInBits = layer - allLayerId;
103  int subSectorInBits = subsector - allSubSectorId;
104 
105  id_ |= (regionInBits & RegionMask_) << RegionStartBit_ | (ringInBits & RingMask_) << RingStartBit_ |
106  (stationInBits & StationMask_) << StationStartBit_ | (sectorInBits & SectorMask_) << SectorStartBit_ |
107  (layerInBits & LayerMask_) << LayerStartBit_ | (subSectorInBits & SubSectorMask_) << SubSectorStartBit_;
108 }
109 
111  if (this->type() == 0) {
112  this->initGas();
113  }
114 }
115 
117  std::string buf(this->dbname());
118  // check if the name contains the dcs namespace
119  if (buf.find(':') != buf.npos) {
120  buf = buf.substr(buf.find(':') + 1, buf.npos);
121  }
122  _dbname = buf;
123  // Check if endcap o barrel
124  int region = 0;
125  if (buf.substr(0, 1) == "W") {
126  region = 0;
127  } else if (buf.substr(0, 2) == "EP") {
128  region = 1;
129  } else if (buf.substr(0, 2) == "EM") {
130  region = -1;
131  } else {
132  throw cms::Exception("InvalidDBName")
133  << " RPCCompDetId: " << this->dbname() << " is not a valid DB Name for RPCCompDetId"
134  << " det: " << det() << " subdet: " << subdetId();
135  }
136  int ring = allRingId;
137  int station = allStationId;
138  int sector = allSectorId;
139  int layer = allLayerId;
141  //Barrel
142  if (region == 0) {
143  // Extract the Wheel (named ring)
144  {
145  std::stringstream os;
146  os << buf.substr(2, 1);
147  os >> ring;
148  if (buf.substr(1, 1) == "M") {
149  ring *= -1;
150  }
151  }
152  //Extract the station
153  {
154  std::stringstream os;
155  os << buf.substr(buf.find("RB") + 2, 1);
156  os >> station;
157  }
158  //Extract the sector
159  {
160  std::stringstream os;
161  os << buf.substr(buf.find('S') + 1, 2);
162  os >> sector;
163  }
164  //Extract subsector of sectors 4 and 10
165  {
166  if (buf.find("4L") != buf.npos)
167  subsector = 1;
168  if (buf.find("4R") != buf.npos)
169  subsector = 2;
170  }
171  } else {
172  // Extract the Ring
173  {
174  std::stringstream os;
175  os << buf.substr(buf.find("_R0") + 3, 1);
176  os >> ring;
177  }
178  //Extract the disk (named station)
179  {
180  std::stringstream os;
181  os << buf.substr(2, 1);
182  os >> station;
183  }
184  //Extract the sector or chamber
185  {
186  std::stringstream os;
187  os << buf.substr(buf.find("_C") + 2, 2);
188  os >> sector;
189  }
190  //Extract layer
191  {
192  if (buf.find("UP") != buf.npos)
193  layer = 1;
194  if (buf.find("DW") != buf.npos)
195  layer = 2;
196  }
197  }
198  this->init(region, ring, station, sector, layer, subsector);
199 }
200 
202  std::stringstream os;
203  if (this->region() == 0) {
204  // Barrel
205  std::string wsign = "P";
206  if (this->wheel() < 0)
207  wsign = "M";
208  std::string lr = "";
209  if (this->subsector() == 1)
210  lr = "L";
211  if (this->subsector() == 2)
212  lr = "R";
213  os << "W" << wsign << abs(this->wheel()) << "_S" << std::setw(2) << std::setfill('0') << this->sector() << "_RB"
214  << this->station() << lr;
215  } else {
216  // Endcap
217  std::string esign = "P";
218  if (this->region() < 0)
219  esign = "M";
220 
221  os << "E" << esign << this->disk();
222 
223  if (this->disk() == 1) {
224  os << "_R" << std::setw(2) << std::setfill('0') << this->ring() << "_C" << std::setw(2) << std::setfill('0')
225  << this->sector() << "_C" << std::setw(2) << std::setfill('0') << this->sector() + 5;
226  } else {
227  os << "_R" << std::setw(2) << std::setfill('0') << this->ring() << "_R" << std::setw(2) << std::setfill('0')
228  << this->ring() + 1 << "_C" << std::setw(2) << std::setfill('0') << this->sector() << "_C" << std::setw(2)
229  << std::setfill('0') << this->sector() + 2;
230  }
231  std::string lay = "";
232  if (this->layer() == 1)
233  lay = "UP";
234  else if (this->layer() == 2)
235  lay = "DW";
236 
237  os << "_" << lay;
238  }
239  return os.str();
240 }
241 
242 std::ostream& operator<<(std::ostream& os, const RPCCompDetId& id) {
243  os << id.dbname();
244 
245  return os;
246 }
l1t::mtf7::RPC
RPC Data Record : block->header().getID() = 4.
Definition: Block.h:20
RPCCompDetId::allRingId
static const int allRingId
Definition: RPCCompDetId.h:59
RPCCompDetId::station
int station() const
Definition: RPCCompDetId.cc:56
HLT_FULL_cff.maxRing
maxRing
Definition: HLT_FULL_cff.py:46711
RPCCompDetId::allSectorId
static const int allSectorId
Definition: RPCCompDetId.h:71
RPCCompDetId::RingMask_
static const unsigned int RingMask_
Definition: RPCCompDetId.h:88
RPCCompDetId::type
int type() const
Definition: RPCCompDetId.cc:71
RPCCompDetId::operator<
bool operator<(const RPCCompDetId &r) const
Sort Operator based on the name.
Definition: RPCCompDetId.cc:43
RPCCompDetId::SectorStartBit_
static const int SectorStartBit_
Definition: RPCCompDetId.h:95
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
RPCCompDetId.h
RPCCompDetId::RegionMask_
static const int RegionMask_
Definition: RPCCompDetId.h:84
RPCCompDetId::SubSectorStartBit_
static const int SubSectorStartBit_
Definition: RPCCompDetId.h:103
RPCCompDetId::maxStationId
static const int maxStationId
Definition: RPCCompDetId.h:62
Muon
Definition: Muon.py:1
RPCCompDetId::gasDBname
std::string gasDBname() const
Definition: RPCCompDetId.cc:201
RPCCompDetId::maxSubSectorId
static const int maxSubSectorId
Definition: RPCCompDetId.h:78
RPCCompDetId::maxLayerId
static const int maxLayerId
Definition: RPCCompDetId.h:74
DetId
Definition: DetId.h:17
RPCCompDetId::RPCCompDetId
RPCCompDetId()
Definition: RPCCompDetId.cc:17
RPCCompDetId::LayerMask_
static const unsigned int LayerMask_
Definition: RPCCompDetId.h:100
RPCCompDetId::allSubSectorId
static const int allSubSectorId
Definition: RPCCompDetId.h:79
RPCCompDetId::RegionStartBit_
static const int RegionStartBit_
Definition: RPCCompDetId.h:83
w
const double w
Definition: UKUtility.cc:23
RPCCompDetId::disk
int disk() const
Definition: RPCCompDetId.cc:58
RPCCompDetId::region
int region() const
Definition: RPCCompDetId.cc:45
RPCCompDetId::layer
int layer() const
Definition: RPCCompDetId.cc:67
RPCCompDetId::StationStartBit_
static const int StationStartBit_
Definition: RPCCompDetId.h:91
RPCCompDetId::RingStartBit_
static const int RingStartBit_
Definition: RPCCompDetId.h:87
RPCCompDetId::SubSectorMask_
static const unsigned int SubSectorMask_
Definition: RPCCompDetId.h:104
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
RPCCompDetId::ring
int ring() const
Definition: RPCCompDetId.cc:47
RPCCompDetId
Definition: RPCCompDetId.h:21
a
double a
Definition: hdecay.h:119
DetId::id_
uint32_t id_
Definition: DetId.h:69
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
RPCCompDetId::dbname
std::string dbname() const
Definition: RPCCompDetId.cc:73
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
createfilelist.int
int
Definition: createfilelist.py:10
RPCCompDetId::allStationId
static const int allStationId
Definition: RPCCompDetId.h:63
MuonSubdetId.h
RPCCompDetId::initGas
void initGas()
Definition: RPCCompDetId.cc:116
visDQMUpload.buf
buf
Definition: visDQMUpload.py:160
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
alignCSCRings.r
r
Definition: alignCSCRings.py:93
RPCCompDetId::allLayerId
static const int allLayerId
Definition: RPCCompDetId.h:75
RPCCompDetId::StationMask_
static const unsigned int StationMask_
Definition: RPCCompDetId.h:92
RPCCompDetId::SectorMask_
static const unsigned int SectorMask_
Definition: RPCCompDetId.h:96
MuonSubdetId::RPC
static constexpr int RPC
Definition: MuonSubdetId.h:13
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
RPCCompDetId::LayerStartBit_
static const int LayerStartBit_
Definition: RPCCompDetId.h:99
Exception
Definition: hltDiff.cc:245
RPCCompDetId::_dbname
std::string _dbname
Definition: RPCCompDetId.h:114
RPCCompDetId::maxRingBarrelId
static const int maxRingBarrelId
Definition: RPCCompDetId.h:57
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
RPCCompDetId::wheel
int wheel() const
Definition: RPCCompDetId.cc:49
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
RPCCompDetId::sector
int sector() const
Definition: RPCCompDetId.cc:65
RPCCompDetId::maxRegionId
static const int maxRegionId
Definition: RPCCompDetId.h:51
ztail.d
d
Definition: ztail.py:151
operator<<
std::ostream & operator<<(std::ostream &os, const RPCCompDetId &id)
Definition: RPCCompDetId.cc:242
DetId::Muon
Definition: DetId.h:26
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RPCCompDetId::subsector
int subsector() const
Definition: RPCCompDetId.cc:69
RPCCompDetId::allRegionId
static const int allRegionId
Definition: RPCCompDetId.h:52
MuonSubdetId
Definition: MuonSubdetId.h:9
RPCCompDetId::init
void init()
Definition: RPCCompDetId.cc:110
RPCCompDetId::_type
int _type
Definition: RPCCompDetId.h:115
RPCCompDetId::maxSectorId
static const int maxSectorId
Definition: RPCCompDetId.h:66
RPCCompDetId::maxRingForwardId
static const int maxRingForwardId
Definition: RPCCompDetId.h:55