BPHRecoCandidate

BuilderParameters

esType

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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
#ifndef HeavyFlavorAnalysis_RecoDecay_BPHRecoCandidate_h
#define HeavyFlavorAnalysis_RecoDecay_BPHRecoCandidate_h
/** \class BPHRecoCandidate
 *
 *  Description: 
 *     High level class for reconstructed decay candidates:
 *     - only constructor interfaces are defined in this class
 *     - functions returning results are defined in base classes:
 *       BPHDecayMomentum : decay products simple momentum sum
 *       BPHDecayVertex   : vertex reconstruction
 *       BPHKinematicFit  : kinematic fit and fitted momentum sum
 *
 *  \author Paolo Ronchese INFN Padova
 *
 */

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

//------------------------------------
// Collaborating Class Declarations --
//------------------------------------
#include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoBuilder.h"
#include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoCandidatePtr.h"
#include "DataFormats/PatCandidates/interface/CompositeCandidate.h"

class BPHEventSetupWrapper;

namespace reco {
  class Candidate;
}

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

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

class BPHRecoCandidate : public virtual BPHKinematicFit {
public:
  typedef BPHRecoCandidatePtr pointer;
  typedef BPHRecoConstCandPtr const_pointer;

  /** Constructor
   */
  /// create an "empty" object to add daughters later
  /// (see BPHDecayMomentum)
  BPHRecoCandidate(const BPHEventSetupWrapper* es, int daugNum = 2, int compNum = 2);
  /// create an object with daughters as specified in the ComponentSet
  BPHRecoCandidate(const BPHEventSetupWrapper* es, const BPHRecoBuilder::ComponentSet& compSet);

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

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

  /** Operations
   */
  /// add a simple particle giving it a name
  /// particles are cloned, eventually specifying a different mass
  /// and a sigma
  virtual void add(const std::string& name, const reco::Candidate* daug, double mass = -1.0, double sigma = -1.0) {
    addK(name, daug, "cfhpmig", mass, sigma);
    return;
  }
  virtual void add(const std::string& name,
                   const reco::Candidate* daug,
                   const std::string& searchList,
                   double mass = -1.0,
                   double sigma = -1.0) {
    addK(name, daug, searchList, mass, sigma);
    return;
  }
  virtual void add(const std::string& name, const BPHRecoConstCandPtr& comp) {
    addK(name, comp);
    return;
  }

  /// look for candidates starting from particle collections as
  /// specified in the BPHRecoBuilder
  struct BuilderParameters {
    double constrMass;
    double constrSigma;
  };
  static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, const BuilderParameters& par) {
    return build(builder, par.constrMass, par.constrSigma);
  }
  static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, double mass = -1, double msig = -1);

  /// clone object, cloning daughters as well up to required depth
  /// level = -1 to clone all levels
  virtual BPHRecoCandidate* clone(int level = -1) const;

  enum esType { transientTrackBuilder };

protected:
  // function doing the job to clone reconstructed decays:
  // copy stable particles and clone cascade decays up to chosen level
  void fill(BPHRecoCandidate* ptr, int level) const override;

  // template function called by "build" to allow
  // the creation of derived objects
  template <class T>
  static void fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
                   const BPHRecoBuilder& builder,
                   double mass = -1,
                   double msig = -1);
};

template <class T>
void BPHRecoCandidate::fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
                            const BPHRecoBuilder& builder,
                            double mass,
                            double msig) {
  // create particle combinations
  const std::vector<BPHRecoBuilder::ComponentSet> dll = builder.build();
  // loop over combinations and create reconstructed particles
  int i;
  int n = dll.size();
  cList.reserve(n);
  T* rc = nullptr;
  for (i = 0; i < n; ++i) {
    // create reconstructed particle
    rc = new T(builder.eventSetup(), dll[i]);
    // apply mass constraint, if requested
    if (mass > 0)
      rc->setConstraint(mass, msig);
    // apply post selection
    if (builder.accept(*rc))
      cList.push_back(typename BPHGenericPtr<const T>::type(rc));
    else
      delete rc;
  }
  return;
}

#endif