CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiPixelRecHitSoAFromLegacy Class Reference
Inheritance diagram for SiPixelRecHitSoAFromLegacy:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

using HitModuleStart = std::array< uint32_t, gpuClustering::maxNumModules+1 >
 
using HMSstorage = HostProduct< uint32_t[]>
 
- 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
 

Public Member Functions

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

const edm::EDGetTokenT
< reco::BeamSpot
bsGetToken_
 
const edm::EDGetTokenT
< SiPixelClusterCollectionNew
clusterToken_
 
const bool convert2Legacy_
 
const edm::ESGetToken
< PixelClusterParameterEstimator,
TkPixelCPERecord
cpeToken_
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
geomToken_
 
const edm::EDPutTokenT
< TrackingRecHit2DCPU
tokenHit_
 
const edm::EDPutTokenT
< HMSstorage
tokenModuleStart_
 

Additional Inherited Members

- Protected Member Functions inherited from edm::ProducerBase
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< B > consumes (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 () noexcept
 
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...
 
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 29 of file SiPixelRecHitSoAFromLegacy.cc.

Member Typedef Documentation

Definition at line 36 of file SiPixelRecHitSoAFromLegacy.cc.

Definition at line 37 of file SiPixelRecHitSoAFromLegacy.cc.

Constructor & Destructor Documentation

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

Definition at line 51 of file SiPixelRecHitSoAFromLegacy.cc.

References edm::ParameterSet::getParameter().

54  bsGetToken_{consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))},
55  clusterToken_{consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<edm::InputTag>("src"))},
56  tokenHit_{produces<TrackingRecHit2DCPU>()},
57  tokenModuleStart_{produces<HMSstorage>()},
58  convert2Legacy_(iConfig.getParameter<bool>("convertToLegacy")) {
59  if (convert2Legacy_)
60  produces<SiPixelRecHitCollectionNew>();
61 }
const edm::EDGetTokenT< reco::BeamSpot > bsGetToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > cpeToken_
const edm::EDPutTokenT< HMSstorage > tokenModuleStart_
const edm::EDPutTokenT< TrackingRecHit2DCPU > tokenHit_
const edm::EDGetTokenT< SiPixelClusterCollectionNew > clusterToken_
SiPixelRecHitSoAFromLegacy::~SiPixelRecHitSoAFromLegacy ( )
overridedefault

Member Function Documentation

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

Definition at line 63 of file SiPixelRecHitSoAFromLegacy.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

63  {
65 
66  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
67  desc.add<edm::InputTag>("src", edm::InputTag("siPixelClustersPreSplitting"));
68  desc.add<std::string>("CPE", "PixelCPEFast");
69  desc.add<bool>("convertToLegacy", false);
70  descriptions.addWithDefaultLabel(desc);
71 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void SiPixelRecHitSoAFromLegacy::produce ( edm::StreamID  streamID,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 73 of file SiPixelRecHitSoAFromLegacy.cc.

References gpuClustering::adc, cms::cuda::assert(), cms::cuda::bs, bsGetToken_, clusterToken_, convert2Legacy_, cpeToken_, Exception, geomToken_, edm::Event::get(), edm::Event::getByToken(), edm::EventSetup::getData(), h, mps_fire::i, TrackerGeometry::idToDetUnit(), GeomDet::index(), input, gpuClustering::invalidModuleId, LogDebug, edmNew::makeRefTo(), gpuClustering::maxHitsInModule(), gpuClustering::maxNumModules, eostools::move(), dqmiodumpmetadata::n, phase1PixelTopology::numberOfLayers, convertSQLitetoXML_cfg::output, gpuVertexFinder::printf(), edmNew::DetSetVector< T >::FastFiller::push_back(), edm::Event::put(), tokenModuleStart_, BeamSpotPOD::x, reco::BeamSpot::x0(), BeamSpotPOD::y, reco::BeamSpot::y0(), BeamSpotPOD::z, and reco::BeamSpot::z0().

73  {
74  const TrackerGeometry* geom_ = &es.getData(geomToken_);
75  PixelCPEFast const* fcpe = dynamic_cast<const PixelCPEFast*>(&es.getData(cpeToken_));
76  if (not fcpe) {
77  throw cms::Exception("Configuration") << "SiPixelRecHitSoAFromLegacy can only use a CPE of type PixelCPEFast";
78  }
79  auto const& cpeView = fcpe->getCPUProduct();
80 
81  const reco::BeamSpot& bs = iEvent.get(bsGetToken_);
82 
83  BeamSpotPOD bsHost;
84  bsHost.x = bs.x0();
85  bsHost.y = bs.y0();
86  bsHost.z = bs.z0();
87 
89  iEvent.getByToken(clusterToken_, hclusters);
90  auto const& input = *hclusters;
91 
92  // allocate a buffer for the indices of the clusters
93  auto hmsp = std::make_unique<uint32_t[]>(gpuClustering::maxNumModules + 1);
94  // hitsModuleStart is a non-owning pointer to the buffer
95  auto hitsModuleStart = hmsp.get();
96  // wrap the buffer in a HostProduct
97  auto hms = std::make_unique<HMSstorage>(std::move(hmsp));
98  // move the HostProduct to the Event, without reallocating the buffer or affecting hitsModuleStart
99  iEvent.put(tokenModuleStart_, std::move(hms));
100 
101  // legacy output
102  auto legacyOutput = std::make_unique<SiPixelRecHitCollectionNew>();
103 
104  // storage
105  std::vector<uint16_t> xx;
106  std::vector<uint16_t> yy;
107  std::vector<uint16_t> adc;
108  std::vector<uint16_t> moduleInd;
109  std::vector<int32_t> clus;
110 
111  std::vector<edm::Ref<edmNew::DetSetVector<SiPixelCluster>, SiPixelCluster>> clusterRef;
112 
113  constexpr uint32_t maxHitsInModule = gpuClustering::maxHitsInModule();
114 
115  HitModuleStart moduleStart_; // index of the first pixel of each module
116  HitModuleStart clusInModule_;
117  memset(&clusInModule_, 0, sizeof(HitModuleStart)); // needed??
118  assert(gpuClustering::maxNumModules + 1 == clusInModule_.size());
119  assert(0 == clusInModule_[gpuClustering::maxNumModules]);
120  uint32_t moduleId_;
121  moduleStart_[1] = 0; // we run sequentially....
122 
124  moduleStart_.data(), clusInModule_.data(), &moduleId_, hitsModuleStart};
125 
126  // fill cluster arrays
127  int numberOfClusters = 0;
128  for (auto const& dsv : input) {
129  unsigned int detid = dsv.detId();
130  DetId detIdObject(detid);
131  const GeomDetUnit* genericDet = geom_->idToDetUnit(detIdObject);
132  auto gind = genericDet->index();
134  auto const nclus = dsv.size();
135  clusInModule_[gind] = nclus;
136  numberOfClusters += nclus;
137  }
138  hitsModuleStart[0] = 0;
139  for (int i = 1, n = clusInModule_.size(); i < n; ++i)
140  hitsModuleStart[i] = hitsModuleStart[i - 1] + clusInModule_[i - 1];
141  assert(numberOfClusters == int(hitsModuleStart[gpuClustering::maxNumModules]));
142 
143  // output SoA
144  // element 96 is the start of BPIX2 (i.e. the number of clusters in BPIX1)
145  auto output =
146  std::make_unique<TrackingRecHit2DCPU>(numberOfClusters, hitsModuleStart[96], &cpeView, hitsModuleStart, nullptr);
147 
148  if (0 == numberOfClusters) {
149  iEvent.put(std::move(output));
150  if (convert2Legacy_)
151  iEvent.put(std::move(legacyOutput));
152  return;
153  }
154 
155  if (convert2Legacy_)
156  legacyOutput->reserve(gpuClustering::maxNumModules, numberOfClusters);
157 
158  int numberOfDetUnits = 0;
159  int numberOfHits = 0;
160  for (auto const& dsv : input) {
161  numberOfDetUnits++;
162  unsigned int detid = dsv.detId();
163  DetId detIdObject(detid);
164  const GeomDetUnit* genericDet = geom_->idToDetUnit(detIdObject);
165  auto const gind = genericDet->index();
167  const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
168  assert(pixDet);
169  auto const nclus = dsv.size();
170  assert(clusInModule_[gind] == nclus);
171  if (0 == nclus)
172  continue; // is this really possible?
173 
174  auto const fc = hitsModuleStart[gind];
175  auto const lc = hitsModuleStart[gind + 1];
176  assert(lc > fc);
177  LogDebug("SiPixelRecHitSoAFromLegacy") << "in det " << gind << ": conv " << nclus << " hits from " << dsv.size()
178  << " legacy clusters" << ' ' << fc << ',' << lc;
179  assert((lc - fc) == nclus);
180  if (nclus > maxHitsInModule)
181  printf(
182  "WARNING: too many clusters %d in Module %d. Only first %d Hits converted\n", nclus, gind, maxHitsInModule);
183 
184  // fill digis
185  xx.clear();
186  yy.clear();
187  adc.clear();
188  moduleInd.clear();
189  clus.clear();
190  clusterRef.clear();
191  moduleId_ = gind;
192  uint32_t ic = 0;
193  uint32_t ndigi = 0;
194  for (auto const& clust : dsv) {
195  assert(clust.size() > 0);
196  for (int i = 0, nd = clust.size(); i < nd; ++i) {
197  auto px = clust.pixel(i);
198  xx.push_back(px.x);
199  yy.push_back(px.y);
200  adc.push_back(px.adc);
201  moduleInd.push_back(gind);
202  clus.push_back(ic);
203  ++ndigi;
204  }
205  assert(clust.originalId() == ic); // make sure hits and clus are in sync
206  if (convert2Legacy_)
207  clusterRef.emplace_back(edmNew::makeRefTo(hclusters, &clust));
208  ic++;
209  }
210  assert(nclus == ic);
211  assert(clus.size() == ndigi);
212  numberOfHits += nclus;
213  // filled creates view
214  SiPixelDigisCUDA::DeviceConstView digiView{xx.data(), yy.data(), adc.data(), moduleInd.data(), clus.data()};
215  assert(digiView.adc(0) != 0);
216  // we run on blockId.x==0
217  gpuPixelRecHits::getHits(&cpeView, &bsHost, &digiView, ndigi, &clusterView, output->view());
218  for (auto h = fc; h < lc; ++h)
219  if (h - fc < maxHitsInModule)
220  assert(gind == output->view()->detectorIndex(h));
221  else
222  assert(gpuClustering::invalidModuleId == output->view()->detectorIndex(h));
223  if (convert2Legacy_) {
224  SiPixelRecHitCollectionNew::FastFiller recHitsOnDetUnit(*legacyOutput, detid);
225  for (auto h = fc; h < lc; ++h) {
226  auto ih = h - fc;
227  if (ih >= maxHitsInModule)
228  break;
229  assert(ih < clusterRef.size());
230  LocalPoint lp(output->view()->xLocal(h), output->view()->yLocal(h));
231  LocalError le(output->view()->xerrLocal(h), 0, output->view()->yerrLocal(h));
233  SiPixelRecHit hit(lp, le, rqw, *genericDet, clusterRef[ih]);
234  recHitsOnDetUnit.push_back(hit);
235  }
236  }
237  }
238  assert(numberOfHits == numberOfClusters);
239 
240  // fill data structure to support CA
241  for (auto i = 0U; i < phase1PixelTopology::numberOfLayers + 1; ++i) {
242  output->hitsLayerStart()[i] = hitsModuleStart[cpeView.layerGeometry().layerStart[i]];
243  }
244  cms::cuda::fillManyFromVector(output->phiBinner(),
246  output->iphi(),
247  output->hitsLayerStart(),
248  numberOfHits,
249  256,
250  output->phiBinnerStorage());
251 
252  LogDebug("SiPixelRecHitSoAFromLegacy") << "created HitSoa for " << numberOfClusters << " clusters in "
253  << numberOfDetUnits << " Dets";
254  iEvent.put(std::move(output));
255  if (convert2Legacy_)
256  iEvent.put(std::move(legacyOutput));
257 }
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
double z0() const
z coordinate
Definition: BeamSpot.h:65
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
constexpr uint32_t numberOfLayers
constexpr uint32_t maxHitsInModule()
const edm::EDGetTokenT< reco::BeamSpot > bsGetToken_
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
def move
Definition: eostools.py:511
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
constexpr uint16_t maxNumModules
int index() const
Definition: GeomDet.h:83
constexpr uint16_t invalidModuleId
Definition: DetId.h:17
std::array< uint32_t, gpuClustering::maxNumModules+1 > HitModuleStart
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > cpeToken_
Pixel cluster – collection of neighboring pixels above threshold.
const edm::EDPutTokenT< HMSstorage > tokenModuleStart_
double y0() const
y coordinate
Definition: BeamSpot.h:63
const edm::EDGetTokenT< SiPixelClusterCollectionNew > clusterToken_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Our base class.
Definition: SiPixelRecHit.h:23
#define LogDebug(id)
double x0() const
x coordinate
Definition: BeamSpot.h:61

Member Data Documentation

const edm::EDGetTokenT<reco::BeamSpot> SiPixelRecHitSoAFromLegacy::bsGetToken_
private

Definition at line 44 of file SiPixelRecHitSoAFromLegacy.cc.

Referenced by produce().

const edm::EDGetTokenT<SiPixelClusterCollectionNew> SiPixelRecHitSoAFromLegacy::clusterToken_
private

Definition at line 45 of file SiPixelRecHitSoAFromLegacy.cc.

Referenced by produce().

const bool SiPixelRecHitSoAFromLegacy::convert2Legacy_
private

Definition at line 48 of file SiPixelRecHitSoAFromLegacy.cc.

Referenced by produce().

const edm::ESGetToken<PixelClusterParameterEstimator, TkPixelCPERecord> SiPixelRecHitSoAFromLegacy::cpeToken_
private

Definition at line 43 of file SiPixelRecHitSoAFromLegacy.cc.

Referenced by produce().

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiPixelRecHitSoAFromLegacy::geomToken_
private

Definition at line 42 of file SiPixelRecHitSoAFromLegacy.cc.

Referenced by produce().

const edm::EDPutTokenT<TrackingRecHit2DCPU> SiPixelRecHitSoAFromLegacy::tokenHit_
private

Definition at line 46 of file SiPixelRecHitSoAFromLegacy.cc.

const edm::EDPutTokenT<HMSstorage> SiPixelRecHitSoAFromLegacy::tokenModuleStart_
private

Definition at line 47 of file SiPixelRecHitSoAFromLegacy.cc.

Referenced by produce().