CMS 3D CMS Logo

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

Public Member Functions

 PATTrackAndVertexUnpacker (const edm::ParameterSet &iConfig)
 
void produce (edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 ~PATTrackAndVertexUnpacker () 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::vector< ModuleDescription const * > &modules, 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef std::vector< edm::InputTagVInputTag
 

Private Attributes

const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > AdditionalTracks_
 
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > Cands_
 
const edm::EDGetTokenT< reco::VertexCollectionPVs_
 
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollectionSVs_
 

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 26 of file TrackAndVertexUnpacker.cc.

Member Typedef Documentation

◆ VInputTag

Definition at line 34 of file TrackAndVertexUnpacker.cc.

Constructor & Destructor Documentation

◆ PATTrackAndVertexUnpacker()

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

Definition at line 47 of file TrackAndVertexUnpacker.cc.

48  : Cands_(consumes<std::vector<pat::PackedCandidate>>(iConfig.getParameter<edm::InputTag>("packedCandidates"))),
49  PVs_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("slimmedVertices"))),
50  SVs_(consumes<reco::VertexCompositePtrCandidateCollection>(
51  iConfig.getParameter<edm::InputTag>("slimmedSecondaryVertices"))),
53  consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("additionalTracks"))) {
54  produces<reco::TrackCollection>();
55  produces<reco::VertexCollection>();
56  produces<reco::VertexCollection>("secondary");
57 }

◆ ~PATTrackAndVertexUnpacker()

PATTrackAndVertexUnpacker::~PATTrackAndVertexUnpacker ( )
override

Definition at line 59 of file TrackAndVertexUnpacker.cc.

59 {}

Member Function Documentation

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 61 of file TrackAndVertexUnpacker.cc.

61  {
62  using namespace edm;
63  using namespace std;
64  using namespace reco;
66  iEvent.getByToken(Cands_, cands);
68  iEvent.getByToken(PVs_, pvs);
70  iEvent.getByToken(SVs_, svs);
72  iEvent.getByToken(AdditionalTracks_, addTracks);
73 
74  auto outTks = std::make_unique<std::vector<reco::Track>>();
75  std::map<unsigned int, std::vector<unsigned int>> asso;
76  std::map<unsigned int, unsigned int> trackKeys;
77  unsigned int j = 0;
78  for (unsigned int i = 0; i < cands->size(); i++) {
79  const pat::PackedCandidate& c = (*cands)[i];
80  if (c.hasTrackDetails() && c.charge() != 0 && c.numberOfHits() > 0) {
81  outTks->push_back(c.pseudoTrack());
82  for (size_t ipv = 0; ipv < pvs->size(); ++ipv) {
83  if (c.fromPV(ipv) == pat::PackedCandidate::PVUsedInFit)
84  asso[ipv].push_back(j);
85  }
86  trackKeys[i] = j;
87  j++;
88  }
89  }
90 
91  int offsetAdd = j;
92  for (unsigned int i = 0; i < addTracks->size(); i++) {
93  if ((*addTracks)[i].hasTrackDetails()) {
94  outTks->push_back((*addTracks)[i].pseudoTrack());
95  for (size_t ipv = 0; ipv < pvs->size(); ++ipv) {
96  if ((*addTracks)[i].fromPV(ipv) == pat::PackedCandidate::PVUsedInFit)
97  asso[ipv].push_back(j);
98  }
99  j++;
100  }
101  }
102 
104 
105  auto outPv = std::make_unique<std::vector<reco::Vertex>>();
106 
107  for (size_t ipv = 0; ipv < pvs->size(); ++ipv) {
108  reco::Vertex pv = (*pvs)[ipv];
109  for (unsigned int i = 0; i < asso[ipv].size(); i++) {
110  TrackRef r(oh, asso[ipv][i]);
111  TrackBaseRef rr(r);
112  pv.add(rr);
113  }
114  outPv->push_back(pv);
115  }
116  iEvent.put(std::move(outPv));
117 
118  auto outSv = std::make_unique<std::vector<reco::Vertex>>();
119  for (size_t i = 0; i < svs->size(); i++) {
120  const reco::VertexCompositePtrCandidate& sv = (*svs)[i];
121  outSv->push_back(reco::Vertex(sv.vertex(), sv.vertexCovariance(), sv.vertexChi2(), sv.vertexNdof(), 0));
122  for (size_t j = 0; j < sv.numberOfDaughters(); j++) {
123  TrackRef r;
124  if (sv.daughterPtr(j).id() == cands.id()) {
125  // use trackKeys because cand->track has gaps from neutral
126  r = TrackRef(oh, trackKeys[sv.daughterPtr(j).key()]);
127  } else {
128  // use directly the key because addTracks is only charged
129  r = TrackRef(oh, offsetAdd + sv.daughterPtr(j).key());
130  }
131  TrackBaseRef rr(r);
132  outSv->back().add(rr);
133  }
134  }
135 
136  iEvent.put(std::move(outSv), "secondary");
137 }

References AdditionalTracks_, HltBtagPostValidation_cff::c, HLT_FULL_cff::cands, Cands_, mps_fire::i, iEvent, dqmiolumiharvest::j, eostools::move(), MetAnalyzer::pv(), FSQDQM_cfi::pvs, PVs_, pat::PackedCandidate::PVUsedInFit, alignCSCRings::r, findQualityFiles::rr, pfDeepBoostedJetPreprocessParams_cfi::sv, and SVs_.

Member Data Documentation

◆ AdditionalTracks_

const edm::EDGetTokenT<std::vector<pat::PackedCandidate> > pat::PATTrackAndVertexUnpacker::AdditionalTracks_
private

Definition at line 39 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

◆ Cands_

const edm::EDGetTokenT<std::vector<pat::PackedCandidate> > pat::PATTrackAndVertexUnpacker::Cands_
private

Definition at line 36 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

◆ PVs_

const edm::EDGetTokenT<reco::VertexCollection> pat::PATTrackAndVertexUnpacker::PVs_
private

Definition at line 37 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

◆ SVs_

const edm::EDGetTokenT<reco::VertexCompositePtrCandidateCollection> pat::PATTrackAndVertexUnpacker::SVs_
private

Definition at line 38 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

mps_fire.i
i
Definition: mps_fire.py:428
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
edm
HLT enums.
Definition: AlignableModifier.h:19
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
pat::PATTrackAndVertexUnpacker::AdditionalTracks_
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > AdditionalTracks_
Definition: TrackAndVertexUnpacker.cc:39
reco::VertexCompositePtrCandidate
Definition: VertexCompositePtrCandidate.h:16
edm::Ref< TrackCollection >
pat::PackedCandidate::PVUsedInFit
Definition: PackedCandidate.h:703
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15208
pat::PackedCandidate
Definition: PackedCandidate.h:22
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
FSQDQM_cfi.pvs
pvs
Definition: FSQDQM_cfi.py:12
alignCSCRings.r
r
Definition: alignCSCRings.py:93
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::OrphanHandle
Definition: EDProductfwd.h:39
pat::PATTrackAndVertexUnpacker::PVs_
const edm::EDGetTokenT< reco::VertexCollection > PVs_
Definition: TrackAndVertexUnpacker.cc:37
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< reco::Track >
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
pat::PATTrackAndVertexUnpacker::SVs_
const edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollection > SVs_
Definition: TrackAndVertexUnpacker.cc:38
pat::PATTrackAndVertexUnpacker::Cands_
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > Cands_
Definition: TrackAndVertexUnpacker.cc:36