CMS 3D CMS Logo

HcalCPUDigisProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 
14 
15 class HcalCPUDigisProducer : public edm::stream::EDProducer<edm::ExternalWork> {
16 public:
17  explicit HcalCPUDigisProducer(edm::ParameterSet const& ps);
18  ~HcalCPUDigisProducer() override;
20 
21 private:
23  void produce(edm::Event&, edm::EventSetup const&) override;
24 
25 private:
32 
33  using OProductTypef01 =
36  using OProductTypef5 =
39  using OProductTypef3 =
42 
43  // needed to pass data from acquire to produce
47 };
48 
51 
52  desc.add<edm::InputTag>("digisLabelF01HEIn", edm::InputTag{"hcalRawToDigiGPU", "f01HEDigisGPU"});
53  desc.add<edm::InputTag>("digisLabelF5HBIn", edm::InputTag{"hcalRawToDigiGPU", "f5HBDigisGPU"});
54  desc.add<edm::InputTag>("digisLabelF3HBIn", edm::InputTag{"hcalRawToDigiGPU", "f3HBDigisGPU"});
55  desc.add<std::string>("digisLabelF01HEOut", "f01HEDigis");
56  desc.add<std::string>("digisLabelF5HBOut", "f5HBDigis");
57  desc.add<std::string>("digisLabelF3HBOut", "f3HBDigis");
58 
59  confDesc.addWithDefaultLabel(desc);
60 }
61 
63  : digisF01HETokenIn_{consumes<IProductTypef01>(ps.getParameter<edm::InputTag>("digisLabelF01HEIn"))},
64  digisF5HBTokenIn_{consumes<IProductTypef5>(ps.getParameter<edm::InputTag>("digisLabelF5HBIn"))},
65  digisF3HBTokenIn_{consumes<IProductTypef3>(ps.getParameter<edm::InputTag>("digisLabelF3HBIn"))},
66  digisF01HETokenOut_{produces<OProductTypef01>(ps.getParameter<std::string>("digisLabelF01HEOut"))},
67  digisF5HBTokenOut_{produces<OProductTypef5>(ps.getParameter<std::string>("digisLabelF5HBOut"))},
68  digisF3HBTokenOut_{produces<OProductTypef3>(ps.getParameter<std::string>("digisLabelF3HBOut"))} {}
69 
71 
73  edm::EventSetup const& setup,
75  // retrieve data/ctx
76  auto const& f01HEProduct = event.get(digisF01HETokenIn_);
77  auto const& f5HBProduct = event.get(digisF5HBTokenIn_);
78  auto const& f3HBProduct = event.get(digisF3HBTokenIn_);
79  cms::cuda::ScopedContextAcquire ctx{f01HEProduct, std::move(taskHolder)};
80  auto const& f01HEDigis = ctx.get(f01HEProduct);
81  auto const& f5HBDigis = ctx.get(f5HBProduct);
82  auto const& f3HBDigis = ctx.get(f3HBProduct);
83 
84  // resize out tmp buffers
85  digisf01HE_.stride = f01HEDigis.stride;
86  digisf5HB_.stride = f5HBDigis.stride;
87  digisf3HB_.stride = f3HBDigis.stride;
88  digisf01HE_.resize(f01HEDigis.size);
89  digisf5HB_.resize(f5HBDigis.size);
90  digisf3HB_.resize(f3HBDigis.size);
91 
92  auto lambdaToTransfer = [&ctx](auto& dest, auto* src) {
93  using vector_type = typename std::remove_reference<decltype(dest)>::type;
94  using type = typename vector_type::value_type;
95  using src_data_type = typename std::remove_pointer<decltype(src)>::type;
96  static_assert(std::is_same<src_data_type, type>::value && "Dest and Src data types do not match");
97  cudaCheck(cudaMemcpyAsync(dest.data(), src, dest.size() * sizeof(type), cudaMemcpyDeviceToHost, ctx.stream()));
98  };
99 
100  lambdaToTransfer(digisf01HE_.data, f01HEDigis.data.get());
101  lambdaToTransfer(digisf01HE_.ids, f01HEDigis.ids.get());
102 
103  lambdaToTransfer(digisf5HB_.data, f5HBDigis.data.get());
104  lambdaToTransfer(digisf5HB_.ids, f5HBDigis.ids.get());
105  lambdaToTransfer(digisf5HB_.npresamples, f5HBDigis.npresamples.get());
106 
107  lambdaToTransfer(digisf3HB_.data, f3HBDigis.data.get());
108  lambdaToTransfer(digisf3HB_.ids, f3HBDigis.ids.get());
109 }
110 
112  event.emplace(digisF01HETokenOut_, std::move(digisf01HE_));
113  event.emplace(digisF5HBTokenOut_, std::move(digisf5HB_));
114  event.emplace(digisF3HBTokenOut_, std::move(digisf3HB_));
115 }
116 
HcalCPUDigisProducer::HcalCPUDigisProducer
HcalCPUDigisProducer(edm::ParameterSet const &ps)
Definition: HcalCPUDigisProducer.cc:62
HostAllocator.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm::EDPutTokenT
Definition: EDPutToken.h:33
HcalCPUDigisProducer::digisF3HBTokenOut_
edm::EDPutTokenT< OProductTypef3 > digisF3HBTokenOut_
Definition: HcalCPUDigisProducer.cc:41
HcalCPUDigisProducer::digisf5HB_
OProductTypef5 digisf5HB_
Definition: HcalCPUDigisProducer.cc:45
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HcalCPUDigisProducer::digisF01HETokenIn_
edm::EDGetTokenT< IProductTypef01 > digisF01HETokenIn_
Definition: HcalCPUDigisProducer.cc:27
hcal::DigiCollectionBase::resize
std::enable_if< std::is_same< T, ::calo::common::tags::Vec >::value, void >::type resize(std::size_t size)
Definition: DigiCollection.h:98
EDProducer.h
DigiCollection.h
HcalCPUDigisProducer::~HcalCPUDigisProducer
~HcalCPUDigisProducer() override
Definition: HcalCPUDigisProducer.cc:70
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
HcalCPUDigisProducer::acquire
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
Definition: HcalCPUDigisProducer.cc:72
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
MakerMacros.h
HcalCPUDigisProducer::digisf3HB_
OProductTypef3 digisf3HB_
Definition: HcalCPUDigisProducer.cc:46
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HcalDigiCollections.h
hcal::DigiCollection< hcal::Flavor1, calo::common::VecStoragePolicy< calo::common::CUDAHostAllocatorAlias > >
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
Event.h
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
HcalCPUDigisProducer
Definition: HcalCPUDigisProducer.cc:15
HcalCPUDigisProducer::digisF01HETokenOut_
edm::EDPutTokenT< OProductTypef01 > digisF01HETokenOut_
Definition: HcalCPUDigisProducer.cc:35
FEDRawDataCollection.h
cudaCheck.h
HcalCPUDigisProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: HcalCPUDigisProducer.cc:49
edm::stream::EDProducer
Definition: EDProducer.h:38
HcalCPUDigisProducer::digisF3HBTokenIn_
edm::EDGetTokenT< IProductTypef3 > digisF3HBTokenIn_
Definition: HcalCPUDigisProducer.cc:31
edm::EventSetup
Definition: EventSetup.h:58
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
HcalCPUDigisProducer::digisF5HBTokenIn_
edm::EDGetTokenT< IProductTypef5 > digisF5HBTokenIn_
Definition: HcalCPUDigisProducer.cc:29
hcal::DigiCollectionBase::stride
uint32_t stride
Definition: DigiCollection.h:117
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
hcal::DigiCollectionBase::data
StoragePolicy::template StorageSelector< uint16_t >::type data
Definition: DigiCollection.h:116
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:62
relativeConstraints.value
value
Definition: relativeConstraints.py:53
cms::cuda::Product
Definition: Product.h:34
ScopedContext.h
HcalCPUDigisProducer::produce
void produce(edm::Event &, edm::EventSetup const &) override
Definition: HcalCPUDigisProducer.cc:111
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalCPUDigisProducer::digisf01HE_
OProductTypef01 digisf01HE_
Definition: HcalCPUDigisProducer.cc:44
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
hcal::DigiCollectionBase::ids
StoragePolicy::template StorageSelector< uint32_t >::type ids
Definition: DigiCollection.h:115
edm::InputTag
Definition: InputTag.h:15
HcalCPUDigisProducer::digisF5HBTokenOut_
edm::EDPutTokenT< OProductTypef5 > digisF5HBTokenOut_
Definition: HcalCPUDigisProducer.cc:38
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87
mps_fire.dest
dest
Definition: mps_fire.py:179