Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:35

0001 #ifndef HeavyFlavorAnalysis_SpecificDecay_BPHDecayToResTrkTrkSameMassBuilder_h
0002 #define HeavyFlavorAnalysis_SpecificDecay_BPHDecayToResTrkTrkSameMassBuilder_h
0003 /** \class BPHDecayToResTrkTrkSameMassBuilder
0004  *
0005  *  Description: 
0006  *     Class to build a particle decaying to a resonance, decaying itself
0007  *     to an opposite charged particles pair,
0008  *     and two additional opposite charged particles pair
0009  *
0010  *  \author Paolo Ronchese INFN Padova
0011  *
0012  */
0013 
0014 //----------------------
0015 // Base Class Headers --
0016 //----------------------
0017 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHDecayConstrainedBuilder.h"
0018 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHDecayToResTrkTrkSameMassBuilderBase.h"
0019 
0020 //------------------------------------
0021 // Collaborating Class Declarations --
0022 //------------------------------------
0023 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHParticlePtSelect.h"
0024 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHParticleEtaSelect.h"
0025 
0026 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoBuilder.h"
0027 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoCandidate.h"
0028 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHPlusMinusCandidate.h"
0029 
0030 #include "FWCore/Framework/interface/EventSetup.h"
0031 
0032 class BPHEventSetupWrapper;
0033 class BPHParticleNeutralVeto;
0034 
0035 //---------------
0036 // C++ Headers --
0037 //---------------
0038 #include <string>
0039 #include <vector>
0040 
0041 //              ---------------------
0042 //              -- Class Interface --
0043 //              ---------------------
0044 
0045 template <class ProdType, class ResType>
0046 class BPHDecayToResTrkTrkSameMassBuilder : public BPHDecayToResTrkTrkSameMassBuilderBase,
0047                                            public BPHDecayConstrainedBuilder<ProdType, ResType> {
0048 public:
0049   using typename BPHDecayGenericBuilder<ProdType>::prod_ptr;
0050   using typename BPHDecayConstrainedBuilder<ProdType, ResType>::res_ptr;
0051 
0052   /** Constructor
0053    */
0054   BPHDecayToResTrkTrkSameMassBuilder(const BPHEventSetupWrapper& es,
0055                                      const std::string& resName,
0056                                      double resMass,
0057                                      double resWidth,
0058                                      const std::vector<res_ptr>& resCollection,
0059                                      const std::string& posName,
0060                                      const std::string& negName,
0061                                      double trkMass,
0062                                      double trkSigma,
0063                                      const BPHRecoBuilder::BPHGenericCollection* posCollection,
0064                                      const BPHRecoBuilder::BPHGenericCollection* negCollection)
0065       : BPHDecayGenericBuilderBase(es, nullptr),
0066         BPHDecayConstrainedBuilderBase(resName, resMass, resWidth),
0067         BPHDecayToResTrkTrkSameMassBuilderBase(posName, negName, trkMass, trkSigma, posCollection, negCollection),
0068         BPHDecayConstrainedBuilder<ProdType, ResType>(resCollection) {}
0069 
0070   // deleted copy constructor and assignment operator
0071   BPHDecayToResTrkTrkSameMassBuilder(const BPHDecayToResTrkTrkSameMassBuilder& x) = delete;
0072   BPHDecayToResTrkTrkSameMassBuilder& operator=(const BPHDecayToResTrkTrkSameMassBuilder& x) = delete;
0073 
0074   /** Destructor
0075    */
0076   ~BPHDecayToResTrkTrkSameMassBuilder() override = default;
0077 
0078 protected:
0079   BPHDecayToResTrkTrkSameMassBuilder(const std::vector<res_ptr>& resCollection,
0080                                      const std::string& posName,
0081                                      const std::string& negName,
0082                                      double trkMass,
0083                                      double trkSigma,
0084                                      const BPHRecoBuilder::BPHGenericCollection* posCollection,
0085                                      const BPHRecoBuilder::BPHGenericCollection* negCollection)
0086       : BPHDecayToResTrkTrkSameMassBuilderBase(posName, negName, trkMass, trkSigma, posCollection, negCollection),
0087         BPHDecayConstrainedBuilder<ProdType, ResType>(resCollection) {}
0088 
0089   void fillRecList() override {
0090     std::vector<res_ptr> resList;
0091     int nRes = this->rCollection->size();
0092     int iRes;
0093     resList.reserve(nRes);
0094     for (iRes = 0; iRes < nRes; ++iRes) {
0095       const res_ptr& rCand = this->rCollection->at(iRes);
0096       if (this->resoSel->accept(*rCand))
0097         resList.push_back(rCand);
0098     }
0099     if (resList.empty())
0100       return;
0101     nRes = resList.size();
0102 
0103     fillTrkTrkList();
0104     if (ttPairs.empty())
0105       return;
0106 
0107     int nPair = ttPairs.size();
0108     int iPair;
0109     for (iPair = 0; iPair < nPair; ++iPair) {
0110       const BPHPlusMinusConstCandPtr tt = ttPairs[iPair];
0111       for (iRes = 0; iRes < nRes; ++iRes) {
0112         ProdType* cand = new ProdType(evSetup);
0113         prod_ptr cPtr(cand);
0114         cand->add(rName, resList[iRes]);
0115         cand->add(pName, tt->originalReco(tt->getDaug(pName)), tMass, tSigma);
0116         cand->add(nName, tt->originalReco(tt->getDaug(nName)), tMass, tSigma);
0117         if (!massSel->accept(*cand))
0118           continue;
0119         if ((chi2Sel != nullptr) && !chi2Sel->accept(*cand))
0120           continue;
0121         if (!mFitSel->accept(*cand))
0122           continue;
0123         this->recList.push_back(cPtr);
0124       }
0125     }
0126     ttPairs.clear();
0127 
0128     return;
0129   }
0130 };
0131 
0132 #endif