CMS 3D CMS Logo

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

#include <PF_PU_FirstVertexTracks.h>

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

Public Member Functions

 PF_PU_FirstVertexTracks (const edm::ParameterSet &)
 
- 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 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
bool trackMatch (const reco::Track &, const reco::Track &) const
 

Private Attributes

edm::InputTag input_AssociationType_
 
int input_MinQuality_
 
edm::EDGetTokenT< reco::TrackCollectiontoken_generalTracksCollection_
 
edm::EDGetTokenT< TrackToVertexAssMaptoken_TrackToVertexAssMap_
 
edm::EDGetTokenT< reco::VertexCollectiontoken_VertexCollection_
 
edm::EDGetTokenT< VertexToTrackAssMaptoken_VertexToTrackAssMap_
 

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
 
- 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 49 of file PF_PU_FirstVertexTracks.h.

Constructor & Destructor Documentation

◆ PF_PU_FirstVertexTracks()

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

Definition at line 52 of file PF_PU_FirstVertexTracks.cc.

References gather_cfg::cout, and edm::ParameterSet::getParameter().

52  {
53  //now do what ever other initialization is needed
54 
55  input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
56 
57  token_TrackToVertexAssMap_ = mayConsume<TrackToVertexAssMap>(iConfig.getParameter<InputTag>("AssociationMap"));
58  token_VertexToTrackAssMap_ = mayConsume<VertexToTrackAssMap>(iConfig.getParameter<InputTag>("AssociationMap"));
59 
60  token_generalTracksCollection_ = consumes<TrackCollection>(iConfig.getParameter<InputTag>("TrackCollection"));
61 
62  token_VertexCollection_ = mayConsume<VertexCollection>(iConfig.getParameter<InputTag>("VertexCollection"));
63 
64  input_MinQuality_ = iConfig.getParameter<int>("MinQuality");
65 
66  //register your products
67 
68  if (input_AssociationType_.label() == "TracksToVertex") {
69  produces<TrackCollection>("T2V");
70  } else {
71  if (input_AssociationType_.label() == "VertexToTracks") {
72  produces<TrackCollection>("V2T");
73  } else {
74  if (input_AssociationType_.label() == "Both") {
75  produces<TrackCollection>("T2V");
76  produces<TrackCollection>("V2T");
77  } else {
78  std::cout << "No correct InputTag for AssociationType!" << std::endl;
79  std::cout << "Won't produce any TrackCollection!" << std::endl;
80  }
81  }
82  }
83 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< VertexToTrackAssMap > token_VertexToTrackAssMap_
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
edm::EDGetTokenT< TrackToVertexAssMap > token_TrackToVertexAssMap_
edm::EDGetTokenT< reco::TrackCollection > token_generalTracksCollection_

Member Function Documentation

◆ fillDescriptions()

void PF_PU_FirstVertexTracks::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 186 of file PF_PU_FirstVertexTracks.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

186  {
187  //The following says we do not know what parameters are allowed so do no validation
188  // Please change this to state exactly what you do use, even if it is no parameters
190 
191  using namespace edm;
192  desc.add<InputTag>("AssociationType");
193  desc.add<InputTag>("AssociationMap");
194  desc.add<InputTag>("TrackCollection");
195  desc.add<InputTag>("VertexCollection");
196  desc.add<int>("MinQuality");
197 
198  descriptions.addDefault(desc);
199 }
void addDefault(ParameterSetDescription const &psetDescription)
HLT enums.

◆ produce()

void PF_PU_FirstVertexTracks::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 90 of file PF_PU_FirstVertexTracks.cc.

References edm::AssociationMap< Tag >::begin(), gather_cfg::cout, edm::AssociationMap< Tag >::end(), edm::first(), iEvent, edm::helpers::KeyVal< K, V >::key, eostools::move(), quality, edm::second(), and edm::helpers::KeyVal< K, V >::val.

90  {
91  unique_ptr<TrackCollection> t2v_firstvertextracks(new TrackCollection());
92  unique_ptr<TrackCollection> v2t_firstvertextracks(new TrackCollection());
93 
94  bool t2vassmap = false;
95  bool v2tassmap = false;
96 
97  //get the input vertex<->general track association map
100 
101  string asstype = input_AssociationType_.label();
102 
103  if ((asstype == "TracksToVertex") || (asstype == "Both")) {
104  if (iEvent.getByToken(token_TrackToVertexAssMap_, t2vAM)) {
105  t2vassmap = true;
106  }
107  }
108 
109  if ((asstype == "VertexToTracks") || (asstype == "Both")) {
110  if (iEvent.getByToken(token_VertexToTrackAssMap_, v2tAM)) {
111  v2tassmap = true;
112  }
113  }
114 
115  if (!t2vassmap && !v2tassmap) {
116  cout << "No input collection could be found" << endl;
117  return;
118  }
119 
120  //get the input track collection
121  Handle<TrackCollection> input_trckcollH;
122  iEvent.getByToken(token_generalTracksCollection_, input_trckcollH);
123 
124  if (t2vassmap) {
125  const TrackQualityPairVector trckcoll = t2vAM->begin()->val;
126 
127  //get the tracks associated to the first vertex and store them in a track collection
128  for (unsigned int trckcoll_ite = 0; trckcoll_ite < trckcoll.size(); trckcoll_ite++) {
129  float quality = trckcoll[trckcoll_ite].second;
130 
131  if (quality >= input_MinQuality_) {
132  TrackRef AMtrkref = trckcoll[trckcoll_ite].first;
133 
134  for (unsigned int index_input_trck = 0; index_input_trck < input_trckcollH->size(); index_input_trck++) {
135  TrackRef input_trackref = TrackRef(input_trckcollH, index_input_trck);
136 
137  if (trackMatch(*AMtrkref, *input_trackref)) {
138  t2v_firstvertextracks->push_back(*AMtrkref);
139  break;
140  }
141  }
142  }
143  }
144 
145  iEvent.put(std::move(t2v_firstvertextracks), "T2V");
146  }
147 
148  if (v2tassmap) {
149  //get the input vertex collection
150  Handle<VertexCollection> input_vtxcollH;
151  iEvent.getByToken(token_VertexCollection_, input_vtxcollH);
152 
153  VertexRef firstVertexRef(input_vtxcollH, 0);
154 
156 
157  for (v2t_ite = v2tAM->begin(); v2t_ite != v2tAM->end(); v2t_ite++) {
158  TrackRef AMtrkref = v2t_ite->key;
159 
160  for (unsigned int index_input_trck = 0; index_input_trck < input_trckcollH->size(); index_input_trck++) {
161  TrackRef input_trackref = TrackRef(input_trckcollH, index_input_trck);
162 
163  if (trackMatch(*AMtrkref, *input_trackref)) {
164  for (unsigned v_ite = 0; v_ite < (v2t_ite->val).size(); v_ite++) {
165  VertexRef vtxref = (v2t_ite->val)[v_ite].first;
166  float quality = (v2t_ite->val)[v_ite].second;
167 
168  if ((vtxref == firstVertexRef) && (quality >= input_MinQuality_)) {
169  v2t_firstvertextracks->push_back(*AMtrkref);
170  }
171  }
172  }
173  }
174  }
175 
176  iEvent.put(std::move(v2t_firstvertextracks), "V2T");
177  }
178 }
size
Write out results.
edm::EDGetTokenT< VertexToTrackAssMap > token_VertexToTrackAssMap_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
bool trackMatch(const reco::Track &, const reco::Track &) const
std::string const & label() const
Definition: InputTag.h:36
const_iterator end() const
last iterator over the map (read only)
U second(std::pair< T, U > const &p)
string quality
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
std::vector< TrackQualityPair > TrackQualityPairVector
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
const_iterator begin() const
first iterator over the map (read only)
edm::EDGetTokenT< TrackToVertexAssMap > token_TrackToVertexAssMap_
edm::EDGetTokenT< reco::TrackCollection > token_generalTracksCollection_
def move(src, dest)
Definition: eostools.py:511

◆ trackMatch()

bool PF_PU_FirstVertexTracks::trackMatch ( const reco::Track track1,
const reco::Track track2 
) const
private

Definition at line 180 of file PF_PU_FirstVertexTracks.cc.

References nano_mu_local_reco_cff::chi2, PVValHelper::eta, ndof, and AlCaHLTBitMon_ParallelJobs::p.

180  {
181  return ((track1).eta() == (track2).eta() && (track1).phi() == (track2).phi() && (track1).chi2() == (track2).chi2() &&
182  (track1).ndof() == (track2).ndof() && (track1).p() == (track2).p());
183 }

Member Data Documentation

◆ input_AssociationType_

edm::InputTag PF_PU_FirstVertexTracks::input_AssociationType_
private

Definition at line 61 of file PF_PU_FirstVertexTracks.h.

◆ input_MinQuality_

int PF_PU_FirstVertexTracks::input_MinQuality_
private

Definition at line 68 of file PF_PU_FirstVertexTracks.h.

◆ token_generalTracksCollection_

edm::EDGetTokenT<reco::TrackCollection> PF_PU_FirstVertexTracks::token_generalTracksCollection_
private

Definition at line 65 of file PF_PU_FirstVertexTracks.h.

◆ token_TrackToVertexAssMap_

edm::EDGetTokenT<TrackToVertexAssMap> PF_PU_FirstVertexTracks::token_TrackToVertexAssMap_
private

Definition at line 63 of file PF_PU_FirstVertexTracks.h.

◆ token_VertexCollection_

edm::EDGetTokenT<reco::VertexCollection> PF_PU_FirstVertexTracks::token_VertexCollection_
private

Definition at line 66 of file PF_PU_FirstVertexTracks.h.

◆ token_VertexToTrackAssMap_

edm::EDGetTokenT<VertexToTrackAssMap> PF_PU_FirstVertexTracks::token_VertexToTrackAssMap_
private

Definition at line 64 of file PF_PU_FirstVertexTracks.h.