CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::PATConversionProducer Class Reference

#include <PATConversionProducer.h>

Inheritance diagram for pat::PATConversionProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATConversionProducer (const edm::ParameterSet &iConfig)
 
void produce (edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 ~PATConversionProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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::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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const edm::EDGetTokenT< reco::BeamSpotbsToken_
 
const edm::EDGetTokenT< reco::ConversionCollectionconversionsToken_
 
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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::global::EDProducerBase
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 37 of file PATConversionProducer.h.

Constructor & Destructor Documentation

PATConversionProducer::PATConversionProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 46 of file PATConversionProducer.cc.

46  :
48  bsToken_(consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))),
49  conversionsToken_(consumes<reco::ConversionCollection>(edm::InputTag("allConversions"))) {
50  // produces vector of muons
51  produces<std::vector<Conversion> >();
52 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::ConversionCollection > conversionsToken_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
PATConversionProducer::~PATConversionProducer ( )
override

Definition at line 55 of file PATConversionProducer.cc.

55  {
56 }

Member Function Documentation

void PATConversionProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
override

Definition at line 59 of file PATConversionProducer.cc.

References bsToken_, reco::Vertex::chi2(), conv, conversionsToken_, DEFINE_FWK_MODULE, nano_cff::electrons, electronToken_, edm::Event::getByToken(), ConversionTools::matchesConversion(), eostools::move(), reco::Vertex::ndof(), reco::BeamSpot::position(), edm::Handle< T >::product(), edm::Event::put(), pat::Conversion::setLxy(), pat::Conversion::setNHitsMax(), pat::Conversion::setVtxProb(), extraflags_cff::vtx, reco::Vertex::x(), and reco::Vertex::y().

59  {
60 
61  // Get the collection of electrons from the event
63  iEvent.getByToken(electronToken_, electrons);
64 
66  iEvent.getByToken(bsToken_, bsHandle);
67  const reco::BeamSpot &beamspot = *bsHandle.product();
68 
69  // for conversion veto selection
71  iEvent.getByToken(conversionsToken_, hConversions);
72 
73  std::vector<Conversion> * patConversions = new std::vector<Conversion>();
74 
75  for (reco::ConversionCollection::const_iterator conv = hConversions->begin(); conv!= hConversions->end(); ++conv) {
76 
77  reco::Vertex vtx = conv->conversionVertex();
78 
79  int index = 0;
80  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end(); ++itElectron) {
81 
82  //find matched conversions with electron and save those conversions with matched electron index
83  if (ConversionTools::matchesConversion(*itElectron, *conv)) {
84 
85  double vtxProb = TMath::Prob( vtx.chi2(), vtx.ndof());
86  math::XYZVector mom(conv->refittedPairMomentum());
87  double dbsx = vtx.x() - beamspot.position().x();
88  double dbsy = vtx.y() - beamspot.position().y();
89  double lxy = (mom.x()*dbsx + mom.y()*dbsy)/mom.rho();
90  int nHitsMax = 0;
91 
92  for (std::vector<uint8_t>::const_iterator it = conv->nHitsBeforeVtx().begin(); it!=conv->nHitsBeforeVtx().end(); ++it) {
93  if ((*it) > nHitsMax) nHitsMax = (*it);
94  }
95 
96  pat::Conversion anConversion( index );
97  anConversion.setVtxProb( vtxProb );
98  anConversion.setLxy( lxy );
99  anConversion.setNHitsMax( nHitsMax );
100 
101  patConversions->push_back(anConversion);
102  break;
103  }
104  index++;
105  }
106 
107  }
108 
109  // add the electrons to the event output
110  std::unique_ptr<std::vector<Conversion> > ptr(patConversions);
111  iEvent.put(std::move(ptr));
112 
113 }
static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
const edm::EDGetTokenT< reco::ConversionCollection > conversionsToken_
static HepMC::IO_HEPEVT conv
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
double y() const
y coordinate
Definition: Vertex.h:113
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
double chi2() const
chi-squares
Definition: Vertex.h:98
double ndof() const
Definition: Vertex.h:105
double x() const
x coordinate
Definition: Vertex.h:111
T const * product() const
Definition: Handle.h:74
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
const Point & position() const
position
Definition: BeamSpot.h:62
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

const edm::EDGetTokenT<reco::BeamSpot> pat::PATConversionProducer::bsToken_
private

Definition at line 50 of file PATConversionProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::ConversionCollection> pat::PATConversionProducer::conversionsToken_
private

Definition at line 51 of file PATConversionProducer.h.

Referenced by produce().

const edm::EDGetTokenT<edm::View<reco::GsfElectron> > pat::PATConversionProducer::electronToken_
private

Definition at line 49 of file PATConversionProducer.h.

Referenced by produce().