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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TtSemiLepSignalSelMVAComputer (const edm::ParameterSet &)
 
 ~TtSemiLepSignalSelMVAComputer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

double DiscSel
 
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
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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  : muonsToken_(consumes<edm::View<pat::Muon> >(cfg.getParameter<edm::InputTag>("muons"))),
15  jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
16  METsToken_(consumes<edm::View<pat::MET> >(cfg.getParameter<edm::InputTag>("mets"))),
18  produces<double>("DiscSel");
19 }

◆ ~TtSemiLepSignalSelMVAComputer()

TtSemiLepSignalSelMVAComputer::~TtSemiLepSignalSelMVAComputer ( )
override

Definition at line 21 of file TtSemiLepSignalSelMVAComputer.cc.

21 {}

Member Function Documentation

◆ beginJob()

void TtSemiLepSignalSelMVAComputer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 123 of file TtSemiLepSignalSelMVAComputer.cc.

123 {}

◆ DeltaPhi()

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

Definition at line 127 of file TtSemiLepSignalSelMVAComputer.cc.

127  {
128  double dPhi = fabs(v1.Phi() - v2.Phi());
129  if (dPhi > TMath::Pi())
130  dPhi = 2 * TMath::Pi() - dPhi;
131  return dPhi;
132 }

References HLT_FULL_cff::dPhi, and Pi.

Referenced by DeltaR().

◆ DeltaR()

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

Definition at line 134 of file TtSemiLepSignalSelMVAComputer.cc.

134  {
135  double dPhi = DeltaPhi(v1, v2);
136  double dR = TMath::Sqrt((v1.Eta() - v2.Eta()) * (v1.Eta() - v2.Eta()) + dPhi * dPhi);
137  return dR;
138 }

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

Referenced by produce().

◆ endJob()

void TtSemiLepSignalSelMVAComputer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 125 of file TtSemiLepSignalSelMVAComputer.cc.

125 {}

◆ produce()

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

Implements edm::EDProducer.

Definition at line 23 of file TtSemiLepSignalSelMVAComputer.cc.

23  {
24  std::unique_ptr<double> pOutDisc(new double);
25 
26  mvaComputer.update<TtSemiLepSignalSelMVARcd>(setup, "ttSemiLepSignalSelMVA");
27 
28  // read name of the last processor in the MVA calibration
29  // (to be used as meta information)
31  setup.get<TtSemiLepSignalSelMVARcd>().get(calibContainer);
32  std::vector<PhysicsTools::Calibration::VarProcessor*> processors =
33  (calibContainer->find("ttSemiLepSignalSelMVA")).getProcessors();
34 
35  //make your preselection! This must!! be the same one as in TraintreeSaver.cc
37  evt.getByToken(METsToken_, MET_handle);
38  if (!MET_handle.isValid())
39  return;
40  const edm::View<pat::MET> MET = *MET_handle;
41 
43  evt.getByToken(jetsToken_, jet_handle);
44  if (!jet_handle.isValid())
45  return;
46  const std::vector<pat::Jet> jets = *jet_handle;
47  unsigned int nJets = 0;
48  std::vector<pat::Jet> seljets;
49  for (std::vector<pat::Jet>::const_iterator it = jets.begin(); it != jets.end(); it++) {
51  continue;
52  if (it->pt() > 30. && fabs(it->eta()) < 2.4) {
53  seljets.push_back(*it);
54  nJets++;
55  }
56  }
57 
59  evt.getByToken(muonsToken_, muon_handle);
60  if (!muon_handle.isValid())
61  return;
62  const edm::View<pat::Muon> muons = *muon_handle;
63  int nmuons = 0;
64  std::vector<pat::Muon> selMuons;
65  for (edm::View<pat::Muon>::const_iterator it = muons.begin(); it != muons.end(); it++) {
66  reco::TrackRef gltr = it->track(); // global track
67  reco::TrackRef trtr = it->innerTrack(); // tracker track
68  if (it->pt() > 30 && fabs(it->eta()) < 2.1 && (it->pt() / (it->pt() + it->trackIso() + it->caloIso())) > 0.95 &&
69  it->isGlobalMuon()) {
70  if (gltr.isNull())
71  continue; //temporary problems with dead trackrefs
72  if ((gltr->chi2() / gltr->ndof()) < 10 && trtr->numberOfValidHits() > 11) {
73  double dRmin = 9999.;
74  for (std::vector<pat::Jet>::const_iterator ajet = seljets.begin(); ajet != seljets.end(); ajet++) {
75  math::XYZTLorentzVector jet = ajet->p4();
76  math::XYZTLorentzVector muon = it->p4();
77  double tmpdR = DeltaR(muon, jet);
78  if (tmpdR < dRmin)
79  dRmin = tmpdR;
80  }
81  if (dRmin > 0.3) { //temporary problems with muon isolation
82  nmuons++;
83  selMuons.push_back(*it);
84  }
85  }
86  }
87  }
88 
89  edm::Handle<edm::View<pat::Electron> > electron_handle;
90  evt.getByToken(electronsToken_, electron_handle);
91  if (!electron_handle.isValid())
92  return;
93  const edm::View<pat::Electron> electrons = *electron_handle;
94  int nelectrons = 0;
95  for (edm::View<pat::Electron>::const_iterator it = electrons.begin(); it != electrons.end(); it++) {
96  if (it->pt() > 30 && fabs(it->eta()) < 2.4 && (it->pt() / (it->pt() + it->trackIso() + it->caloIso())) > 0.95 &&
97  it->isElectronIDAvailable("eidTight")) {
98  if (it->electronID("eidTight") == 1)
99  nelectrons++;
100  }
101  }
102 
103  double discrim;
104  // discriminator output for events which do not pass the preselection is set to -1
105  if (nmuons != 1 || nJets < 4 || nelectrons > 0)
106  discrim = -1.; //std::cout<<"nJets: "<<seljets.size()<<" numLeptons: "<<nleptons<<std::endl;}
107  else {
108  //check wheter a event was already selected (problem with duplicated events)
109  math::XYZTLorentzVector muon = selMuons.begin()->p4();
110 
112 
114  }
115 
116  *pOutDisc = discrim;
117 
118  evt.put(std::move(pOutDisc), "DiscSel");
119 
120  DiscSel = discrim;
121 }

References DeltaR(), DiscSel, pwdgSkimBPark_cfi::electrons, pat::Flags::Overlap::Electrons, electronsToken_, evaluateTtSemiLepSignalSel(), get, edm::Event::getByToken(), edm::Ref< C, T, F >::isNull(), edm::HandleBase::isValid(), metsig::jet, singleTopDQM_cfi::jets, jetsToken_, METsToken_, eostools::move(), PDWG_BPHSkim_cff::muons, muonsToken_, mvaComputer, B2GMonitoring_cff::nelectrons, B2GMonitoring_cff::nmuons, edm::Event::put(), corrVsCorr::selection, singleTopDQM_cfi::setup, pat::Flags::test(), and PhysicsTools::MVAComputerCache::update().

Member Data Documentation

◆ DiscSel

double TtSemiLepSignalSelMVAComputer::DiscSel
private

Definition at line 41 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ electronsToken_

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

Definition at line 37 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ jetsToken_

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

Definition at line 35 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ METsToken_

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

Definition at line 36 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ muonsToken_

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

Definition at line 34 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

◆ mvaComputer

PhysicsTools::MVAComputerCache TtSemiLepSignalSelMVAComputer::mvaComputer
private

Definition at line 39 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
B2GMonitoring_cff.nmuons
nmuons
Definition: B2GMonitoring_cff.py:147
muon
Definition: MuonCocktails.h:17
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
TtSemiLepSignalSelMVAComputer::DiscSel
double DiscSel
Definition: TtSemiLepSignalSelMVAComputer.h:41
TtSemiLepSignalSelMVAComputer::electronsToken_
edm::EDGetTokenT< edm::View< pat::Electron > > electronsToken_
Definition: TtSemiLepSignalSelMVAComputer.h:37
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
B2GMonitoring_cff.nelectrons
nelectrons
Definition: B2GMonitoring_cff.py:145
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13703
edm::Handle
Definition: AssociativeIterator.h:50
TtSemiLepSignalSelMVAComputer::muonsToken_
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
Definition: TtSemiLepSignalSelMVAComputer.h:34
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::Ref< TrackCollection >
TtSemiLepSignalSelMVARcd
Definition: TtSemiLepSignalSelMVAComputer.h:18
TtSemiLepSignalSelMVAComputer::mvaComputer
PhysicsTools::MVAComputerCache mvaComputer
Definition: TtSemiLepSignalSelMVAComputer.h:39
TtSemiLepSignalSelMVAComputer::DeltaR
double DeltaR(const math::XYZTLorentzVector &v1, const math::XYZTLorentzVector &v2)
Definition: TtSemiLepSignalSelMVAComputer.cc:134
pat::Flags::test
static bool test(uint32_t val, uint32_t mask)
Definition: Flags.h:28
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
edm::ESHandle
Definition: DTSurvey.h:22
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
edm::View
Definition: CaloClusterFwd.h:14
TtSemiLepSignalSelMVAComputer::METsToken_
edm::EDGetTokenT< edm::View< pat::MET > > METsToken_
Definition: TtSemiLepSignalSelMVAComputer.h:36
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
evaluateTtSemiLepSignalSel
double evaluateTtSemiLepSignalSel(PhysicsTools::MVAComputerCache &mvaComputer, const TtSemiLepSignalSel &sigsel, float weight=1., const bool isSignal=false)
Definition: TtSemiLepSignalSelEval.h:13
pat::Flags::Overlap::Electrons
Definition: Flags.h:57
get
#define get
looper.cfg
cfg
Definition: looper.py:297
eostools.move
def move(src, dest)
Definition: eostools.py:511
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
PhysicsTools::MVAComputerCache::update
bool update(const Calibration::MVAComputer *computer)
Definition: MVAComputerCache.cc:15
metsig::jet
Definition: SignAlgoResolutions.h:47
MET
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
TtSemiLepSignalSelMVAComputer::jetsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Definition: TtSemiLepSignalSelMVAComputer.h:35
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:155
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
TtSemiLepSignalSel
Definition: TtSemiLepSignalSel.h:11
edm::InputTag
Definition: InputTag.h:15
TtSemiLepSignalSelMVAComputer::DeltaPhi
double DeltaPhi(const math::XYZTLorentzVector &v1, const math::XYZTLorentzVector &v2)
Definition: TtSemiLepSignalSelMVAComputer.cc:127