Skip to content

Commit

Permalink
Added isPhase1 for amplitudeError issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSandever committed Apr 29, 2022
1 parent 908045a commit 887c410
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class EcalCPUUncalibRecHitProducer : public edm::stream::EDProducer<edm::Externa
void produce(edm::Event&, edm::EventSetup const&) override;

private:
bool produceEE_;
bool isPhase1_;
using InputProduct = cms::cuda::Product<ecal::UncalibratedRecHit<calo::common::DevStoragePolicy>>;
edm::EDGetTokenT<InputProduct> recHitsInEBToken_, recHitsInEEToken_;
using OutputProduct = ecal::UncalibratedRecHit<calo::common::VecStoragePolicy<calo::common::CUDAHostAllocatorAlias>>;
Expand All @@ -44,7 +44,7 @@ void EcalCPUUncalibRecHitProducer::fillDescriptions(edm::ConfigurationDescriptio
desc.add<std::string>("recHitsOutLabelEB", "EcalUncalibRecHitsEB");

desc.add<bool>("containsTimingInformation", false);
desc.add<bool>("produceEE", true);
desc.add<bool>("isPhase1", true);

desc.add<edm::InputTag>("recHitsInLabelEE", edm::InputTag{"ecalUncalibRecHitProducerGPU", "EcalUncalibRecHitsEE"});
desc.add<std::string>("recHitsOutLabelEE", "EcalUncalibRecHitsEE");
Expand All @@ -53,11 +53,11 @@ void EcalCPUUncalibRecHitProducer::fillDescriptions(edm::ConfigurationDescriptio
}

EcalCPUUncalibRecHitProducer::EcalCPUUncalibRecHitProducer(const edm::ParameterSet& ps)
: produceEE_{ps.getParameter<bool>("produceEE")},
: isPhase1_{ps.getParameter<bool>("isPhase1")},
recHitsInEBToken_{consumes<InputProduct>(ps.getParameter<edm::InputTag>("recHitsInLabelEB"))},
recHitsOutEBToken_{produces<OutputProduct>(ps.getParameter<std::string>("recHitsOutLabelEB"))},
containsTimingInformation_{ps.getParameter<bool>("containsTimingInformation")} {
if (produceEE_) {
if (isPhase1_) {
recHitsInEEToken_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("recHitsInLabelEE"));
recHitsOutEEToken_ = produces<OutputProduct>(ps.getParameter<std::string>("recHitsOutLabelEE"));
}
Expand All @@ -84,7 +84,7 @@ void EcalCPUUncalibRecHitProducer::acquire(edm::Event const& event,
cudaCheck(cudaMemcpyAsync(dest.data(), src, dest.size() * sizeof(type), cudaMemcpyDeviceToHost, ctx.stream()));
};

if (produceEE_) {
if (isPhase1_) {
auto const& eeRecHitsProduct = event.get(recHitsInEEToken_);
auto const& eeRecHits = ctx.get(eeRecHitsProduct);
recHitsEE_.resize(eeRecHits.size);
Expand All @@ -93,23 +93,23 @@ void EcalCPUUncalibRecHitProducer::acquire(edm::Event const& event,
lambdaToTransfer(recHitsEB_.did, ebRecHits.did.get());
lambdaToTransfer(recHitsEB_.amplitudesAll, ebRecHits.amplitudesAll.get());
lambdaToTransfer(recHitsEB_.amplitude, ebRecHits.amplitude.get());
lambdaToTransfer(recHitsEB_.amplitudeError, ebRecHits.amplitudeError.get());
lambdaToTransfer(recHitsEB_.chi2, ebRecHits.chi2.get());
lambdaToTransfer(recHitsEB_.pedestal, ebRecHits.pedestal.get());
lambdaToTransfer(recHitsEB_.flags, ebRecHits.flags.get());
if (containsTimingInformation_) {
lambdaToTransfer(recHitsEB_.jitter, ebRecHits.jitter.get());
lambdaToTransfer(recHitsEB_.jitterError, ebRecHits.jitterError.get());
}
if (!(isPhase1_))
lambdaToTransfer(recHitsEB_.amplitudeError, ebRecHits.amplitudeError.get());

if (produceEE_) {
if (isPhase1_) {
auto const& eeRecHitsProduct = event.get(recHitsInEEToken_);
auto const& eeRecHits = ctx.get(eeRecHitsProduct);
recHitsEE_.resize(eeRecHits.size);
lambdaToTransfer(recHitsEE_.did, eeRecHits.did.get());
lambdaToTransfer(recHitsEE_.amplitudesAll, eeRecHits.amplitudesAll.get());
lambdaToTransfer(recHitsEE_.amplitude, eeRecHits.amplitude.get());
lambdaToTransfer(recHitsEE_.amplitudeError, eeRecHits.amplitudeError.get());
lambdaToTransfer(recHitsEE_.chi2, eeRecHits.chi2.get());
lambdaToTransfer(recHitsEE_.pedestal, eeRecHits.pedestal.get());
lambdaToTransfer(recHitsEE_.flags, eeRecHits.flags.get());
Expand All @@ -126,7 +126,7 @@ void EcalCPUUncalibRecHitProducer::produce(edm::Event& event, edm::EventSetup co
// put into event
event.put(recHitsOutEBToken_, std::move(recHitsOutEB));

if (produceEE_) {
if (isPhase1_) {
auto recHitsOutEE = std::make_unique<OutputProduct>(std::move(recHitsEE_));
event.put(recHitsOutEEToken_, std::move(recHitsOutEE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class EcalUncalibRecHitConvertGPU2CPUFormat : public edm::stream::EDProducer<> {
void produce(edm::Event&, edm::EventSetup const&) override;

private:
bool produceEE_;
bool isPhase1_;
const edm::EDGetTokenT<InputProduct> recHitsGPUEB_;
edm::EDGetTokenT<InputProduct> recHitsGPUEE_;

Expand All @@ -34,7 +34,7 @@ void EcalUncalibRecHitConvertGPU2CPUFormat::fillDescriptions(edm::ConfigurationD

desc.add<std::string>("recHitsLabelCPUEB", "EcalUncalibRecHitsEB");

desc.add<bool>("produceEE", true);
desc.add<bool>("isPhase1", true);

desc.add<edm::InputTag>("recHitsLabelGPUEE", edm::InputTag("ecalUncalibRecHitProducerGPU", "EcalUncalibRecHitsEE"));
desc.add<std::string>("recHitsLabelCPUEE", "EcalUncalibRecHitsEE");
Expand All @@ -43,11 +43,11 @@ void EcalUncalibRecHitConvertGPU2CPUFormat::fillDescriptions(edm::ConfigurationD
}

EcalUncalibRecHitConvertGPU2CPUFormat::EcalUncalibRecHitConvertGPU2CPUFormat(const edm::ParameterSet& ps)
: produceEE_{ps.getParameter<bool>("produceEE")},
: isPhase1_{ps.getParameter<bool>("isPhase1")},
recHitsGPUEB_{consumes<InputProduct>(ps.getParameter<edm::InputTag>("recHitsLabelGPUEB"))},
recHitsLabelCPUEB_{ps.getParameter<std::string>("recHitsLabelCPUEB")} {
produces<EBUncalibratedRecHitCollection>(recHitsLabelCPUEB_);
if (produceEE_) {
if (isPhase1_) {
recHitsGPUEE_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("recHitsLabelGPUEE"));
recHitsLabelCPUEE_ = ps.getParameter<std::string>("recHitsLabelCPUEE");
produces<EEUncalibratedRecHitCollection>(recHitsLabelCPUEE_);
Expand All @@ -68,13 +68,14 @@ void EcalUncalibRecHitConvertGPU2CPUFormat::produce(edm::Event& event, edm::Even
recHitsGPUEB.jitter[i],
recHitsGPUEB.chi2[i],
recHitsGPUEB.flags[i]);
(*recHitsCPUEB)[i].setAmplitudeError(recHitsGPUEB.amplitudeError[i]);
if (!(isPhase1_))
(*recHitsCPUEB)[i].setAmplitudeError(recHitsGPUEB.amplitudeError[i]);
(*recHitsCPUEB)[i].setJitterError(recHitsGPUEB.jitterError[i]);
auto const offset = i * EcalDataFrame::MAXSAMPLES;
for (uint32_t sample = 0; sample < EcalDataFrame::MAXSAMPLES; ++sample)
(*recHitsCPUEB)[i].setOutOfTimeAmplitude(sample, recHitsGPUEB.amplitudesAll[offset + sample]);
}
if (produceEE_) {
if (isPhase1_) {
auto const& recHitsGPUEE = event.get(recHitsGPUEE_);
auto recHitsCPUEE = std::make_unique<EEUncalibratedRecHitCollection>();
recHitsCPUEE->reserve(recHitsGPUEE.amplitude.size());
Expand All @@ -85,7 +86,6 @@ void EcalUncalibRecHitConvertGPU2CPUFormat::produce(edm::Event& event, edm::Even
recHitsGPUEE.jitter[i],
recHitsGPUEE.chi2[i],
recHitsGPUEE.flags[i]);
(*recHitsCPUEB)[i].setAmplitudeError(recHitsGPUEE.amplitudeError[i]);
(*recHitsCPUEE)[i].setJitterError(recHitsGPUEE.jitterError[i]);
auto const offset = i * EcalDataFrame::MAXSAMPLES;
for (uint32_t sample = 0; sample < EcalDataFrame::MAXSAMPLES; ++sample) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from RecoLocalCalo.EcalRecProducers.ecalCPUUncalibRecHitProducer_cfi import ecalCPUUncalibRecHitProducer as _ecalCPUUncalibRecHitProducer
ecalMultiFitUncalibRecHitSoAnew = _ecalCPUUncalibRecHitProducer.clone(
recHitsInLabelEB = cms.InputTag('ecalUncalibRecHitPhase2GPU', 'EcalUncalibRecHitsEB'),
produceEE = cms.bool(False)
isPhase1 = cms.bool(False)
)


Expand All @@ -36,7 +36,7 @@
gpu.toModify(ecalUncalibRecHitPhase2,
cuda = _ecalUncalibRecHitConvertGPU2CPUFormat.clone(
recHitsLabelGPUEB = cms.InputTag('ecalMultiFitUncalibRecHitSoAnew', 'EcalUncalibRecHitsEB'),
produceEE = cms.bool(False)
isPhase1 = cms.bool(False)
)
)

Expand Down

0 comments on commit 887c410

Please sign in to comment.