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
#include "DQM/HcalCommon/interface/HashFilter.h"

namespace hcaldqm {
  using namespace mapper;
  using namespace hashfunctions;
  namespace filter {
    HashFilter::HashFilter(FilterType ftype, HashType htype) : HashMapper(htype), _ftype(ftype) {}

    HashFilter::HashFilter(FilterType ftype, HashType htype, std::vector<uint32_t> const &v)
        : HashMapper(htype), _ftype(ftype) {
      for (std::vector<uint32_t>::const_iterator it = v.begin(); it != v.end(); ++it)
        _ids.insert(*it);
    }

    HashFilter::HashFilter(HashFilter const &hf) : HashMapper(hf._htype), _ftype(hf._ftype) { _ids = hf._ids; }

    /* virtual */ void HashFilter::initialize(FilterType ftype, HashType htype, std::vector<uint32_t> const &v) {
      HashMapper::initialize(htype);
      _ftype = ftype;
      for (std::vector<uint32_t>::const_iterator it = v.begin(); it != v.end(); ++it)
        _ids.insert(*it);
    }

    /* virtual */ bool HashFilter::filter(HcalDetId const &did) const {
      return _ftype == fFilter ? skip(getHash(did)) : preserve(getHash(did));
    }

    /* virtual */ bool HashFilter::filter(HcalElectronicsId const &eid) const {
      return _ftype == fFilter ? skip(getHash(eid)) : preserve(getHash(eid));
    }

    /* virtual */ bool HashFilter::filter(HcalTrigTowerDetId const &tid) const {
      return _ftype == fFilter ? skip(getHash(tid)) : preserve(getHash(tid));
    }

    /* virtual */ bool HashFilter::skip(uint32_t id) const { return _ids.find(id) == _ids.end() ? false : true; }

    /* virtual */ bool HashFilter::preserve(uint32_t id) const { return _ids.find(id) == _ids.end() ? true : false; }

    /* virtual */ void HashFilter::print() {}
  }  // namespace filter
}  // namespace hcaldqm