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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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::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
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)
 
- 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 21 of file TtSemiLepSignalSelMVAComputer.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file TtSemiLepSignalSelMVAComputer.cc.

14  :
16  jetsToken_ (consumes< std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
19 {
20  produces< double >("DiscSel");
21 }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
edm::EDGetTokenT< edm::View< pat::MET > > METsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::EDGetTokenT< edm::View< pat::Electron > > electronsToken_
TtSemiLepSignalSelMVAComputer::~TtSemiLepSignalSelMVAComputer ( )

Definition at line 25 of file TtSemiLepSignalSelMVAComputer.cc.

26 {
27 }

Member Function Documentation

void TtSemiLepSignalSelMVAComputer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 126 of file TtSemiLepSignalSelMVAComputer.cc.

127 {
128 }
double TtSemiLepSignalSelMVAComputer::DeltaPhi ( const math::XYZTLorentzVector v1,
const math::XYZTLorentzVector v2 
)
private

Definition at line 135 of file TtSemiLepSignalSelMVAComputer.cc.

References Pi.

Referenced by DeltaR().

136 {
137  double dPhi = fabs(v1.Phi() - v2.Phi());
138  if (dPhi > TMath::Pi()) dPhi = 2*TMath::Pi() - dPhi;
139  return dPhi;
140 }
const double Pi
double TtSemiLepSignalSelMVAComputer::DeltaR ( const math::XYZTLorentzVector v1,
const math::XYZTLorentzVector v2 
)
private

Definition at line 142 of file TtSemiLepSignalSelMVAComputer.cc.

References DeltaPhi(), and PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR.

Referenced by produce().

143 {
144  double dPhi = DeltaPhi(v1,v2);
145  double dR = TMath::Sqrt((v1.Eta()-v2.Eta())*(v1.Eta()-v2.Eta())+dPhi*dPhi);
146  return dR;
147 }
double DeltaPhi(const math::XYZTLorentzVector &v1, const math::XYZTLorentzVector &v2)
void TtSemiLepSignalSelMVAComputer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 131 of file TtSemiLepSignalSelMVAComputer.cc.

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

Definition at line 30 of file TtSemiLepSignalSelMVAComputer.cc.

References edm::View< T >::begin(), DeltaR(), DiscSel, genericTrackCleaner_cfi::electrons, pat::Flags::Overlap::Electrons, electronsToken_, edm::View< T >::end(), evaluateTtSemiLepSignalSel(), edm::eventsetup::EventSetupRecord::get(), edm::Event::getByToken(), edm::Ref< C, T, F >::isNull(), edm::HandleBase::isValid(), metsig::jet, fwrapper::jets, jetsToken_, METsToken_, eostools::move(), electronCleaner_cfi::muons, muonsToken_, mvaComputer, edm::Event::put(), corrVsCorr::selection, GeneralSetup::setup(), pat::Flags::test(), and PhysicsTools::MVAComputerCache::update().

31 {
32  std::unique_ptr< double > pOutDisc (new double);
33 
34  mvaComputer.update<TtSemiLepSignalSelMVARcd>(setup, "ttSemiLepSignalSelMVA");
35 
36  // read name of the last processor in the MVA calibration
37  // (to be used as meta information)
39  setup.get<TtSemiLepSignalSelMVARcd>().get( calibContainer );
40  std::vector<PhysicsTools::Calibration::VarProcessor*> processors
41  = (calibContainer->find("ttSemiLepSignalSelMVA")).getProcessors();
42 
43  //make your preselection! This must!! be the same one as in TraintreeSaver.cc
45  evt.getByToken(METsToken_,MET_handle);
46  if(!MET_handle.isValid()) return;
47  const edm::View<pat::MET> MET = *MET_handle;
48 
50  evt.getByToken(jetsToken_, jet_handle);
51  if(!jet_handle.isValid()) return;
52  const std::vector<pat::Jet> jets = *jet_handle;
53  unsigned int nJets = 0;
54  std::vector<pat::Jet> seljets;
55  for(std::vector<pat::Jet>::const_iterator it = jets.begin(); it != jets.end(); it++) {
57  if(it->pt()>30. && fabs(it->eta())<2.4) {
58  seljets.push_back(*it);
59  nJets++;
60  }
61  }
62 
64  evt.getByToken(muonsToken_, muon_handle);
65  if(!muon_handle.isValid()) return;
66  const edm::View<pat::Muon> muons = *muon_handle;
67  int nmuons = 0;
68  std::vector<pat::Muon> selMuons;
69  for(edm::View<pat::Muon>::const_iterator it = muons.begin(); it!=muons.end(); it++) {
70  reco::TrackRef gltr = it->track(); // global track
71  reco::TrackRef trtr = it->innerTrack(); // tracker track
72  if(it->pt()>30 && fabs(it->eta())<2.1 && (it->pt()/(it->pt()+it->trackIso()+it->caloIso()))>0.95 && it->isGlobalMuon()){
73  if(gltr.isNull()) continue; //temporary problems with dead trackrefs
74  if((gltr->chi2()/gltr->ndof())<10 && trtr->numberOfValidHits()>11) {
75  double dRmin = 9999.;
76  for(std::vector<pat::Jet>::const_iterator ajet = seljets.begin(); ajet != seljets.end(); ajet++) {
77  math::XYZTLorentzVector jet = ajet->p4();
78  math::XYZTLorentzVector muon = it->p4();
79  double tmpdR = DeltaR(muon,jet);
80  if(tmpdR<dRmin) dRmin = tmpdR;
81  }
82  if(dRmin>0.3) { //temporary problems with muon isolation
83  nmuons++;
84  selMuons.push_back(*it);
85  }
86  }
87  }
88  }
89 
90  edm::Handle< edm::View<pat::Electron> > electron_handle;
91  evt.getByToken(electronsToken_, electron_handle);
92  if(!electron_handle.isValid()) 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 && it->isElectronIDAvailable("eidTight"))
97  {
98  if(it->electronID("eidTight")==1) nelectrons++;
99  }
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 ||
106  nJets < 4 ||
107  nelectrons > 0 ) discrim = -1.; //std::cout<<"nJets: "<<seljets.size()<<" numLeptons: "<<nleptons<<std::endl;}
108  else {
109  //check wheter a event was already selected (problem with duplicated events)
110  math::XYZTLorentzVector muon = selMuons.begin()->p4();
111 
112  TtSemiLepSignalSel selection(seljets,muon,MET);
113 
115  }
116 
117  *pOutDisc = discrim;
118 
119  evt.put(std::move(pOutDisc), "DiscSel");
120 
121  DiscSel = discrim;
122 
123 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
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:28
selection
main part
Definition: corrVsCorr.py:98
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
PhysicsTools::MVAComputerCache mvaComputer
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
const_iterator begin() const
vector< PseudoJet > jets
void get(HolderT &iHolder) const
double DeltaR(const math::XYZTLorentzVector &v1, const math::XYZTLorentzVector &v2)
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
bool isValid() const
Definition: HandleBase.h:74
bool isNull() const
Checks for null.
Definition: Ref.h:249
edm::EDGetTokenT< edm::View< pat::MET > > METsToken_
bool update(const Calibration::MVAComputer *computer)
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDGetTokenT< edm::View< pat::Electron > > electronsToken_
const_iterator end() const
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

double TtSemiLepSignalSelMVAComputer::DiscSel
private

Definition at line 44 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

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

Definition at line 40 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

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

Definition at line 38 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

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

Definition at line 39 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

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

Definition at line 37 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().

PhysicsTools::MVAComputerCache TtSemiLepSignalSelMVAComputer::mvaComputer
private

Definition at line 42 of file TtSemiLepSignalSelMVAComputer.h.

Referenced by produce().