File indexing completed on 2024-04-06 12:15:35
0001 #ifndef HeavyFlavorAnalysis_SpecificDecay_BPHDecayToFlyingCascadeBuilder_h
0002 #define HeavyFlavorAnalysis_SpecificDecay_BPHDecayToFlyingCascadeBuilder_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHDecayToFlyingCascadeBuilderBase.h"
0017 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHDecayGenericBuilder.h"
0018
0019
0020
0021
0022 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHKinFitChi2Select.h"
0023
0024 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoBuilder.h"
0025
0026 #include "FWCore/Framework/interface/EventSetup.h"
0027
0028 class BPHEventSetupWrapper;
0029
0030
0031
0032
0033 #include <string>
0034 #include <vector>
0035 #include <iostream>
0036
0037
0038
0039
0040 template <class ProdType, class FlyingType>
0041 class BPHDecayToFlyingCascadeBuilder : public virtual BPHDecayToFlyingCascadeBuilderBase,
0042 public virtual BPHDecayGenericBuilder<ProdType> {
0043 public:
0044 using typename BPHDecayGenericBuilder<ProdType>::prod_ptr;
0045 typedef typename FlyingType::const_pointer flying_ptr;
0046
0047
0048
0049 BPHDecayToFlyingCascadeBuilder(const BPHEventSetupWrapper& es,
0050 const std::string& flyName,
0051 double flyMass,
0052 double flyMSigma,
0053 const std::vector<flying_ptr>& flyCollection)
0054 : BPHDecayGenericBuilderBase(es, nullptr),
0055 BPHDecayToFlyingCascadeBuilderBase(flyName, flyMass, flyMSigma),
0056 fCollection(&flyCollection) {}
0057
0058
0059 BPHDecayToFlyingCascadeBuilder(const BPHDecayToFlyingCascadeBuilder& x) = delete;
0060 BPHDecayToFlyingCascadeBuilder& operator=(const BPHDecayToFlyingCascadeBuilder& x) = delete;
0061
0062
0063
0064 ~BPHDecayToFlyingCascadeBuilder() override = default;
0065
0066 protected:
0067 BPHDecayToFlyingCascadeBuilder(const std::vector<flying_ptr>& flyCollection) : fCollection(&flyCollection) {}
0068
0069 const std::vector<flying_ptr>* fCollection;
0070
0071 void addFlyCollection(BPHRecoBuilder& brb) override {
0072 const std::vector<flying_ptr>& fc = *this->fCollection;
0073 if (flySel->getMassMax() > 0.0) {
0074 fCollectSel.clear();
0075 fCollectSel.reserve(fc.size());
0076 for (const flying_ptr& f : fc) {
0077 if (flySel->accept(*f))
0078 fCollectSel.push_back(f);
0079 }
0080 brb.add(fName, fCollectSel);
0081 } else
0082 brb.add(fName, *this->fCollection);
0083 }
0084
0085
0086 void fitAndFilter(std::vector<prod_ptr>& prodList) {
0087 std::vector<prod_ptr> tempList;
0088 int iRec;
0089 int nRec = prodList.size();
0090 tempList.reserve(nRec);
0091 for (iRec = 0; iRec < nRec; ++iRec) {
0092 prod_ptr& ctmp = prodList[iRec];
0093 ProdType* cptr = ctmp->clone();
0094 prod_ptr cand(cptr);
0095
0096
0097 cptr->setIndependentFit(fName, true, fMass, fMSigma);
0098 cptr->resetKinematicFit();
0099 if ((mFitSel->getMassMax() >= 0) && (!mFitSel->accept(*cptr)))
0100 continue;
0101 const RefCountedKinematicVertex tdv = cptr->topDecayVertex();
0102 if ((kfChi2Sel->getProbMin() >= 0) && !kfChi2Sel->accept(*cptr))
0103 continue;
0104 const std::vector<std::string>& cList = ctmp->compNames();
0105 int iComp;
0106 int nComp = cList.size();
0107 for (iComp = 0; iComp < nComp; ++iComp) {
0108 const std::string& cName = cList[iComp];
0109 dMap[cand->getComp(cName).get()] = ctmp->getComp(cName).get();
0110 }
0111 tempList.push_back(cand);
0112 }
0113 prodList = tempList;
0114 }
0115
0116 private:
0117 std::vector<flying_ptr> fCollectSel;
0118 };
0119
0120 #endif