Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:21

0001 #include "AnalysisDataFormats/TopObjects/interface/TtSemiLepEvtPartons.h"
0002 #include "TopQuarkAnalysis/TopJetCombination/interface/TtSemiLepJetComb.h"
0003 
0004 #include "Math/VectorUtil.h"
0005 
0006 TtSemiLepJetComb::TtSemiLepJetComb() {}
0007 
0008 TtSemiLepJetComb::TtSemiLepJetComb(const std::vector<pat::Jet>& jets,
0009                                    const std::vector<int>& combination,
0010                                    const math::XYZTLorentzVector& lepton,
0011                                    const pat::MET& neutrino) {
0012   // receive right jet association
0013   // from jet-parton matching
0014   hadQJet_ = jets[combination[TtSemiLepEvtPartons::LightQ]];
0015   hadQBarJet_ = jets[combination[TtSemiLepEvtPartons::LightQBar]];
0016   hadBJet_ = jets[combination[TtSemiLepEvtPartons::HadB]];
0017   lepBJet_ = jets[combination[TtSemiLepEvtPartons::LepB]];
0018   lepton_ = lepton;
0019   neutrino_ = neutrino;
0020   // create mother candidates from
0021   // final-state candidates
0022   deduceMothers();
0023 }
0024 
0025 TtSemiLepJetComb::~TtSemiLepJetComb() {}
0026 
0027 double TtSemiLepJetComb::topVar(JetComb::DecayType decay, JetComb::VarType var) const {
0028   switch (var) {
0029     case JetComb::kMass:
0030       return top(decay).mass();
0031     case JetComb::kPt:
0032       return top(decay).pt();
0033     case JetComb::kEta:
0034       return top(decay).eta();
0035     case JetComb::kPhi:
0036       return top(decay).phi();
0037     case JetComb::kTheta:
0038       return top(decay).theta();
0039   };
0040   return -9999.;
0041 }
0042 
0043 double TtSemiLepJetComb::wBosonVar(JetComb::DecayType decay, JetComb::VarType var) const {
0044   switch (var) {
0045     case JetComb::kMass:
0046       return wBoson(decay).mass();
0047     case JetComb::kPt:
0048       return wBoson(decay).pt();
0049     case JetComb::kEta:
0050       return wBoson(decay).eta();
0051     case JetComb::kPhi:
0052       return wBoson(decay).phi();
0053     case JetComb::kTheta:
0054       return wBoson(decay).theta();
0055   };
0056   return -9999.;
0057 }
0058 
0059 double TtSemiLepJetComb::bQuarkVar(JetComb::DecayType decay, JetComb::VarType var) const {
0060   switch (var) {
0061     case JetComb::kMass:
0062       return -9999.;
0063     case JetComb::kPt:
0064       return bQuark(decay).p4().pt();
0065     case JetComb::kEta:
0066       return bQuark(decay).p4().eta();
0067     case JetComb::kPhi:
0068       return bQuark(decay).p4().phi();
0069     case JetComb::kTheta:
0070       return bQuark(decay).p4().theta();
0071   };
0072   return -9999.;
0073 }
0074 
0075 double TtSemiLepJetComb::lightQVar(bool qbar, JetComb::VarType var) const {
0076   switch (var) {
0077     case JetComb::kMass:
0078       return -9999.;
0079     case JetComb::kPt:
0080       return lightQ(qbar).p4().pt();
0081     case JetComb::kEta:
0082       return lightQ(qbar).p4().eta();
0083     case JetComb::kPhi:
0084       return lightQ(qbar).p4().phi();
0085     case JetComb::kTheta:
0086       return lightQ(qbar).p4().theta();
0087   };
0088   return -9999.;
0089 }
0090 
0091 double TtSemiLepJetComb::leptonVar(JetComb::VarType var) const {
0092   switch (var) {
0093     case JetComb::kMass:
0094       return -9999.;
0095     case JetComb::kPt:
0096       return lepton_.pt();
0097     case JetComb::kEta:
0098       return lepton_.eta();
0099     case JetComb::kPhi:
0100       return lepton_.phi();
0101     case JetComb::kTheta:
0102       return lepton_.theta();
0103   };
0104   return -9999.;
0105 }
0106 
0107 double TtSemiLepJetComb::neutrinoVar(JetComb::VarType var) const {
0108   switch (var) {
0109     case JetComb::kMass:
0110       return -9999.;
0111     case JetComb::kPt:
0112       return neutrino_.p4().pt();
0113     case JetComb::kEta:
0114       return neutrino_.p4().eta();
0115     case JetComb::kPhi:
0116       return neutrino_.p4().phi();
0117     case JetComb::kTheta:
0118       return neutrino_.p4().theta();
0119   };
0120   return -9999.;
0121 }
0122 
0123 double TtSemiLepJetComb::compareHadTopLepTop(JetComb::CompType comp) const {
0124   switch (comp) {
0125     case JetComb::kDeltaM:
0126       return top(JetComb::kHad).mass() - top(JetComb::kLep).mass();
0127     case JetComb::kDeltaR:
0128       return ROOT::Math::VectorUtil::DeltaR(top(JetComb::kHad), top(JetComb::kLep));
0129     case JetComb::kDeltaPhi:
0130       return fabs(ROOT::Math::VectorUtil::DeltaPhi(top(JetComb::kHad), top(JetComb::kLep)));
0131     case JetComb::kDeltaTheta:
0132       return ROOT::Math::VectorUtil::Angle(top(JetComb::kHad), top(JetComb::kLep));
0133   };
0134   return -9999.;
0135 }
0136 
0137 double TtSemiLepJetComb::compareHadWLepW(JetComb::CompType comp) const {
0138   switch (comp) {
0139     case JetComb::kDeltaM:
0140       return wBoson(JetComb::kHad).mass() - wBoson(JetComb::kLep).mass();
0141     case JetComb::kDeltaR:
0142       return ROOT::Math::VectorUtil::DeltaR(wBoson(JetComb::kHad), wBoson(JetComb::kLep));
0143     case JetComb::kDeltaPhi:
0144       return fabs(ROOT::Math::VectorUtil::DeltaPhi(wBoson(JetComb::kHad), wBoson(JetComb::kLep)));
0145     case JetComb::kDeltaTheta:
0146       return ROOT::Math::VectorUtil::Angle(wBoson(JetComb::kHad), wBoson(JetComb::kLep));
0147   };
0148   return -9999.;
0149 }
0150 
0151 double TtSemiLepJetComb::compareHadBLepB(JetComb::CompType comp) const {
0152   switch (comp) {
0153     case JetComb::kDeltaM:
0154       return -9999.;
0155     case JetComb::kDeltaR:
0156       return ROOT::Math::VectorUtil::DeltaR(bQuark(JetComb::kHad).p4(), bQuark(JetComb::kLep).p4());
0157     case JetComb::kDeltaPhi:
0158       return fabs(ROOT::Math::VectorUtil::DeltaPhi(bQuark(JetComb::kHad).p4(), bQuark(JetComb::kLep).p4()));
0159     case JetComb::kDeltaTheta:
0160       return ROOT::Math::VectorUtil::Angle(bQuark(JetComb::kHad).p4(), bQuark(JetComb::kLep).p4());
0161   };
0162   return -9999.;
0163 }
0164 
0165 double TtSemiLepJetComb::compareLightQuarks(JetComb::CompType comp) const {
0166   switch (comp) {
0167     case JetComb::kDeltaM:
0168       return -9999.;
0169     case JetComb::kDeltaR:
0170       return ROOT::Math::VectorUtil::DeltaR(lightQ().p4(), lightQ(true).p4());
0171     case JetComb::kDeltaPhi:
0172       return fabs(ROOT::Math::VectorUtil::DeltaPhi(lightQ().p4(), lightQ(true).p4()));
0173     case JetComb::kDeltaTheta:
0174       return ROOT::Math::VectorUtil::Angle(lightQ().p4(), lightQ(true).p4());
0175   };
0176   return -9999.;
0177 }
0178 
0179 double TtSemiLepJetComb::compareLeptonNeutrino(JetComb::CompType comp) const {
0180   switch (comp) {
0181     case JetComb::kDeltaM:
0182       return -9999.;
0183     case JetComb::kDeltaR:
0184       return ROOT::Math::VectorUtil::DeltaR(lepton_, neutrino_.p4());
0185     case JetComb::kDeltaPhi:
0186       return fabs(ROOT::Math::VectorUtil::DeltaPhi(lepton_, neutrino_.p4()));
0187     case JetComb::kDeltaTheta:
0188       return ROOT::Math::VectorUtil::Angle(lepton_, neutrino_.p4());
0189   };
0190   return -9999.;
0191 }
0192 
0193 double TtSemiLepJetComb::compareTopW(JetComb::DecayType dec1, JetComb::DecayType dec2, JetComb::CompType comp) const {
0194   switch (comp) {
0195     case JetComb::kDeltaM:
0196       return top(dec1).mass() - wBoson(dec2).mass();
0197     case JetComb::kDeltaR:
0198       return ROOT::Math::VectorUtil::DeltaR(top(dec1), wBoson(dec2));
0199     case JetComb::kDeltaPhi:
0200       return fabs(ROOT::Math::VectorUtil::DeltaPhi(top(dec1), wBoson(dec2)));
0201     case JetComb::kDeltaTheta:
0202       return ROOT::Math::VectorUtil::Angle(top(dec1), wBoson(dec2));
0203   };
0204   return -9999.;
0205 }
0206 
0207 double TtSemiLepJetComb::compareTopB(JetComb::DecayType dec1, JetComb::DecayType dec2, JetComb::CompType comp) const {
0208   switch (comp) {
0209     case JetComb::kDeltaM:
0210       return -9999.;
0211     case JetComb::kDeltaR:
0212       return ROOT::Math::VectorUtil::DeltaR(top(dec1), bQuark(dec2).p4());
0213     case JetComb::kDeltaPhi:
0214       return fabs(ROOT::Math::VectorUtil::DeltaPhi(top(dec1), bQuark(dec2).p4()));
0215     case JetComb::kDeltaTheta:
0216       return ROOT::Math::VectorUtil::Angle(top(dec1), bQuark(dec2).p4());
0217   };
0218   return -9999.;
0219 }
0220 
0221 double TtSemiLepJetComb::compareWB(JetComb::DecayType dec1, JetComb::DecayType dec2, JetComb::CompType comp) const {
0222   switch (comp) {
0223     case JetComb::kDeltaM:
0224       return -9999.;
0225     case JetComb::kDeltaR:
0226       return ROOT::Math::VectorUtil::DeltaR(wBoson(dec1), bQuark(dec2).p4());
0227     case JetComb::kDeltaPhi:
0228       return fabs(ROOT::Math::VectorUtil::DeltaPhi(wBoson(dec1), bQuark(dec2).p4()));
0229     case JetComb::kDeltaTheta:
0230       return ROOT::Math::VectorUtil::Angle(wBoson(dec1), bQuark(dec2).p4());
0231   };
0232   return -9999.;
0233 }
0234 
0235 double TtSemiLepJetComb::compareTopLepton(JetComb::DecayType decay, JetComb::CompType comp) const {
0236   switch (comp) {
0237     case JetComb::kDeltaM:
0238       return -9999.;
0239     case JetComb::kDeltaR:
0240       return ROOT::Math::VectorUtil::DeltaR(top(decay), lepton_);
0241     case JetComb::kDeltaPhi:
0242       return fabs(ROOT::Math::VectorUtil::DeltaPhi(top(decay), lepton_));
0243     case JetComb::kDeltaTheta:
0244       return ROOT::Math::VectorUtil::Angle(top(decay), lepton_);
0245   };
0246   return -9999.;
0247 }
0248 
0249 double TtSemiLepJetComb::compareTopNeutrino(JetComb::DecayType decay, JetComb::CompType comp) const {
0250   switch (comp) {
0251     case JetComb::kDeltaM:
0252       return -9999.;
0253     case JetComb::kDeltaR:
0254       return ROOT::Math::VectorUtil::DeltaR(top(decay), neutrino_.p4());
0255     case JetComb::kDeltaPhi:
0256       return fabs(ROOT::Math::VectorUtil::DeltaPhi(top(decay), neutrino_.p4()));
0257     case JetComb::kDeltaTheta:
0258       return ROOT::Math::VectorUtil::Angle(top(decay), neutrino_.p4());
0259   };
0260   return -9999.;
0261 }
0262 
0263 double TtSemiLepJetComb::compareWLepton(JetComb::DecayType decay, JetComb::CompType comp) const {
0264   switch (comp) {
0265     case JetComb::kDeltaM:
0266       return -9999.;
0267     case JetComb::kDeltaR:
0268       return ROOT::Math::VectorUtil::DeltaR(wBoson(decay), lepton_);
0269     case JetComb::kDeltaPhi:
0270       return fabs(ROOT::Math::VectorUtil::DeltaPhi(wBoson(decay), lepton_));
0271     case JetComb::kDeltaTheta:
0272       return ROOT::Math::VectorUtil::Angle(wBoson(decay), lepton_);
0273   };
0274   return -9999.;
0275 }
0276 
0277 double TtSemiLepJetComb::compareWNeutrino(JetComb::DecayType decay, JetComb::CompType comp) const {
0278   switch (comp) {
0279     case JetComb::kDeltaM:
0280       return -9999.;
0281     case JetComb::kDeltaR:
0282       return ROOT::Math::VectorUtil::DeltaR(wBoson(decay), neutrino_.p4());
0283     case JetComb::kDeltaPhi:
0284       return fabs(ROOT::Math::VectorUtil::DeltaPhi(wBoson(decay), neutrino_.p4()));
0285     case JetComb::kDeltaTheta:
0286       return ROOT::Math::VectorUtil::Angle(wBoson(decay), neutrino_.p4());
0287   };
0288   return -9999.;
0289 }
0290 
0291 double TtSemiLepJetComb::compareBLepton(JetComb::DecayType decay, JetComb::CompType comp) const {
0292   switch (comp) {
0293     case JetComb::kDeltaM:
0294       return -9999.;
0295     case JetComb::kDeltaR:
0296       return ROOT::Math::VectorUtil::DeltaR(bQuark(decay).p4(), lepton_);
0297     case JetComb::kDeltaPhi:
0298       return fabs(ROOT::Math::VectorUtil::DeltaPhi(bQuark(decay).p4(), lepton_));
0299     case JetComb::kDeltaTheta:
0300       return ROOT::Math::VectorUtil::Angle(bQuark(decay).p4(), lepton_);
0301   };
0302   return -9999.;
0303 }
0304 
0305 double TtSemiLepJetComb::compareBNeutrino(JetComb::DecayType decay, JetComb::CompType comp) const {
0306   switch (comp) {
0307     case JetComb::kDeltaM:
0308       return -9999.;
0309     case JetComb::kDeltaR:
0310       return ROOT::Math::VectorUtil::DeltaR(bQuark(decay).p4(), neutrino_.p4());
0311     case JetComb::kDeltaPhi:
0312       return fabs(ROOT::Math::VectorUtil::DeltaPhi(bQuark(decay).p4(), neutrino_.p4()));
0313     case JetComb::kDeltaTheta:
0314       return ROOT::Math::VectorUtil::Angle(bQuark(decay).p4(), neutrino_.p4());
0315   };
0316   return -9999.;
0317 }
0318 
0319 double TtSemiLepJetComb::relativePtHadronicTop() const {
0320   return top(JetComb::kHad).pt() /
0321          (top(JetComb::kHad).pt() + (lightQ().p4() + lightQ(true).p4() + bQuark(JetComb::kLep).p4()).pt() +
0322           (lightQ().p4() + bQuark(JetComb::kHad).p4() + bQuark(JetComb::kLep).p4()).pt() +
0323           (bQuark(JetComb::kHad).p4() + lightQ(true).p4() + bQuark(JetComb::kLep).p4()).pt());
0324 }
0325 
0326 double TtSemiLepJetComb::bOverLightQPt() const {
0327   return (bQuark(JetComb::kHad).p4().pt() + bQuark(JetComb::kLep).p4().pt()) /
0328          (lightQ().p4().pt() + lightQ(true).p4().pt());
0329 }
0330 
0331 double TtSemiLepJetComb::combinedBTags(JetComb::BTagAlgo algo, JetComb::Operator op) const {
0332   switch (op) {
0333     case JetComb::kAdd:
0334       return bTag(JetComb::kHad, algo) + bTag(JetComb::kLep, algo);
0335     case JetComb::kMult:
0336       return bTag(JetComb::kHad, algo) * bTag(JetComb::kLep, algo);
0337   };
0338   return -9999.;
0339 }
0340 
0341 double TtSemiLepJetComb::combinedBTagsForLightQuarks(JetComb::BTagAlgo algo, JetComb::Operator op) const {
0342   switch (op) {
0343     case JetComb::kAdd:
0344       return bTag(lightQ(), algo) + bTag(lightQ(true), algo);
0345     case JetComb::kMult:
0346       return bTag(lightQ(), algo) * bTag(lightQ(true), algo);
0347   };
0348   return -9999.;
0349 }
0350 
0351 // ----------------------------------------------------------------------
0352 // private methods
0353 // ----------------------------------------------------------------------
0354 
0355 void TtSemiLepJetComb::deduceMothers() {
0356   hadW_ = hadQJet_.p4() + hadQBarJet_.p4();
0357   lepW_ = lepton_ + neutrino_.p4();
0358   hadTop_ = hadW_ + hadBJet_.p4();
0359   lepTop_ = lepW_ + lepBJet_.p4();
0360 }
0361 
0362 double TtSemiLepJetComb::bTag(const pat::Jet& jet, JetComb::BTagAlgo algo) const {
0363   switch (algo) {
0364     case JetComb::kTrackCountHighEff:
0365       return jet.bDiscriminator("trackCountingHighEffBJetTags");
0366     case JetComb::kTrackCountHighPur:
0367       return jet.bDiscriminator("trackCountingHighPurBJetTags");
0368     case JetComb::kSoftMuon:
0369       return jet.bDiscriminator("softMuonBJetTags");
0370     case JetComb::kSoftMuonByPt:
0371       return jet.bDiscriminator("softMuonByPtBJetTags");
0372     case JetComb::kSofMuonByIP3d:
0373       return jet.bDiscriminator("softMuonByIP3dBJetTags");
0374     case JetComb::kSoftElec:
0375       return jet.bDiscriminator("softElectronBJetTags");
0376     case JetComb::kProbability:
0377       return jet.bDiscriminator("jetProbabilityBJetTags");
0378     case JetComb::kBProbability:
0379       return jet.bDiscriminator("jetBProbabilityBJetTags");
0380     case JetComb::kSimpleSecondVtx:
0381       return jet.bDiscriminator("simpleSecondaryVertexBJetTags");
0382     case JetComb::kCombSecondVtx:
0383       return jet.bDiscriminator("combinedSecondaryVertexBJetTags");
0384     case JetComb::kCombSecondVtxMVA:
0385       return jet.bDiscriminator("combinedSecondaryVertexMVABJetTags");
0386   };
0387   return -9999.;
0388 }