CMS 3D CMS Logo

CSCReadoutMapping.cc
Go to the documentation of this file.
3 #include <iostream>
4 
5 CSCReadoutMapping::CSCReadoutMapping() : myName_("CSCReadoutMapping"), debugV_(false) {}
6 
8 
9 int CSCReadoutMapping::chamber(int endcap, int station, int vme, int dmb, int tmb) const {
10  // Build hw id from input, find sw id to match
11  int cid = 0;
12  int hid = hwId(endcap, station, vme, dmb, tmb);
13  // Search for that hw id in mapping
14  std::map<int, int>::const_iterator it = hw2sw_.find(hid);
15  if (it != hw2sw_.end()) {
16  cid = it->second;
17  // std::cout << "hwid = " << hid << ", swid = " << cid << std::endl;
18  // LogDebug("CSC") << " for requested hw id = " << hid << ", found sw id = " << cid;
19  } else {
20  edm::LogError("CSC") << " cannot find requested hw id = " << hid << " in mapping.";
21  }
22  return cid;
23 }
24 
25 CSCDetId CSCReadoutMapping::detId(int endcap, int station, int vme, int dmb, int tmb, int cfeb, int layer) const {
26  // Find CSCDetId index of chamber corresponding to the hardware readout arguments
27  int cid = chamber(endcap, station, vme, dmb, tmb);
28 
29  // Decode the individual labels
30  // ... include endcap & station for MTCC when they are unique in the mapping file
31  // and so do not need to be specified as input arguments
32  endcap = CSCDetId::endcap(cid);
34  int chamber = CSCDetId::chamber(cid);
35  int ring = CSCDetId::ring(cid);
36 
37  // Now sort out ME1a from ME11-combined
38  // cfeb =0-3 for ME1b, cfeb=4 for ME1a (pre-LS1) cfeb=4-6 (post-LS1)
39  if (station == 1 && ring == 1 && cfeb >= 4 && cfeb <= 6) {
40  // This is ME1a region
41  ring = 4; // reset from 1 to 4 which flags ME1a
42  }
43 
45 }
46 
48  int station,
49  int ring,
50  int chamber,
51  int vmecrate,
52  int dmb,
53  int tmb,
54  int tsector,
55  int cscid,
56  int ddu,
57  int dcc) {
58  CSCLabel newRecord(endcap, station, ring, chamber, vmecrate, dmb, tmb, tsector, cscid, ddu, dcc);
59  mapping_.push_back(newRecord);
60  int hid = hwId(endcap, station, vmecrate, dmb, tmb);
61  int sid = swId(endcap, station, ring, chamber);
62  // LogDebug("CSC") << " map hw " << hid << " to sw " << sid;
63  if (hw2sw_.insert(std::make_pair(hid, sid)).second) {
64  // LogDebug("CSC") << " insert pair succeeded.";
65  } else {
66  edm::LogError("CSC") << " already have key = " << hid;
67  }
69  sw2hw_.insert(std::make_pair(sid, newRecord));
70 }
71 
72 int CSCReadoutMapping::swId(int endcap, int station, int ring, int chamber) const {
73  // Software id is just CSCDetId for the chamber - but no distinction within ME11
74  return CSCDetId::rawIdMaker(endcap, station, ring, chamber, 0); // usual detid for chamber, i.e. layer=0
75 }
76 
78  CSCLabel hid;
79  int sid = CSCDetId::rawIdMaker(id.endcap(), id.station(), id.ring(), id.chamber(), 0);
81  std::map<int, CSCLabel>::const_iterator it = sw2hw_.find(sid);
82  if (it != sw2hw_.end()) {
83  hid = it->second;
84  // std::cout << "hwid = " << hid << ", swid = " << cid << std::endl;
85  // LogDebug("CSC") << " for requested hw id = " << hid << ", found sw id = " << cid;
86  } else {
87  edm::LogError("CSC") << " cannot find requested sw id = " << id << " in mapping.";
88  }
89  return hid;
90 }
91 
92 int CSCReadoutMapping::crate(const CSCDetId& id) const {
93  CSCLabel hid = findHardwareId(id);
94  return hid.vmecrate_;
95 }
96 int CSCReadoutMapping::dmbId(const CSCDetId& id) const {
97  CSCLabel hid = findHardwareId(id);
98  return hid.dmb_;
99 }
100 int CSCReadoutMapping::dduId(const CSCDetId& id) const {
101  CSCLabel hid = findHardwareId(id);
102  return hid.ddu_;
103 }
104 int CSCReadoutMapping::dccId(const CSCDetId& id) const {
105  CSCLabel hid = findHardwareId(id);
106  return hid.dcc_;
107 }
CSCReadoutMapping::~CSCReadoutMapping
virtual ~CSCReadoutMapping()
Destructor.
Definition: CSCReadoutMapping.cc:7
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
CSCDetId::rawIdMaker
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:146
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
CSCReadoutMapping::hwId
virtual int hwId(int endcap, int station, int vme, int dmb, int tmb) const =0
CSCReadoutMapping::CSCLabel::ddu_
int ddu_
Definition: CSCReadoutMapping.h:68
CSCReadoutMapping::dccId
int dccId(const CSCDetId &) const
returns DCC# given CSCDetId
Definition: CSCReadoutMapping.cc:104
CSCReadoutMapping.h
CSCReadoutMapping::mapping_
std::vector< CSCLabel > mapping_
Definition: CSCReadoutMapping.h:148
CSCReadoutMapping::chamber
int chamber(int endcap, int station, int vmecrate, int dmb, int tmb) const
Definition: CSCReadoutMapping.cc:9
CSCReadoutMapping::findHardwareId
CSCLabel findHardwareId(const CSCDetId &) const
returns hardware ids given chamber id
Definition: CSCReadoutMapping.cc:77
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
CSCReadoutMapping::dduId
int dduId(const CSCDetId &) const
returns DDU# given CSCDetId
Definition: CSCReadoutMapping.cc:100
CSCReadoutMapping::addRecord
void addRecord(int endcap, int station, int ring, int chamber, int vmecrate, int dmb, int tmb, int tsector, int cscid, int ddu, int dcc)
Definition: CSCReadoutMapping.cc:47
CSCReadoutMapping::CSCLabel::vmecrate_
int vmecrate_
Definition: CSCReadoutMapping.h:63
CSCReadoutMapping::CSCLabel
Definition: CSCReadoutMapping.h:33
CSCReadoutMapping::CSCLabel::dmb_
int dmb_
Definition: CSCReadoutMapping.h:64
CSCReadoutMapping::hw2sw_
std::map< int, int > hw2sw_
Definition: CSCReadoutMapping.h:149
CSCReadoutMapping::CSCReadoutMapping
CSCReadoutMapping()
Default constructor.
Definition: CSCReadoutMapping.cc:5
CSCDetId
Definition: CSCDetId.h:26
CSCReadoutMapping::sw2hw_
std::map< int, CSCLabel > sw2hw_
Definition: CSCReadoutMapping.h:150
CSCReadoutMapping::swId
int swId(int endcap, int station, int ring, int chamber) const
Definition: CSCReadoutMapping.cc:72
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
CSCReadoutMapping::crate
int crate(const CSCDetId &) const
returns vmecrate given CSCDetId
Definition: CSCReadoutMapping.cc:92
CSCReadoutMapping::dmbId
int dmbId(const CSCDetId &) const
returns dmbId given CSCDetId
Definition: CSCReadoutMapping.cc:96
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
CSCReadoutMapping::CSCLabel::dcc_
int dcc_
Definition: CSCReadoutMapping.h:69
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
CSCReadoutMapping::detId
CSCDetId detId(int endcap, int station, int vmecrate, int dmb, int tmb, int cfeb, int layer=0) const
Definition: CSCReadoutMapping.cc:25