CMS 3D CMS Logo

BPHRecoCandidate.h
Go to the documentation of this file.
1 #ifndef HeavyFlavorAnalysis_RecoDecay_BPHRecoCandidate_h
2 #define HeavyFlavorAnalysis_RecoDecay_BPHRecoCandidate_h
3 
17 //----------------------
18 // Base Class Headers --
19 //----------------------
21 
22 //------------------------------------
23 // Collaborating Class Declarations --
24 //------------------------------------
28 
30 
31 namespace reco {
32  class Candidate;
33 }
34 
35 //---------------
36 // C++ Headers --
37 //---------------
38 #include <vector>
39 
40 // ---------------------
41 // -- Class Interface --
42 // ---------------------
43 
44 class BPHRecoCandidate : public virtual BPHKinematicFit {
45 public:
48 
51  BPHRecoCandidate(const BPHEventSetupWrapper* es, int daugNum = 2, int compNum = 2);
56 
57  // deleted copy constructor and assignment operator
58  BPHRecoCandidate(const BPHRecoCandidate& x) = delete;
59  BPHRecoCandidate& operator=(const BPHRecoCandidate& x) = delete;
60 
63  ~BPHRecoCandidate() override = default;
64 
67  virtual void add(const std::string& name, const reco::Candidate* daug, double mass = -1.0, double sigma = -1.0) {
71  addK(name, daug, "cfhpmig", mass, sigma);
72  return;
73  }
74  virtual void add(const std::string& name,
75  const reco::Candidate* daug,
76  const std::string& searchList,
77  double mass = -1.0,
78  double sigma = -1.0) {
79  addK(name, daug, searchList, mass, sigma);
80  return;
81  }
82  virtual void add(const std::string& name, const BPHRecoConstCandPtr& comp) {
83  addK(name, comp);
84  return;
85  }
86 
90  double constrMass;
91  double constrSigma;
92  };
93  static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, const BuilderParameters& par) {
94  return build(builder, par.constrMass, par.constrSigma);
95  }
96  static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, double mass = -1, double msig = -1);
97 
100  virtual BPHRecoCandidate* clone(int level = -1) const;
101 
103 
104 protected:
105  // function doing the job to clone reconstructed decays:
106  // copy stable particles and clone cascade decays up to chosen level
107  void fill(BPHRecoCandidate* ptr, int level) const override;
108 
109  // template function called by "build" to allow
110  // the creation of derived objects
111  template <class T>
112  static void fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
113  const BPHRecoBuilder& builder,
114  double mass = -1,
115  double msig = -1);
116 };
117 
118 template <class T>
120  const BPHRecoBuilder& builder,
121  double mass,
122  double msig) {
123  // create particle combinations
124  const std::vector<BPHRecoBuilder::ComponentSet> dll = builder.build();
125  // loop over combinations and create reconstructed particles
126  int i;
127  int n = dll.size();
128  cList.reserve(n);
129  T* rc = nullptr;
130  for (i = 0; i < n; ++i) {
131  // create reconstructed particle
132  rc = new T(builder.eventSetup(), dll[i]);
133  // apply mass constraint, if requested
134  if (mass > 0)
135  rc->setConstraint(mass, msig);
136  // apply post selection
137  if (builder.accept(*rc))
138  cList.push_back(typename BPHGenericPtr<const T>::type(rc));
139  else
140  delete rc;
141  }
142  return;
143 }
144 
145 #endif
std::vector< BPHRecoConstCandPtr > cList
BPHGenericPtr< BPHRecoCandidate >::type BPHRecoCandidatePtr
virtual void addK(const std::string &name, const reco::Candidate *daug, double mass=-1.0, double sigma=-1.0)
virtual BPHRecoCandidate * clone(int level=-1) const
std::shared_ptr< T > type
Definition: BPHGenericPtr.h:8
bool accept(const BPHRecoCandidate &cand) const
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
BPHRecoCandidate & operator=(const BPHRecoCandidate &x)=delete
virtual void add(const std::string &name, const reco::Candidate *daug, const std::string &searchList, double mass=-1.0, double sigma=-1.0)
void fill(BPHRecoCandidate *ptr, int level) const override
BPHRecoCandidatePtr pointer
virtual void add(const std::string &name, const reco::Candidate *daug, double mass=-1.0, double sigma=-1.0)
BPHRecoConstCandPtr const_pointer
BPHRecoCandidate(const BPHEventSetupWrapper *es, int daugNum=2, int compNum=2)
std::vector< ComponentSet > build() const
build a set of combinations of particles fulfilling the selections
virtual void add(const std::string &name, const BPHRecoConstCandPtr &comp)
~BPHRecoCandidate() override=default
const BPHEventSetupWrapper * eventSetup() const
get the EventSetup set in the constructor
fixed size matrix
virtual ParticleMass mass() const
long double T
static std::vector< BPHRecoConstCandPtr > build(const BPHRecoBuilder &builder, const BuilderParameters &par)