File indexing completed on 2024-04-06 12:15:33
0001 #ifndef HeavyFlavorAnalysis_RecoDecay_BPHRecoCandidate_h
0002 #define HeavyFlavorAnalysis_RecoDecay_BPHRecoCandidate_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHKinematicFit.h"
0021
0022
0023
0024
0025 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoBuilder.h"
0026 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoCandidatePtr.h"
0027 #include "DataFormats/PatCandidates/interface/CompositeCandidate.h"
0028
0029 class BPHEventSetupWrapper;
0030
0031 namespace reco {
0032 class Candidate;
0033 }
0034
0035
0036
0037
0038 #include <vector>
0039
0040
0041
0042
0043
0044 class BPHRecoCandidate : public virtual BPHKinematicFit {
0045 public:
0046 typedef BPHRecoCandidatePtr pointer;
0047 typedef BPHRecoConstCandPtr const_pointer;
0048
0049
0050
0051
0052
0053 BPHRecoCandidate(const BPHEventSetupWrapper* es, int daugNum = 2, int compNum = 2);
0054
0055 BPHRecoCandidate(const BPHEventSetupWrapper* es, const BPHRecoBuilder::ComponentSet& compSet);
0056
0057
0058 BPHRecoCandidate(const BPHRecoCandidate& x) = delete;
0059 BPHRecoCandidate& operator=(const BPHRecoCandidate& x) = delete;
0060
0061
0062
0063 ~BPHRecoCandidate() override = default;
0064
0065
0066
0067
0068
0069
0070 virtual void add(const std::string& name, const reco::Candidate* daug, double mass = -1.0, double sigma = -1.0) {
0071 addK(name, daug, "cfhpmig", mass, sigma);
0072 return;
0073 }
0074 virtual void add(const std::string& name,
0075 const reco::Candidate* daug,
0076 const std::string& searchList,
0077 double mass = -1.0,
0078 double sigma = -1.0) {
0079 addK(name, daug, searchList, mass, sigma);
0080 return;
0081 }
0082 virtual void add(const std::string& name, const BPHRecoConstCandPtr& comp) {
0083 addK(name, comp);
0084 return;
0085 }
0086
0087
0088
0089 struct BuilderParameters {
0090 double constrMass;
0091 double constrSigma;
0092 };
0093 static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, const BuilderParameters& par) {
0094 return build(builder, par.constrMass, par.constrSigma);
0095 }
0096 static std::vector<BPHRecoConstCandPtr> build(const BPHRecoBuilder& builder, double mass = -1, double msig = -1);
0097
0098
0099
0100 virtual BPHRecoCandidate* clone(int level = -1) const;
0101
0102 enum esType { transientTrackBuilder };
0103
0104 protected:
0105
0106
0107 void fill(BPHRecoCandidate* ptr, int level) const override;
0108
0109
0110
0111 template <class T>
0112 static void fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
0113 const BPHRecoBuilder& builder,
0114 double mass = -1,
0115 double msig = -1);
0116 };
0117
0118 template <class T>
0119 void BPHRecoCandidate::fill(std::vector<typename BPHGenericPtr<const T>::type>& cList,
0120 const BPHRecoBuilder& builder,
0121 double mass,
0122 double msig) {
0123
0124 const std::vector<BPHRecoBuilder::ComponentSet> dll = builder.build();
0125
0126 int i;
0127 int n = dll.size();
0128 cList.reserve(n);
0129 T* rc = nullptr;
0130 for (i = 0; i < n; ++i) {
0131
0132 rc = new T(builder.eventSetup(), dll[i]);
0133
0134 if (mass > 0)
0135 rc->setConstraint(mass, msig);
0136
0137 if (builder.accept(*rc))
0138 cList.push_back(typename BPHGenericPtr<const T>::type(rc));
0139 else
0140 delete rc;
0141 }
0142 return;
0143 }
0144
0145 #endif