Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:24

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author Paolo Ronchese INFN Padova
0005  *
0006  */
0007 
0008 //-----------------------
0009 // This Class' Header --
0010 //-----------------------
0011 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHDecayToResFlyingBuilder.h"
0012 
0013 //-------------------------------
0014 // Collaborating Class Headers --
0015 //-------------------------------
0016 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoBuilder.h"
0017 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHPlusMinusCandidate.h"
0018 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoCandidate.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 using namespace std;
0024 
0025 //-------------------
0026 // Initializations --
0027 //-------------------
0028 
0029 //----------------
0030 // Constructors --
0031 //----------------
0032 BPHDecayToResFlyingBuilder::BPHDecayToResFlyingBuilder(const edm::EventSetup& es,
0033                                                        const std::string& resName,
0034                                                        double resMass,
0035                                                        double resWidth,
0036                                                        const std::vector<BPHPlusMinusConstCandPtr>& resCollection,
0037                                                        const std::string& flyName,
0038                                                        double flyMass,
0039                                                        double flyMSigma,
0040                                                        const std::vector<BPHPlusMinusConstCandPtr>& flyCollection)
0041     : BPHDecayConstrainedBuilder(es, resName, resMass, resWidth, resCollection),
0042       fName(flyName),
0043       fMass(flyMass),
0044       fMSigma(flyMSigma),
0045       fCollection(&flyCollection),
0046       flySel(new BPHMassFitSelect(-2.0e+06, -1.0e+06)),
0047       kfChi2Sel(new BPHKinFitChi2Select(-1.0)) {}
0048 
0049 //--------------
0050 // Destructor --
0051 //--------------
0052 BPHDecayToResFlyingBuilder::~BPHDecayToResFlyingBuilder() {
0053   delete flySel;
0054   delete kfChi2Sel;
0055 }
0056 
0057 //--------------
0058 // Operations --
0059 //--------------
0060 vector<BPHRecoConstCandPtr> BPHDecayToResFlyingBuilder::build() {
0061   if (updated)
0062     return recList;
0063 
0064   recList.clear();
0065 
0066   BPHRecoBuilder brb(*evSetup);
0067   brb.setMinPDiffererence(minPDiff);
0068   brb.add(rName, *rCollection);
0069   brb.add(fName, *fCollection);
0070 
0071   if (resoSel->getMassMax() >= 0.0)
0072     brb.filter(rName, *resoSel);
0073   if (flySel->getMassMax() >= 0.0)
0074     brb.filter(fName, *flySel);
0075 
0076   if (massSel->getMassMax() >= 0.0)
0077     brb.filter(*massSel);
0078 
0079   vector<BPHRecoConstCandPtr> tmpList = BPHRecoCandidate::build(brb);
0080   //
0081   //  Apply kinematic constraint on the resonance mass.
0082   //
0083   int iRec;
0084   int nRec = tmpList.size();
0085   recList.reserve(nRec);
0086   for (iRec = 0; iRec < nRec; ++iRec) {
0087     BPHRecoConstCandPtr ctmp = tmpList[iRec];
0088     BPHRecoCandidate* cptr = ctmp->clone();
0089     BPHRecoConstCandPtr cand(cptr);
0090     // fit for flying reconstruction
0091     // indipendent from other particles
0092     cptr->setIndependentFit(fName, true, fMass, fMSigma);
0093     cptr->resetKinematicFit();
0094     if ((mFitSel->getMassMax() >= 0) && (!mFitSel->accept(*cptr)))
0095       continue;
0096     const RefCountedKinematicVertex tdv = cptr->topDecayVertex();
0097     if ((kfChi2Sel->getProbMin() >= 0) && !kfChi2Sel->accept(*cptr))
0098       continue;
0099     dMap[cand->getComp(rName).get()] = ctmp->getComp(rName).get();
0100     dMap[cand->getComp(fName).get()] = ctmp->getComp(fName).get();
0101     recList.push_back(cand);
0102   }
0103   updated = true;
0104   return recList;
0105 }
0106 
0107 /// set cuts
0108 void BPHDecayToResFlyingBuilder::setFlyingMassMin(double m) {
0109   updated = false;
0110   flySel->setMassMin(m);
0111   return;
0112 }
0113 
0114 void BPHDecayToResFlyingBuilder::setFlyingMassMax(double m) {
0115   updated = false;
0116   flySel->setMassMax(m);
0117   return;
0118 }
0119 
0120 void BPHDecayToResFlyingBuilder::setFlyingMassRange(double mMin, double mMax) {
0121   updated = false;
0122   flySel->setMassMin(mMin);
0123   flySel->setMassMax(mMax);
0124   return;
0125 }
0126 
0127 void BPHDecayToResFlyingBuilder::setKinFitProbMin(double p) {
0128   updated = false;
0129   kfChi2Sel->setProbMin(p);
0130 }