CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::PATSecondaryVertexSlimmer Class Reference
Inheritance diagram for pat::PATSecondaryVertexSlimmer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATSecondaryVertexSlimmer (const edm::ParameterSet &)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~PATSecondaryVertexSlimmer () 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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, 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::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map2_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
 
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollectionsrc_
 
const edm::EDGetTokenT< std::vector< reco::Vertex > > srcLegacy_
 
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollectionsrcV0s_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 21 of file PATSecondaryVertexSlimmer.cc.

Constructor & Destructor Documentation

◆ PATSecondaryVertexSlimmer()

pat::PATSecondaryVertexSlimmer::PATSecondaryVertexSlimmer ( const edm::ParameterSet iConfig)
explicit

Definition at line 37 of file PATSecondaryVertexSlimmer.cc.

38  : src_(consumes<reco::VertexCompositePtrCandidateCollection>(iConfig.getParameter<edm::InputTag>("src"))),
39  srcLegacy_(mayConsume<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("src"))),
40  srcV0s_(mayConsume<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("src"))),
42  iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
44  iConfig.existsAs<edm::InputTag>("lostTracksCandidates")
45  ? iConfig.getParameter<edm::InputTag>("lostTracksCandidates")
46  : edm::InputTag("lostTracks"))) {
47  produces<reco::VertexCompositePtrCandidateCollection>();
48 }
const edm::EDGetTokenT< std::vector< reco::Vertex > > srcLegacy_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map2_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:172
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > srcV0s_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollection > src_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)

◆ ~PATSecondaryVertexSlimmer()

pat::PATSecondaryVertexSlimmer::~PATSecondaryVertexSlimmer ( )
override

Definition at line 50 of file PATSecondaryVertexSlimmer.cc.

50 {}

Member Function Documentation

◆ produce()

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

Must be V0s VertexCompositeCandidate format

Implements edm::global::EDProducerBase.

Definition at line 52 of file PATSecondaryVertexSlimmer.cc.

References BPhysicsValidation_cfi::daughters, mps_fire::i, iEvent, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, eostools::move(), dqmiodumpmetadata::n, edm::refToPtr(), findQualityFiles::v, and AlignmentTracksFromVertexSelector_cfi::vertices.

52  {
53  auto outPtr = std::make_unique<reco::VertexCompositePtrCandidateCollection>();
54 
56  iEvent.getByToken(src_, candVertices);
57 
59  iEvent.getByToken(map_, pf2pc);
60 
61  // if reco::VertexCompositePtrCandidate secondary vertices are present
62  if (candVertices.isValid()) {
63  outPtr->reserve(candVertices->size());
64  for (unsigned int i = 0, n = candVertices->size(); i < n; ++i) {
65  reco::VertexCompositePtrCandidate v = (*candVertices)[i];
66 
67  std::vector<reco::CandidatePtr> daughters = v.daughterPtrVector();
68  v.clearDaughters();
69 
70  for (std::vector<reco::CandidatePtr>::const_iterator it = daughters.begin(); it != daughters.end(); ++it) {
71  if ((*pf2pc)[*it].isNonnull() && (*pf2pc)[*it]->numberOfHits() > 0)
72  v.addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[*it])));
73  }
74 
75  outPtr->push_back(v);
76  }
77  }
78  // otherwise fallback to reco::Vertex secondary vertices
79  else {
81  iEvent.getByToken(srcLegacy_, vertices);
82 
83  if (vertices.isValid()) {
85  iEvent.getByToken(map2_, pf2pc2);
86 
87  outPtr->reserve(vertices->size());
88  for (unsigned int i = 0, n = vertices->size(); i < n; ++i) {
89  const reco::Vertex& v = (*vertices)[i];
90  outPtr->push_back(reco::VertexCompositePtrCandidate(0, v.p4(), v.position(), v.error(), v.chi2(), v.ndof()));
91 
92  for (reco::Vertex::trackRef_iterator it = v.tracks_begin(); it != v.tracks_end(); it++) {
93  if (v.trackWeight(*it) > 0.5) {
94  if ((*pf2pc)[*it].isNonnull() && (*pf2pc)[*it]->numberOfHits() > 0) {
95  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[*it])));
96  } else {
97  if ((*pf2pc2)[*it].isNonnull()) {
98  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc2)[*it])));
99  } else {
100  edm::LogError("PATSecondaryVertexSlimmer") << "HELPME" << std::endl;
101  }
102  }
103  }
104  }
105  }
106  } else {
109  iEvent.getByToken(srcV0s_, srcV0s);
110 
112  iEvent.getByToken(map2_, pf2pc2);
113 
114  outPtr->reserve(srcV0s->size());
115  for (unsigned int i = 0, n = srcV0s->size(); i < n; ++i) {
116  const reco::VertexCompositeCandidate& v = (*srcV0s)[i];
117  outPtr->push_back(reco::VertexCompositePtrCandidate(
118  0, v.p4(), v.vertex(), v.vertexCovariance(), v.vertexChi2(), v.vertexNdof()));
119 
120  for (size_t dIdx = 0; dIdx < v.numberOfDaughters(); dIdx++) {
121  reco::TrackRef trackRef = (dynamic_cast<const reco::RecoChargedCandidate*>(v.daughter(dIdx)))->track();
122  if ((*pf2pc)[trackRef].isNonnull() && (*pf2pc)[trackRef]->numberOfHits() > 0) {
123  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[trackRef])));
124  } else {
125  if ((*pf2pc2)[trackRef].isNonnull()) {
126  outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc2)[trackRef])));
127  } else {
128  edm::LogError("PATSecondaryVertexSlimmer") << "HELPME" << std::endl;
129  }
130  }
131  }
132  }
133 
134  } // if reco::Vertex
135  } // if Candidate
136 
137  iEvent.put(std::move(outPtr));
138 }
const edm::EDGetTokenT< std::vector< reco::Vertex > > srcLegacy_
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map2_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
Log< level::Error, false > LogError
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > srcV0s_
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollection > src_
def move(src, dest)
Definition: eostools.py:511
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38

Member Data Documentation

◆ map2_

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PATSecondaryVertexSlimmer::map2_
private

Definition at line 33 of file PATSecondaryVertexSlimmer.cc.

◆ map_

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PATSecondaryVertexSlimmer::map_
private

Definition at line 32 of file PATSecondaryVertexSlimmer.cc.

◆ src_

const edm::EDGetTokenT<reco::VertexCompositePtrCandidateCollection> pat::PATSecondaryVertexSlimmer::src_
private

Definition at line 29 of file PATSecondaryVertexSlimmer.cc.

◆ srcLegacy_

const edm::EDGetTokenT<std::vector<reco::Vertex> > pat::PATSecondaryVertexSlimmer::srcLegacy_
private

Definition at line 30 of file PATSecondaryVertexSlimmer.cc.

◆ srcV0s_

const edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> pat::PATSecondaryVertexSlimmer::srcV0s_
private

Definition at line 31 of file PATSecondaryVertexSlimmer.cc.