CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
TrackerDetToDTCELinkCablingMap Class Reference

#include <CondFormats/Phase2TrackerDTC/src/TrackerDetToDTCELinkCablingMap.cc>

Public Member Functions

void clear ()
 Clears the map. More...
 
std::pair< std::unordered_multimap< uint32_t, DTCELinkId >::const_iterator, std::unordered_multimap< uint32_t, DTCELinkId >::const_iterator > detIdToDTCELinkId (uint32_t const) const
 Resolves one or more DTCELinkId of eLinks which are connected to the detector identified by the given raw DetId. More...
 
std::unordered_map< DTCELinkId, uint32_t >::const_iterator dtcELinkIdToDetId (DTCELinkId const &) const
 Resolves the raw DetId of the detector connected to the eLink identified by a DTCELinkId. More...
 
std::vector< uint32_t > getKnownDetIds () const
 Returns a vector containing all detector DetId known to the map. More...
 
std::vector< DTCELinkIdgetKnownDTCELinkIds () const
 Returns a vector containing all elink DTCELinkId nown to the map. More...
 
void insert (DTCELinkId const &, uint32_t const)
 Inserts in the cabling map a record corresponding to the connection of an eLink identified by the given DTCELinkId to a detector identified by the given raw DetId. More...
 
bool knowsDetId (uint32_t) const
 Returns true if the cabling map has a record corresponding to an eLink identified by the given DTCELinkId. More...
 
bool knowsDTCELinkId (DTCELinkId const &) const
 Returns true if the cabling map has a record corresponding to a detector identified by the given raw DetId. More...
 
 TrackerDetToDTCELinkCablingMap ()
 
virtual ~TrackerDetToDTCELinkCablingMap ()
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

std::unordered_multimap< uint32_t, DTCELinkIdcablingMapDetIdToDTCELinkId_
 
std::unordered_map< DTCELinkId, uint32_t > cablingMapDTCELinkIdToDetId_
 

Friends

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

Detailed Description

Description: Map associating DTCELinkId of Phase2 tracker DTCs to DetId of the sensors connected to each of them.

Implementation: [Notes on implementation]

Definition at line 29 of file TrackerDetToDTCELinkCablingMap.h.

Constructor & Destructor Documentation

TrackerDetToDTCELinkCablingMap::TrackerDetToDTCELinkCablingMap ( )

Definition at line 8 of file TrackerDetToDTCELinkCablingMap.cc.

9 {
10 
11 }
TrackerDetToDTCELinkCablingMap::~TrackerDetToDTCELinkCablingMap ( )
virtual

Definition at line 13 of file TrackerDetToDTCELinkCablingMap.cc.

14 {
15 
16 }

Member Function Documentation

void TrackerDetToDTCELinkCablingMap::clear ( void  )
std::pair< std::unordered_multimap< uint32_t, DTCELinkId >::const_iterator, std::unordered_multimap< uint32_t, DTCELinkId >::const_iterator > TrackerDetToDTCELinkCablingMap::detIdToDTCELinkId ( uint32_t const  key) const

Resolves one or more DTCELinkId of eLinks which are connected to the detector identified by the given raw DetId.

Definition at line 30 of file TrackerDetToDTCELinkCablingMap.cc.

References cablingMapDetIdToDTCELinkId_, and Exception.

Referenced by DTCCablingMapTestReader::analyze().

31 {
32  auto const DTCELinkId_itpair = cablingMapDetIdToDTCELinkId_.equal_range(key);
33 
34  if (DTCELinkId_itpair.first == cablingMapDetIdToDTCELinkId_.end())
35  {
36  throw cms::Exception("TrackerDetToDTCELinkCablingMap has been asked to return a DTCELinkId associated to a DetId, but the latter is unknown to the map. ")<<" DetId = " << key << std::endl;
37  }
38 
39  return DTCELinkId_itpair;
40 }
std::unordered_multimap< uint32_t, DTCELinkId > cablingMapDetIdToDTCELinkId_
std::unordered_map< DTCELinkId, uint32_t >::const_iterator TrackerDetToDTCELinkCablingMap::dtcELinkIdToDetId ( DTCELinkId const &  key) const

Resolves the raw DetId of the detector connected to the eLink identified by a DTCELinkId.

Definition at line 19 of file TrackerDetToDTCELinkCablingMap.cc.

References cablingMapDTCELinkIdToDetId_, DTCELinkId::dtc_id(), DTCELinkId::elink_id(), Exception, and DTCELinkId::gbtlink_id().

Referenced by DTCCablingMapTestReader::analyze().

20 {
22  {
23  throw cms::Exception("TrackerDetToDTCELinkCablingMap has been asked to return a DetId associated to a DTCELinkId, but the latter is unknown to the map. ")<<" (DTC, GBT, Elink) numbers = (" << key.dtc_id() << "," << key.gbtlink_id() << "," << key.elink_id() << ")" << std::endl;
24  }
25 
26  return cablingMapDTCELinkIdToDetId_.find(key);
27 }
std::unordered_map< DTCELinkId, uint32_t > cablingMapDTCELinkIdToDetId_
std::vector< uint32_t > TrackerDetToDTCELinkCablingMap::getKnownDetIds ( ) const

Returns a vector containing all detector DetId known to the map.

Definition at line 65 of file TrackerDetToDTCELinkCablingMap.cc.

References cablingMapDetIdToDTCELinkId_.

Referenced by DTCCablingMapTestReader::analyze().

66 {
67  std::vector<uint32_t> knownDetId;
68 
69  // To get the list of unique DetIds we need to iterate over the various equal_ranges
70  // in the map associated to each unique key, and count them only once.
71 
72  for (auto allpairs_it = cablingMapDetIdToDTCELinkId_.begin(), allpairs_end = cablingMapDetIdToDTCELinkId_.end(); allpairs_it != allpairs_end; )
73  {
74  // ***Store the first instance of the key***
75  knownDetId.push_back(uint32_t(allpairs_it->first));
76 
77  // *** Skip to the end of the equal range ***
78  // The following is just explicative, the bottom expression is equivalent
79  //auto const current_key = allpairs_it->first;
80  //auto const current_key_equal_range = cablingMapDetIdToDTCELinkId_.equal_range(current_key);
81  //auto const current_key_range_end = current_key_equal_range.second;
82  auto const current_key_range_end = cablingMapDetIdToDTCELinkId_.equal_range(allpairs_it->first).second;
83 
84  while (allpairs_it != current_key_range_end)
85  ++allpairs_it;
86  }
87 
88  return knownDetId;
89 }
std::unordered_multimap< uint32_t, DTCELinkId > cablingMapDetIdToDTCELinkId_
std::vector< DTCELinkId > TrackerDetToDTCELinkCablingMap::getKnownDTCELinkIds ( ) const

Returns a vector containing all elink DTCELinkId nown to the map.

Definition at line 54 of file TrackerDetToDTCELinkCablingMap.cc.

References cablingMapDTCELinkIdToDetId_, and create_public_lumi_plots::transform.

Referenced by DTCCablingMapTestReader::analyze().

55 {
56  std::vector<DTCELinkId> knownDTCELinkIds(cablingMapDTCELinkIdToDetId_.size());
57 
58  // Unzip the map into a vector of DTCELinkId, discarding the DetIds
59  std::transform(cablingMapDTCELinkIdToDetId_.begin(), cablingMapDTCELinkIdToDetId_.end(), knownDTCELinkIds.begin(), [=](auto pair){return pair.first;});
60 
61  return knownDTCELinkIds;
62 }
std::unordered_map< DTCELinkId, uint32_t > cablingMapDTCELinkIdToDetId_
void TrackerDetToDTCELinkCablingMap::insert ( DTCELinkId const &  dtcELinkId,
uint32_t const  detId 
)

Inserts in the cabling map a record corresponding to the connection of an eLink identified by the given DTCELinkId to a detector identified by the given raw DetId.

Definition at line 92 of file TrackerDetToDTCELinkCablingMap.cc.

References cablingMapDetIdToDTCELinkId_, and cablingMapDTCELinkIdToDetId_.

Referenced by BeautifulSoup.PageElement::append().

93 {
94  cablingMapDTCELinkIdToDetId_.insert(std::make_pair(DTCELinkId(dtcELinkId), uint32_t(detId)));
95  cablingMapDetIdToDTCELinkId_.insert(std::make_pair(uint32_t(detId), DTCELinkId(dtcELinkId)));
96 }
std::unordered_map< DTCELinkId, uint32_t > cablingMapDTCELinkIdToDetId_
std::unordered_multimap< uint32_t, DTCELinkId > cablingMapDetIdToDTCELinkId_
bool TrackerDetToDTCELinkCablingMap::knowsDetId ( uint32_t  key) const

Returns true if the cabling map has a record corresponding to an eLink identified by the given DTCELinkId.

Definition at line 48 of file TrackerDetToDTCELinkCablingMap.cc.

References cablingMapDetIdToDTCELinkId_.

49 {
51 }
std::unordered_multimap< uint32_t, DTCELinkId > cablingMapDetIdToDTCELinkId_
bool TrackerDetToDTCELinkCablingMap::knowsDTCELinkId ( DTCELinkId const &  key) const

Returns true if the cabling map has a record corresponding to a detector identified by the given raw DetId.

Definition at line 43 of file TrackerDetToDTCELinkCablingMap.cc.

References cablingMapDTCELinkIdToDetId_.

44 {
46 }
std::unordered_map< DTCELinkId, uint32_t > cablingMapDTCELinkIdToDetId_
template<class Archive >
void TrackerDetToDTCELinkCablingMap::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 69 of file TrackerDetToDTCELinkCablingMap.h.

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

Definition at line 69 of file TrackerDetToDTCELinkCablingMap.h.

Member Data Documentation

std::unordered_multimap<uint32_t, DTCELinkId> TrackerDetToDTCELinkCablingMap::cablingMapDetIdToDTCELinkId_
private
std::unordered_map<DTCELinkId, uint32_t> TrackerDetToDTCELinkCablingMap::cablingMapDTCELinkIdToDetId_
private