CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TtSemiLepSignalSelMVAComputer Class Reference

#include <TtSemiLepSignalSelMVAComputer.h>

Inheritance diagram for TtSemiLepSignalSelMVAComputer:
edm::stream::EDProducer<>

Public Member Functions

 TtSemiLepSignalSelMVAComputer (const edm::ParameterSet &)
 
 ~TtSemiLepSignalSelMVAComputer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

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

Private Attributes

edm::EDGetTokenT< edm::View< pat::Electron > > electronsToken_
 
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
 
edm::EDGetTokenT< edm::View< pat::MET > > METsToken_
 
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
 
PhysicsTools::MVAComputerCache mvaComputer
 
edm::ESGetToken< PhysicsTools::Calibration::MVAComputerContainer, TtSemiLepSignalSelMVARcdmvaToken_
 
edm::EDPutTokenT< double > putToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 21 of file TtSemiLepSignalSelMVAComputer.h.

Constructor & Destructor Documentation

◆ TtSemiLepSignalSelMVAComputer()

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

Definition at line 13 of file TtSemiLepSignalSelMVAComputer.cc.

14  : mvaToken_(esConsumes()),
15  muonsToken_(consumes<edm::View<pat::Muon> >(cfg.getParameter<edm::InputTag>("muons"))),
16  jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
17  METsToken_(consumes<edm::View<pat::MET> >(cfg.getParameter<edm::InputTag>("mets"))),
18  electronsToken_(consumes<edm::View<pat::Electron> >(cfg.getParameter<edm::InputTag>("elecs"))),
19  putToken_(produces("DiscSel")) {}
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::EDGetTokenT< edm::View< pat::Electron > > electronsToken_
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
edm::EDGetTokenT< edm::View< pat::MET > > METsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::ESGetToken< PhysicsTools::Calibration::MVAComputerContainer, TtSemiLepSignalSelMVARcd > mvaToken_

◆ ~TtSemiLepSignalSelMVAComputer()

TtSemiLepSignalSelMVAComputer::~TtSemiLepSignalSelMVAComputer ( )
override

Definition at line 21 of file TtSemiLepSignalSelMVAComputer.cc.

21 {}

Member Function Documentation

◆ DeltaPhi()

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

Definition at line 110 of file TtSemiLepSignalSelMVAComputer.cc.

References HLT_2023v12_cff::dPhi, and Pi.

Referenced by DeltaR().

110  {
111  double dPhi = fabs(v1.Phi() - v2.Phi());
112  if (dPhi > TMath::Pi())
113  dPhi = 2 * TMath::Pi() - dPhi;
114  return dPhi;
115 }
const double Pi

◆ DeltaR()

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

Definition at line 117 of file TtSemiLepSignalSelMVAComputer.cc.

References DeltaPhi(), HLT_2023v12_cff::dPhi, and HGC3DClusterGenMatchSelector_cfi::dR.

Referenced by produce().

117  {
118  double dPhi = DeltaPhi(v1, v2);
119  double dR = TMath::Sqrt((v1.Eta() - v2.Eta()) * (v1.Eta() - v2.Eta()) + dPhi * dPhi);
120  return dR;
121 }
double DeltaPhi(const math::XYZTLorentzVector &v1, const math::XYZTLorentzVector &v2)

◆ produce()

void TtSemiLepSignalSelMVAComputer::produce ( edm::Event evt,
const edm::EventSetup setup 
)
overrideprivate

Definition at line 23 of file TtSemiLepSignalSelMVAComputer.cc.

References DeltaR(), HLT_2023v12_cff::dRmin, pwdgSkimBPark_cfi::electrons, pat::Flags::Overlap::Electrons, electronsToken_, edm::Event::emplace(), evaluateTtSemiLepSignalSel(), edm::Event::getByToken(), edm::Ref< C, T, F >::isNull(), edm::HandleBase::isValid(), metsig::jet, PDWG_EXODelayedJetMET_cff::jets, jetsToken_, METsToken_, PDWG_BPHSkim_cff::muons, muonsToken_, mvaComputer, mvaToken_, B2GMonitoring_cff::nelectrons, l1ctJetFileWriter_cfi::nJets, B2GMonitoring_cff::nmuons, putToken_, corrVsCorr::selection, singleTopDQM_cfi::setup, pat::Flags::test(), and PhysicsTools::MVAComputerCache::update().

23  {
24  mvaComputer.update(&setup.getData(mvaToken_), "ttSemiLepSignalSelMVA");
25 
26  //make your preselection! This must!! be the same one as in TraintreeSaver.cc
28  evt.getByToken(METsToken_, MET_handle);
29  if (!MET_handle.isValid())
30  return;
31  const edm::View<pat::MET> MET = *MET_handle;
32 
34  evt.getByToken(jetsToken_, jet_handle);
35  if (!jet_handle.isValid())
36  return;
37  const std::vector<pat::Jet> jets = *jet_handle;
38  unsigned int nJets = 0;
39  std::vector<pat::Jet> seljets;
40  for (std::vector<pat::Jet>::const_iterator it = jets.begin(); it != jets.end(); it++) {
42  continue;
43  if (it->pt() > 30. && fabs(it->eta()) < 2.4) {
44  seljets.push_back(*it);
45  nJets++;
46  }
47  }
48 
50  evt.getByToken(muonsToken_, muon_handle);
51  if (!muon_handle.isValid())
52  return;
53  const edm::View<pat::Muon> muons = *muon_handle;
54  int nmuons = 0;
55  std::vector<pat::Muon> selMuons;
56  for (edm::View<pat::Muon>::const_iterator it = muons.begin(); it != muons.end(); it++) {
57  reco::TrackRef gltr = it->track(); // global track
58  reco::TrackRef trtr = it->innerTrack(); // tracker track
59  if (it->pt() > 30 && fabs(it->eta()) < 2.1 && (it->pt() / (it->pt() + it->trackIso() + it->caloIso())) > 0.95 &&
60  it->isGlobalMuon()) {
61  if (gltr.isNull())
62  continue; //temporary problems with dead trackrefs
63  if ((gltr->chi2() / gltr->ndof()) < 10 && trtr->numberOfValidHits() > 11) {
64  double dRmin = 9999.;
65  for (std::vector<pat::Jet>::const_iterator ajet = seljets.begin(); ajet != seljets.end(); ajet++) {
66  math::XYZTLorentzVector jet = ajet->p4();
67  math::XYZTLorentzVector muon = it->p4();
68  double tmpdR = DeltaR(muon, jet);
69  if (tmpdR < dRmin)
70  dRmin = tmpdR;
71  }
72  if (dRmin > 0.3) { //temporary problems with muon isolation
73  nmuons++;
74  selMuons.push_back(*it);
75  }
76  }
77  }
78  }
79 
80  edm::Handle<edm::View<pat::Electron> > electron_handle;
81  evt.getByToken(electronsToken_, electron_handle);
82  if (!electron_handle.isValid())
83  return;
84  const edm::View<pat::Electron> electrons = *electron_handle;
85  int nelectrons = 0;
86  for (edm::View<pat::Electron>::const_iterator it = electrons.begin(); it != electrons.end(); it++) {
87  if (it->pt() > 30 && fabs(it->eta()) < 2.4 && (it->pt() / (it->pt() + it->trackIso() + it->caloIso())) > 0.95 &&
88  it->isElectronIDAvailable("eidTight")) {
89  if (it->electronID("eidTight") == 1)
90  nelectrons++;
91  }
92  }
93 
94  double discrim;
95  // discriminator output for events which do not pass the preselection is set to -1
96  if (nmuons != 1 || nJets < 4 || nelectrons > 0)
97  discrim = -1.; //std::cout<<"nJets: "<<seljets.size()<<" numLeptons: "<<nleptons<<std::endl;}
98  else {
99  //check wheter a event was already selected (problem with duplicated events)
100  math::XYZTLorentzVector muon = selMuons.begin()->p4();
101 
103 
105  }
106 
107  evt.emplace(putToken_, discrim);
108 }
static bool test(uint32_t val, uint32_t mask)
Definition: Flags.h:28
edm::EDGetTokenT< edm::View< pat::Electron > > electronsToken_
selection
main part
Definition: corrVsCorr.py:100
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
PhysicsTools::MVAComputerCache mvaComputer
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
double evaluateTtSemiLepSignalSel(PhysicsTools::MVAComputerCache &mvaComputer, const TtSemiLepSignalSel &sigsel, float weight=1., const bool isSignal=false)
double DeltaR(const math::XYZTLorentzVector &v1, const math::XYZTLorentzVector &v2)
bool isNull() const
Checks for null.
Definition: Ref.h:235
edm::EDGetTokenT< edm::View< pat::MET > > METsToken_
bool update(const Calibration::MVAComputer *computer)
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
Definition: Event.h:434
bool isValid() const
Definition: HandleBase.h:70
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::ESGetToken< PhysicsTools::Calibration::MVAComputerContainer, TtSemiLepSignalSelMVARcd > mvaToken_

Member Data Documentation

◆ electronsToken_

edm::EDGetTokenT<edm::View<pat::Electron> > TtSemiLepSignalSelMVAComputer::electronsToken_
private

Definition at line 36 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ jetsToken_

edm::EDGetTokenT<std::vector<pat::Jet> > TtSemiLepSignalSelMVAComputer::jetsToken_
private

Definition at line 34 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ METsToken_

edm::EDGetTokenT<edm::View<pat::MET> > TtSemiLepSignalSelMVAComputer::METsToken_
private

Definition at line 35 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ muonsToken_

edm::EDGetTokenT<edm::View<pat::Muon> > TtSemiLepSignalSelMVAComputer::muonsToken_
private

Definition at line 33 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ mvaComputer

PhysicsTools::MVAComputerCache TtSemiLepSignalSelMVAComputer::mvaComputer
private

Definition at line 39 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ mvaToken_

Definition at line 32 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ putToken_

edm::EDPutTokenT<double> TtSemiLepSignalSelMVAComputer::putToken_
private

Definition at line 37 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().