CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
VertexProducer Class Reference

#include <VertexProducer.h>

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

Public Member Functions

 VertexProducer (const edm::ParameterSet &)
 
 ~VertexProducer () 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 Types

typedef std::vector< TTTrackTypeTTTrackCollectionType
 
typedef edm::View< TTTrackTypeTTTrackCollectionView
 
typedef edm::RefVector< TTTrackCollectionTypeTTTrackRefCollectionType
 
typedef TTTrack< Ref_Phase2TrackerDigi_TTTrackType
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const edm::EDGetTokenT< TTTrackRefCollectionTypel1TracksToken_
 
const std::string outputCollectionName_
 
tensorflow::GraphDef * PattRecGraph_
 
tensorflow::Session * PattRecSesh_
 
l1tVertexFinder::AlgoSettings settings_
 
tensorflow::GraphDef * TrkWGraph_
 
tensorflow::Session * TrkWSesh_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtTopoToken
 

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 32 of file VertexProducer.h.

Member Typedef Documentation

◆ TTTrackCollectionType

typedef std::vector<TTTrackType> VertexProducer::TTTrackCollectionType
private

Definition at line 39 of file VertexProducer.h.

◆ TTTrackCollectionView

Definition at line 41 of file VertexProducer.h.

◆ TTTrackRefCollectionType

Definition at line 40 of file VertexProducer.h.

◆ TTTrackType

Definition at line 38 of file VertexProducer.h.

Constructor & Destructor Documentation

◆ VertexProducer()

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

Definition at line 18 of file VertexProducer.cc.

References tensorflow::createSession(), l1tVertexFinder::AlgoSettings::debug(), tensorflow::loadGraphDef(), outputCollectionName_, PattRecGraph_, PattRecSesh_, settings_, TrkWGraph_, TrkWSesh_, l1tVertexFinder::AlgoSettings::vx_algo(), l1tVertexFinder::AlgoSettings::vx_pattrec_graph(), and l1tVertexFinder::AlgoSettings::vx_trkw_graph().

19  : l1TracksToken_(consumes<TTTrackRefCollectionType>(iConfig.getParameter<edm::InputTag>("l1TracksInputTag"))),
20  tTopoToken(esConsumes<TrackerTopology, TrackerTopologyRcd>()),
21  outputCollectionName_(iConfig.getParameter<std::string>("l1VertexCollectionName")),
22  settings_(AlgoSettings(iConfig)) {
23  // Get configuration parameters
24 
25  switch (settings_.vx_algo()) {
26  case Algorithm::fastHisto:
27  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using the fastHisto binning algorithm";
28  break;
29  case Algorithm::fastHistoEmulation:
30  edm::LogInfo("VertexProducer")
31  << "VertexProducer::Finding vertices using the emulation version of the fastHisto binning algorithm";
32  break;
33  case Algorithm::fastHistoLooseAssociation:
34  edm::LogInfo("VertexProducer")
35  << "VertexProducer::Finding vertices using the fastHistoLooseAssociation binning algorithm";
36  break;
37  case Algorithm::GapClustering:
38  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a gap clustering algorithm";
39  break;
40  case Algorithm::agglomerativeHierarchical:
41  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a Simple Merge Clustering algorithm";
42  break;
43  case Algorithm::DBSCAN:
44  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a DBSCAN algorithm";
45  break;
46  case Algorithm::PVR:
47  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a PVR algorithm";
48  break;
49  case Algorithm::adaptiveVertexReconstruction:
50  edm::LogInfo("VertexProducer")
51  << "VertexProducer::Finding vertices using an AdaptiveVertexReconstruction algorithm";
52  break;
53  case Algorithm::HPV:
54  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a Highest Pt Vertex algorithm";
55  break;
56  case Algorithm::Kmeans:
57  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a kmeans algorithm";
58  break;
59  case Algorithm::NNEmulation:
60  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using the Neural Network Emulation";
61  break;
62  }
63 
64  //--- Define EDM output to be written to file (if required)
65  if (settings_.vx_algo() == Algorithm::fastHistoEmulation || settings_.vx_algo() == Algorithm::NNEmulation) {
66  produces<l1t::VertexWordCollection>(outputCollectionName_ + "Emulation");
67  } else {
68  produces<l1t::VertexCollection>(outputCollectionName_);
69  }
70 
71  if (settings_.vx_algo() == Algorithm::NNEmulation) {
72  // load graphs, create a new session and add the graphDef
73  if (settings_.debug() > 1) {
74  edm::LogInfo("VertexProducer") << "loading TrkWeight graph from " << settings_.vx_trkw_graph() << std::endl;
75  edm::LogInfo("VertexProducer") << "loading PatternRec graph from " << settings_.vx_pattrec_graph() << std::endl;
76  }
81  }
82 }
tensorflow::GraphDef * TrkWGraph_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:119
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken
tensorflow::Session * TrkWSesh_
const edm::EDGetTokenT< TTTrackRefCollectionType > l1TracksToken_
const std::string outputCollectionName_
unsigned int debug() const
Definition: AlgoSettings.h:86
std::string vx_trkw_graph() const
Definition: AlgoSettings.h:82
std::string vx_pattrec_graph() const
Definition: AlgoSettings.h:83
tensorflow::GraphDef * PattRecGraph_
Session * createSession()
Definition: TensorFlow.cc:136
Log< level::Info, false > LogInfo
tensorflow::Session * PattRecSesh_
Algorithm vx_algo() const
Definition: AlgoSettings.h:36
l1tVertexFinder::AlgoSettings settings_

◆ ~VertexProducer()

VertexProducer::~VertexProducer ( )
inlineoverride

Definition at line 35 of file VertexProducer.h.

35 {}

Member Function Documentation

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 84 of file VertexProducer.cc.

References l1tVertexFinder::VertexFinder::adaptiveVertexReconstruction(), l1tVertexFinder::VertexFinder::agglomerativeHierarchicalClustering(), l1tVertexFinder::VertexFinder::DBSCAN(), l1tVertexFinder::AlgoSettings::debug(), l1tVertexFinder::VertexFinder::fastHisto(), l1tVertexFinder::VertexFinder::fastHistoEmulation(), l1tVertexFinder::VertexFinder::fastHistoLooseAssociation(), l1tVertexFinder::VertexFinder::findPrimaryVertex(), l1tVertexFinder::VertexFinder::GapClustering(), edm::EventSetup::getData(), l1tVertexFinder::VertexFinder::HPV(), iEvent, l1tVertexFinder::VertexFinder::Kmeans(), hltEgammaEleL1TrkIsoL1Seeded_cfi::l1Tracks, l1TracksToken_, eostools::move(), l1tVertexFinder::VertexFinder::NNVtxEmulation(), outputCollectionName_, PattRecSesh_, l1tVertexFinder::VertexFinder::PVR(), edm::refToPtr(), settings_, edm::RefVector< C, T, F >::size(), l1tVertexFinder::VertexFinder::sortVerticesInPt(), HLT_2024v14_cff::track, TrkWSesh_, tTopoToken, l1tVertexFinder::VertexFinder::vertices(), l1tVertexFinder::VertexFinder::verticesEmulation(), L1BJetProducer_cff::vtx, l1tVertexFinder::AlgoSettings::vx_algo(), and l1tVertexFinder::AlgoSettings::vx_TrackMinPt().

84  {
86  iEvent.getByToken(l1TracksToken_, l1TracksHandle);
87 
88  std::vector<l1tVertexFinder::L1Track> l1Tracks;
89  l1Tracks.reserve(l1TracksHandle->size());
90  if (settings_.debug() > 1) {
91  edm::LogInfo("VertexProducer") << "produce::Processing " << l1TracksHandle->size() << " tracks";
92  }
93  for (const auto& track : *l1TracksHandle) {
94  auto l1track = L1Track(edm::refToPtr(track));
95  if (l1track.pt() >= settings_.vx_TrackMinPt()) {
96  l1Tracks.push_back(l1track);
97  } else {
98  if (settings_.debug() > 2) {
99  edm::LogInfo("VertexProducer") << "produce::Removing track with too low of a pt (" << l1track.pt() << ")\n"
100  << " word = " << l1track.getTTTrackPtr()->getTrackWord().to_string(2);
101  }
102  }
103  }
104 
105  if (settings_.debug() > 1) {
106  edm::LogInfo("VertexProducer") << "produce::Processing " << l1Tracks.size() << " tracks after minimum pt cut of"
107  << settings_.vx_TrackMinPt() << " GeV";
108  }
109 
111 
112  switch (settings_.vx_algo()) {
113  case Algorithm::fastHisto: {
114  const TrackerTopology& tTopo = iSetup.getData(tTopoToken);
115  vf.fastHisto(&tTopo);
116  break;
117  }
118  case Algorithm::fastHistoEmulation:
119  vf.fastHistoEmulation();
120  break;
121  case Algorithm::fastHistoLooseAssociation:
122  vf.fastHistoLooseAssociation();
123  break;
124  case Algorithm::GapClustering:
125  vf.GapClustering();
126  break;
127  case Algorithm::agglomerativeHierarchical:
128  vf.agglomerativeHierarchicalClustering();
129  break;
130  case Algorithm::DBSCAN:
131  vf.DBSCAN();
132  break;
133  case Algorithm::PVR:
134  vf.PVR();
135  break;
136  case Algorithm::adaptiveVertexReconstruction:
137  vf.adaptiveVertexReconstruction();
138  break;
139  case Algorithm::HPV:
140  vf.HPV();
141  break;
142  case Algorithm::Kmeans:
143  vf.Kmeans();
144  break;
145  case Algorithm::NNEmulation:
146  vf.NNVtxEmulation(TrkWSesh_, PattRecSesh_);
147  break;
148  }
149 
150  vf.sortVerticesInPt();
151  vf.findPrimaryVertex();
152 
153  // //=== Store output EDM track and hardware stub collections.
154  if (settings_.vx_algo() == Algorithm::fastHistoEmulation || settings_.vx_algo() == Algorithm::NNEmulation) {
155  std::unique_ptr<l1t::VertexWordCollection> product_emulation =
156  std::make_unique<l1t::VertexWordCollection>(vf.verticesEmulation().begin(), vf.verticesEmulation().end());
157  iEvent.put(std::move(product_emulation), outputCollectionName_ + "Emulation");
158  } else {
159  std::unique_ptr<l1t::VertexCollection> product(new std::vector<l1t::Vertex>());
160  for (const auto& vtx : vf.vertices()) {
161  product->emplace_back(vtx.vertex());
162  }
163  iEvent.put(std::move(product), outputCollectionName_);
164  }
165 }
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
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken
tensorflow::Session * TrkWSesh_
const edm::EDGetTokenT< TTTrackRefCollectionType > l1TracksToken_
const std::string outputCollectionName_
unsigned int debug() const
Definition: AlgoSettings.h:86
int iEvent
Definition: GenABIO.cc:224
Log< level::Info, false > LogInfo
tensorflow::Session * PattRecSesh_
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
TTTrack< Ref_Phase2TrackerDigi_ > L1Track
Definition: L1Track.h:8
Algorithm vx_algo() const
Definition: AlgoSettings.h:36
def move(src, dest)
Definition: eostools.py:511
l1tVertexFinder::AlgoSettings settings_

Member Data Documentation

◆ l1TracksToken_

const edm::EDGetTokenT<TTTrackRefCollectionType> VertexProducer::l1TracksToken_
private

Definition at line 46 of file VertexProducer.h.

Referenced by produce().

◆ outputCollectionName_

const std::string VertexProducer::outputCollectionName_
private

Definition at line 48 of file VertexProducer.h.

Referenced by produce(), and VertexProducer().

◆ PattRecGraph_

tensorflow::GraphDef* VertexProducer::PattRecGraph_
private

Definition at line 52 of file VertexProducer.h.

Referenced by VertexProducer().

◆ PattRecSesh_

tensorflow::Session* VertexProducer::PattRecSesh_
private

Definition at line 53 of file VertexProducer.h.

Referenced by produce(), and VertexProducer().

◆ settings_

l1tVertexFinder::AlgoSettings VertexProducer::settings_
private

Definition at line 55 of file VertexProducer.h.

Referenced by produce(), and VertexProducer().

◆ TrkWGraph_

tensorflow::GraphDef* VertexProducer::TrkWGraph_
private

Definition at line 50 of file VertexProducer.h.

Referenced by VertexProducer().

◆ TrkWSesh_

tensorflow::Session* VertexProducer::TrkWSesh_
private

Definition at line 51 of file VertexProducer.h.

Referenced by produce(), and VertexProducer().

◆ tTopoToken

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> VertexProducer::tTopoToken
private

Definition at line 47 of file VertexProducer.h.

Referenced by produce().