CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  virtual uint32_t getHash(HcalDetId const& did) const
34  {return hash_did[_htype](did);}
35  virtual uint32_t getHash(HcalElectronicsId const& eid) const
36  {return hash_eid[_htype-nHashType_did-1](eid);}
37  virtual uint32_t getHash(HcalTrigTowerDetId const& tid) const
38  {return hash_tid[_htype-nHashType_eid-1](tid);}
39 
40  // get name of the hashed element
41  virtual std::string getName(HcalDetId const &did) const
42  {return hashfunctions::name_did[_htype](did);}
43  virtual std::string getName(HcalElectronicsId const& eid) const
44  {return hashfunctions::name_eid[_htype-nHashType_did-1](eid);}
45  virtual std::string getName(HcalTrigTowerDetId const& tid) const
46  {return hashfunctions::name_tid[_htype-nHashType_eid-1](tid);}
47 
48  // get the Hash Type Name
49  virtual std::string getHashTypeName() const
50  {return hash_names[this->getLinearHashType(_htype)];}
51  virtual HashType getHashType() const
52  {return _htype;}
53 
54  // determine the type of the hash
55  virtual bool isDHash() const
56  {return _htype<nHashType_did ? true : false;}
57  virtual bool isEHash() const
58  {
59  return (_htype>nHashType_did && _htype<nHashType_eid) ?
60  true : false;
61  }
62  virtual bool isTHash() const
63  {
64  return (_htype>nHashType_eid && _htype<nHashType_tid) ?
65  true : false;
66  }
67 
68  // get the Linear Hash Type
69  virtual int getLinearHashType(HashType htype) const
70  {
71  int l = 0;
72  if (htype<nHashType_did)
73  l = htype;
74  else if (htype<nHashType_eid)
75  l = htype - 1;
76  else
77  l = htype - 2;
78  return l;
79  }
80 
81  protected:
83  };
84  }
85 }
86 
87 #endif
virtual uint32_t getHash(HcalDetId const &did) const
Definition: HashMapper.h:33
virtual void initialize(HashType htype)
Definition: HashMapper.h:30
virtual HashType getHashType() const
Definition: HashMapper.h:51
virtual bool isTHash() const
Definition: HashMapper.h:62
virtual int getLinearHashType(HashType htype) const
Definition: HashMapper.h:69
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:49
virtual std::string getName(HcalTrigTowerDetId const &tid) const
Definition: HashMapper.h:45
hash_function_did const hash_did[nHashType_did]
virtual uint32_t getHash(HcalElectronicsId const &eid) const
Definition: HashMapper.h:35
virtual std::string getName(HcalElectronicsId const &eid) const
Definition: HashMapper.h:43
virtual uint32_t getHash(HcalTrigTowerDetId const &tid) const
Definition: HashMapper.h:37
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:55
name_function_did const name_did[nHashType_did]
HashMapper(HashType htype)
Definition: HashMapper.h:25
virtual bool isEHash() const
Definition: HashMapper.h:57
name_function_eid const name_eid[nHashType_eid-nHashType_did-1]
virtual std::string getName(HcalDetId const &did) const
Definition: HashMapper.h:41
Readout chain identification for Hcal.