CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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() ) std::cout << myName_ << ": for requested hw id = " << hid <<
18  ", found sw id = " << cid << std::endl;
19  }
20  else {
21  std::cout << myName_ << ": ERROR, cannot find requested hw id = " << hid <<
22  " in mapping." << std::endl;
23  }
24  return cid;
25 }
26 
27 CSCDetId CSCTriggerMapping::detId( int endcap, int station, int sector, int subsector, int cscid, int layer ) const {
28  int cid = chamber( endcap, station, sector, subsector, cscid );
29  int lid = cid + layer;
30  return CSCDetId( lid );
31 }
32 
33 void CSCTriggerMapping::addRecord( int rendcap, int rstation, int rsector, int rsubsector, int rcscid,
34  int cendcap, int cstation, int csector, int csubsector, int ccscid ) {
35 
36  Connection newRecord( rendcap, rstation, rsector, rsubsector, rcscid, cendcap, cstation, csector, csubsector, ccscid );
37  mapping_.push_back( newRecord );
38  int hid = hwId( rendcap, rstation, rsector, rsubsector, rcscid );
39  int sid = swId( cendcap, cstation, csector, csubsector, ccscid );
40  if ( debugV() ) std::cout << myName_ << ": map hw " << hid << " to sw " << sid << std::endl;
41  if ( hw2sw_.insert( std::make_pair( hid, sid) ).second ) {
42  if ( debugV() ) std::cout << myName_ << ": insert pair succeeded." << std::endl;
43  }
44  else {
45  std::cout << myName_ << ": ERROR, already have key = " << hid << std::endl;
46  }
47 }
48 
49 int CSCTriggerMapping::swId( int endcap, int station, int sector, int subsector, int cscid ) const {
50  // Software id is just CSCDetId for the chamber
52  int chamber = CSCTriggerNumbering::chamberFromTriggerLabels(sector,subsector,station,cscid);
53  return CSCDetId::rawIdMaker( endcap, station, ring, chamber, 0 ); // usual detid for chamber, i.e. layer=0
54 }
std::map< int, int > hw2sw_
int chamber(int endcap, int station, int sector, int subsector, int cscid) const
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:146
bool debugV(void) const
static int ringFromTriggerLabels(int station, int triggerCSCID)
CSCTriggerMapping()
Default constructor.
void addRecord(int rendcap, int rstation, int rsector, int rsubsector, int rcscid, int cendcap, int cstation, int csector, int csubsector, int ccscid)
std::vector< Connection > mapping_
virtual ~CSCTriggerMapping()
Destructor.
int swId(int endcap, int station, int sector, int subsector, int cscid) const
CSCDetId detId(int endcap, int station, int sector, int subsector, int cscid, int layer=0) const
tuple cout
Definition: gather_cfg.py:121
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
virtual int hwId(int endcap, int station, int sector, int subsector, int cscid) const =0