CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
TtSemiLepSignalSelMVAComputer Class Reference

#include <TtSemiLepSignalSelMVAComputer.h>

Inheritance diagram for TtSemiLepSignalSelMVAComputer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TtSemiLepSignalSelMVAComputer (const edm::ParameterSet &)
 
 ~TtSemiLepSignalSelMVAComputer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
double DeltaPhi (const math::XYZTLorentzVector &v1, const math::XYZTLorentzVector &v2)
 
double DeltaR (const math::XYZTLorentzVector &v1, const 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
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 17 of file TtSemiLepSignalSelMVAComputer.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file TtSemiLepSignalSelMVAComputer.cc.

18  :
19  muons_ (cfg.getParameter<edm::InputTag>("muons")),
20  jets_ (cfg.getParameter<edm::InputTag>("jets")),
21  METs_ (cfg.getParameter<edm::InputTag>("mets")),
22  electrons_ (cfg.getParameter<edm::InputTag>("elecs"))
23 {
24  produces< double >("DiscSel");
25 }
T getParameter(std::string const &) const
TtSemiLepSignalSelMVAComputer::~TtSemiLepSignalSelMVAComputer ( )

Definition at line 29 of file TtSemiLepSignalSelMVAComputer.cc.

30 {
31 }

Member Function Documentation

void TtSemiLepSignalSelMVAComputer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 130 of file TtSemiLepSignalSelMVAComputer.cc.

131 {
132 }
double TtSemiLepSignalSelMVAComputer::DeltaPhi ( const math::XYZTLorentzVector v1,
const math::XYZTLorentzVector v2 
)
private

Definition at line 139 of file TtSemiLepSignalSelMVAComputer.cc.

References dPhi(), and Pi.

Referenced by DeltaR().

140 {
141  double dPhi = fabs(v1.Phi() - v2.Phi());
142  if (dPhi > TMath::Pi()) dPhi = 2*TMath::Pi() - dPhi;
143  return dPhi;
144 }
const double Pi
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
double TtSemiLepSignalSelMVAComputer::DeltaR ( const math::XYZTLorentzVector v1,
const math::XYZTLorentzVector v2 
)
private

Definition at line 146 of file TtSemiLepSignalSelMVAComputer.cc.

References DeltaPhi(), dPhi(), and PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR.

Referenced by produce().

147 {
148  double dPhi = DeltaPhi(v1,v2);
149  double dR = TMath::Sqrt((v1.Eta()-v2.Eta())*(v1.Eta()-v2.Eta())+dPhi*dPhi);
150  return dR;
151 }
double DeltaPhi(const math::XYZTLorentzVector &v1, const math::XYZTLorentzVector &v2)
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
void TtSemiLepSignalSelMVAComputer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 135 of file TtSemiLepSignalSelMVAComputer.cc.

136 {
137 }
void TtSemiLepSignalSelMVAComputer::produce ( edm::Event evt,
const edm::EventSetup setup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 34 of file TtSemiLepSignalSelMVAComputer.cc.

References edm::View< T >::begin(), DeltaR(), DiscSel, pat::Flags::Overlap::Electrons, HI_PhotonSkim_cff::electrons, electrons_, edm::View< T >::end(), evaluateTtSemiLepSignalSel(), edm::Event::getByLabel(), edm::Ref< C, T, F >::isNull(), edm::HandleBase::isValid(), metsig::jet, fwrapper::jets, jets_, METs_, metsig::muon, patZpeak::muons, muons_, mvaComputer, edm::Event::put(), corrVsCorr::selection, HcalObjRepresent::setup(), pat::Flags::test(), and PhysicsTools::MVAComputerCache::update().

35 {
36  std::auto_ptr< double > pOutDisc (new double);
37 
38  mvaComputer.update<TtSemiLepSignalSelMVARcd>(setup, "ttSemiLepSignalSelMVA");
39 
40  // read name of the last processor in the MVA calibration
41  // (to be used as meta information)
43  setup.get<TtSemiLepSignalSelMVARcd>().get( calibContainer );
44  std::vector<PhysicsTools::Calibration::VarProcessor*> processors
45  = (calibContainer->find("ttSemiLepSignalSelMVA")).getProcessors();
46 
47  //make your preselection! This must!! be the same one as in TraintreeSaver.cc
49  evt.getByLabel(METs_,MET_handle);
50  if(!MET_handle.isValid()) return;
51  const edm::View<pat::MET> MET = *MET_handle;
52 
54  evt.getByLabel(jets_, jet_handle);
55  if(!jet_handle.isValid()) return;
56  const std::vector<pat::Jet> jets = *jet_handle;
57  unsigned int nJets = 0;
58  std::vector<pat::Jet> seljets;
59  for(std::vector<pat::Jet>::const_iterator it = jets.begin(); it != jets.end(); it++) {
61  if(it->pt()>30. && fabs(it->eta())<2.4) {
62  seljets.push_back(*it);
63  nJets++;
64  }
65  }
66 
67  edm::Handle< edm::View<pat::Muon> > muon_handle;
68  evt.getByLabel(muons_, muon_handle);
69  if(!muon_handle.isValid()) return;
70  const edm::View<pat::Muon> muons = *muon_handle;
71  int nmuons = 0;
72  std::vector<pat::Muon> selMuons;
73  for(edm::View<pat::Muon>::const_iterator it = muons.begin(); it!=muons.end(); it++) {
74  reco::TrackRef gltr = it->track(); // global track
75  reco::TrackRef trtr = it->innerTrack(); // tracker track
76  if(it->pt()>30 && fabs(it->eta())<2.1 && (it->pt()/(it->pt()+it->trackIso()+it->caloIso()))>0.95 && it->isGlobalMuon()){
77  if(gltr.isNull()) continue; //temporary problems with dead trackrefs
78  if((gltr->chi2()/gltr->ndof())<10 && trtr->numberOfValidHits()>11) {
79  double dRmin = 9999.;
80  for(std::vector<pat::Jet>::const_iterator ajet = seljets.begin(); ajet != seljets.end(); ajet++) {
81  math::XYZTLorentzVector jet = ajet->p4();
82  math::XYZTLorentzVector muon = it->p4();
83  double tmpdR = DeltaR(muon,jet);
84  if(tmpdR<dRmin) dRmin = tmpdR;
85  }
86  if(dRmin>0.3) { //temporary problems with muon isolation
87  nmuons++;
88  selMuons.push_back(*it);
89  }
90  }
91  }
92  }
93 
94  edm::Handle< edm::View<pat::Electron> > electron_handle;
95  evt.getByLabel(electrons_, electron_handle);
96  if(!electron_handle.isValid()) return;
97  const edm::View<pat::Electron> electrons = *electron_handle;
98  int nelectrons = 0;
99  for(edm::View<pat::Electron>::const_iterator it = electrons.begin(); it!=electrons.end(); it++) {
100  if(it->pt()>30 && fabs(it->eta())<2.4 && (it->pt()/(it->pt()+it->trackIso()+it->caloIso()))>0.95 && it->isElectronIDAvailable("eidTight"))
101  {
102  if(it->electronID("eidTight")==1) nelectrons++;
103  }
104  }
105 
106 
107  double discrim;
108  // discriminator output for events which do not pass the preselection is set to -1
109  if( nmuons!=1 ||
110  nJets < 4 ||
111  nelectrons > 0 ) discrim = -1.; //std::cout<<"nJets: "<<seljets.size()<<" numLeptons: "<<nleptons<<std::endl;}
112  else {
113  //check wheter a event was already selected (problem with duplicated events)
114  math::XYZTLorentzVector muon = selMuons.begin()->p4();
115 
116  TtSemiLepSignalSel selection(seljets,muon,MET);
117 
119  }
120 
121  *pOutDisc = discrim;
122 
123  evt.put(pOutDisc, "DiscSel");
124 
125  DiscSel = discrim;
126 
127 }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
double evaluateTtSemiLepSignalSel(PhysicsTools::MVAComputerCache &mvaComputer, const TtSemiLepSignalSel &sigsel, float weight=1., const bool training=false, const bool isSignal=false)
static bool test(uint32_t val, uint32_t mask)
Definition: Flags.h:30
selection
main part
Definition: corrVsCorr.py:98
PhysicsTools::MVAComputerCache mvaComputer
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
bool isNull() const
Checks for null.
Definition: Ref.h:247
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
vector< PseudoJet > jets
double DeltaR(const math::XYZTLorentzVector &v1, const math::XYZTLorentzVector &v2)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
bool update(const Calibration::MVAComputer *computer)
tuple muons
Definition: patZpeak.py:38
const_iterator begin() const
const_iterator end() const
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")

Member Data Documentation

double TtSemiLepSignalSelMVAComputer::DiscSel
private

Definition at line 40 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

edm::InputTag TtSemiLepSignalSelMVAComputer::electrons_
private

Definition at line 36 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

edm::InputTag TtSemiLepSignalSelMVAComputer::jets_
private

Definition at line 34 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

edm::InputTag TtSemiLepSignalSelMVAComputer::METs_
private

Definition at line 35 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

edm::InputTag TtSemiLepSignalSelMVAComputer::muons_
private

Definition at line 33 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

PhysicsTools::MVAComputerCache TtSemiLepSignalSelMVAComputer::mvaComputer
private

Definition at line 38 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().