Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:42

0001 
0002 #ifndef DataFormats_SiStripCommon_SiStripDetKey_h
0003 #define DataFormats_SiStripCommon_SiStripDetKey_h
0004 
0005 #include "DataFormats/SiStripCommon/interface/ConstantsForGranularity.h"
0006 #include "DataFormats/SiStripCommon/interface/SiStripKey.h"
0007 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
0008 
0009 /**
0010    @class SiStripDetKey
0011    @author R.Bainbridge, S.Lowette
0012 
0013    @brief Utility class that identifies a position within the strip
0014    tracker geometrical structure, down to the level of an APV25 chip.
0015 
0016    NOTA BENE: *** NOT FINISHED ***
0017    
0018    can generate another key that is NOT DetId and packs
0019    sistrip-specific data in a more condensed way, so that all levels
0020    can be encoded with "all" and "invalid" values, down to level of
0021    apv. also, need "conversion tool" that re-generates DetId key from
0022    this new key. this is only way...!!!  maybe can "safeguard" use of
0023    this key as a DetId by reserving bits 22-24 as a flag (eg, set all
0024    high), so that if an attempt to build DetId using SiStripDetId
0025    class, we can understand if key is real DetId or not... what about
0026    going to level of apv?... what about levels about module?...
0027 */
0028 class SiStripDetKey : public SiStripKey {
0029 public:
0030   // ---------- Constructors ----------
0031 
0032   /** Constructor using partition. */
0033   SiStripDetKey(const uint16_t& partition);
0034 
0035   /** Constructor using DetId, APV pair and APV pos within pair. */
0036   SiStripDetKey(const DetId& det_id, const uint16_t& apv_pair_number = 0, const uint16_t& apv_within_pair = 0);
0037 
0038   /** Constructor using SiStripDetId. */
0039   SiStripDetKey(const SiStripDetId& det_id);
0040 
0041   /** Constructor using 32-bit "DET key". */
0042   SiStripDetKey(const uint32_t& det_key);
0043 
0044   /** Constructor using directory path. */
0045   SiStripDetKey(const std::string& directory_path);
0046 
0047   /** Copy constructor. */
0048   SiStripDetKey(const SiStripDetKey&);
0049 
0050   /** Copy constructor using base class. */
0051   SiStripDetKey(const SiStripKey&);
0052 
0053   /** Copy to level specified by granularity. */
0054   SiStripDetKey(const SiStripKey&, const sistrip::Granularity&);
0055 
0056   /** Default constructor */
0057   SiStripDetKey();
0058 
0059   // ---------- Public interface to member data ----------
0060 
0061   /** Returns partition. */
0062   inline const uint16_t& partition() const;
0063 
0064   /** Returns APV pair number. */
0065   inline const uint16_t& apvPairNumber() const;
0066 
0067   /** Returns APV position within pair. */
0068   inline const uint16_t& apvWithinPair() const;
0069 
0070   // ---------- Numbering schemes ----------
0071 
0072   //@@ nothing yet
0073   //@@ switch b/w det_id and det_key
0074   //@@ switch b/w strip, pair, apv, etc...
0075 
0076   // ---------- Utility methods ----------
0077 
0078   /** Identifies key objects with identical member data. */
0079   bool isEqual(const SiStripKey&) const override;
0080 
0081   /** "Consistent" means identical and/or null (ie, "all") data. */
0082   bool isConsistent(const SiStripKey&) const override;
0083 
0084   /** Identifies all member data as being "valid" or null ("all"). */
0085   bool isValid() const override;
0086 
0087   /** All member data to level of "Granularity" are valid. If
0088       sistrip::Granularity is "undefined", returns false. */
0089   bool isValid(const sistrip::Granularity&) const override;
0090 
0091   /** Identifies all member data as being invalid. */
0092   bool isInvalid() const override;
0093 
0094   /** All member data to level of "Granularity" are invalid. If
0095       sistrip::Granularity is "undefined", returns true.  */
0096   bool isInvalid(const sistrip::Granularity&) const override;
0097 
0098   // ---------- Print methods ----------
0099 
0100   /** Print member data of the key  */
0101   void print(std::stringstream& ss) const override;
0102 
0103   /** A terse summary of the key  */
0104   void terse(std::stringstream& ss) const override;
0105 
0106 private:
0107   // ---------- Private methods ----------
0108 
0109   void initFromValue() override;
0110   void initFromKey() override;
0111   void initFromPath() override;
0112   void initGranularity() override;
0113 
0114   // ---------- Private member data ----------
0115 
0116   /** partition [0,1-4,invalid]. */
0117   uint16_t partition_;
0118 
0119   /** APV pair number [0,1-3,invalid]. */
0120   uint16_t apvPairNumber_;
0121 
0122   /** APV position within pair [0,1-2,invalid]. */
0123   uint16_t apvWithinPair_;
0124 
0125   // Definition of bit field positions for 32-bit key
0126   static const uint16_t partitionOffset_ = 29;
0127 
0128   // Definition of bit field masks for 32-bit key
0129   static const uint16_t partitionMask_ = 0x07;  // (3 bits)
0130 };
0131 
0132 // ---------- inline methods ----------
0133 
0134 const uint16_t& SiStripDetKey::partition() const { return partition_; }
0135 const uint16_t& SiStripDetKey::apvPairNumber() const { return apvPairNumber_; }
0136 const uint16_t& SiStripDetKey::apvWithinPair() const { return apvWithinPair_; }
0137 
0138 /** Debug info for SiStripDetKey class. */
0139 std::ostream& operator<<(std::ostream&, const SiStripDetKey&);
0140 
0141 inline bool operator<(const SiStripDetKey& a, const SiStripDetKey& b) { return (a.key() < b.key()); }
0142 
0143 #endif  // DataFormats_SiStripCommon_SiStripDetKey_h