Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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/BPHDecayToChargedXXbarBuilder.h"
0012 
0013 //-------------------------------
0014 // Collaborating Class Headers --
0015 //-------------------------------
0016 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHDecayGenericBuilderBase.h"
0017 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHParticlePtSelect.h"
0018 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHParticleEtaSelect.h"
0019 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHMassSelect.h"
0020 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHChi2Select.h"
0021 #include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHParticleMasses.h"
0022 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoBuilder.h"
0023 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHPlusMinusCandidate.h"
0024 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHTrackReference.h"
0025 #include "DataFormats/Candidate/interface/Candidate.h"
0026 #include "DataFormats/Math/interface/LorentzVector.h"
0027 
0028 //---------------
0029 // C++ Headers --
0030 //---------------
0031 using namespace std;
0032 
0033 //-------------------
0034 // Initializations --
0035 //-------------------
0036 
0037 //----------------
0038 // Constructors --
0039 //----------------
0040 BPHDecayToChargedXXbarBuilder::BPHDecayToChargedXXbarBuilder(const BPHEventSetupWrapper& es,
0041                                                              const string& dPosName,
0042                                                              const string& dNegName,
0043                                                              double daugMass,
0044                                                              double daugSigma,
0045                                                              const BPHRecoBuilder::BPHGenericCollection* posCollection,
0046                                                              const BPHRecoBuilder::BPHGenericCollection* negCollection)
0047     : BPHDecayGenericBuilderBase(es),
0048       ptMin(-1.0),
0049       etaMax(10.0),
0050       dzMax(1.0),
0051       pName(dPosName),
0052       nName(dNegName),
0053       dMass(daugMass),
0054       dSigma(daugSigma),
0055       pCollection(posCollection),
0056       nCollection(negCollection) {}
0057 
0058 //--------------
0059 // Operations --
0060 //--------------
0061 
0062 /// set cuts
0063 void BPHDecayToChargedXXbarBuilder::setPtMin(double pt) {
0064   outdated = true;
0065   ptMin = pt;
0066   return;
0067 }
0068 
0069 void BPHDecayToChargedXXbarBuilder::setEtaMax(double eta) {
0070   outdated = true;
0071   etaMax = eta;
0072   return;
0073 }
0074 
0075 void BPHDecayToChargedXXbarBuilder::setDzMax(double dz) {
0076   outdated = true;
0077   dzMax = dz;
0078   return;
0079 }
0080 
0081 /// build candidates
0082 void BPHDecayToChargedXXbarBuilder::fillRecList() {
0083   // extract basic informations from input collections
0084 
0085   vector<Particle*> pList;
0086   vector<Particle*> nList;
0087 
0088   addParticle(pCollection, +1, pList);
0089   addParticle(nCollection, -1, nList);
0090   int iPos;
0091   int iNeg;
0092   int nPos = pList.size();
0093   int nNeg = nList.size();
0094   double massMin = getMassMin();
0095   double massMax = getMassMax();
0096   double mSqMin = massMin * massMin * 0.9;
0097   double mSqMax = massMax * massMax * 1.1;
0098   if (mSqMin < 0.0)
0099     mSqMin = 0.0;
0100 
0101   for (iPos = 0; iPos < nPos; ++iPos) {
0102     Particle* pc = pList[iPos];
0103     const reco::Track* pt = pc->track;
0104     double px = pc->px;
0105     double py = pc->py;
0106     double pz = pc->pz;
0107     double pe = pc->en;
0108     for (iNeg = 0; iNeg < nNeg; ++iNeg) {
0109       Particle* nc = nList[iNeg];
0110       const reco::Track* nt = nc->track;
0111       if (fabs(nt->dz() - pt->dz()) > 1.0)
0112         continue;
0113       double nx = nc->px;
0114       double ny = nc->py;
0115       double nz = nc->pz;
0116       double ne = nc->en;
0117       const float tx = px + nx;
0118       const float ty = py + ny;
0119       const float tz = pz + nz;
0120       const float te = pe + ne;
0121       const float m2 = (te * te) - ((tx * tx) + (ty * ty) + (tz * tz));
0122       if (m2 < mSqMin)
0123         continue;
0124       if (m2 > mSqMax)
0125         continue;
0126       BPHPlusMinusCandidatePtr rc = BPHPlusMinusCandidateWrap::create(evSetup);
0127       rc->add(pName, pc->cand, dMass, dSigma);
0128       rc->add(nName, nc->cand, dMass, dSigma);
0129       double mass = rc->composite().mass();
0130       if (mass < massMin)
0131         continue;
0132       if (mass > massMax)
0133         continue;
0134       if (!chi2Sel->accept(*rc))
0135         continue;
0136       recList.push_back(rc);
0137     }
0138   }
0139 
0140   for (iPos = 0; iPos < nPos; ++iPos)
0141     delete pList[iPos];
0142   for (iNeg = 0; iNeg < nNeg; ++iNeg)
0143     delete nList[iNeg];
0144 
0145   return;
0146 }
0147 
0148 void BPHDecayToChargedXXbarBuilder::addParticle(const BPHRecoBuilder::BPHGenericCollection* collection,
0149                                                 int charge,
0150                                                 vector<Particle*>& list) {
0151   int i;
0152   int n = collection->size();
0153   list.reserve(n);
0154   for (i = 0; i < n; ++i) {
0155     const reco::Candidate& cand = collection->get(i);
0156     int q = cand.charge();
0157     if ((charge > 0) && (q <= 0))
0158       continue;
0159     if ((charge < 0) && (q >= 0))
0160       continue;
0161     const reco::Candidate::LorentzVector p4 = cand.p4();
0162     if (p4.pt() < ptMin)
0163       continue;
0164     if (p4.eta() > etaMax)
0165       continue;
0166     const reco::Track* tk = BPHTrackReference::getTrack(cand, "cfhp");
0167     if (tk == nullptr)
0168       continue;
0169     double px = p4.px();
0170     double py = p4.py();
0171     double pz = p4.pz();
0172     list.push_back(new Particle(&cand, tk, px, py, pz, sqrt((px * px) + (py * py) + (pz * pz) + (dMass * dMass))));
0173   }
0174   return;
0175 }