Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-08 01:45:52

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/RecoDecay/interface/BPHPlusMinusCandidate.h"
0012 
0013 //-------------------------------
0014 // Collaborating Class Headers --
0015 //-------------------------------
0016 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHAnalyzerTokenWrapper.h"
0017 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoBuilder.h"
0018 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoSelect.h"
0019 #include "DataFormats/PatCandidates/interface/CompositeCandidate.h"
0020 #include "DataFormats/Math/interface/deltaPhi.h"
0021 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHAddFourMomenta.h"
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 
0024 //---------------
0025 // C++ Headers --
0026 //---------------
0027 
0028 using namespace std;
0029 
0030 //-------------------
0031 // Initializations --
0032 //-------------------
0033 
0034 //----------------
0035 // Constructors --
0036 //----------------
0037 BPHPlusMinusCandidate::BPHPlusMinusCandidate(const BPHEventSetupWrapper* es)
0038     : BPHDecayVertex(es), BPHPlusMinusVertex(es), BPHRecoCandidate(es) {}
0039 
0040 BPHPlusMinusCandidate::BPHPlusMinusCandidate(const BPHEventSetupWrapper* es,
0041                                              const BPHRecoBuilder::ComponentSet& compList)
0042     : BPHDecayMomentum(compList.daugMap, compList.compMap),
0043       BPHDecayVertex(this, es),
0044       BPHKinematicFit(this),
0045       BPHPlusMinusVertex(es),
0046       BPHRecoCandidate(es, compList) {}
0047 
0048 //--------------
0049 // Operations --
0050 //--------------
0051 void BPHPlusMinusCandidate::add(const string& name, const reco::Candidate* daug, double mass, double sigma) {
0052   add(name, daug, "cfhpmig", mass, sigma);
0053   return;
0054 }
0055 
0056 void BPHPlusMinusCandidate::add(
0057     const string& name, const reco::Candidate* daug, const string& searchList, double mass, double sigma) {
0058   const vector<const reco::Candidate*>& dL = daughters();
0059   bool accept = false;
0060   switch (dL.size()) {
0061     case 0:
0062       accept = true;
0063       break;
0064     case 1:
0065       if ((daug->charge() * dL.front()->charge()) > 0) {
0066         edm::LogPrint("TooManyParticles") << "BPHPlusMinusCandidate::add: "
0067                                           << "already containing same sign particle, add rejected";
0068         return;
0069       }
0070       accept = true;
0071       break;
0072     default:
0073       edm::LogPrint("TooManyParticles") << "BPHPlusMinusCandidate::add: "
0074                                         << "complete, add rejected";
0075       return;
0076   }
0077   if (accept)
0078     addK(name, daug, searchList, mass, sigma);
0079   return;
0080 }
0081 
0082 vector<BPHPlusMinusConstCandPtr> BPHPlusMinusCandidate::build(
0083     const BPHRecoBuilder& builder, const string& nPos, const string& nNeg, double mass, double msig) {
0084   vector<BPHPlusMinusConstCandPtr> cList;
0085   class ChargeSelect : public BPHRecoSelect {
0086   public:
0087     ChargeSelect(int c) : charge(c) {}
0088     ~ChargeSelect() override = default;
0089     bool accept(const reco::Candidate& cand) const override { return ((charge * cand.charge()) > 0); }
0090 
0091   private:
0092     int charge;
0093   };
0094   ChargeSelect tkPos(+1);
0095   ChargeSelect tkNeg(-1);
0096   builder.filter(nPos, tkPos);
0097   builder.filter(nNeg, tkNeg);
0098   fill<BPHPlusMinusCandidate>(cList, builder, mass, msig);
0099   return cList;
0100 }
0101 
0102 /// clone object, cloning daughters as well up to required depth
0103 /// level = -1 to clone all levels
0104 BPHRecoCandidate* BPHPlusMinusCandidate::clone(int level) const {
0105   BPHPlusMinusCandidate* ptr = new BPHPlusMinusCandidate(getEventSetup());
0106   fill(ptr, level);
0107   return ptr;
0108 }
0109 
0110 const pat::CompositeCandidate& BPHPlusMinusCandidate::composite() const {
0111   static const pat::CompositeCandidate compCand;
0112   static const string msg = "BPHPlusMinusCandidate incomplete, no composite available";
0113   if (!chkSize(msg))
0114     return compCand;
0115   return BPHDecayMomentum::composite();
0116 }
0117 
0118 bool BPHPlusMinusCandidate::isCowboy() const {
0119   static const string msg = "BPHPlusMinusCandidate incomplete, no cowboy/sailor classification";
0120   return (chkSize(msg) && phiDiff());
0121 }
0122 
0123 bool BPHPlusMinusCandidate::isSailor() const {
0124   static const string msg = "BPHPlusMinusCandidate incomplete, no cowboy/sailor classification";
0125   return (chkSize(msg) && !phiDiff());
0126 }
0127 
0128 bool BPHPlusMinusCandidate::phiDiff() const {
0129   const vector<const reco::Candidate*>& dL = daughters();
0130   int idPos = (dL.front()->charge() > 0 ? 0 : 1);
0131   return reco::deltaPhi(dL[idPos]->phi(), dL[1 - idPos]->phi()) > 0;
0132 }