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.

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 {}

References edm::ParameterSet::getParameter().

◆ ~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.

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 }

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.

◆ fillDescriptions()

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

Definition at line 41 of file HcalCPURecHitsProducer.cc.

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 }

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

◆ produce()

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

Definition at line 99 of file HcalCPURecHitsProducer.cc.

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  recHitsLegacy->emplace_back(HcalDetId{tmpRecHits_.did[i]},
108  0 // timeRising
109  );
110 
111  // update newly pushed guy
112  (*recHitsLegacy)[i].setChiSquared(tmpRecHits_.chi2[i]);
113  (*recHitsLegacy)[i].setRawEnergy(tmpRecHits_.energyM0[i]);
114  }
115 
116  // put the legacy collection
117  event.put(recHitsLegacyTokenOut_, std::move(recHitsLegacy));
118  }
119 
120  if (produceSoA_) {
121  // put the SoA collection
122  event.emplace(recHitsM0TokenOut_, std::move(tmpRecHits_));
123  }
124  // clear the temporary collection for the next event
125  tmpRecHits_.resize(0);
126 }

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_.

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().

hcal::RecHitCollection::timeM0
StoragePolicy::template StorageSelector< float >::type timeM0
Definition: RecHitCollection.h:23
hcal::RecHitCollection::resize
std::enable_if< std::is_same< U, ::calo::common::tags::Vec >::value, void >::type resize(size_t size)
Definition: RecHitCollection.h:27
mps_fire.i
i
Definition: mps_fire.py:428
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HcalCPURecHitsProducer::recHitsLegacyTokenOut_
const edm::EDPutTokenT< HBHERecHitCollection > recHitsLegacyTokenOut_
Definition: HcalCPURecHitsProducer.cc:35
edm::SortedCollection
Definition: SortedCollection.h:49
HcalCPURecHitsProducer::produceLegacy_
const bool produceLegacy_
Definition: HcalCPURecHitsProducer.cc:28
HcalCPURecHitsProducer::tmpRecHits_
OProductType tmpRecHits_
Definition: HcalCPURecHitsProducer.cc:38
HcalCPURecHitsProducer::OProductType
hcal::RecHitCollection< calo::common::VecStoragePolicy< calo::common::CUDAHostAllocatorAlias > > OProductType
Definition: HcalCPURecHitsProducer.cc:33
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
HcalCPURecHitsProducer::recHitsM0TokenIn_
const edm::EDGetTokenT< IProductType > recHitsM0TokenIn_
Definition: HcalCPURecHitsProducer.cc:31
HcalDetId
Definition: HcalDetId.h:12
HcalCPURecHitsProducer::recHitsM0TokenOut_
const edm::EDPutTokenT< OProductType > recHitsM0TokenOut_
Definition: HcalCPURecHitsProducer.cc:34
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
hcal::RecHitCollection::chi2
StoragePolicy::template StorageSelector< float >::type chi2
Definition: RecHitCollection.h:21
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::cuda::ScopedContextAcquire
Definition: ScopedContext.h:101
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
relativeConstraints.value
value
Definition: relativeConstraints.py:53
hcal::RecHitCollection::energyM0
StoragePolicy::template StorageSelector< float >::type energyM0
Definition: RecHitCollection.h:22
hcal::RecHitCollection::did
StoragePolicy::template StorageSelector< uint32_t >::type did
Definition: RecHitCollection.h:24
edm::InputTag
Definition: InputTag.h:15
hcal::RecHitCollection::energy
StoragePolicy::template StorageSelector< float >::type energy
Definition: RecHitCollection.h:20
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87
mps_fire.dest
dest
Definition: mps_fire.py:179
HcalCPURecHitsProducer::produceSoA_
const bool produceSoA_
Definition: HcalCPURecHitsProducer.cc:27