CMS 3D CMS Logo

CSCTriggerMapping.cc
Go to the documentation of this file.
3 #include <iostream>
4 
5 CSCTriggerMapping::CSCTriggerMapping() : myName_("CSCTriggerMapping"), debugV_(false) {}
6 
8 
9 int CSCTriggerMapping::chamber(int endcap, int station, int sector, int subsector, int cscid) const {
10  // Build hw id from input, find sw id to match
11  int cid = 0;
12  int hid = hwId(endcap, station, sector, subsector, cscid);
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  if (debugV())
18  std::cout << myName_ << ": for requested hw id = " << hid << ", found sw id = " << cid << std::endl;
19  } else {
20  std::cout << myName_ << ": ERROR, cannot find requested hw id = " << hid << " in mapping." << std::endl;
21  }
22  return cid;
23 }
24 
25 CSCDetId CSCTriggerMapping::detId(int endcap, int station, int sector, int subsector, int cscid, int layer) const {
26  int cid = chamber(endcap, station, sector, subsector, cscid);
27  int lid = cid + layer;
28  return CSCDetId(lid);
29 }
30 
32  int rstation,
33  int rsector,
34  int rsubsector,
35  int rcscid,
36  int cendcap,
37  int cstation,
38  int csector,
39  int csubsector,
40  int ccscid) {
41  Connection newRecord(rendcap, rstation, rsector, rsubsector, rcscid, cendcap, cstation, csector, csubsector, ccscid);
42  mapping_.push_back(newRecord);
43  int hid = hwId(rendcap, rstation, rsector, rsubsector, rcscid);
44  int sid = swId(cendcap, cstation, csector, csubsector, ccscid);
45  if (debugV())
46  std::cout << myName_ << ": map hw " << hid << " to sw " << sid << std::endl;
47  if (hw2sw_.insert(std::make_pair(hid, sid)).second) {
48  if (debugV())
49  std::cout << myName_ << ": insert pair succeeded." << std::endl;
50  } else {
51  std::cout << myName_ << ": ERROR, already have key = " << hid << std::endl;
52  }
53 }
54 
55 int CSCTriggerMapping::swId(int endcap, int station, int sector, int subsector, int cscid) const {
56  // Software id is just CSCDetId for the chamber
58  int chamber = CSCTriggerNumbering::chamberFromTriggerLabels(sector, subsector, station, cscid);
59  return CSCDetId::rawIdMaker(endcap, station, ring, chamber, 0); // usual detid for chamber, i.e. layer=0
60 }
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:146
static int ringFromTriggerLabels(int station, int triggerCSCID)
CSCTriggerMapping()
Default constructor.
int swId(int endcap, int station, int sector, int subsector, int cscid) const
void addRecord(int rendcap, int rstation, int rsector, int rsubsector, int rcscid, int cendcap, int cstation, int csector, int csubsector, int ccscid)
constexpr std::array< uint8_t, layerIndexSize > layer
std::map< int, int > hw2sw_
virtual ~CSCTriggerMapping()
Destructor.
int chamber(int endcap, int station, int sector, int subsector, int cscid) const
bool debugV(void) const
CSCDetId detId(int endcap, int station, int sector, int subsector, int cscid, int layer=0) const
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
std::vector< Connection > mapping_
virtual int hwId(int endcap, int station, int sector, int subsector, int cscid) const =0