CMS 3D CMS Logo

BPHParticleChargeSelect.h
Go to the documentation of this file.
1 #ifndef HeavyFlavorAnalysis_SpecificDecay_BPHParticleChargeSelect_h
2 #define HeavyFlavorAnalysis_SpecificDecay_BPHParticleChargeSelect_h
3 
12 //----------------------
13 // Base Class Headers --
14 //----------------------
16 
17 //------------------------------------
18 // Collaborating Class Declarations --
19 //------------------------------------
21 
22 //---------------
23 // C++ Headers --
24 //---------------
25 
26 // ---------------------
27 // -- Class Interface --
28 // ---------------------
29 
31 public:
34  BPHParticleChargeSelect(int c) : charge(c ? (c > 0 ? 1 : -1) : 0) {}
35 
36  // deleted copy constructor and assignment operator
39 
42  ~BPHParticleChargeSelect() override = default;
43 
46  bool accept(const reco::Candidate& cand) const override {
48  switch (charge) {
49  default:
50  case 0:
51  return (cand.charge() != 0);
52  case 1:
53  return (cand.charge() > 0);
54  case -1:
55  return (cand.charge() < 0);
56  }
57  return true;
58  };
59 
61  void setCharge(int c) {
62  charge = (c ? (c > 0 ? 1 : -1) : 0);
63  return;
64  }
65 
67  double getCharge() const { return charge; }
68 
69 private:
70  int charge;
71 };
72 
73 #endif
double getCharge() const
get selection charge
bool accept(const reco::Candidate &cand) const override
select particle
~BPHParticleChargeSelect() override=default
void setCharge(int c)
set selection charge
BPHParticleChargeSelect & operator=(const BPHParticleChargeSelect &x)=delete