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