Skip to content

Commit

Permalink
Update ECAL and HCAL reconstruction to run on multple GPUs [3/3] (#504)
Browse files Browse the repository at this point in the history
Fix fillDescriptions() for EcalRecHitParametersGPUESProducer.
  • Loading branch information
amassiro authored and fwyzard committed Nov 9, 2020
1 parent 116b425 commit 080466c
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,83 @@
#include <tuple>
#include <utility>

#include "EcalRecHitParametersGPURecord.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/ESProductHost.h"
#include "FWCore/Framework/interface/ESTransientHandle.h"
#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
#include "FWCore/Framework/interface/SourceFactory.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/ReusableObjectHolder.h"
#include "FWCore/Utilities/interface/typelookup.h"

#include "RecoLocalCalo/EcalRecAlgos/interface/EcalRecHitParametersGPU.h"
#include "EcalRecHitParametersGPURecord.h"

#include "FWCore/Framework/interface/SourceFactory.h"

class EcalRecHitParametersGPUESProducer
: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
class EcalRecHitParametersGPUESProducer : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
public:
EcalRecHitParametersGPUESProducer(edm::ParameterSet const&);
~EcalRecHitParametersGPUESProducer() override = default;
EcalRecHitParametersGPUESProducer(edm::ParameterSet const&);
~EcalRecHitParametersGPUESProducer() override = default;

static void fillDescriptions(edm::ConfigurationDescriptions&);
std::unique_ptr<EcalRecHitParametersGPU> produce(EcalRecHitParametersGPURecord const&);
static void fillDescriptions(edm::ConfigurationDescriptions&);
std::unique_ptr<EcalRecHitParametersGPU> produce(EcalRecHitParametersGPURecord const&);

protected:
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
const edm::IOVSyncValue&,
edm::ValidityInterval&) override;
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
const edm::IOVSyncValue&,
edm::ValidityInterval&) override;

private:
edm::ParameterSet const& pset_;
edm::ParameterSet const& pset_;
};

EcalRecHitParametersGPUESProducer::EcalRecHitParametersGPUESProducer(
edm::ParameterSet const& pset) : pset_{pset}
{
setWhatProduced(this);
findingRecord<EcalRecHitParametersGPURecord>();
EcalRecHitParametersGPUESProducer::EcalRecHitParametersGPUESProducer(edm::ParameterSet const& pset) : pset_{pset} {
setWhatProduced(this);
findingRecord<EcalRecHitParametersGPURecord>();
}

void EcalRecHitParametersGPUESProducer::setIntervalFor(
const edm::eventsetup::EventSetupRecordKey& iKey,
const edm::IOVSyncValue& iTime,
edm::ValidityInterval& oInterval) {
oInterval = edm::ValidityInterval(
edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
void EcalRecHitParametersGPUESProducer::setIntervalFor(const edm::eventsetup::EventSetupRecordKey& iKey,
const edm::IOVSyncValue& iTime,
edm::ValidityInterval& oInterval) {
oInterval = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
}

void EcalRecHitParametersGPUESProducer::fillDescriptions(
edm::ConfigurationDescriptions& desc) {
edm::ParameterSetDescription d;
void EcalRecHitParametersGPUESProducer::fillDescriptions(edm::ConfigurationDescriptions& desc) {
edm::ParameterSetDescription d;

//---- db statuses to be exluded from reconstruction
d.add<std::vector<std::string>>("ChannelStatusToBeExcluded",
{
"kDAC",
"kNoisy",
"kNNoisy",
"kFixedG6",
"kFixedG1",
"kFixedG0",
"kNonRespondingIsolated",
"kDeadVFE",
"kDeadFE",
"kNoDataNoTP",
});

// reco flags association to DB flag
edm::ParameterSetDescription desc_list_flagsMapDBReco;
desc_list_flagsMapDBReco.add<std::vector<std::string>>("kGood", {"kOk", "kDAC", "kNoLaser", "kNoisy"});
desc_list_flagsMapDBReco.add<std::vector<std::string>>("kNoisy", {"kNNoisy", "kFixedG6", "kFixedG1"});
desc_list_flagsMapDBReco.add<std::vector<std::string>>("kNeighboursRecovered",
{"kFixedG0", "kNonRespondingIsolated", "kDeadVFE"});
desc_list_flagsMapDBReco.add<std::vector<std::string>>("kTowerRecovered", {"kDeadFE"});
desc_list_flagsMapDBReco.add<std::vector<std::string>>("kDead", {"kNoDataNoTP"});

// ## db statuses to be exluded from reconstruction (some will be recovered)
edm::ParameterSetDescription desc_ChannelStatusToBeExcluded;
desc_ChannelStatusToBeExcluded.add<std::string>("kDAC");
desc_ChannelStatusToBeExcluded.add<std::string>("kNoisy");
desc_ChannelStatusToBeExcluded.add<std::string>("kNNoisy");
desc_ChannelStatusToBeExcluded.add<std::string>("kFixedG6");
desc_ChannelStatusToBeExcluded.add<std::string>("kFixedG1");
desc_ChannelStatusToBeExcluded.add<std::string>("kFixedG0");
desc_ChannelStatusToBeExcluded.add<std::string>("kNonRespondingIsolated");
desc_ChannelStatusToBeExcluded.add<std::string>("kDeadVFE");
desc_ChannelStatusToBeExcluded.add<std::string>("kDeadFE");
desc_ChannelStatusToBeExcluded.add<std::string>("kNoDataNoTP");
std::vector<edm::ParameterSet> default_ChannelStatusToBeExcluded(1);
d.addVPSet("ChannelStatusToBeExcluded", desc_ChannelStatusToBeExcluded, default_ChannelStatusToBeExcluded);
d.add<edm::ParameterSetDescription>("flagsMapDBReco", desc_list_flagsMapDBReco);

desc.addWithDefaultLabel(d);
desc.addWithDefaultLabel(d);
}

std::unique_ptr<EcalRecHitParametersGPU> EcalRecHitParametersGPUESProducer::produce(
EcalRecHitParametersGPURecord const&) {
return std::make_unique<EcalRecHitParametersGPU>(pset_);
EcalRecHitParametersGPURecord const&) {
return std::make_unique<EcalRecHitParametersGPU>(pset_);
}

DEFINE_FWK_EVENTSETUP_SOURCE(EcalRecHitParametersGPUESProducer);
39 changes: 8 additions & 31 deletions RecoLocalCalo/EcalRecProducers/plugins/EcalRecHitProducerGPU.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalLaserAPDPNRatiosRefGPU.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalLaserAlphasGPU.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalLinearCorrectionsGPU.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalRecHitParametersGPU.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalRechitADCToGeVConstantGPU.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalRechitChannelStatusGPU.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalRecHitParametersGPU.h"

#include "EcalRecHitBuilderKernels.h"
#include "EcalRecHitParametersGPURecord.h"
Expand Down Expand Up @@ -73,15 +73,7 @@ class EcalRecHitProducerGPU : public edm::stream::EDProducer<edm::ExternalWork>
edm::ESHandle<EcalLinearCorrectionsGPU> LinearCorrectionsHandle_;
edm::ESHandle<EcalRecHitParametersGPU> recHitParametersHandle_;

// configuration
std::vector<int> v_chstatus_;

//
// https://github.com/cms-sw/cmssw/blob/266e21cfc9eb409b093e4cf064f4c0a24c6ac293/RecoLocalCalo/EcalRecProducers/plugins/EcalRecHitWorkerSimple.h
//

// Associate reco flagbit ( outer vector) to many db status flags (inner vector)
// std::vector<std::vector<uint32_t> > v_DB_reco_flags_;
// Associate reco flagbit (outer vector) to many db status flags (inner vector)
std::vector<int>
expanded_v_DB_reco_flags_; // Transform a map in a vector // FIXME AM: int or uint32 to be checked
std::vector<uint32_t> expanded_Sizes_v_DB_reco_flags_; // Saving the size for each piece
Expand Down Expand Up @@ -113,20 +105,12 @@ void EcalRecHitProducerGPU::fillDescriptions(edm::ConfigurationDescriptions& con

EcalRecHitProducerGPU::EcalRecHitProducerGPU(const edm::ParameterSet& ps) {
//---- input
uncalibRecHitsInEBToken_ = consumes<InputProduct>(
ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEB"));
uncalibRecHitsInEEToken_ = consumes<InputProduct>(
ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEE"));
uncalibRecHitsInEBToken_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEB"));
uncalibRecHitsInEEToken_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEE"));

//---- output
recHitsTokenEB_ =
produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEB"));
recHitsTokenEE_ =
produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEE"));

//---- db statuses to be exluded from reconstruction
v_chstatus_ = StringToEnumValue<EcalChannelStatusCode::Code>(
ps.getParameter<std::vector<std::string>>("ChannelStatusToBeExcluded"));
recHitsTokenEB_ = produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEB"));
recHitsTokenEE_ = produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEE"));

bool killDeadChannels = ps.getParameter<bool>("killDeadChannels");
configParameters_.killDeadChannels = killDeadChannels;
Expand Down Expand Up @@ -240,20 +224,13 @@ void EcalRecHitProducerGPU::acquire(edm::Event const& event,

edm::TimeValue_t event_time = event.time().value();

ecal::rechit::create_ecal_rehit(inputDataGPU,
eventOutputDataGPU_,
// eventDataForScratchGPU_,
conditions,
configParameters_,
nchannelsEB,
event_time,
ctx.stream());
ecal::rechit::create_ecal_rehit(
inputDataGPU, eventOutputDataGPU_, conditions, configParameters_, nchannelsEB, event_time, ctx.stream());

cudaCheck(cudaGetLastError());
}

void EcalRecHitProducerGPU::produce(edm::Event& event, edm::EventSetup const& setup) {
//DurationMeasurer<std::chrono::milliseconds> timer{std::string{"produce duration"}};
cms::cuda::ScopedContextProduce ctx{cudaState_};

eventOutputDataGPU_.recHitsEB.size = neb_;
Expand Down
11 changes: 11 additions & 0 deletions RecoLocalCalo/EcalRecProducers/test/testEcalRechitProducer_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@

#process.ecalMultiFitUncalibRecHitgpu.algoPSet.threads = cms.vint32(256, 1, 1)

#from RecoLocalCalo.EcalRecProducers.ecalMultifitParametersGPUESProducer_cfi import ecalMultifitParametersGPUESProducer
process.load("RecoLocalCalo.EcalRecProducers.ecalMultifitParametersGPUESProducer_cfi")

#
#
# No "EcalRecHitParametersGPURecord" record found in the EventSetup.n
# #--->
#
process.load("RecoLocalCalo.EcalRecProducers.ecalRecHitParametersGPUESProducer_cfi")
#ecalRecHitParametersGPUESProducer_cfi.py


##
## force HLT configuration for ecalMultiFitUncalibRecHit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
#process.ecalMultiFitUncalibRecHitgpu.algoPSet.threads = cms.vint32(256, 1, 1)


process.load("RecoLocalCalo.EcalRecProducers.ecalMultifitParametersGPUESProducer_cfi")



##
## force HLT configuration for ecalMultiFitUncalibRecHit
##
Expand Down

0 comments on commit 080466c

Please sign in to comment.