BPHMassSymSelect

Macros

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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#ifndef HeavyFlavorAnalysis_SpecificDecay_BPHMassSymSelect_h
#define HeavyFlavorAnalysis_SpecificDecay_BPHMassSymSelect_h
/** \class BPHMassSymSelect
 *
 *  Description: 
 *     Class for candidate selection by invariant mass (at momentum sum level)
 *     allowing for decay product mass swap
 *
 *  \author Paolo Ronchese INFN Padova
 *
 */

//----------------------
// Base Class Headers --
//----------------------
#include "HeavyFlavorAnalysis/RecoDecay/interface/BPHMomentumSelect.h"

//------------------------------------
// Collaborating Class Declarations --
//------------------------------------
#include "HeavyFlavorAnalysis/RecoDecay/interface/BPHDecayMomentum.h"
#include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHMassSelect.h"

//---------------
// C++ Headers --
//---------------
#include <string>

//              ---------------------
//              -- Class Interface --
//              ---------------------

class BPHMassSymSelect : public BPHMomentumSelect {
public:
  /** Constructor
   */
  BPHMassSymSelect(const std::string& np, const std::string& nn, const BPHMassSelect* ms)
      : nPos(np), nNeg(nn), mSel(ms) {}

  // deleted copy constructor and assignment operator
  BPHMassSymSelect(const BPHMassSymSelect& x) = delete;
  BPHMassSymSelect& operator=(const BPHMassSymSelect& x) = delete;

  /** Destructor
   */
  ~BPHMassSymSelect() override = default;

  /** Operations
   */
  /// select particle
  bool accept(const BPHDecayMomentum& cand) const override {
    if (mSel->accept(cand))
      return true;

    const reco::Candidate* pp = cand.getDaug(nPos);
    const reco::Candidate* np = cand.getDaug(nNeg);

    reco::Candidate* pc = cand.originalReco(pp)->clone();
    reco::Candidate* nc = cand.originalReco(np)->clone();

    pc->setMass(np->p4().mass());
    nc->setMass(pp->p4().mass());
    const reco::Candidate::LorentzVector s4 = pc->p4() + nc->p4();
    double mass = s4.mass();

    delete pc;
    delete nc;
    return ((mass >= mSel->getMassMin()) && (mass <= mSel->getMassMax()));
  }

private:
  std::string nPos;
  std::string nNeg;
  const BPHMassSelect* mSel;
};

#endif