Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:31

0001 //
0002 //
0003 
0004 #include "DataFormats/Math/interface/deltaR.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "AnalysisDataFormats/TopObjects/interface/TtDilepEvtSolution.h"
0007 
0008 TtDilepEvtSolution::TtDilepEvtSolution() {
0009   jetCorrScheme_ = 0;
0010   wpDecay_ = "NotDefined";
0011   wmDecay_ = "NotDefined";
0012   bestSol_ = false;
0013   topmass_ = 0.;
0014   weightmax_ = 0.;
0015 }
0016 
0017 TtDilepEvtSolution::~TtDilepEvtSolution() {}
0018 
0019 //-------------------------------------------
0020 // get calibrated base objects
0021 //-------------------------------------------
0022 pat::Jet TtDilepEvtSolution::getJetB() const {
0023   // WARNING this is obsolete and only
0024   // kept for backwards compatibility
0025   if (jetCorrScheme_ == 1) {
0026     //jet calibrated according to MC truth
0027     return jetB_->correctedJet("HAD", "B");
0028   } else if (jetCorrScheme_ == 2) {
0029     return jetB_->correctedJet("HAD", "B");
0030   } else {
0031     return *jetB_;
0032   }
0033 }
0034 
0035 pat::Jet TtDilepEvtSolution::getJetBbar() const {
0036   // WARNING this is obsolete and only
0037   // kept for backwards compatibility
0038   if (jetCorrScheme_ == 1) {
0039     //jet calibrated according to MC truth
0040     return jetBbar_->correctedJet("HAD", "B");
0041   } else if (jetCorrScheme_ == 2) {
0042     return jetBbar_->correctedJet("HAD", "B");
0043   } else {
0044     return *jetBbar_;
0045   }
0046 }
0047 
0048 //-------------------------------------------
0049 // returns the 4-vector of the positive
0050 // lepton, with the charge and the pdgId
0051 //-------------------------------------------
0052 reco::Particle TtDilepEvtSolution::getLeptPos() const {
0053   reco::Particle p;
0054   if (wpDecay_ == "muon") {
0055     p = reco::Particle(+1, getMuonp().p4());
0056     p.setPdgId(-11);
0057   }
0058   if (wpDecay_ == "electron") {
0059     p = reco::Particle(+1, getElectronp().p4());
0060     p.setPdgId(-13);
0061   }
0062   if (wmDecay_ == "tau") {
0063     p = reco::Particle(+1, getTaup().p4());
0064     p.setPdgId(-15);
0065   }
0066   return p;
0067 }
0068 
0069 //-------------------------------------------
0070 // miscellaneous
0071 //-------------------------------------------
0072 double TtDilepEvtSolution::getJetResidual() const {
0073   double distance = 0.;
0074   if (!getGenB() || !getGenBbar())
0075     return distance;
0076   distance += reco::deltaR(getCalJetB(), *getGenB());
0077   distance += reco::deltaR(getCalJetBbar(), *getGenBbar());
0078   return distance;
0079 }
0080 
0081 double TtDilepEvtSolution::getLeptonResidual() const {
0082   double distance = 0.;
0083   if (!getGenLepp() || !getGenLepm())
0084     return distance;
0085   if (getWpDecay() == "electron")
0086     distance += reco::deltaR(getElectronp(), *getGenLepp());
0087   else if (getWpDecay() == "muon")
0088     distance += reco::deltaR(getMuonp(), *getGenLepp());
0089   else if (getWpDecay() == "tau")
0090     distance += reco::deltaR(getTaup(), *getGenLepp());
0091   if (getWmDecay() == "electron")
0092     distance += reco::deltaR(getElectronm(), *getGenLepm());
0093   else if (getWmDecay() == "muon")
0094     distance += reco::deltaR(getMuonm(), *getGenLepm());
0095   else if (getWmDecay() == "tau")
0096     distance += reco::deltaR(getTaum(), *getGenLepm());
0097   return distance;
0098 }
0099 
0100 //-------------------------------------------
0101 // returns the 4-vector of the negative
0102 // lepton, with the charge and the pdgId
0103 //-------------------------------------------
0104 reco::Particle TtDilepEvtSolution::getLeptNeg() const {
0105   reco::Particle p;
0106   if (wmDecay_ == "electron") {
0107     p = reco::Particle(-1, getElectronm().p4());
0108     p.setPdgId(11);
0109   }
0110   if (wmDecay_ == "muon") {
0111     p = reco::Particle(-1, getMuonm().p4());
0112     p.setPdgId(13);
0113   }
0114   if (wmDecay_ == "tau") {
0115     p = reco::Particle(-1, getTaum().p4());
0116     p.setPdgId(15);
0117   }
0118   return p;
0119 }
0120 
0121 //-------------------------------------------
0122 // get info on the outcome of the signal
0123 //selection LR
0124 //-------------------------------------------
0125 double TtDilepEvtSolution::getLRSignalEvtObsVal(unsigned int selObs) const {
0126   double val = -999.;
0127   for (size_t i = 0; i < lrSignalEvtVarVal_.size(); i++) {
0128     if (lrSignalEvtVarVal_[i].first == selObs)
0129       val = lrSignalEvtVarVal_[i].second;
0130   }
0131   return val;
0132 }
0133 
0134 //-------------------------------------------
0135 // set the generated event
0136 //-------------------------------------------
0137 void TtDilepEvtSolution::setGenEvt(const edm::Handle<TtGenEvent>& aGenEvt) {
0138   if (!aGenEvt->isFullLeptonic()) {
0139     edm::LogInfo("TtGenEventNotFilled") << "genEvt is not di-leptonic; TtGenEvent is not filled";
0140     return;
0141   }
0142   theGenEvt_ = edm::RefProd<TtGenEvent>(aGenEvt);
0143 }
0144 
0145 //-------------------------------------------
0146 // set the outcome of the signal selection LR
0147 //-------------------------------------------
0148 void TtDilepEvtSolution::setLRSignalEvtObservables(const std::vector<std::pair<unsigned int, double> >& varval) {
0149   lrSignalEvtVarVal_.clear();
0150   for (size_t ise = 0; ise < varval.size(); ise++)
0151     lrSignalEvtVarVal_.push_back(varval[ise]);
0152 }