Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:33

0001 #ifndef CondFormats_Phase2TrackerDTC_TrackerDetToDTCELinkCablingMap_h
0002 #define CondFormats_Phase2TrackerDTC_TrackerDetToDTCELinkCablingMap_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    CondFormats/Phase2TrackerDTC
0007 // Class:      TrackerDetToDTCELinkCablingMap
0008 //
0009 /**\class TrackerDetToDTCELinkCablingMap TrackerDetToDTCELinkCablingMap.cc CondFormats/Phase2TrackerDTC/src/TrackerDetToDTCELinkCablingMap.cc
0010 
0011 Description: Map associating DTCELinkId of Phase2 tracker DTCs to DetId of the sensors connected to each of them.
0012 
0013 Implementation:
0014         [Notes on implementation]
0015 */
0016 //
0017 // Original Author:  Luigi Calligaris, SPRACE, Sao Paulo, BR
0018 // Created        :  Wed, 27 Feb 2019 21:41:13 GMT
0019 //
0020 //
0021 
0022 #include <vector>
0023 #include <unordered_map>
0024 #include <cstdint>
0025 
0026 #include "CondFormats/Serialization/interface/Serializable.h"
0027 #include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h"
0028 
0029 class TrackerDetToDTCELinkCablingMap {
0030 public:
0031   TrackerDetToDTCELinkCablingMap();
0032   virtual ~TrackerDetToDTCELinkCablingMap();
0033 
0034   /// Resolves the raw DetId of the detector connected to the eLink identified by a DTCELinkId
0035   std::unordered_map<DTCELinkId, uint32_t>::const_iterator dtcELinkIdToDetId(DTCELinkId const&) const;
0036 
0037   /// Resolves one or more DTCELinkId of eLinks which are connected to the detector identified by the given raw DetId
0038   std::pair<std::unordered_multimap<uint32_t, DTCELinkId>::const_iterator,
0039             std::unordered_multimap<uint32_t, DTCELinkId>::const_iterator>
0040   detIdToDTCELinkId(uint32_t const) const;
0041 
0042   /// Returns true if the cabling map has a record corresponding to a detector identified by the given raw DetId
0043   bool knowsDTCELinkId(DTCELinkId const&) const;
0044 
0045   /// Returns true if the cabling map has a record corresponding to an eLink identified by the given DTCELinkId
0046   bool knowsDetId(uint32_t) const;
0047 
0048   // IMPORTANT: The following information is not stored, to preserve space in memory.
0049   // As these vectors are generated each time the functions are called, you are encouraged to
0050   // either cache the results or avoid calling them in hot loops.
0051   // NOTE: This vectors are unsorted
0052 
0053   /// Returns a vector containing all elink DTCELinkId nown to the map
0054   std::vector<DTCELinkId> getKnownDTCELinkIds() const;
0055 
0056   /// Returns a vector containing all detector DetId known to the map
0057   std::vector<uint32_t> getKnownDetIds() const;
0058 
0059   /// 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
0060   void insert(DTCELinkId const&, uint32_t const);
0061 
0062   /// Clears the map
0063   void clear();
0064 
0065 private:
0066   std::unordered_multimap<uint32_t, DTCELinkId> cablingMapDetIdToDTCELinkId_;
0067   std::unordered_map<DTCELinkId, uint32_t> cablingMapDTCELinkIdToDetId_;
0068 
0069   COND_SERIALIZABLE;
0070 };
0071 
0072 #endif  // end CondFormats_Phase2TrackerDTC_TrackerDetToDTCELinkCablingMap_h