Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-08 01:45:55

0001 #ifndef HeavyFlavorAnalysis_SpecificDecay_BPHParticleChargeSelect_h
0002 #define HeavyFlavorAnalysis_SpecificDecay_BPHParticleChargeSelect_h
0003 /** \class BPHParticleChargeSelect
0004  *
0005  *  Description: 
0006  *     Class for particle selection by charge
0007  *
0008  *  \author Paolo Ronchese INFN Padova
0009  *
0010  */
0011 
0012 //----------------------
0013 // Base Class Headers --
0014 //----------------------
0015 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoSelect.h"
0016 
0017 //------------------------------------
0018 // Collaborating Class Declarations --
0019 //------------------------------------
0020 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
0021 
0022 //---------------
0023 // C++ Headers --
0024 //---------------
0025 
0026 //              ---------------------
0027 //              -- Class Interface --
0028 //              ---------------------
0029 
0030 class BPHParticleChargeSelect : public BPHRecoSelect {
0031 public:
0032   /** Constructor
0033    */
0034   BPHParticleChargeSelect(int c) : charge(c ? (c > 0 ? 1 : -1) : 0) {}
0035 
0036   // deleted copy constructor and assignment operator
0037   BPHParticleChargeSelect(const BPHParticleChargeSelect& x) = delete;
0038   BPHParticleChargeSelect& operator=(const BPHParticleChargeSelect& x) = delete;
0039 
0040   /** Destructor
0041    */
0042   ~BPHParticleChargeSelect() override = default;
0043 
0044   /** Operations
0045    */
0046   /// select particle
0047   bool accept(const reco::Candidate& cand) const override {
0048     switch (charge) {
0049       default:
0050       case 0:
0051         return (cand.charge() != 0);
0052       case 1:
0053         return (cand.charge() > 0);
0054       case -1:
0055         return (cand.charge() < 0);
0056     }
0057     return true;
0058   };
0059 
0060   /// set selection charge
0061   void setCharge(int c) {
0062     charge = (c ? (c > 0 ? 1 : -1) : 0);
0063     return;
0064   }
0065 
0066   /// get selection charge
0067   double getCharge() const { return charge; }
0068 
0069 private:
0070   int charge;
0071 };
0072 
0073 #endif