CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::PATConversionProducer Class Reference
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
 
 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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::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 45 of file PATConversionProducer.cc.

Constructor & Destructor Documentation

◆ PATConversionProducer()

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

Definition at line 64 of file PATConversionProducer.cc.

66  bsToken_(consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))),
67  conversionsToken_(consumes<reco::ConversionCollection>(edm::InputTag("allConversions"))) {
68  // produces vector of muons
69  produces<std::vector<Conversion> >();
70 }

◆ ~PATConversionProducer()

PATConversionProducer::~PATConversionProducer ( )
override

Definition at line 72 of file PATConversionProducer.cc.

72 {}

Member Function Documentation

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 74 of file PATConversionProducer.cc.

74  {
75  // Get the collection of electrons from the event
77  iEvent.getByToken(electronToken_, electrons);
78 
80  iEvent.getByToken(bsToken_, bsHandle);
81  const reco::BeamSpot &beamspot = *bsHandle.product();
82 
83  // for conversion veto selection
85  iEvent.getByToken(conversionsToken_, hConversions);
86 
87  std::vector<Conversion> *patConversions = new std::vector<Conversion>();
88 
89  for (reco::ConversionCollection::const_iterator conv = hConversions->begin(); conv != hConversions->end(); ++conv) {
90  reco::Vertex vtx = conv->conversionVertex();
91 
92  int index = 0;
93  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end();
94  ++itElectron) {
95  //find matched conversions with electron and save those conversions with matched electron index
96  if (ConversionTools::matchesConversion(*itElectron, *conv)) {
97  double vtxProb = TMath::Prob(vtx.chi2(), vtx.ndof());
98  math::XYZVector mom(conv->refittedPairMomentum());
99  double dbsx = vtx.x() - beamspot.position().x();
100  double dbsy = vtx.y() - beamspot.position().y();
101  double lxy = (mom.x() * dbsx + mom.y() * dbsy) / mom.rho();
102  int nHitsMax = 0;
103 
104  for (std::vector<uint8_t>::const_iterator it = conv->nHitsBeforeVtx().begin();
105  it != conv->nHitsBeforeVtx().end();
106  ++it) {
107  if ((*it) > nHitsMax)
108  nHitsMax = (*it);
109  }
110 
111  pat::Conversion anConversion(index);
112  anConversion.setVtxProb(vtxProb);
113  anConversion.setLxy(lxy);
114  anConversion.setNHitsMax(nHitsMax);
115 
116  patConversions->push_back(anConversion);
117  break;
118  }
119  index++;
120  }
121  }
122 
123  // add the electrons to the event output
124  std::unique_ptr<std::vector<Conversion> > ptr(patConversions);
125  iEvent.put(std::move(ptr));
126 }

References bsToken_, conv, conversionsToken_, pwdgSkimBPark_cfi::electrons, electronToken_, iEvent, ConversionTools::matchesConversion(), eostools::move(), edm::Handle< T >::product(), pat::Conversion::setLxy(), pat::Conversion::setNHitsMax(), pat::Conversion::setVtxProb(), and extraflags_cff::vtx.

Member Data Documentation

◆ bsToken_

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

Definition at line 55 of file PATConversionProducer.cc.

Referenced by produce().

◆ conversionsToken_

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

Definition at line 56 of file PATConversionProducer.cc.

Referenced by produce().

◆ electronToken_

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

Definition at line 54 of file PATConversionProducer.cc.

Referenced by produce().

pat::PATConversionProducer::conversionsToken_
const edm::EDGetTokenT< reco::ConversionCollection > conversionsToken_
Definition: PATConversionProducer.cc:56
edm::Handle::product
T const * product() const
Definition: Handle.h:70
pat::PATConversionProducer::bsToken_
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
Definition: PATConversionProducer.cc:55
edm::Handle
Definition: AssociativeIterator.h:50
reco::BeamSpot
Definition: BeamSpot.h:21
beamspot
Definition: BeamSpotWrite2Txt.h:8
pat::Conversion
Definition: Conversion.h:21
edm::View
Definition: CaloClusterFwd.h:14
ConversionTools::matchesConversion
static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false)
Definition: ConversionTools.cc:53
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
iEvent
int iEvent
Definition: GenABIO.cc:224
eostools.move
def move(src, dest)
Definition: eostools.py:511
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:19
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:159
pat::PATConversionProducer::electronToken_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
Definition: PATConversionProducer.cc:54
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
conv
EPOS::IO_EPOS conv
Definition: ReggeGribovPartonMCHadronizer.cc:42