File indexing completed on 2024-04-06 12:02:00
0001 #include <CondFormats/CSCObjects/interface/CSCTriggerMapping.h>
0002 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
0003 #include <iostream>
0004
0005 CSCTriggerMapping::CSCTriggerMapping() : myName_("CSCTriggerMapping"), debugV_(false) {}
0006
0007 CSCTriggerMapping::~CSCTriggerMapping() {}
0008
0009 int CSCTriggerMapping::chamber(int endcap, int station, int sector, int subsector, int cscid) const {
0010
0011 int cid = 0;
0012 int hid = hwId(endcap, station, sector, subsector, cscid);
0013
0014 std::map<int, int>::const_iterator it = hw2sw_.find(hid);
0015 if (it != hw2sw_.end()) {
0016 cid = it->second;
0017 if (debugV())
0018 std::cout << myName_ << ": for requested hw id = " << hid << ", found sw id = " << cid << std::endl;
0019 } else {
0020 std::cout << myName_ << ": ERROR, cannot find requested hw id = " << hid << " in mapping." << std::endl;
0021 }
0022 return cid;
0023 }
0024
0025 CSCDetId CSCTriggerMapping::detId(int endcap, int station, int sector, int subsector, int cscid, int layer) const {
0026 int cid = chamber(endcap, station, sector, subsector, cscid);
0027 int lid = cid + layer;
0028 return CSCDetId(lid);
0029 }
0030
0031 void CSCTriggerMapping::addRecord(int rendcap,
0032 int rstation,
0033 int rsector,
0034 int rsubsector,
0035 int rcscid,
0036 int cendcap,
0037 int cstation,
0038 int csector,
0039 int csubsector,
0040 int ccscid) {
0041 Connection newRecord(rendcap, rstation, rsector, rsubsector, rcscid, cendcap, cstation, csector, csubsector, ccscid);
0042 mapping_.push_back(newRecord);
0043 int hid = hwId(rendcap, rstation, rsector, rsubsector, rcscid);
0044 int sid = swId(cendcap, cstation, csector, csubsector, ccscid);
0045 if (debugV())
0046 std::cout << myName_ << ": map hw " << hid << " to sw " << sid << std::endl;
0047 if (hw2sw_.insert(std::make_pair(hid, sid)).second) {
0048 if (debugV())
0049 std::cout << myName_ << ": insert pair succeeded." << std::endl;
0050 } else {
0051 std::cout << myName_ << ": ERROR, already have key = " << hid << std::endl;
0052 }
0053 }
0054
0055 int CSCTriggerMapping::swId(int endcap, int station, int sector, int subsector, int cscid) const {
0056
0057 int ring = CSCTriggerNumbering::ringFromTriggerLabels(station, cscid);
0058 int chamber = CSCTriggerNumbering::chamberFromTriggerLabels(sector, subsector, station, cscid);
0059 return CSCDetId::rawIdMaker(endcap, station, ring, chamber, 0);
0060 }