CMS 3D CMS Logo

HashMapper.h
Go to the documentation of this file.
1 #ifndef HashMapper_h
2 #define HashMapper_h
3 
14 
15 namespace hcaldqm
16 {
17  using namespace hashfunctions;
18  namespace mapper
19  {
20  class HashMapper : public Mapper
21  {
22  public:
23  // constructors/destructors
25  HashMapper(HashType htype) : Mapper(), _htype(htype)
26  {}
27  virtual ~HashMapper() {}
28 
29  // initialize
30  virtual void initialize(HashType htype) {_htype = htype;}
31 
32  // get hash
33  using Mapper::getHash;
34  virtual uint32_t getHash(HcalDetId const& did) const
35  {return hash_did[_htype](did);}
36  virtual uint32_t getHash(HcalElectronicsId const& eid) const
37  {return hash_eid[_htype-nHashType_did-1](eid);}
38  virtual uint32_t getHash(HcalTrigTowerDetId const& tid) const
39  {return hash_tid[_htype-nHashType_eid-1](tid);}
40 
41  // get name of the hashed element
42  using Mapper::getName;
43  virtual std::string getName(HcalDetId const &did) const
44  {return hashfunctions::name_did[_htype](did);}
45  virtual std::string getName(HcalElectronicsId const& eid) const
46  {return hashfunctions::name_eid[_htype-nHashType_did-1](eid);}
47  virtual std::string getName(HcalTrigTowerDetId const& tid) const
48  {return hashfunctions::name_tid[_htype-nHashType_eid-1](tid);}
49 
50  // get the Hash Type Name
51  virtual std::string getHashTypeName() const
52  {return hash_names[this->getLinearHashType(_htype)];}
53  virtual HashType getHashType() const
54  {return _htype;}
55 
56  // determine the type of the hash
57  virtual bool isDHash() const
58  {return _htype<nHashType_did ? true : false;}
59  virtual bool isEHash() const
60  {
61  return (_htype>nHashType_did && _htype<nHashType_eid) ?
62  true : false;
63  }
64  virtual bool isTHash() const
65  {
66  return (_htype>nHashType_eid && _htype<nHashType_tid) ?
67  true : false;
68  }
69 
70  // get the Linear Hash Type
71  virtual int getLinearHashType(HashType htype) const
72  {
73  int l = 0;
74  if (htype<nHashType_did)
75  l = htype;
76  else if (htype<nHashType_eid)
77  l = htype - 1;
78  else
79  l = htype - 2;
80  return l;
81  }
82 
83  protected:
85  };
86  }
87 }
88 
89 #endif
virtual uint32_t getHash(HcalDetId const &did) const
Definition: HashMapper.h:34
virtual void initialize(HashType htype)
Definition: HashMapper.h:30
virtual std::string getName(HcalDetId const &) const
Definition: Mapper.h:34
virtual HashType getHashType() const
Definition: HashMapper.h:53
virtual bool isTHash() const
Definition: HashMapper.h:64
virtual int getLinearHashType(HashType htype) const
Definition: HashMapper.h:71
std::string const hash_names[nhashes]
hash_function_tid const hash_tid[nHashType_tid-nHashType_eid-1]
virtual std::string getHashTypeName() const
Definition: HashMapper.h:51
virtual std::string getName(HcalTrigTowerDetId const &tid) const
Definition: HashMapper.h:47
hash_function_did const hash_did[nHashType_did]
virtual uint32_t getHash(HcalElectronicsId const &eid) const
Definition: HashMapper.h:36
virtual std::string getName(HcalElectronicsId const &eid) const
Definition: HashMapper.h:45
virtual uint32_t getHash(HcalTrigTowerDetId const &tid) const
Definition: HashMapper.h:38
name_function_tid const name_tid[nHashType_tid-nHashType_eid-1]
hash_function_eid const hash_eid[nHashType_eid-nHashType_did-1]
virtual bool isDHash() const
Definition: HashMapper.h:57
virtual uint32_t getHash(HcalDetId const &) const
Definition: Mapper.h:30
name_function_did const name_did[nHashType_did]
HashMapper(HashType htype)
Definition: HashMapper.h:25
virtual bool isEHash() const
Definition: HashMapper.h:59
name_function_eid const name_eid[nHashType_eid-nHashType_did-1]
virtual std::string getName(HcalDetId const &did) const
Definition: HashMapper.h:43
Readout chain identification for Hcal.