CMS 3D CMS Logo

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

#include <SoftPFElectronTagInfoProducer.h>

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

Public Member Functions

 SoftPFElectronTagInfoProducer (const edm::ParameterSet &conf)
 
 ~SoftPFElectronTagInfoProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

float boostedPPar (const math::XYZVector &, const math::XYZVector &)
 
bool isElecClean (edm::Event &, const reco::GsfElectron *)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

float DeltaRElectronJet
 
bool goodvertex
 
float MaxSip3Dsig
 
edm::EDGetTokenT< reco::ConversionCollectiontoken_allConversions
 
edm::EDGetTokenT< reco::BeamSpottoken_BeamSpot
 
edm::EDGetTokenT< edm::View< reco::GsfElectron > > token_elec
 
edm::EDGetTokenT< edm::View< reco::Jet > > token_jets
 
edm::EDGetTokenT< reco::VertexCollectiontoken_primaryVertex
 
const TransientTrackBuildertransientTrackBuilder
 
const reco::Vertexvertex
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 30 of file SoftPFElectronTagInfoProducer.h.

Constructor & Destructor Documentation

SoftPFElectronTagInfoProducer::SoftPFElectronTagInfoProducer ( const edm::ParameterSet conf)

Definition at line 29 of file SoftPFElectronTagInfoProducer.cc.

References DeltaRElectronJet, edm::ParameterSet::getParameter(), MaxSip3Dsig, token_allConversions, token_BeamSpot, token_elec, token_jets, and token_primaryVertex.

30 {
31  token_jets = consumes<edm::View<reco::Jet> >(conf.getParameter<edm::InputTag>("jets"));
32  token_elec = consumes<edm::View<reco::GsfElectron> >(conf.getParameter<edm::InputTag>("electrons"));
33  token_primaryVertex = consumes<reco::VertexCollection>(conf.getParameter<edm::InputTag>("primaryVertex"));
34  token_BeamSpot = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
35  token_allConversions= consumes<reco::ConversionCollection>(edm::InputTag("allConversions"));
36  DeltaRElectronJet = conf.getParameter<double>("DeltaRElectronJet");
37  MaxSip3Dsig = conf.getParameter<double>("MaxSip3Dsig");
38  produces<reco::CandSoftLeptonTagInfoCollection>();
39 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::ConversionCollection > token_allConversions
edm::EDGetTokenT< edm::View< reco::GsfElectron > > token_elec
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot
edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
edm::EDGetTokenT< edm::View< reco::Jet > > token_jets
SoftPFElectronTagInfoProducer::~SoftPFElectronTagInfoProducer ( )
override

Definition at line 41 of file SoftPFElectronTagInfoProducer.cc.

42 {
43 
44 }

Member Function Documentation

float SoftPFElectronTagInfoProducer::boostedPPar ( const math::XYZVector vector,
const math::XYZVector axis 
)
private

Definition at line 139 of file SoftPFElectronTagInfoProducer.cc.

References metsig::jet.

Referenced by produce().

139  {
140  static const double lepton_mass = 0.00;
141  static const double jet_mass = 5.279;
142  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > lepton(vector.Dot(axis) / axis.r(), ROOT::Math::VectorUtil::Perp(vector, axis), 0., lepton_mass);
143  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > jet( axis.r(), 0., 0., jet_mass );
144  ROOT::Math::BoostX boost( -jet.Beta() );
145  return boost(lepton).x();
146 }
Definition: CLHEP.h:16
bool SoftPFElectronTagInfoProducer::isElecClean ( edm::Event iEvent,
const reco::GsfElectron candidate 
)
private

Definition at line 125 of file SoftPFElectronTagInfoProducer.cc.

References edm::Ref< C, T, F >::get(), reco::HitPattern::getHitPattern(), and reco::GsfElectron::gsfTrack().

Referenced by produce().

126 {
127  using namespace reco;
128  const HitPattern &hitPattern = candidate->gsfTrack().get()->hitPattern();
129  uint32_t hit = hitPattern.getHitPattern(HitPattern::TRACK_HITS, 0);
130  bool hitCondition = !(HitPattern::validHitFilter(hit)
131  && ((HitPattern::pixelBarrelHitFilter(hit)
132  && HitPattern::getLayer(hit) < 3)
133  || HitPattern::pixelEndcapHitFilter(hit)));
134  if(hitCondition) return false;
135 
136  return true;
137 }
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
fixed size matrix
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:553
void SoftPFElectronTagInfoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 46 of file SoftPFElectronTagInfoProducer.cc.

References funct::abs(), boostedPPar(), TransientTrackBuilder::build(), reco::SoftLeptonProperties::charge, reco::LeafCandidate::charge(), reco::deltaR(), reco::SoftLeptonProperties::deltaR, reco::deltaR2(), DeltaRElectronJet, dot(), reco::SoftLeptonProperties::elec_mva, reco::SoftLeptonProperties::etaRel, edm::EventSetup::get(), edm::Ref< C, T, F >::get(), edm::Event::getByToken(), goodvertex, reco::GsfElectron::gsfTrack(), ConversionTools::hasMatchedConversion(), mps_fire::i, reco::TemplatedSoftLeptonTagInfo< REF >::insert(), electrons_cff::ip3d, isElecClean(), edm::HandleBase::isValid(), cmsBatch::log, mag(), MaxSip3Dsig, reco::LeafCandidate::momentum(), eostools::move(), reco::GsfElectron::mva_e_pi(), Vispa.Plugins.EdmBrowser.EdmDataAccessor::ne(), reco::SoftLeptonProperties::p0Par, reco::LeafCandidate::p4(), reco::GsfElectron::p4(), pat::Electron::passConversionVeto(), reco::BeamSpot::position(), edm::Handle< T >::product(), reco::LeafCandidate::pt(), reco::SoftLeptonProperties::ptRel, edm::Event::put(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), dttmaxenums::R, reco::SoftLeptonProperties::ratio, reco::SoftLeptonProperties::ratioRel, reco::JetTagInfo::setJetRef(), IPTools::signedImpactParameter3D(), IPTools::signedTransverseImpactParameter(), Measurement1D::significance(), reco::SoftLeptonProperties::sip2d, reco::SoftLeptonProperties::sip2dsig, reco::SoftLeptonProperties::sip3d, reco::SoftLeptonProperties::sip3dsig, token_allConversions, token_BeamSpot, token_elec, token_jets, token_primaryVertex, transientTrackBuilder, Measurement1D::value(), and vertex.

47 {
48  auto theElecTagInfo = std::make_unique<reco::CandSoftLeptonTagInfoCollection>();
50  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
51  transientTrackBuilder=builder.product();
52 
54  iEvent.getByToken(token_primaryVertex, PVCollection);
55  if(!PVCollection.isValid()) return;
56  if(!PVCollection->empty()){
57  goodvertex = true;
58  vertex=&PVCollection->front();
59  }else goodvertex = false;
61  iEvent.getByToken(token_allConversions, hConversions);
62 
63  edm::Handle<edm::View<reco::Jet> > theJetCollection;
64  iEvent.getByToken(token_jets, theJetCollection);
65 
66  edm::Handle<edm::View<reco::GsfElectron > > theGEDGsfElectronCollection;
67  iEvent.getByToken(token_elec, theGEDGsfElectronCollection);
68 
70  iEvent.getByToken(token_BeamSpot, bsHandle);
71  const reco::BeamSpot &beamspot = *bsHandle.product();
72 
73  for (unsigned int i = 0; i < theJetCollection->size(); i++){
74  edm::RefToBase<reco::Jet> jetRef = theJetCollection->refAt(i);
76  tagInfo.setJetRef(jetRef);
77  std::vector<const reco::GsfElectron *> Elec;
78  for(unsigned int ie=0, ne=theGEDGsfElectronCollection->size(); ie<ne; ++ie){
79  //Get the edm::Ptr and the GsfElectron
80  edm::Ptr<reco::Candidate> lepPtr=theGEDGsfElectronCollection->ptrAt(ie);
81  const reco::GsfElectron* recoelectron=theGEDGsfElectronCollection->refAt(ie).get();
82  const pat::Electron* patelec=dynamic_cast<const pat::Electron*>(recoelectron);
83  if(patelec){
84  if(!patelec->passConversionVeto()) continue;
85  }
86  else{
87  if(ConversionTools::hasMatchedConversion(*(recoelectron),*hConversions,beamspot.position())) continue;
88  }
89  //Make sure that the electron is inside the jet
90  if(reco::deltaR2((*recoelectron),(*jetRef))>DeltaRElectronJet*DeltaRElectronJet) continue;
91  // Need a gsfTrack
92  if(recoelectron->gsfTrack().get()==nullptr) continue;
93  reco::SoftLeptonProperties properties;
94  // reject if it has issues with the track
95  if(!isElecClean(iEvent,recoelectron) ) continue;
96  //Compute the TagInfos members
97  math::XYZVector pel=recoelectron->p4().Vect();
98  math::XYZVector pjet=jetRef->p4().Vect();
99  reco::TransientTrack transientTrack=transientTrackBuilder->build(recoelectron->gsfTrack());
100  Measurement1D ip2d = IPTools::signedTransverseImpactParameter(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second;
101  Measurement1D ip3d = IPTools::signedImpactParameter3D(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second;
102  properties.sip2dsig = ip2d.significance();
103  properties.sip3dsig = ip3d.significance();
104  properties.sip2d = ip2d.value();
105  properties.sip3d = ip3d.value();
106  properties.deltaR = reco::deltaR((*jetRef), (*recoelectron));
107  properties.ptRel = ( (pjet-pel).Cross(pel) ).R() / pjet.R();
108  float mag = pel.R()*pjet.R();
109  float dot = recoelectron->p4().Dot(jetRef->p4());
110  properties.etaRel = -log((mag - dot)/(mag + dot)) / 2.;
111  properties.ratio = recoelectron->pt() / jetRef->pt();
112  properties.ratioRel = recoelectron->p4().Dot(jetRef->p4()) / pjet.Mag2();
113  properties.p0Par = boostedPPar(recoelectron->momentum(), jetRef->momentum());
114  properties.elec_mva = recoelectron->mva_e_pi();
115  properties.charge = recoelectron->charge();
116  if(std::abs(properties.sip3dsig)>MaxSip3Dsig) continue;
117  // Fill the TagInfos
118  tagInfo.insert(lepPtr, properties );
119  }
120  theElecTagInfo->push_back(tagInfo);
121  }
122  iEvent.put(std::move(theElecTagInfo));
123 }
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
float boostedPPar(const math::XYZVector &, const math::XYZVector &)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
edm::EDGetTokenT< reco::ConversionCollection > token_allConversions
edm::EDGetTokenT< edm::View< reco::GsfElectron > > token_elec
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:228
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
double px() const final
x coordinate of momentum vector
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot
reco::TransientTrack build(const reco::Track *p) const
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
double pt() const final
transverse momentum
int charge() const final
electric charge
Definition: LeafCandidate.h:91
void setJetRef(const edm::Ref< T > &jetRef)
Definition: JetTagInfo.h:25
Vector momentum() const final
spatial momentum vector
double pz() const final
z coordinate of momentum vector
static bool hasMatchedConversion(const reco::GsfElectron &ele, const reco::ConversionCollection &convCol, const math::XYZPoint &beamspot, bool allowCkfMatch=true, float lxyMin=2.0, float probMin=1e-6, unsigned int nHitsBeforeVtxMax=0)
bool isElecClean(edm::Event &, const reco::GsfElectron *)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
bool isValid() const
Definition: HandleBase.h:74
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
void insert(const REF &lepton, const SoftLeptonProperties &properties)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
double significance() const
Definition: Measurement1D.h:29
T const * product() const
Definition: Handle.h:74
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
Analysis-level electron class.
Definition: Electron.h:52
double py() const final
y coordinate of momentum vector
double value() const
Definition: Measurement1D.h:25
bool passConversionVeto() const
vertex fit combined with missing number of hits method
Definition: Electron.h:261
float mva_e_pi() const
Definition: GsfElectron.h:702
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
T get() const
Definition: EventSetup.h:71
const Point & position() const
position
Definition: BeamSpot.h:62
edm::EDGetTokenT< edm::View< reco::Jet > > token_jets
def move(src, dest)
Definition: eostools.py:511
const TransientTrackBuilder * transientTrackBuilder
Global3DVector GlobalVector
Definition: GlobalVector.h:10

Member Data Documentation

float SoftPFElectronTagInfoProducer::DeltaRElectronJet
private

Definition at line 50 of file SoftPFElectronTagInfoProducer.h.

Referenced by produce(), and SoftPFElectronTagInfoProducer().

bool SoftPFElectronTagInfoProducer::goodvertex
private

Definition at line 51 of file SoftPFElectronTagInfoProducer.h.

Referenced by produce().

float SoftPFElectronTagInfoProducer::MaxSip3Dsig
private

Definition at line 50 of file SoftPFElectronTagInfoProducer.h.

Referenced by produce(), and SoftPFElectronTagInfoProducer().

edm::EDGetTokenT<reco::ConversionCollection> SoftPFElectronTagInfoProducer::token_allConversions
private

Definition at line 49 of file SoftPFElectronTagInfoProducer.h.

Referenced by produce(), and SoftPFElectronTagInfoProducer().

edm::EDGetTokenT<reco::BeamSpot> SoftPFElectronTagInfoProducer::token_BeamSpot
private

Definition at line 48 of file SoftPFElectronTagInfoProducer.h.

Referenced by produce(), and SoftPFElectronTagInfoProducer().

edm::EDGetTokenT<edm::View<reco::GsfElectron> > SoftPFElectronTagInfoProducer::token_elec
private

Definition at line 47 of file SoftPFElectronTagInfoProducer.h.

Referenced by produce(), and SoftPFElectronTagInfoProducer().

edm::EDGetTokenT<edm::View<reco::Jet> > SoftPFElectronTagInfoProducer::token_jets
private

Definition at line 46 of file SoftPFElectronTagInfoProducer.h.

Referenced by produce(), and SoftPFElectronTagInfoProducer().

edm::EDGetTokenT<reco::VertexCollection> SoftPFElectronTagInfoProducer::token_primaryVertex
private

Definition at line 45 of file SoftPFElectronTagInfoProducer.h.

Referenced by produce(), and SoftPFElectronTagInfoProducer().

const TransientTrackBuilder* SoftPFElectronTagInfoProducer::transientTrackBuilder
private

Definition at line 44 of file SoftPFElectronTagInfoProducer.h.

Referenced by produce().

const reco::Vertex* SoftPFElectronTagInfoProducer::vertex
private

Definition at line 53 of file SoftPFElectronTagInfoProducer.h.

Referenced by Tau.Tau::dxy(), and produce().