CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
HcalCPURecHitsProducer Class Reference
Inheritance diagram for HcalCPURecHitsProducer:
edm::stream::EDProducer< edm::ExternalWork >

Public Member Functions

 HcalCPURecHitsProducer (edm::ParameterSet const &ps)
 
 ~HcalCPURecHitsProducer () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::ExternalWork >
 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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Types

using IProductType = cms::cuda::Product< hcal::RecHitCollection< calo::common::DevStoragePolicy > >
 
using OProductType = hcal::RecHitCollection< calo::common::VecStoragePolicy< calo::common::CUDAHostAllocatorAlias > >
 

Private Member Functions

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

Private Attributes

const bool produceLegacy_
 
const bool produceSoA_
 
const edm::EDPutTokenT< HBHERecHitCollectionrecHitsLegacyTokenOut_
 
const edm::EDGetTokenT< IProductTyperecHitsM0TokenIn_
 
const edm::EDPutTokenT< OProductTyperecHitsM0TokenOut_
 
OProductType tmpRecHits_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::ExternalWork >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 15 of file HcalCPURecHitsProducer.cc.

Member Typedef Documentation

◆ IProductType

Definition at line 30 of file HcalCPURecHitsProducer.cc.

◆ OProductType

Definition at line 33 of file HcalCPURecHitsProducer.cc.

Constructor & Destructor Documentation

◆ HcalCPURecHitsProducer()

HcalCPURecHitsProducer::HcalCPURecHitsProducer ( edm::ParameterSet const &  ps)
explicit

Definition at line 53 of file HcalCPURecHitsProducer.cc.

References edm::ParameterSet::getParameter().

54  : produceSoA_{ps.getParameter<bool>("produceSoA")},
55  produceLegacy_{ps.getParameter<bool>("produceLegacy")},
56  recHitsM0TokenIn_{consumes<IProductType>(ps.getParameter<edm::InputTag>("recHitsM0LabelIn"))},
57  recHitsM0TokenOut_{produceSoA_ ? produces<OProductType>(ps.getParameter<std::string>("recHitsM0LabelOut"))
58  : edm::EDPutTokenT<OProductType>{}}, // empty token if disabled
60  ? produces<HBHERecHitCollection>(ps.getParameter<std::string>("recHitsLegacyLabelOut"))
61  : edm::EDPutTokenT<HBHERecHitCollection>{}} // empty token if disabled
62 {}
const edm::EDPutTokenT< OProductType > recHitsM0TokenOut_
hcal::RecHitCollection< calo::common::VecStoragePolicy< calo::common::CUDAHostAllocatorAlias > > OProductType
const edm::EDGetTokenT< IProductType > recHitsM0TokenIn_
const edm::EDPutTokenT< HBHERecHitCollection > recHitsLegacyTokenOut_
HLT enums.

◆ ~HcalCPURecHitsProducer()

HcalCPURecHitsProducer::~HcalCPURecHitsProducer ( )
overridedefault

Member Function Documentation

◆ acquire()

void HcalCPURecHitsProducer::acquire ( edm::Event const &  event,
edm::EventSetup const &  setup,
edm::WaitingTaskWithArenaHolder  taskHolder 
)
overrideprivate

Definition at line 64 of file HcalCPURecHitsProducer.cc.

References hcal::RecHitCollection< StoragePolicy >::chi2, gather_cfg::cout, cudaCheck, mps_fire::dest, hcal::RecHitCollection< StoragePolicy >::did, hcal::RecHitCollection< StoragePolicy >::energy, hcal::RecHitCollection< StoragePolicy >::energyM0, eostools::move(), FastTrackerRecHitMaskProducer_cfi::recHits, recHitsM0TokenIn_, hcal::RecHitCollection< StoragePolicy >::resize(), TrackRefitter_38T_cff::src, hcal::RecHitCollection< StoragePolicy >::timeM0, tmpRecHits_, and relativeConstraints::value.

66  {
67  // retrieve data/ctx
68  auto const& recHitsProduct = event.get(recHitsM0TokenIn_);
69  cms::cuda::ScopedContextAcquire ctx{recHitsProduct, std::move(taskHolder)};
70  auto const& recHits = ctx.get(recHitsProduct);
71 
72  // resize tmp buffers
74 
75 #ifdef HCAL_MAHI_CPUDEBUG
76  std::cout << "num rec Hits = " << recHits.size << std::endl;
77 #endif
78 
79  // do not try to copy the rechits if they are empty
80  if (recHits.size == 0) {
81  return;
82  }
83 
84  auto lambdaToTransfer = [&ctx](auto& dest, auto* src) {
85  using vector_type = typename std::remove_reference<decltype(dest)>::type;
86  using src_data_type = typename std::remove_pointer<decltype(src)>::type;
87  using type = typename vector_type::value_type;
88  static_assert(std::is_same<src_data_type, type>::value && "Dest and Src data types do not match");
89  cudaCheck(cudaMemcpyAsync(dest.data(), src, dest.size() * sizeof(type), cudaMemcpyDeviceToHost, ctx.stream()));
90  };
91 
92  lambdaToTransfer(tmpRecHits_.energy, recHits.energy.get());
93  lambdaToTransfer(tmpRecHits_.chi2, recHits.chi2.get());
94  lambdaToTransfer(tmpRecHits_.energyM0, recHits.energyM0.get());
95  lambdaToTransfer(tmpRecHits_.timeM0, recHits.timeM0.get());
96  lambdaToTransfer(tmpRecHits_.did, recHits.did.get());
97 }
StoragePolicy::template StorageSelector< float >::type chi2
StoragePolicy::template StorageSelector< uint32_t >::type did
const edm::EDGetTokenT< IProductType > recHitsM0TokenIn_
StoragePolicy::template StorageSelector< float >::type energy
std::enable_if< std::is_same< U, ::calo::common::tags::Vec >::value, void >::type resize(size_t size)
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
StoragePolicy::template StorageSelector< float >::type timeM0
StoragePolicy::template StorageSelector< float >::type energyM0
def move(src, dest)
Definition: eostools.py:511

◆ fillDescriptions()

void HcalCPURecHitsProducer::fillDescriptions ( edm::ConfigurationDescriptions confDesc)
static

Definition at line 41 of file HcalCPURecHitsProducer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

41  {
43 
44  desc.add<edm::InputTag>("recHitsM0LabelIn", edm::InputTag{"hbheRecHitProducerGPU"});
45  desc.add<std::string>("recHitsM0LabelOut", "");
46  desc.add<std::string>("recHitsLegacyLabelOut", "");
47  desc.add<bool>("produceSoA", true);
48  desc.add<bool>("produceLegacy", true);
49 
50  confDesc.addWithDefaultLabel(desc);
51 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

void HcalCPURecHitsProducer::produce ( edm::Event event,
edm::EventSetup const &  setup 
)
overrideprivate

Definition at line 99 of file HcalCPURecHitsProducer.cc.

References hcal::RecHitCollection< StoragePolicy >::chi2, hcal::RecHitCollection< StoragePolicy >::did, hcal::RecHitCollection< StoragePolicy >::energy, hcal::RecHitCollection< StoragePolicy >::energyM0, mps_fire::i, eostools::move(), produceLegacy_, produceSoA_, recHitsLegacyTokenOut_, recHitsM0TokenOut_, hcal::RecHitCollection< StoragePolicy >::resize(), and tmpRecHits_.

99  {
100  if (produceLegacy_) {
101  // populate the legacy collection
102  auto recHitsLegacy = std::make_unique<HBHERecHitCollection>();
103  // did not set size with ctor as there is no setter for did
104  recHitsLegacy->reserve(tmpRecHits_.did.size());
105  for (uint32_t i = 0; i < tmpRecHits_.did.size(); i++) {
106  // skip bad channels
107  if (tmpRecHits_.chi2[i] < 0)
108  continue;
109 
110  // build a legacy rechit with the computed detid and MAHI energy
111  recHitsLegacy->emplace_back(HcalDetId{tmpRecHits_.did[i]},
113  0 // timeRising
114  );
115  // update the legacy rechit with the Chi2 and M0 values
116  recHitsLegacy->back().setChiSquared(tmpRecHits_.chi2[i]);
117  recHitsLegacy->back().setRawEnergy(tmpRecHits_.energyM0[i]);
118  }
119 
120  // put the legacy collection
121  event.put(recHitsLegacyTokenOut_, std::move(recHitsLegacy));
122  }
123 
124  if (produceSoA_) {
125  // put the SoA collection
126  event.emplace(recHitsM0TokenOut_, std::move(tmpRecHits_));
127  }
128  // clear the temporary collection for the next event
129  tmpRecHits_.resize(0);
130 }
const edm::EDPutTokenT< OProductType > recHitsM0TokenOut_
StoragePolicy::template StorageSelector< float >::type chi2
StoragePolicy::template StorageSelector< uint32_t >::type did
StoragePolicy::template StorageSelector< float >::type energy
const edm::EDPutTokenT< HBHERecHitCollection > recHitsLegacyTokenOut_
std::enable_if< std::is_same< U, ::calo::common::tags::Vec >::value, void >::type resize(size_t size)
StoragePolicy::template StorageSelector< float >::type energyM0
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ produceLegacy_

const bool HcalCPURecHitsProducer::produceLegacy_
private

Definition at line 28 of file HcalCPURecHitsProducer.cc.

Referenced by produce().

◆ produceSoA_

const bool HcalCPURecHitsProducer::produceSoA_
private

Definition at line 27 of file HcalCPURecHitsProducer.cc.

Referenced by produce().

◆ recHitsLegacyTokenOut_

const edm::EDPutTokenT<HBHERecHitCollection> HcalCPURecHitsProducer::recHitsLegacyTokenOut_
private

Definition at line 35 of file HcalCPURecHitsProducer.cc.

Referenced by produce().

◆ recHitsM0TokenIn_

const edm::EDGetTokenT<IProductType> HcalCPURecHitsProducer::recHitsM0TokenIn_
private

Definition at line 31 of file HcalCPURecHitsProducer.cc.

Referenced by acquire().

◆ recHitsM0TokenOut_

const edm::EDPutTokenT<OProductType> HcalCPURecHitsProducer::recHitsM0TokenOut_
private

Definition at line 34 of file HcalCPURecHitsProducer.cc.

Referenced by produce().

◆ tmpRecHits_

OProductType HcalCPURecHitsProducer::tmpRecHits_
private

Definition at line 38 of file HcalCPURecHitsProducer.cc.

Referenced by acquire(), and produce().