CMS 3D CMS Logo

TtSemiEvtSolution.cc

Go to the documentation of this file.
00001 //
00002 // $Id: TtSemiEvtSolution.cc,v 1.27.2.1 2009/04/01 22:32:53 rwolf Exp $
00003 //
00004 
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "AnalysisDataFormats/TopObjects/interface/TtSemiEvtSolution.h"
00007 #include "DataFormats/Candidate/interface/ShallowClonePtrCandidate.h"
00008 #include "PhysicsTools/CandUtils/interface/AddFourMomenta.h"
00009 
00010 TtSemiEvtSolution::TtSemiEvtSolution() : 
00011   mcHyp_  ("ttSemiEvtMCHyp"), 
00012   recoHyp_("ttSemiEvtRecoHyp"),
00013   fitHyp_ ("ttSemiEvtFitHyp")
00014 {
00015   jetCorrScheme_     = 0;
00016   sumAnglejp_        = -999.;
00017   angleHadp_         = -999.;
00018   angleHadq_         = -999.;
00019   angleHadb_         = -999.;
00020   angleLepb_         = -999.;
00021   changeWQ_          = -999;
00022   probChi2_          = -999.;
00023   mcBestJetComb_     = -999;
00024   simpleBestJetComb_ = -999;
00025   lrBestJetComb_     = -999;
00026   lrJetCombLRval_    = -999.;
00027   lrJetCombProb_     = -999.;
00028   lrSignalEvtLRval_  = -999.;
00029   lrSignalEvtProb_   = -999.;
00030 }
00031 
00032 TtSemiEvtSolution::~TtSemiEvtSolution() 
00033 {
00034 }
00035 
00036 //-------------------------------------------
00037 // get calibrated base objects 
00038 //------------------------------------------- 
00039 pat::Jet TtSemiEvtSolution::getHadb() const 
00040 {
00041   // WARNING this is obsolete and only 
00042   // kept for backwards compatibility
00043   if (jetCorrScheme_ == 1) return hadb_->correctedJet("HAD", "B"); // calibrate jets according to MC truth
00044   else if (jetCorrScheme_ == 2) return hadb_->correctedJet("HAD", "B");
00045   else return *hadb_;
00046 }
00047 
00048 pat::Jet TtSemiEvtSolution::getHadp() const 
00049 {
00050   // WARNING this is obsolete and only 
00051   // kept for backwards compatibility
00052   if (jetCorrScheme_ == 1) return hadp_->correctedJet("HAD", "UDS"); // calibrate jets according to MC truth
00053   else if (jetCorrScheme_ == 2) return hadp_->correctedJet("HAD", "UDS");
00054   else return *hadp_;
00055 }
00056 
00057 pat::Jet TtSemiEvtSolution::getHadq() const 
00058 {
00059   // WARNING this is obsolete and only 
00060   // kept for backwards compatibility
00061   if (jetCorrScheme_ == 1) return hadq_->correctedJet("HAD", "UDS"); // calibrate jets according to MC truth
00062   else if (jetCorrScheme_ == 2) return hadq_->correctedJet("HAD", "UDS");
00063   else return *hadq_;
00064 }
00065 
00066 pat::Jet TtSemiEvtSolution::getLepb() const 
00067 {
00068   // WARNING this is obsolete and only 
00069   // kept for backwards compatibility
00070   if (jetCorrScheme_ == 1) return lepb_->correctedJet("HAD", "B"); // calibrate jets according to MC truth
00071   else if (jetCorrScheme_ == 2) return lepb_->correctedJet("HAD", "B");
00072   else return *lepb_;
00073 }
00074 
00075 //-------------------------------------------
00076 // get (un-)/calibrated reco objects
00077 //-------------------------------------------
00078 reco::Particle TtSemiEvtSolution::getRecHadt() const 
00079 {
00080   // FIXME: the charge from the genevent
00081   return reco::Particle(0,this->getRecHadp().p4() + this->getRecHadq().p4() + this->getRecHadb().p4());
00082 }
00083 
00084 reco::Particle TtSemiEvtSolution::getRecHadW() const 
00085 {
00086   // FIXME: the charge from the genevent
00087   return reco::Particle(0,this->getRecHadp().p4() + this->getRecHadq().p4());
00088 }
00089 
00090 reco::Particle TtSemiEvtSolution::getRecLept() const 
00091 {
00092   // FIXME: the charge from the genevent
00093   reco::Particle p;
00094   if (this->getDecay() == "muon")     p = reco::Particle(0,this->getRecLepm().p4() + this->getRecLepn().p4() + this->getRecLepb().p4());
00095   if (this->getDecay() == "electron") p = reco::Particle(0,this->getRecLepe().p4() + this->getRecLepn().p4() + this->getRecLepb().p4());
00096   return p;
00097 }
00098 
00099 reco::Particle TtSemiEvtSolution::getRecLepW() const 
00100 { 
00101   // FIXME: the charge from the genevent
00102   reco::Particle p;
00103   if (this->getDecay() == "muon")     p = reco::Particle(0,this->getRecLepm().p4() + this->getRecLepn().p4());
00104   if (this->getDecay() == "electron") p = reco::Particle(0,this->getRecLepe().p4() + this->getRecLepn().p4());
00105   return p;
00106 }
00107 
00108 // FIXME: Why these functions??? Not needed!
00109   // methods to get calibrated objects 
00110 reco::Particle TtSemiEvtSolution::getCalHadt() const 
00111 { 
00112   return reco::Particle(0,this->getCalHadp().p4() + this->getCalHadq().p4() + this->getCalHadb().p4()); 
00113 }
00114 
00115 reco::Particle TtSemiEvtSolution::getCalHadW() const 
00116 { 
00117   return reco::Particle(0,this->getCalHadp().p4() + this->getCalHadq().p4()); 
00118 }
00119 
00120 reco::Particle TtSemiEvtSolution::getCalLept() const 
00121 {
00122   reco::Particle p;
00123   if (this->getDecay() == "muon")     p = reco::Particle(0,this->getRecLepm().p4() + this->getRecLepn().p4() + this->getCalLepb().p4());
00124   if (this->getDecay() == "electron") p = reco::Particle(0,this->getRecLepe().p4() + this->getRecLepn().p4() + this->getCalLepb().p4());
00125   return p;
00126 }
00127 
00128 reco::Particle TtSemiEvtSolution::getCalLepW() const 
00129 {
00130   reco::Particle p;
00131   if (this->getDecay() == "muon")     p = reco::Particle(0,this->getRecLepm().p4() + this->getRecLepn().p4());
00132   if (this->getDecay() == "electron") p = reco::Particle(0,this->getRecLepe().p4() + this->getRecLepn().p4());
00133   return p;
00134 }
00135 
00136 //-------------------------------------------
00137 // get objects from kinematic fit
00138 //-------------------------------------------  
00139 reco::Particle TtSemiEvtSolution::getFitHadt() const 
00140 {
00141   // FIXME: provide the correct charge from generated event
00142   return reco::Particle(0, this->getFitHadp().p4() + this->getFitHadq().p4() + this->getFitHadb().p4());
00143 }
00144 
00145 reco::Particle TtSemiEvtSolution::getFitHadW() const 
00146 {
00147   // FIXME: provide the correct charge from generated event
00148   return reco::Particle(0, this->getFitHadp().p4() + this->getFitHadq().p4());
00149 }
00150 
00151 reco::Particle TtSemiEvtSolution::getFitLept() const 
00152 { 
00153   // FIXME: provide the correct charge from generated event
00154   return reco::Particle(0, this->getFitLepl().p4() + this->getFitLepn().p4() + this->getFitLepb().p4());
00155 }
00156 
00157 reco::Particle TtSemiEvtSolution::getFitLepW() const 
00158 { 
00159   // FIXME: provide the correct charge from generated event
00160   return reco::Particle(0, this->getFitLepl().p4() + this->getFitLepn().p4());
00161 }
00162 
00163 //-------------------------------------------
00164 // get info on the outcome of the signal 
00165 // selection LR
00166 //-------------------------------------------
00167 double TtSemiEvtSolution::getLRSignalEvtObsVal(unsigned int selObs) const {
00168   double val = -999.;
00169   for(size_t o=0; o<lrSignalEvtVarVal_.size(); o++){
00170     if(lrSignalEvtVarVal_[o].first == selObs) val = lrSignalEvtVarVal_[o].second;
00171   }
00172   return val;
00173 }
00174 
00175 //-------------------------------------------
00176 // get info on the outcome of the different 
00177 // jet combination methods
00178 //-------------------------------------------
00179 double TtSemiEvtSolution::getLRJetCombObsVal(unsigned int selObs) const 
00180 {
00181   double val = -999.;
00182   for(size_t o=0; o<lrJetCombVarVal_.size(); o++){
00183     if(lrJetCombVarVal_[o].first == selObs) val = lrJetCombVarVal_[o].second;
00184   }
00185   return val;
00186 }
00187 
00188 //-------------------------------------------  
00189 // set the generated event
00190 //-------------------------------------------
00191 void TtSemiEvtSolution::setGenEvt(const edm::Handle<TtGenEvent> & aGenEvt)
00192 {
00193   if( !aGenEvt->isSemiLeptonic(false) ){
00194     edm::LogWarning( "TtGenEventNotFilled" ) << "genEvt is not semi-leptonic; TtGenEvent is not filled";
00195     return;
00196   }
00197   theGenEvt_ = edm::RefProd<TtGenEvent>(aGenEvt);
00198 }
00199 
00200 //-------------------------------------------  
00201 // set the outcome of the different jet 
00202 // combination methods
00203 //-------------------------------------------  
00204 void TtSemiEvtSolution::setLRJetCombObservables(std::vector<std::pair<unsigned int, double> > varval) 
00205 {
00206   lrJetCombVarVal_.clear();
00207   for(size_t ijc = 0; ijc<varval.size(); ijc++) lrJetCombVarVal_.push_back(varval[ijc]);
00208 }
00209 
00210 //-------------------------------------------  
00211 // set the outcome of the signal selection LR
00212 //-------------------------------------------  
00213 void TtSemiEvtSolution::setLRSignalEvtObservables(std::vector<std::pair<unsigned int, double> > varval) 
00214 {
00215   lrSignalEvtVarVal_.clear();
00216   for(size_t ise = 0; ise<varval.size(); ise++) lrSignalEvtVarVal_.push_back(varval[ise]);
00217 }
00218 
00219 
00220 void TtSemiEvtSolution::setupHyp() 
00221 {
00222 
00223   AddFourMomenta addFourMomenta;
00224 
00225   recoHyp_.clearDaughters();
00226   recoHyp_.clearRoles();
00227 
00228   // Setup transient references
00229   reco::CompositeCandidate recHadt;
00230   reco::CompositeCandidate recLept;
00231   reco::CompositeCandidate recHadW;
00232   reco::CompositeCandidate recLepW;
00233 
00234   // Get refs to leaf nodes
00235   reco::ShallowClonePtrCandidate hadp( hadp_, hadp_->charge(), hadp_->p4(), hadp_->vertex() );
00236   reco::ShallowClonePtrCandidate hadq( hadq_, hadq_->charge(), hadq_->p4(), hadq_->vertex() );
00237   reco::ShallowClonePtrCandidate hadb( hadb_, hadb_->charge(), hadb_->p4(), hadb_->vertex() );
00238   reco::ShallowClonePtrCandidate lepb( lepb_, lepb_->charge(), lepb_->p4(), lepb_->vertex() );
00239 
00240   reco::ShallowClonePtrCandidate neutrino( neutrino_, neutrino_->charge(), neutrino_->p4(), neutrino_->vertex() );
00241 
00242 
00243 //   JetCandRef hadp( hadp_->p4(), hadp_->charge(), hadp_->vertex());  hadp.setRef( hadp_ );
00244 //   JetCandRef hadq( hadq_->p4(), hadq_->charge(), hadq_->vertex());  hadq.setRef( hadq_ );
00245 //   JetCandRef hadb( hadb_->p4(), hadb_->charge(), hadb_->vertex());  hadb.setRef( hadb_ );
00246 //   JetCandRef lepb( lepb_->p4(), lepb_->charge(), lepb_->vertex());  lepb.setRef( lepb_ );
00247 
00248 //   METCandRef neutrino  ( neutrino_->p4(), neutrino_->charge(), neutrino_->vertex() ); neutrino.setRef( neutrino_ );
00249 
00250 
00251 
00252   recHadW.addDaughter( hadp,    "hadp" );
00253   recHadW.addDaughter( hadq,    "hadq" );
00254 
00255   addFourMomenta.set( recHadW );
00256 
00257   recHadt.addDaughter( hadb,    "hadb" );
00258   recHadt.addDaughter( recHadW, "hadW" );
00259 
00260   addFourMomenta.set( recHadt );
00261   
00262   recLepW.addDaughter( neutrino,"neutrino" );
00263   if ( getDecay() == "electron" ) {
00264     reco::ShallowClonePtrCandidate electron ( electron_, electron_->charge(), electron_->p4(), electron_->vertex() );
00265 //     ElectronCandRef electron ( electron_->p4(), electron_->charge(), electron_->vertex() ); electron.setRef( electron_ );
00266     recLepW.addDaughter ( electron, "electron" );
00267   } else if ( getDecay() == "muon" ) {
00268     reco::ShallowClonePtrCandidate muon ( muon_, muon_->charge(),  muon_->p4(), muon_->vertex() );
00269 //     MuonCandRef muon ( muon_->p4(), muon_->charge(), muon_->vertex() ); muon.setRef( muon_ );
00270     recLepW.addDaughter ( muon, "muon" );
00271   }
00272 
00273   addFourMomenta.set( recLepW );
00274 
00275   recLept.addDaughter( lepb,    "lepb" );
00276   recLept.addDaughter( recLepW,    "lepW" );
00277 
00278   addFourMomenta.set( recLept );
00279 
00280   recoHyp_.addDaughter( recHadt, "hadt" );
00281   recoHyp_.addDaughter( recLept, "lept" );
00282 
00283   addFourMomenta.set( recoHyp_ );
00284 
00285 
00286 //   // Setup transient references
00287 //   reco::CompositeCandidate fitHadt;
00288 //   reco::CompositeCandidate fitLept;
00289 //   reco::CompositeCandidate fitHadW;
00290 //   reco::CompositeCandidate fitLepW;
00291 
00292 //   // Get refs to leaf nodes
00293 //   pat::Particle afitHadp = getFitHadp();
00294 //   pat::Particle afitHadq = getFitHadq();
00295 //   pat::Particle afitHadb = getFitHadb();
00296 //   pat::Particle afitLepb = getFitLepb();
00297 //   reco::ShallowClonePtrCandidate fitHadp( hadp_, afitHadp.charge(), afitHadp.p4(), afitHadp.vertex());
00298 //   reco::ShallowClonePtrCandidate fitHadq( hadq_, afitHadq.charge(), afitHadq.p4(), afitHadq.vertex());
00299 //   reco::ShallowClonePtrCandidate fitHadb( hadb_, afitHadb.charge(), afitHadb.p4(), afitHadb.vertex());
00300 //   reco::ShallowClonePtrCandidate fitLepb( lepb_, afitLepb.charge(), afitLepb.p4(), afitLepb.vertex());
00301 
00302 //   reco::ShallowClonePtrCandidate fitNeutrino  ( neutrino_, fitLepn_.charge(),  fitLepn_.p4(),  fitLepn_.vertex() );
00303 
00304 //   fitHadW.addDaughter( fitHadp,    "hadp" );
00305 //   fitHadW.addDaughter( fitHadq,    "hadq" );
00306 //   fitHadt.addDaughter( fitHadb,    "hadb" );
00307 //   fitHadt.addDaughter( fitHadW,    "hadW" );
00308   
00309 //   fitLepW.addDaughter( fitNeutrino,"neutrino" );
00310 
00311 //   if ( getDecay() == "electron" ) {
00312 //     reco::ShallowClonePtrCandidate fitElectron ( electron_, electron_.charge(),  electron_.p4(), electron_.vertex() );
00313 //     fitLepW.addDaughter ( fitElectron, "electron" );
00314 //   } else if ( getDecay() == "muon" ) {
00315 //     reco::ShallowClonePtrCandidate fitMuon ( muon_, muon_.charge(),  muon_.p4(), muon_.vertex() );
00316 //     fitLepW.addDaughter ( fitMuon, "muon" );
00317 //   }
00318 //   fitLept.addDaughter( fitLepb,    "lepb" );
00319 //   fitLept.addDaughter( fitLepW,    "lepW" );
00320 
00321 //   fitHyp_.addDaughter( fitHadt,   "hadt" );
00322 //   fitHyp_.addDaughter( fitLept,   "lept" );
00323 
00324 
00325   
00326   
00327 }

Generated on Tue Jun 9 17:25:10 2009 for CMSSW by  doxygen 1.5.4