CMS 3D CMS Logo

HcalHitFilter.h
Go to the documentation of this file.
1 #ifndef HcalSimAlgos_HcalHitFilter_h
2 #define HcalSimAlgos_HcalHitFilter_h
3 
7 
8 template <HcalSubdetector... subdets>
10 {
11 public:
13  std::sort(theSubdets.begin(),theSubdets.end());
14  }
15  ~HcalHitFilter() override {}
16 
17  void setDetIds(const std::vector<DetId> & detIds){
18  theDetIds = detIds;
19  std::sort(theDetIds.begin(),theDetIds.end());
20  }
21 
22  bool accepts(const PCaloHit & hit) const override {
23  HcalDetId hcalDetId(hit.id());
24  return ( (theSubdets.empty() || std::binary_search(theSubdets.begin(), theSubdets.end(), hcalDetId.subdet()))
25  && (theDetIds.empty() || std::binary_search(theDetIds.begin(), theDetIds.end(), DetId(hit.id())))
26  );
27  }
28 
29 protected:
30  std::vector<HcalSubdetector> theSubdets;
31  // empty DetIds will always be accepted
32  std::vector<DetId> theDetIds;
33 };
34 
38 
39 #endif
40 
HcalHitFilter< HcalOuter > HOHitFilter
Definition: HcalHitFilter.h:37
HcalHitFilter< HcalForward > HFHitFilter
Definition: HcalHitFilter.h:36
std::vector< HcalSubdetector > theSubdets
Definition: HcalHitFilter.h:30
std::vector< DetId > theDetIds
Definition: HcalHitFilter.h:32
bool accepts(const PCaloHit &hit) const override
Definition: HcalHitFilter.h:22
HcalSubdetector
Definition: HcalAssistant.h:31
unsigned int id() const
Definition: PCaloHit.h:37
~HcalHitFilter() override
Definition: HcalHitFilter.h:15
Definition: DetId.h:18
void setDetIds(const std::vector< DetId > &detIds)
Definition: HcalHitFilter.h:17
static const std::string subdets[7]
Definition: TrackUtils.cc:60
HcalHitFilter< HcalBarrel, HcalEndcap > HBHEHitFilter
Definition: HcalHitFilter.h:35