CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
29 namespace edm {
30  class EventSetup;
31 }
32 
33 namespace reco {
34  class Candidate;
35 }
36 
37 //---------------
38 // C++ Headers --
39 //---------------
40 #include <vector>
41 
42 // ---------------------
43 // -- Class Interface --
44 // ---------------------
45 
46 class BPHRecoCandidate : public virtual BPHKinematicFit {
47 public:
53  // create an object with daughters as specified in the ComponentSet
55 
56  // deleted copy constructor and assignment operator
57  BPHRecoCandidate(const BPHRecoCandidate& x) = delete;
58  BPHRecoCandidate& operator=(const BPHRecoCandidate& x) = delete;
59 
62  ~BPHRecoCandidate() override;
63 
66  virtual void add(const std::string& name, const reco::Candidate* daug, double mass = -1.0, double sigma = -1.0) {
70  addK(name, daug, "cfhpmig", mass, sigma);
71  return;
72  }
73  virtual void add(const std::string& name,
74  const reco::Candidate* daug,
75  const std::string& searchList,
76  double mass = -1.0,
77  double sigma = -1.0) {
78  addK(name, daug, searchList, mass, sigma);
79  return;
80  }
81  virtual void add(const std::string& name, const BPHRecoConstCandPtr& comp) {
82  addK(name, comp);
83  return;
84  }
85 
88  static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, double mass = -1, double msig = -1);
89 
92  virtual BPHRecoCandidate* clone(int level = -1) const;
93 
94 protected:
95  // function doing the job to clone reconstructed decays:
96  // copy stable particles and clone cascade decays up to chosen level
97  void fill(BPHRecoCandidate* ptr, int level) const override;
98 
99  // template function called by "build" to allow
100  // the creation of derived objects
101  template <class T>
102  static void fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
103  const BPHRecoBuilder& builder,
104  double mass = -1,
105  double msig = -1);
106 };
107 
108 template <class T>
110  const BPHRecoBuilder& builder,
111  double mass,
112  double msig) {
113  // create particle combinations
114  const std::vector<BPHRecoBuilder::ComponentSet> dll = builder.build();
115  // loop over combinations and create reconstructed particles
116  int i;
117  int n = dll.size();
118  cList.reserve(n);
119  T* rc = nullptr;
120  for (i = 0; i < n; ++i) {
121  // create reconstructed particle
122  rc = new T(builder.eventSetup(), dll[i]);
123  // apply mass constraint, if requested
124  if (mass > 0)
125  rc->setConstraint(mass, msig);
126  // apply post selection
127  if (builder.accept(*rc))
128  cList.push_back(typename BPHGenericPtr<const T>::type(rc));
129  else
130  delete rc;
131  }
132  return;
133 }
134 
135 #endif
std::vector< BPHRecoConstCandPtr > cList
virtual void addK(const std::string &name, const reco::Candidate *daug, double mass=-1.0, double sigma=-1.0)
BPHRecoCandidate(const edm::EventSetup *es)
std::shared_ptr< T > type
Definition: BPHGenericPtr.h:8
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
std::vector< ComponentSet > build() const
build a set of combinations of particles fulfilling the selections
virtual ParticleMass mass() const
bool accept(const BPHRecoCandidate &cand) const
const edm::EventSetup * eventSetup() const
get the EventSetup set in the constructor
BPHRecoCandidate & operator=(const BPHRecoCandidate &x)=delete
~BPHRecoCandidate() override
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
static std::vector< BPHRecoConstCandPtr > build(const BPHRecoBuilder &builder, double mass=-1, double msig=-1)
virtual void add(const std::string &name, const reco::Candidate *daug, double mass=-1.0, double sigma=-1.0)
virtual void add(const std::string &name, const BPHRecoConstCandPtr &comp)
virtual BPHRecoCandidate * clone(int level=-1) const
tuple level
Definition: testEve_cfg.py:47
long double T