Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef TtSemiLepJetComb_h
0002 #define TtSemiLepJetComb_h
0003 
0004 #include <vector>
0005 #include <string>
0006 
0007 #include "TMath.h"
0008 
0009 #include "DataFormats/PatCandidates/interface/Jet.h"
0010 #include "DataFormats/PatCandidates/interface/MET.h"
0011 
0012 namespace JetComb {
0013   /// distinguish between hadronic and leptonic
0014   /// decay chain of the top
0015   enum DecayType { kHad, kLep };
0016   /// supported std single variable types
0017   enum VarType { kMass, kPt, kEta, kPhi, kTheta };
0018   /// supported comparison types
0019   enum CompType { kDeltaM, kDeltaR, kDeltaPhi, kDeltaTheta };
0020   /// b-tagging algorithms
0021   enum BTagAlgo {
0022     kTrackCountHighEff,
0023     kTrackCountHighPur,
0024     kSoftMuon,
0025     kSoftMuonByPt,
0026     kSofMuonByIP3d,
0027     kSoftElec,
0028     kBProbability,
0029     kProbability,
0030     kSimpleSecondVtx,
0031     kCombSecondVtx,
0032     kCombSecondVtxMVA
0033   };
0034   /// operators for combining variables
0035   enum Operator { kAdd, kMult };
0036 }  // namespace JetComb
0037 
0038 /**
0039    \class   TtSemiLepJetComb TtSemiLepJetComb.h "TopQuarkAnalysis/TopJetCombination/interface/TtSemiLepJetComb.h"
0040 
0041    \brief   Common calculator class to keep multivariate analysis variables
0042             for jet combinations in semi-leptonic ttbar decays
0043 
0044    This class is currently used by TtSemiLepJetCombEval.h, which is included in both the
0045    TtSemiLepJetCombMVAComputer and the TtSemiLepJetCombMVATrainer.
0046 */
0047 
0048 class TtSemiLepJetComb {
0049 public:
0050   /// emtpy constructor
0051   TtSemiLepJetComb();
0052   /// default constructor
0053   TtSemiLepJetComb(const std::vector<pat::Jet>&,
0054                    const std::vector<int>&,
0055                    const math::XYZTLorentzVector&,
0056                    const pat::MET&);
0057   /// default destructor
0058   ~TtSemiLepJetComb();
0059 
0060   /// top quark candidate variable
0061   double topVar(JetComb::DecayType decay, JetComb::VarType var) const;
0062   /// W boson candidate variable
0063   double wBosonVar(JetComb::DecayType decay, JetComb::VarType var) const;
0064   /// b quark candidate variable
0065   double bQuarkVar(JetComb::DecayType decay, JetComb::VarType var) const;
0066   /// light quark candidate variable
0067   double lightQVar(bool qbar, JetComb::VarType var) const;
0068   /// lepton candidate variable
0069   double leptonVar(JetComb::VarType var) const;
0070   /// neutrino candidate variable
0071   double neutrinoVar(JetComb::VarType var) const;
0072 
0073   /// comparison between the two top candidates
0074   double compareHadTopLepTop(JetComb::CompType comp) const;
0075   /// comparison between the two W candidates
0076   double compareHadWLepW(JetComb::CompType comp) const;
0077   /// comparison between the two b candidates
0078   double compareHadBLepB(JetComb::CompType comp) const;
0079   /// comparison between the lightQ and the lightQBar candidate
0080   double compareLightQuarks(JetComb::CompType comp) const;
0081   /// comparison between the lepton and the neutrino candidate
0082   double compareLeptonNeutrino(JetComb::CompType comp) const;
0083   /// comparison between the top and the W candidate
0084   double compareTopW(JetComb::DecayType dec1, JetComb::DecayType dec2, JetComb::CompType comp) const;
0085   /// comparison between the top and the b candidate
0086   double compareTopB(JetComb::DecayType dec1, JetComb::DecayType dec2, JetComb::CompType comp) const;
0087   /// comparison between the W and the b candidate
0088   double compareWB(JetComb::DecayType dec1, JetComb::DecayType dec2, JetComb::CompType comp) const;
0089   /// comparison between the top and the lepton candidate
0090   double compareTopLepton(JetComb::DecayType decay, JetComb::CompType comp) const;
0091   /// comparison between the top and the neutrino candidate
0092   double compareTopNeutrino(JetComb::DecayType decay, JetComb::CompType comp) const;
0093   /// comparison between the W and the lepton candidate
0094   double compareWLepton(JetComb::DecayType decay, JetComb::CompType comp) const;
0095   /// comparison between the W and the neutrino candidate
0096   double compareWNeutrino(JetComb::DecayType decay, JetComb::CompType comp) const;
0097   /// comparison between the b and the lepton candidate
0098   double compareBLepton(JetComb::DecayType decay, JetComb::CompType comp) const;
0099   /// comparison between the b and the neutrino candidate
0100   double compareBNeutrino(JetComb::DecayType decay, JetComb::CompType comp) const;
0101 
0102   /// pt of the hadronic top candidate relative to pt of the
0103   /// sum of all other reconstruction possibilities (returns
0104   /// values between 0 and 1)
0105   double relativePtHadronicTop() const;
0106   /// scalar sum of the pt of the b candidates relative to
0107   /// scalar sum of the pt of the light quark candidates
0108   double bOverLightQPt() const;
0109 
0110   /// b-tag value of a b candidate
0111   double bTag(JetComb::DecayType decay, JetComb::BTagAlgo algo) const { return bTag(bQuark(decay), algo); };
0112   /// combined b-tag values of the two b candidates
0113   double combinedBTags(JetComb::BTagAlgo algo, JetComb::Operator op) const;
0114   /// combined b-tag values of the two light quark candidates
0115   double combinedBTagsForLightQuarks(JetComb::BTagAlgo algo, JetComb::Operator op) const;
0116 
0117   /// add an arbitary user defined variable with given key and value
0118   double addUserVar(std::string key, double value) { return userVariables_[key] = value; };
0119   /// receive user defined variable value with given key
0120   double userVar(const std::string& key) const {
0121     return (userVariables_.find(key) != userVariables_.end() ? userVariables_.find(key)->second : -9999.);
0122   };
0123 
0124 private:
0125   /// reconstruct mother candidates from final state candidates
0126   void deduceMothers();
0127   /// b-tag value of one of the 4 jets
0128   double bTag(const pat::Jet& jet, JetComb::BTagAlgo algo) const;
0129   /// light quark candidate variable with default on q and not qbar
0130   double lightQVar(JetComb::VarType var) const { return lightQVar(false, var); };
0131   /// return lightQ or lightQBar candidate depending on argument
0132   const pat::Jet& lightQ(bool qbar = false) const { return (qbar ? hadQBarJet_ : hadQJet_); }
0133   /// return leptonic or hadronic b candidate depending on argument
0134   const pat::Jet& bQuark(JetComb::DecayType decay) const { return (decay == JetComb::kHad ? hadBJet_ : lepBJet_); }
0135   /// return leptonic or hadronic W candidate depending on argument
0136   const math::XYZTLorentzVector& wBoson(JetComb::DecayType decay) const {
0137     return (decay == JetComb::kHad ? hadW_ : lepW_);
0138   }
0139   /// return leptonic or hadronic top candidate depending on argument
0140   const math::XYZTLorentzVector& top(JetComb::DecayType decay) const {
0141     return (decay == JetComb::kHad ? hadTop_ : lepTop_);
0142   }
0143 
0144 private:
0145   /// lightQ jet
0146   pat::Jet hadQJet_;
0147   /// lightQBar jet
0148   pat::Jet hadQBarJet_;
0149   /// hadronic b jet
0150   pat::Jet hadBJet_;
0151   /// leptonic b jet
0152   pat::Jet lepBJet_;
0153   /// neutrino candidate
0154   pat::MET neutrino_;
0155   /// lepton 4-vector
0156   math::XYZTLorentzVector lepton_;
0157   /// hadronic top 4-vector
0158   math::XYZTLorentzVector hadTop_;
0159   /// hadronic W 4-vector
0160   math::XYZTLorentzVector hadW_;
0161   /// leptonic top 4-vector
0162   math::XYZTLorentzVector lepTop_;
0163   /// leptonic W 4-vector
0164   math::XYZTLorentzVector lepW_;
0165   /// map for user defined variables
0166   std::map<std::string, double> userVariables_;
0167 };
0168 
0169 #endif