SiStripDetKey

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

#ifndef DataFormats_SiStripCommon_SiStripDetKey_h
#define DataFormats_SiStripCommon_SiStripDetKey_h

#include "DataFormats/SiStripCommon/interface/ConstantsForGranularity.h"
#include "DataFormats/SiStripCommon/interface/SiStripKey.h"
#include "DataFormats/SiStripDetId/interface/SiStripDetId.h"

/**
   @class SiStripDetKey
   @author R.Bainbridge, S.Lowette

   @brief Utility class that identifies a position within the strip
   tracker geometrical structure, down to the level of an APV25 chip.

   NOTA BENE: *** NOT FINISHED ***
   
   can generate another key that is NOT DetId and packs
   sistrip-specific data in a more condensed way, so that all levels
   can be encoded with "all" and "invalid" values, down to level of
   apv. also, need "conversion tool" that re-generates DetId key from
   this new key. this is only way...!!!  maybe can "safeguard" use of
   this key as a DetId by reserving bits 22-24 as a flag (eg, set all
   high), so that if an attempt to build DetId using SiStripDetId
   class, we can understand if key is real DetId or not... what about
   going to level of apv?... what about levels about module?...
*/
class SiStripDetKey : public SiStripKey {
public:
  // ---------- Constructors ----------

  /** Constructor using partition. */
  SiStripDetKey(const uint16_t& partition);

  /** Constructor using DetId, APV pair and APV pos within pair. */
  SiStripDetKey(const DetId& det_id, const uint16_t& apv_pair_number = 0, const uint16_t& apv_within_pair = 0);

  /** Constructor using SiStripDetId. */
  SiStripDetKey(const SiStripDetId& det_id);

  /** Constructor using 32-bit "DET key". */
  SiStripDetKey(const uint32_t& det_key);

  /** Constructor using directory path. */
  SiStripDetKey(const std::string& directory_path);

  /** Copy constructor. */
  SiStripDetKey(const SiStripDetKey&);

  /** Copy constructor using base class. */
  SiStripDetKey(const SiStripKey&);

  /** Copy to level specified by granularity. */
  SiStripDetKey(const SiStripKey&, const sistrip::Granularity&);

  /** Default constructor */
  SiStripDetKey();

  // ---------- Public interface to member data ----------

  /** Returns partition. */
  inline const uint16_t& partition() const;

  /** Returns APV pair number. */
  inline const uint16_t& apvPairNumber() const;

  /** Returns APV position within pair. */
  inline const uint16_t& apvWithinPair() const;

  // ---------- Numbering schemes ----------

  //@@ nothing yet
  //@@ switch b/w det_id and det_key
  //@@ switch b/w strip, pair, apv, etc...

  // ---------- Utility methods ----------

  /** Identifies key objects with identical member data. */
  bool isEqual(const SiStripKey&) const override;

  /** "Consistent" means identical and/or null (ie, "all") data. */
  bool isConsistent(const SiStripKey&) const override;

  /** Identifies all member data as being "valid" or null ("all"). */
  bool isValid() const override;

  /** All member data to level of "Granularity" are valid. If
      sistrip::Granularity is "undefined", returns false. */
  bool isValid(const sistrip::Granularity&) const override;

  /** Identifies all member data as being invalid. */
  bool isInvalid() const override;

  /** All member data to level of "Granularity" are invalid. If
      sistrip::Granularity is "undefined", returns true.  */
  bool isInvalid(const sistrip::Granularity&) const override;

  // ---------- Print methods ----------

  /** Print member data of the key  */
  void print(std::stringstream& ss) const override;

  /** A terse summary of the key  */
  void terse(std::stringstream& ss) const override;

private:
  // ---------- Private methods ----------

  void initFromValue() override;
  void initFromKey() override;
  void initFromPath() override;
  void initGranularity() override;

  // ---------- Private member data ----------

  /** partition [0,1-4,invalid]. */
  uint16_t partition_;

  /** APV pair number [0,1-3,invalid]. */
  uint16_t apvPairNumber_;

  /** APV position within pair [0,1-2,invalid]. */
  uint16_t apvWithinPair_;

  // Definition of bit field positions for 32-bit key
  static const uint16_t partitionOffset_ = 29;

  // Definition of bit field masks for 32-bit key
  static const uint16_t partitionMask_ = 0x07;  // (3 bits)
};

// ---------- inline methods ----------

const uint16_t& SiStripDetKey::partition() const { return partition_; }
const uint16_t& SiStripDetKey::apvPairNumber() const { return apvPairNumber_; }
const uint16_t& SiStripDetKey::apvWithinPair() const { return apvWithinPair_; }

/** Debug info for SiStripDetKey class. */
std::ostream& operator<<(std::ostream&, const SiStripDetKey&);

inline bool operator<(const SiStripDetKey& a, const SiStripDetKey& b) { return (a.key() < b.key()); }

#endif  // DataFormats_SiStripCommon_SiStripDetKey_h