test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends
CSCReadoutMapping Class Referenceabstract

#include <CSCReadoutMapping.h>

Inheritance diagram for CSCReadoutMapping:
CSCReadoutMappingForSliceTest CSCReadoutMappingFromFile

Classes

struct  CSCLabel
 

Public Member Functions

void addRecord (int endcap, int station, int ring, int chamber, int vmecrate, int dmb, int tmb, int tsector, int cscid, int ddu, int dcc)
 
int chamber (int endcap, int station, int vmecrate, int dmb, int tmb) const
 
int crate (const CSCDetId &) const
 returns vmecrate given CSCDetId More...
 
 CSCReadoutMapping ()
 Default constructor. More...
 
int dccId (const CSCDetId &) const
 returns DCC# given CSCDetId More...
 
int dduId (const CSCDetId &) const
 returns DDU# given CSCDetId More...
 
bool debugV (void) const
 
CSCDetId detId (int endcap, int station, int vmecrate, int dmb, int tmb, int cfeb, int layer=0) const
 
int dmbId (const CSCDetId &) const
 returns dmbId given CSCDetId More...
 
virtual void fill (const edm::ParameterSet &)=0
 
CSCLabel findHardwareId (const CSCDetId &) const
 returns hardware ids given chamber id More...
 
const std::string & myName (void) const
 
void setDebugV (bool dbg)
 
virtual ~CSCReadoutMapping ()
 Destructor. More...
 

Private Member Functions

virtual int hwId (int endcap, int station, int vme, int dmb, int tmb) const =0
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
int swId (int endcap, int station, int ring, int chamber) const
 

Private Attributes

bool debugV_
 
std::map< int, int > hw2sw_
 
std::vector< CSCLabelmapping_
 
std::string myName_
 
std::map< int, CSCLabelsw2hw_
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Author
Tim Cox Abstract class to define mapping between CSC readout hardware ids and other labels.

Defines the ids and labels in the mapping and supplies translation interface. A derived class must define how hardware labels map to a unique integer. A derived, concrete, class must define from where the mapping information comes.

Definition at line 26 of file CSCReadoutMapping.h.

Constructor & Destructor Documentation

CSCReadoutMapping::CSCReadoutMapping ( )

Default constructor.

Definition at line 5 of file CSCReadoutMapping.cc.

5 : myName_("CSCReadoutMapping"), debugV_( false ) {}
CSCReadoutMapping::~CSCReadoutMapping ( )
virtual

Destructor.

Definition at line 7 of file CSCReadoutMapping.cc.

7 {}

Member Function Documentation

void CSCReadoutMapping::addRecord ( int  endcap,
int  station,
int  ring,
int  chamber,
int  vmecrate,
int  dmb,
int  tmb,
int  tsector,
int  cscid,
int  ddu,
int  dcc 
)

Add one record of info to mapping

reverse mapping for software -> hadrware labels

Definition at line 50 of file CSCReadoutMapping.cc.

References hw2sw_, hwId(), mapping_, sw2hw_, and swId().

Referenced by CSCReadoutMappingFromFile::fill().

51  {
52 
53  CSCLabel newRecord( endcap, station, ring, chamber, vmecrate, dmb, tmb, tsector, cscid, ddu, dcc );
54  mapping_.push_back( newRecord );
55  int hid = hwId( endcap, station, vmecrate, dmb, tmb );
56  int sid = swId( endcap, station, ring, chamber);
57  // LogDebug("CSC") << " map hw " << hid << " to sw " << sid;
58  if ( hw2sw_.insert( std::make_pair(hid, sid) ).second ) {
59  // LogDebug("CSC") << " insert pair succeeded.";
60  }
61  else {
62  edm::LogError("CSC") << " already have key = " << hid;
63  }
65  sw2hw_.insert( std::make_pair(sid, newRecord) );
66 
67 }
std::vector< CSCLabel > mapping_
int chamber(int endcap, int station, int vmecrate, int dmb, int tmb) const
int swId(int endcap, int station, int ring, int chamber) const
virtual int hwId(int endcap, int station, int vme, int dmb, int tmb) const =0
std::map< int, int > hw2sw_
std::map< int, CSCLabel > sw2hw_
int CSCReadoutMapping::chamber ( int  endcap,
int  station,
int  vmecrate,
int  dmb,
int  tmb 
) const

Return chamber label corresponding to readout ids vme, tmb and dmb for given endcap endcap = 1 (+z), 2 (-z), station, vme crate number, dmb slot number, tmb slot number.

Definition at line 9 of file CSCReadoutMapping.cc.

References hw2sw_, and hwId().

Referenced by detId(), findHardwareId(), and geometryXMLparser.CSCAlignable::index().

9  {
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  }
20  else {
21  edm::LogError("CSC") << " cannot find requested hw id = " << hid << " in mapping.";
22  }
23  return cid;
24 }
virtual int hwId(int endcap, int station, int vme, int dmb, int tmb) const =0
std::map< int, int > hw2sw_
int CSCReadoutMapping::crate ( const CSCDetId id) const

returns vmecrate given CSCDetId

Definition at line 90 of file CSCReadoutMapping.cc.

References findHardwareId(), and CSCReadoutMapping::CSCLabel::vmecrate_.

90  {
91  CSCLabel hid = findHardwareId(id);
92  return hid.vmecrate_;
93 }
CSCLabel findHardwareId(const CSCDetId &) const
returns hardware ids given chamber id
int CSCReadoutMapping::dccId ( const CSCDetId id) const

returns DCC# given CSCDetId

Definition at line 102 of file CSCReadoutMapping.cc.

References CSCReadoutMapping::CSCLabel::dcc_, and findHardwareId().

102  {
103  CSCLabel hid = findHardwareId(id);
104  return hid.dcc_;
105 }
CSCLabel findHardwareId(const CSCDetId &) const
returns hardware ids given chamber id
int CSCReadoutMapping::dduId ( const CSCDetId id) const

returns DDU# given CSCDetId

Definition at line 98 of file CSCReadoutMapping.cc.

References CSCReadoutMapping::CSCLabel::ddu_, and findHardwareId().

98  {
99  CSCLabel hid = findHardwareId(id);
100  return hid.ddu_;
101 }
CSCLabel findHardwareId(const CSCDetId &) const
returns hardware ids given chamber id
bool CSCReadoutMapping::debugV ( void  ) const
inline

Status of debug printout flag

Definition at line 108 of file CSCReadoutMapping.h.

References debugV_.

108 { return debugV_; }
CSCDetId CSCReadoutMapping::detId ( int  endcap,
int  station,
int  vmecrate,
int  dmb,
int  tmb,
int  cfeb,
int  layer = 0 
) const

Return CSCDetId for layer corresponding to readout ids vme, tmb, and dmb for given endcap and layer no. 1-6, or for chamber if no layer no. supplied. Args: endcap = 1 (+z), 2 (-z), station, vme crate number, dmb slot number, tmb slot number, cfeb number (so we can identify ME1a/b within ME11), layer number

Definition at line 26 of file CSCReadoutMapping.cc.

References CSCDetId::chamber(), chamber(), CSCDetId, CSCDetId::endcap(), relativeConstraints::ring, CSCDetId::ring(), and CSCDetId::station().

27  {
28 
29  // Find CSCDetId index of chamber corresponding to the hardware readout arguments
30  int cid = chamber( endcap, station, vme, dmb, tmb );
31 
32  // Decode the individual labels
33  // ... include endcap & station for MTCC when they are unique in the mapping file
34  // and so do not need to be specified as input arguments
35  endcap = CSCDetId::endcap( cid );
36  station = CSCDetId::station( cid );
37  int chamber = CSCDetId::chamber( cid );
38  int ring = CSCDetId::ring( cid );
39 
40  // Now sort out ME1a from ME11-combined
41  // cfeb =0-3 for ME1b, cfeb=4 for ME1a (pre-LS1) cfeb=4-6 (post-LS1)
42  if ( station == 1 && ring == 1 && cfeb >= 4 && cfeb <= 6 ) {
43  // This is ME1a region
44  ring = 4; // reset from 1 to 4 which flags ME1a
45  }
46 
47  return CSCDetId( endcap, station, ring, chamber, layer );
48 }
int chamber() const
Definition: CSCDetId.h:68
int chamber(int endcap, int station, int vmecrate, int dmb, int tmb) const
int endcap() const
Definition: CSCDetId.h:93
int ring() const
Definition: CSCDetId.h:75
int station() const
Definition: CSCDetId.h:86
int CSCReadoutMapping::dmbId ( const CSCDetId id) const

returns dmbId given CSCDetId

Definition at line 94 of file CSCReadoutMapping.cc.

References CSCReadoutMapping::CSCLabel::dmb_, and findHardwareId().

94  {
95  CSCLabel hid = findHardwareId(id);
96  return hid.dmb_;
97 }
CSCLabel findHardwareId(const CSCDetId &) const
returns hardware ids given chamber id
virtual void CSCReadoutMapping::fill ( const edm::ParameterSet )
pure virtual

Fill mapping store

Implemented in CSCReadoutMappingFromFile.

CSCReadoutMapping::CSCLabel CSCReadoutMapping::findHardwareId ( const CSCDetId id) const

returns hardware ids given chamber id

Search for that sw id in mapping

Definition at line 74 of file CSCReadoutMapping.cc.

References chamber(), Reference_intrackfit_cff::endcap, CSCDetId::rawIdMaker(), relativeConstraints::ring, relativeConstraints::station, and sw2hw_.

Referenced by crate(), dccId(), dduId(), and dmbId().

74  {
75  CSCLabel hid;
76  int sid=CSCDetId::rawIdMaker(id.endcap(), id.station(), id.ring(), id.chamber(), 0 );
78  std::map<int,CSCLabel>::const_iterator it = sw2hw_.find( sid );
79  if ( it != sw2hw_.end() ) {
80  hid = it->second;
81  // std::cout << "hwid = " << hid << ", swid = " << cid << std::endl;
82  // LogDebug("CSC") << " for requested hw id = " << hid << ", found sw id = " << cid;
83  }
84  else {
85  edm::LogError("CSC") << " cannot find requested sw id = " << id << " in mapping.";
86  }
87  return hid;
88 }
int chamber(int endcap, int station, int vmecrate, int dmb, int tmb) const
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:144
std::map< int, CSCLabel > sw2hw_
virtual int CSCReadoutMapping::hwId ( int  endcap,
int  station,
int  vme,
int  dmb,
int  tmb 
) const
privatepure virtual

Build a unique integer out of the readout electronics labels.

In general this must depend on endcap and station, as well as vme crate number and dmb slot number. And possibly tmb slot?

Implemented in CSCReadoutMappingForSliceTest.

Referenced by addRecord(), and chamber().

const std::string& CSCReadoutMapping::myName ( void  ) const
inline

Return class name

Definition at line 113 of file CSCReadoutMapping.h.

References myName_.

113 { return myName_; }
template<class Archive >
void CSCReadoutMapping::serialize ( Archive &  ar,
const unsigned int  version 
)
private
void CSCReadoutMapping::setDebugV ( bool  dbg)
inline

Set debug printout flag

Definition at line 103 of file CSCReadoutMapping.h.

References debugV_.

103 { debugV_ = dbg; }
int CSCReadoutMapping::swId ( int  endcap,
int  station,
int  ring,
int  chamber 
) const
private

Build a unique integer out of chamber labels.

We'll probably use rawId of CSCDetId... You know it makes sense!

Definition at line 69 of file CSCReadoutMapping.cc.

References CSCDetId::rawIdMaker().

Referenced by addRecord().

69  {
70  // Software id is just CSCDetId for the chamber - but no distinction within ME11
71  return CSCDetId::rawIdMaker( endcap, station, ring, chamber, 0 ); // usual detid for chamber, i.e. layer=0
72 }
int chamber(int endcap, int station, int vmecrate, int dmb, int tmb) const
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:144

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 139 of file CSCReadoutMapping.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 139 of file CSCReadoutMapping.h.

Member Data Documentation

bool CSCReadoutMapping::debugV_
private

Definition at line 133 of file CSCReadoutMapping.h.

Referenced by debugV(), and setDebugV().

std::map< int, int > CSCReadoutMapping::hw2sw_
private

Definition at line 135 of file CSCReadoutMapping.h.

Referenced by addRecord(), and chamber().

std::vector< CSCLabel > CSCReadoutMapping::mapping_
private

Definition at line 134 of file CSCReadoutMapping.h.

Referenced by addRecord().

std::string CSCReadoutMapping::myName_
private

Definition at line 132 of file CSCReadoutMapping.h.

Referenced by myName().

std::map< int, CSCLabel > CSCReadoutMapping::sw2hw_
private

Definition at line 136 of file CSCReadoutMapping.h.

Referenced by addRecord(), and findHardwareId().