CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/AnalysisDataFormats/TopObjects/src/TtDilepEvtSolution.cc

Go to the documentation of this file.
00001 //
00002 // $Id: TtDilepEvtSolution.cc,v 1.21 2009/04/29 13:27:58 snaumann Exp $
00003 //
00004 
00005 #include "DataFormats/Math/interface/deltaR.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "AnalysisDataFormats/TopObjects/interface/TtDilepEvtSolution.h"
00008 
00009 TtDilepEvtSolution::TtDilepEvtSolution() 
00010 {
00011   jetCorrScheme_ = 0;
00012   wpDecay_ = "NotDefined";
00013   wmDecay_ = "NotDefined";
00014   bestSol_ = false;
00015   topmass_ = 0.;
00016   weightmax_ = 0.;
00017 }
00018 
00019 TtDilepEvtSolution::~TtDilepEvtSolution() 
00020 {
00021 }
00022 
00023 //-------------------------------------------
00024 // get calibrated base objects 
00025 //-------------------------------------------
00026 pat::Jet TtDilepEvtSolution::getJetB() const 
00027 {
00028   // WARNING this is obsolete and only 
00029   // kept for backwards compatibility
00030   if(jetCorrScheme_==1){
00031     //jet calibrated according to MC truth
00032     return jetB_->correctedJet("HAD", "B");
00033   }
00034   else if(jetCorrScheme_==2){
00035     return jetB_->correctedJet("HAD", "B");
00036   }
00037   else{
00038     return *jetB_;
00039   }
00040 }
00041 
00042 pat::Jet TtDilepEvtSolution::getJetBbar() const 
00043 {
00044   // WARNING this is obsolete and only 
00045   // kept for backwards compatibility
00046   if(jetCorrScheme_==1){
00047     //jet calibrated according to MC truth
00048     return jetBbar_->correctedJet("HAD", "B");
00049   }
00050   else if(jetCorrScheme_==2){
00051     return jetBbar_->correctedJet("HAD", "B");
00052   }
00053   else{
00054     return *jetBbar_;
00055   }
00056 }
00057 
00058 //-------------------------------------------
00059 // returns the 4-vector of the positive 
00060 // lepton, with the charge and the pdgId
00061 //-------------------------------------------
00062 reco::Particle TtDilepEvtSolution::getLeptPos() const 
00063 {
00064   reco::Particle p;
00065   if(wpDecay_ == "muon"){
00066     p = reco::Particle(+1, getMuonp().p4() );
00067     p.setPdgId(-11);
00068   }
00069   if(wpDecay_ == "electron"){
00070     p = reco::Particle(+1, getElectronp().p4() );
00071     p.setPdgId(-13);
00072   }
00073   if(wmDecay_ == "tau"){
00074     p = reco::Particle(+1, getTaup().p4() );
00075     p.setPdgId(-15);
00076   }
00077   return p;
00078 }
00079 
00080 //-------------------------------------------
00081 // miscellaneous
00082 //-------------------------------------------
00083 double TtDilepEvtSolution::getJetResidual() const
00084 {
00085   double distance = 0.;
00086   if(!getGenB() || !getGenBbar()) return distance;
00087   distance += reco::deltaR(getCalJetB(),*getGenB());
00088   distance += reco::deltaR(getCalJetBbar(),*getGenBbar());
00089   return distance;
00090 }
00091 
00092 double TtDilepEvtSolution::getLeptonResidual() const
00093 {
00094   double distance = 0.;
00095   if(!getGenLepp() || !getGenLepm()) return distance;
00096   if(getWpDecay()=="electron")
00097     distance += reco::deltaR(getElectronp(),*getGenLepp());
00098   else if(getWpDecay()=="muon")
00099     distance += reco::deltaR(getMuonp(),*getGenLepp());
00100   else if(getWpDecay()=="tau")
00101     distance += reco::deltaR(getTaup(),*getGenLepp());
00102   if(getWmDecay()=="electron")
00103     distance += reco::deltaR(getElectronm(),*getGenLepm());
00104   else if(getWmDecay()=="muon")
00105     distance += reco::deltaR(getMuonm(),*getGenLepm());
00106   else if(getWmDecay()=="tau")
00107     distance += reco::deltaR(getTaum(),*getGenLepm());
00108   return distance;
00109 }
00110 
00111 //-------------------------------------------
00112 // returns the 4-vector of the negative 
00113 // lepton, with the charge and the pdgId
00114 //-------------------------------------------
00115 reco::Particle TtDilepEvtSolution::getLeptNeg() const 
00116 {
00117   reco::Particle p;
00118   if(wmDecay_ == "electron"){
00119     p = reco::Particle(-1, getElectronm().p4() );
00120     p.setPdgId(11);
00121   }
00122   if(wmDecay_ == "muon"){
00123     p = reco::Particle(-1, getMuonm().p4() );
00124     p.setPdgId(13);
00125   }
00126   if(wmDecay_ == "tau"){
00127     p = reco::Particle(-1, getTaum().p4() );
00128     p.setPdgId(15);
00129   }
00130   return p;
00131 }
00132 
00133 //-------------------------------------------
00134 // get info on the outcome of the signal 
00135 //selection LR
00136 //-------------------------------------------
00137 double TtDilepEvtSolution::getLRSignalEvtObsVal(unsigned int selObs) const 
00138 {
00139   double val = -999.;
00140   for(size_t i=0; i<lrSignalEvtVarVal_.size(); i++){
00141     if(lrSignalEvtVarVal_[i].first == selObs) val = lrSignalEvtVarVal_[i].second;
00142   }
00143   return val;
00144 }
00145 
00146 //-------------------------------------------
00147 // set the generated event
00148 //-------------------------------------------
00149 void TtDilepEvtSolution::setGenEvt(const edm::Handle<TtGenEvent>& aGenEvt) {
00150   if( !aGenEvt->isFullLeptonic() ){
00151     edm::LogInfo( "TtGenEventNotFilled" ) << "genEvt is not di-leptonic; TtGenEvent is not filled";
00152     return;
00153   }
00154   theGenEvt_ = edm::RefProd<TtGenEvent>(aGenEvt);
00155 }
00156 
00157 //-------------------------------------------
00158 // set the outcome of the signal selection LR
00159 //-------------------------------------------
00160 void TtDilepEvtSolution::setLRSignalEvtObservables(std::vector<std::pair<unsigned int, double> > varval) 
00161 {
00162   lrSignalEvtVarVal_.clear();
00163   for(size_t ise = 0; ise<varval.size(); ise++) lrSignalEvtVarVal_.push_back(varval[ise]);
00164 }