CMS 3D CMS Logo

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

Public Types

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

 PixelVertexProducerFromSoA (const edm::ParameterSet &iConfig)
 
 ~PixelVertexProducerFromSoA () 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 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
 
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::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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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< ZVertexHeterogeneoustokenVertex_
 

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

Member Typedef Documentation

◆ IndToEdm

using PixelVertexProducerFromSoA::IndToEdm = std::vector<uint16_t>

Definition at line 28 of file PixelVertexProducerFromSoA.cc.

Constructor & Destructor Documentation

◆ PixelVertexProducerFromSoA()

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

Definition at line 44 of file PixelVertexProducerFromSoA.cc.

45  : tokenVertex_(consumes<ZVertexHeterogeneous>(conf.getParameter<edm::InputTag>("src"))),
46  tokenBeamSpot_(consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("beamSpot"))),
47  tokenTracks_(consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("TrackCollection"))),
48  tokenIndToEdm_(consumes<IndToEdm>(conf.getParameter<edm::InputTag>("TrackCollection"))) {
49  produces<reco::VertexCollection>();
50 }
edm::EDGetTokenT< ZVertexHeterogeneous > tokenVertex_
edm::EDGetTokenT< reco::BeamSpot > tokenBeamSpot_
edm::EDGetTokenT< reco::TrackCollection > tokenTracks_
edm::EDGetTokenT< IndToEdm > tokenIndToEdm_

◆ ~PixelVertexProducerFromSoA()

PixelVertexProducerFromSoA::~PixelVertexProducerFromSoA ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 52 of file PixelVertexProducerFromSoA.cc.

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

52  {
54 
55  desc.add<edm::InputTag>("TrackCollection", edm::InputTag("pixelTracks"));
56  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
57  desc.add<edm::InputTag>("src", edm::InputTag("pixelVerticesSoA"));
58 
59  descriptions.add("pixelVertexFromSoA", desc);
60 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 62 of file PixelVertexProducerFromSoA.cc.

References cms::cuda::assert(), cms::cuda::bs, ZVertexSoA::chi2, gather_cfg::cout, dxdz, dydz, submitPVResolutionJobs::err, mps_fire::i, ZVertexSoA::idv, iEvent, dqmiolumiharvest::j, dqmdumpme::k, LogDebug, eostools::move(), ZVertexSoA::ndof, nt, ZVertexSoA::nvFinal, gpuVertexFinder::soa, ZVertexSoA::sortInd, mathSSE::sqrt(), tokenBeamSpot_, tokenIndToEdm_, tokenTracks_, tokenVertex_, mitigatedMETSequence_cff::U, findQualityFiles::v, jetsAK4_CHS_cff::vertexes, ZVertexSoA::wv, x, y, z, HLTMuonOfflineAnalyzer_cfi::z0, and ZVertexSoA::zv.

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

Member Data Documentation

◆ tokenBeamSpot_

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

Definition at line 39 of file PixelVertexProducerFromSoA.cc.

Referenced by produce().

◆ tokenIndToEdm_

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

Definition at line 41 of file PixelVertexProducerFromSoA.cc.

Referenced by produce().

◆ tokenTracks_

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

Definition at line 40 of file PixelVertexProducerFromSoA.cc.

Referenced by produce().

◆ tokenVertex_

edm::EDGetTokenT<ZVertexHeterogeneous> PixelVertexProducerFromSoA::tokenVertex_
private

Definition at line 38 of file PixelVertexProducerFromSoA.cc.

Referenced by produce().