CMS 3D CMS Logo

BPHDecayToFlyingCascadeBuilder.h
Go to the documentation of this file.
1 #ifndef HeavyFlavorAnalysis_SpecificDecay_BPHDecayToFlyingCascadeBuilder_h
2 #define HeavyFlavorAnalysis_SpecificDecay_BPHDecayToFlyingCascadeBuilder_h
3 
13 //----------------------
14 // Base Class Headers --
15 //----------------------
18 
19 //------------------------------------
20 // Collaborating Class Declarations --
21 //------------------------------------
23 
25 
27 
29 
30 //---------------
31 // C++ Headers --
32 //---------------
33 #include <string>
34 #include <vector>
35 #include <iostream>
36 // ---------------------
37 // -- Class Interface --
38 // ---------------------
39 
40 template <class ProdType, class FlyingType>
42  public virtual BPHDecayGenericBuilder<ProdType> {
43 public:
45  typedef typename FlyingType::const_pointer flying_ptr;
46 
50  const std::string& flyName,
51  double flyMass,
52  double flyMSigma,
53  const std::vector<flying_ptr>& flyCollection)
54  : BPHDecayGenericBuilderBase(es, nullptr),
55  BPHDecayToFlyingCascadeBuilderBase(flyName, flyMass, flyMSigma),
56  fCollection(&flyCollection) {}
57 
58  // deleted copy constructor and assignment operator
61 
64  ~BPHDecayToFlyingCascadeBuilder() override = default;
65 
66 protected:
67  BPHDecayToFlyingCascadeBuilder(const std::vector<flying_ptr>& flyCollection) : fCollection(&flyCollection) {}
68 
69  const std::vector<flying_ptr>* fCollection;
70 
71  void addFlyCollection(BPHRecoBuilder& brb) override {
72  const std::vector<flying_ptr>& fc = *this->fCollection;
73  if (flySel->getMassMax() > 0.0) {
74  fCollectSel.clear();
75  fCollectSel.reserve(fc.size());
76  for (const flying_ptr& f : fc) {
77  if (flySel->accept(*f))
78  fCollectSel.push_back(f);
79  }
80  brb.add(fName, fCollectSel);
81  } else
82  brb.add(fName, *this->fCollection);
83  }
84 
86  void fitAndFilter(std::vector<prod_ptr>& prodList) {
87  std::vector<prod_ptr> tempList;
88  int iRec;
89  int nRec = prodList.size();
90  tempList.reserve(nRec);
91  for (iRec = 0; iRec < nRec; ++iRec) {
92  prod_ptr& ctmp = prodList[iRec];
93  ProdType* cptr = ctmp->clone();
94  prod_ptr cand(cptr);
95  // fit for flying reconstruction
96  // indipendent from other particles
97  cptr->setIndependentFit(fName, true, fMass, fMSigma);
98  cptr->resetKinematicFit();
99  if ((mFitSel->getMassMax() >= 0) && (!mFitSel->accept(*cptr)))
100  continue;
101  const RefCountedKinematicVertex tdv = cptr->topDecayVertex();
102  if ((kfChi2Sel->getProbMin() >= 0) && !kfChi2Sel->accept(*cptr))
103  continue;
104  const std::vector<std::string>& cList = ctmp->compNames();
105  int iComp;
106  int nComp = cList.size();
107  for (iComp = 0; iComp < nComp; ++iComp) {
108  const std::string& cName = cList[iComp];
109  dMap[cand->getComp(cName).get()] = ctmp->getComp(cName).get();
110  }
111  tempList.push_back(cand);
112  }
113  prodList = tempList;
114  }
115 
116 private:
117  std::vector<flying_ptr> fCollectSel;
118 };
119 
120 #endif
ProdType::const_pointer prod_ptr
std::map< const BPHRecoCandidate *, const BPHRecoCandidate * > dMap
void fitAndFilter(std::vector< prod_ptr > &prodList)
fit and select candidates
bool accept(const BPHKinematicFit &cand) const override
select vertex
double getProbMin() const
get current prob min
double f[11][100]
double getMassMax() const
Definition: BPHMassCuts.h:59
BPHDecayToFlyingCascadeBuilder & operator=(const BPHDecayToFlyingCascadeBuilder &x)=delete
void add(const std::string &name, const BPHGenericCollection *collection, double mass=-1.0, double msig=-1.0)
void addFlyCollection(BPHRecoBuilder &brb) override
BPHDecayToFlyingCascadeBuilder(const std::vector< flying_ptr > &flyCollection)
~BPHDecayToFlyingCascadeBuilder() override=default
const std::vector< flying_ptr > * fCollection
BPHDecayToFlyingCascadeBuilder(const BPHEventSetupWrapper &es, const std::string &flyName, double flyMass, double flyMSigma, const std::vector< flying_ptr > &flyCollection)
bool accept(const BPHKinematicFit &cand) const override
select particle