CMS 3D CMS Logo

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

Public Types

using IndToEdm = std::vector< uint32_t >
 
- 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
 

Public Member Functions

 PixelVertexProducerFromSoAAlpaka (const edm::ParameterSet &iConfig)
 
 ~PixelVertexProducerFromSoAAlpaka () override=default
 
- 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)
 

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 streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpottokenBeamSpot_
 
edm::EDGetTokenT< IndToEdmtokenIndToEdm_
 
edm::EDGetTokenT< reco::TrackCollectiontokenTracks_
 
edm::EDGetTokenT< ZVertexHosttokenVertex_
 

Additional Inherited Members

- 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 22 of file PixelVertexProducerFromSoAAlpaka.cc.

Member Typedef Documentation

◆ IndToEdm

using PixelVertexProducerFromSoAAlpaka::IndToEdm = std::vector<uint32_t>

Definition at line 24 of file PixelVertexProducerFromSoAAlpaka.cc.

Constructor & Destructor Documentation

◆ PixelVertexProducerFromSoAAlpaka()

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

Definition at line 40 of file PixelVertexProducerFromSoAAlpaka.cc.

41  : tokenVertex_(consumes(conf.getParameter<edm::InputTag>("src"))),
42  tokenBeamSpot_(consumes(conf.getParameter<edm::InputTag>("beamSpot"))),
43  tokenTracks_(consumes(conf.getParameter<edm::InputTag>("TrackCollection"))),
44  tokenIndToEdm_(consumes(conf.getParameter<edm::InputTag>("TrackCollection"))) {
45  produces<reco::VertexCollection>();
46 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< ZVertexHost > tokenVertex_
edm::EDGetTokenT< reco::BeamSpot > tokenBeamSpot_
edm::EDGetTokenT< reco::TrackCollection > tokenTracks_

◆ ~PixelVertexProducerFromSoAAlpaka()

PixelVertexProducerFromSoAAlpaka::~PixelVertexProducerFromSoAAlpaka ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 48 of file PixelVertexProducerFromSoAAlpaka.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

48  {
50 
51  desc.add<edm::InputTag>("TrackCollection", edm::InputTag("pixelTracks"));
52  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
53  desc.add<edm::InputTag>("src", edm::InputTag("pixelVerticesAlpaka"));
54 
55  descriptions.add("pixelVertexFromSoAAlpaka", desc);
56 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 58 of file PixelVertexProducerFromSoAAlpaka.cc.

References cms::cuda::assert(), cms::cuda::bs, gather_cfg::cout, dxdz, dydz, submitPVResolutionJobs::err, mps_fire::i, iEvent, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, dqmdumpme::k, LogDebug, eostools::move(), nt, gpuVertexFinder::soa, mathSSE::sqrt(), tokenBeamSpot_, tokenIndToEdm_, tokenTracks_, tokenVertex_, run3scouting_cff::tracksSize, mitigatedMETSequence_cff::U, findQualityFiles::v, jetsAK4_CHS_cff::vertexes, x, y, z, and HLTMuonOfflineAnalyzer_cfi::z0.

60  {
61  auto vertexes = std::make_unique<reco::VertexCollection>();
62 
63  auto tracksHandle = iEvent.getHandle(tokenTracks_);
64  auto tracksSize = tracksHandle->size();
65  auto const &indToEdm = iEvent.get(tokenIndToEdm_);
66  auto bsHandle = iEvent.getHandle(tokenBeamSpot_);
67 
68  float x0 = 0, y0 = 0, z0 = 0, dxdz = 0, dydz = 0;
69  std::vector<int32_t> itrk;
70  itrk.reserve(64); // avoid first relocations
71  if (!bsHandle.isValid()) {
72  edm::LogWarning("PixelVertexProducer") << "No beamspot found. returning vertexes with (0,0,Z) ";
73  } else {
74  const reco::BeamSpot &bs = *bsHandle;
75  x0 = bs.x0();
76  y0 = bs.y0();
77  z0 = bs.z0();
78  dxdz = bs.dxdz();
79  dydz = bs.dydz();
80  }
81 
82  auto const &soa = iEvent.get(tokenVertex_);
83 
84  int nv = soa.view().nvFinal();
85 
86 #ifdef PIXVERTEX_DEBUG_PRODUCE
87  std::cout << "converting " << nv << " vertices "
88  << " from " << indToEdm.size() << " tracks" << std::endl;
89 #endif // PIXVERTEX_DEBUG_PRODUCE
90 
91  std::set<uint32_t> uind; // for verifing index consistency
92  for (int j = nv - 1; j >= 0; --j) {
93  auto i = soa.view()[j].sortInd(); // on gpu sorted in ascending order....
94  assert(i < nv);
95  uind.insert(i);
96  assert(itrk.empty());
97  auto z = soa.view()[i].zv();
98  auto x = x0 + dxdz * z;
99  auto y = y0 + dydz * z;
100  z += z0;
102  err(2, 2) = 1.f / soa.view()[i].wv();
103  err(2, 2) *= 2.; // artifically inflate error
104  //Copy also the tracks (no intention to be efficient....)
105  for (auto k = 0U; k < indToEdm.size(); ++k) {
106  if (soa.view()[k].idv() == int16_t(i))
107  itrk.push_back(k);
108  }
109  auto nt = itrk.size();
110  if (nt == 0) {
111 #ifdef PIXVERTEX_DEBUG_PRODUCE
112  std::cout << "vertex " << i << " with no tracks..." << std::endl;
113 #endif // PIXVERTEX_DEBUG_PRODUCE
114  continue;
115  }
116  if (nt < 2) {
117  itrk.clear();
118  continue;
119  } // remove outliers
120  (*vertexes).emplace_back(reco::Vertex::Point(x, y, z), err, soa.view()[i].chi2(), soa.view()[i].ndof(), nt);
121  auto &v = (*vertexes).back();
122  v.reserve(itrk.size());
123  for (auto it : itrk) {
124  assert(it < int(indToEdm.size()));
125  auto k = indToEdm[it];
126  if (k > tracksSize) {
127  edm::LogWarning("PixelVertexProducer") << "oops track " << it << " does not exists on CPU " << k;
128  continue;
129  }
130  auto tk = reco::TrackRef(tracksHandle, k);
131  v.add(tk);
132  }
133  itrk.clear();
134  }
135 
136  LogDebug("PixelVertexProducer") << ": Found " << vertexes->size() << " vertexes\n";
137  for (unsigned int i = 0; i < vertexes->size(); ++i) {
138  LogDebug("PixelVertexProducer") << "Vertex number " << i << " has " << (*vertexes)[i].tracksSize()
139  << " tracks with a position of " << (*vertexes)[i].z() << " +- "
140  << std::sqrt((*vertexes)[i].covariance(2, 2));
141  }
142 
143  // legacy logic....
144  if (vertexes->empty() && bsHandle.isValid()) {
145  const reco::BeamSpot &bs = *bsHandle;
146 
147  GlobalError bse(bs.rotatedCovariance3D());
148  if ((bse.cxx() <= 0.) || (bse.cyy() <= 0.) || (bse.czz() <= 0.)) {
150  we(0, 0) = 10000;
151  we(1, 1) = 10000;
152  we(2, 2) = 10000;
153  vertexes->push_back(reco::Vertex(bs.position(), we, 0., 0., 0));
154 
155  edm::LogInfo("PixelVertexProducer") << "No vertices found. Beamspot with invalid errors " << bse.matrix()
156  << "\nWill put Vertex derived from dummy-fake BeamSpot into Event.\n"
157  << (*vertexes)[0].x() << "\n"
158  << (*vertexes)[0].y() << "\n"
159  << (*vertexes)[0].z() << "\n";
160  } else {
161  vertexes->push_back(reco::Vertex(bs.position(), bs.rotatedCovariance3D(), 0., 0., 0));
162 
163  edm::LogInfo("PixelVertexProducer") << "No vertices found. Will put Vertex derived from BeamSpot into Event:\n"
164  << (*vertexes)[0].x() << "\n"
165  << (*vertexes)[0].y() << "\n"
166  << (*vertexes)[0].z() << "\n";
167  }
168  } else if (vertexes->empty() && !bsHandle.isValid()) {
169  edm::LogWarning("PixelVertexProducer") << "No beamspot and no vertex found. No vertex returned.";
170  }
171 
172  iEvent.put(std::move(vertexes));
173 }
float dydz
float dxdz
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:45
assert(be >=bs)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< ZVertexHost > tokenVertex_
edm::EDGetTokenT< reco::BeamSpot > tokenBeamSpot_
T sqrt(T t)
Definition: SSEVec.h:23
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
int nt
Definition: AMPTWrapper.h:42
Log< level::Info, false > LogInfo
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
edm::EDGetTokenT< reco::TrackCollection > tokenTracks_
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ tokenBeamSpot_

edm::EDGetTokenT<reco::BeamSpot> PixelVertexProducerFromSoAAlpaka::tokenBeamSpot_
private

Definition at line 35 of file PixelVertexProducerFromSoAAlpaka.cc.

Referenced by produce().

◆ tokenIndToEdm_

edm::EDGetTokenT<IndToEdm> PixelVertexProducerFromSoAAlpaka::tokenIndToEdm_
private

Definition at line 37 of file PixelVertexProducerFromSoAAlpaka.cc.

Referenced by produce().

◆ tokenTracks_

edm::EDGetTokenT<reco::TrackCollection> PixelVertexProducerFromSoAAlpaka::tokenTracks_
private

Definition at line 36 of file PixelVertexProducerFromSoAAlpaka.cc.

Referenced by produce().

◆ tokenVertex_

edm::EDGetTokenT<ZVertexHost> PixelVertexProducerFromSoAAlpaka::tokenVertex_
private

Definition at line 34 of file PixelVertexProducerFromSoAAlpaka.cc.

Referenced by produce().