CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CondFormats/CSCObjects/src/CSCTriggerMapping.cc

Go to the documentation of this file.
00001 #include <CondFormats/CSCObjects/interface/CSCTriggerMapping.h>
00002 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
00003 #include <iostream>
00004 
00005 CSCTriggerMapping::CSCTriggerMapping() : myName_("CSCTriggerMapping"), debugV_( false ) {}
00006 
00007 CSCTriggerMapping::~CSCTriggerMapping(){}
00008 
00009 int CSCTriggerMapping::chamber( int endcap, int station, int sector, int subsector, int cscid ) const {
00010   // Build hw id from input, find sw id to match
00011   int cid = 0;
00012   int hid = hwId( endcap, station, sector, subsector, cscid );
00013   // Search for that hw id in mapping
00014   std::map<int,int>::const_iterator it = hw2sw_.find( hid );
00015   if ( it != hw2sw_.end() ) {
00016     cid = it->second;
00017     if ( debugV() ) std::cout << myName_ << ": for requested hw id = " << hid <<
00018        ", found sw id = " << cid << std::endl;
00019   }
00020   else {
00021     std::cout << myName_ << ": ERROR, cannot find requested hw id = " << hid <<
00022       " in mapping." << std::endl;
00023   }
00024   return cid;
00025 }
00026 
00027 CSCDetId CSCTriggerMapping::detId( int endcap, int station, int sector, int subsector, int cscid, int layer ) const {
00028   int cid = chamber( endcap, station, sector, subsector, cscid );
00029   int lid = cid + layer;
00030   return CSCDetId( lid );
00031 }
00032 
00033 void CSCTriggerMapping::addRecord( int rendcap, int rstation, int rsector, int rsubsector, int rcscid, 
00034                                    int cendcap, int cstation, int csector, int csubsector, int ccscid ) {
00035 
00036   Connection newRecord( rendcap, rstation, rsector, rsubsector, rcscid, cendcap, cstation, csector, csubsector, ccscid );
00037   mapping_.push_back( newRecord );
00038   int hid = hwId( rendcap, rstation, rsector, rsubsector, rcscid );
00039   int sid = swId( cendcap, cstation, csector, csubsector, ccscid );
00040   if ( debugV() ) std::cout << myName_ << ": map hw " << hid << " to sw " << sid << std::endl;
00041   if ( hw2sw_.insert( std::make_pair( hid, sid) ).second ) {
00042     if ( debugV() ) std::cout << myName_ << ": insert pair succeeded." << std::endl;
00043   }
00044   else {
00045     std::cout << myName_ << ": ERROR, already have key = " << hid << std::endl;
00046   }
00047 } 
00048 
00049 int CSCTriggerMapping::swId( int endcap, int station, int sector, int subsector, int cscid ) const {
00050   // Software id is just CSCDetId for the chamber
00051   int ring = CSCTriggerNumbering::ringFromTriggerLabels(station, cscid);
00052   int chamber = CSCTriggerNumbering::chamberFromTriggerLabels(sector,subsector,station,cscid);
00053   return CSCDetId::rawIdMaker( endcap, station, ring, chamber, 0 ); // usual detid for chamber, i.e. layer=0
00054 }