CMS 3D CMS Logo

TtSemiLepSignalSelMVAComputer Class Reference

#include <TopQuarkAnalysis/TopEventSelection/plugins/TtSemiLepSignalSelMVAComputer.h>

Inheritance diagram for TtSemiLepSignalSelMVAComputer:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 TtSemiLepSignalSelMVAComputer (const edm::ParameterSet &)
 ~TtSemiLepSignalSelMVAComputer ()

Private Member Functions

virtual void beginJob (const edm::EventSetup &)
double DeltaPhi (math::XYZTLorentzVector v1, math::XYZTLorentzVector v2)
double DeltaR (math::XYZTLorentzVector v1, math::XYZTLorentzVector v2)
virtual void endJob ()
virtual void produce (edm::Event &evt, const edm::EventSetup &setup)

Private Attributes

double DiscSel
edm::InputTag electrons_
edm::InputTag jets_
edm::InputTag METs_
edm::InputTag muons_
PhysicsTools::MVAComputerCache mvaComputer


Detailed Description

Definition at line 25 of file TtSemiLepSignalSelMVAComputer.h.


Constructor & Destructor Documentation

TtSemiLepSignalSelMVAComputer::TtSemiLepSignalSelMVAComputer ( const edm::ParameterSet cfg  )  [explicit]

Definition at line 18 of file TtSemiLepSignalSelMVAComputer.cc.

00018                                                                                       :
00019   muons_ (cfg.getParameter<edm::InputTag>("muons")),
00020   jets_    (cfg.getParameter<edm::InputTag>("jets")),
00021   METs_    (cfg.getParameter<edm::InputTag>("METs")),
00022   electrons_ (cfg.getParameter<edm::InputTag>("electrons"))
00023 {
00024   produces< double        >("DiscSel");
00025 }

TtSemiLepSignalSelMVAComputer::~TtSemiLepSignalSelMVAComputer (  ) 

Definition at line 29 of file TtSemiLepSignalSelMVAComputer.cc.

00030 {
00031 }


Member Function Documentation

void TtSemiLepSignalSelMVAComputer::beginJob ( const edm::EventSetup  )  [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 130 of file TtSemiLepSignalSelMVAComputer.cc.

00131 {
00132 }

double TtSemiLepSignalSelMVAComputer::DeltaPhi ( math::XYZTLorentzVector  v1,
math::XYZTLorentzVector  v2 
) [private]

Definition at line 139 of file TtSemiLepSignalSelMVAComputer.cc.

References dPhi(), and Pi.

Referenced by DeltaR().

00140 {
00141   double dPhi = fabs(v1.Phi() - v2.Phi());
00142   if (dPhi > TMath::Pi()) dPhi =  2*TMath::Pi() - dPhi;
00143   return dPhi;
00144 }

double TtSemiLepSignalSelMVAComputer::DeltaR ( math::XYZTLorentzVector  v1,
math::XYZTLorentzVector  v2 
) [private]

Definition at line 146 of file TtSemiLepSignalSelMVAComputer.cc.

References DeltaPhi(), and dPhi().

Referenced by produce().

00147 {
00148   double dPhi = DeltaPhi(v1,v2);
00149   double dR = TMath::Sqrt((v1.Eta()-v2.Eta())*(v1.Eta()-v2.Eta())+dPhi*dPhi);
00150   return dR;
00151 }

void TtSemiLepSignalSelMVAComputer::endJob ( void   )  [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 135 of file TtSemiLepSignalSelMVAComputer.cc.

00136 {
00137 }

void TtSemiLepSignalSelMVAComputer::produce ( edm::Event evt,
const edm::EventSetup setup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 34 of file TtSemiLepSignalSelMVAComputer.cc.

References edm::View< T >::begin(), DeltaR(), DiscSel, pat::Flags::Overlap::Electrons, electrons_, edm::View< T >::end(), evaluateTtSemiLepSignalSel(), edm::Event::getByLabel(), edm::Ref< C, T, F >::isNull(), edm::Handle< T >::isValid(), it, metsig::jet, pfTauBenchmarkGeneric_cfi::jets, jets_, METs_, metsig::muon, muons_cfi::muons, muons_, mvaComputer, edm::Event::put(), pat::Flags::test(), and PhysicsTools::MVAComputerCache::update().

00035 {
00036   std::auto_ptr< double >        pOutDisc (new double);
00037  
00038   mvaComputer.update<TtSemiLepSignalSelMVARcd>(setup, "ttSemiLepSignalSelMVA");
00039 
00040   // read name of the last processor in the MVA calibration
00041   // (to be used as meta information)
00042   edm::ESHandle<PhysicsTools::Calibration::MVAComputerContainer> calibContainer;
00043   setup.get<TtSemiLepSignalSelMVARcd>().get( calibContainer );
00044   std::vector<PhysicsTools::Calibration::VarProcessor*> processors
00045     = (calibContainer->find("ttSemiLepSignalSelMVA")).getProcessors();
00046 
00047   //make your preselection! This must!! be the same one as in TraintreeSaver.cc  
00048   edm::Handle<edm::View<pat::MET> > MET_handle;
00049   evt.getByLabel(METs_,MET_handle);
00050   if(!MET_handle.isValid()) return;
00051   const edm::View<pat::MET> MET = *MET_handle;
00052 
00053   edm::Handle< std::vector<pat::Jet> > jet_handle;
00054   evt.getByLabel(jets_, jet_handle);
00055   if(!jet_handle.isValid()) return;
00056   const std::vector<pat::Jet> jets = *jet_handle;
00057   unsigned int nJets = 0;
00058   std::vector<pat::Jet> seljets;
00059   for(std::vector<pat::Jet>::const_iterator it = jets.begin(); it != jets.end(); it++) {
00060     if(!(pat::Flags::test(*it, pat::Flags::Overlap::Electrons))) continue;
00061     if(it->pt()>30. && fabs(it->eta())<2.4) {
00062       seljets.push_back(*it);
00063       nJets++;
00064     }
00065   }
00066    
00067   edm::Handle< edm::View<pat::Muon> > muon_handle; 
00068   evt.getByLabel(muons_, muon_handle);
00069   if(!muon_handle.isValid()) return;
00070   const edm::View<pat::Muon> muons = *muon_handle;
00071   int nmuons = 0;
00072   std::vector<pat::Muon> selMuons;
00073   for(edm::View<pat::Muon>::const_iterator it = muons.begin(); it!=muons.end(); it++) {
00074     reco::TrackRef gltr = it->track(); // global track
00075     reco::TrackRef trtr = it->innerTrack(); // tracker track
00076     if(it->pt()>30 && fabs(it->eta())<2.1 && (it->pt()/(it->pt()+it->trackIso()+it->caloIso()))>0.95 && it->isGlobalMuon()){
00077       if(gltr.isNull()) continue;  //temporary problems with dead trackrefs
00078       if((gltr->chi2()/gltr->ndof())<10 && trtr->numberOfValidHits()>11) {
00079         double dRmin = 9999.;
00080         for(std::vector<pat::Jet>::const_iterator ajet = seljets.begin(); ajet != seljets.end(); ajet++) {
00081           math::XYZTLorentzVector jet = ajet->p4();
00082           math::XYZTLorentzVector muon = it->p4();
00083           double tmpdR = DeltaR(muon,jet);
00084           if(tmpdR<dRmin) dRmin = tmpdR;
00085         }
00086         if(dRmin>0.3) {   //temporary problems with muon isolation
00087           nmuons++;
00088           selMuons.push_back(*it);
00089         }
00090       }
00091     }
00092   }
00093   
00094   edm::Handle< edm::View<pat::Electron> > electron_handle; 
00095   evt.getByLabel(electrons_, electron_handle);
00096   if(!electron_handle.isValid()) return;
00097   const edm::View<pat::Electron> electrons = *electron_handle;
00098   int nelectrons = 0;
00099   for(edm::View<pat::Electron>::const_iterator it = electrons.begin(); it!=electrons.end(); it++) {
00100     if(it->pt()>30 && fabs(it->eta())<2.4 && (it->pt()/(it->pt()+it->trackIso()+it->caloIso()))>0.95 && it->isElectronIDAvailable("eidTight"))
00101     { 
00102       if(it->electronID("eidTight")==1) nelectrons++;
00103     }
00104   }
00105  
00106   
00107   double discrim;
00108   // discriminator output for events which do not pass the preselection is set to -1
00109   if( nmuons!=1                    ||
00110       nJets < 4                    ||
00111       nelectrons > 0 ) discrim = -1.; //std::cout<<"nJets: "<<seljets.size()<<" numLeptons: "<<nleptons<<std::endl;}
00112   else {
00113     //check wheter a event was already selected (problem with duplicated events)
00114     math::XYZTLorentzVector muon = selMuons.begin()->p4();
00115 
00116     TtSemiLepSignalSel selection(seljets,muon,MET);
00117 
00118     discrim = evaluateTtSemiLepSignalSel(mvaComputer, selection);
00119   }
00120 
00121   *pOutDisc = discrim;
00122   
00123   evt.put(pOutDisc, "DiscSel");
00124   
00125   DiscSel = discrim;
00126 
00127 }


Member Data Documentation

double TtSemiLepSignalSelMVAComputer::DiscSel [private]

Definition at line 48 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

edm::InputTag TtSemiLepSignalSelMVAComputer::electrons_ [private]

Definition at line 44 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

edm::InputTag TtSemiLepSignalSelMVAComputer::jets_ [private]

Definition at line 42 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

edm::InputTag TtSemiLepSignalSelMVAComputer::METs_ [private]

Definition at line 43 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

edm::InputTag TtSemiLepSignalSelMVAComputer::muons_ [private]

Definition at line 41 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

PhysicsTools::MVAComputerCache TtSemiLepSignalSelMVAComputer::mvaComputer [private]

Definition at line 46 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:34:46 2009 for CMSSW by  doxygen 1.5.4