Skip to content

Commit

Permalink
Rename with camelCase convention
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrothman committed Oct 21, 2021
1 parent 83ba6cf commit fac11a6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 38 deletions.
@@ -1,6 +1,6 @@
//--------------------------------------------------------------------------------------------------
//
// SCEnergyCorrectorSemiParm_DRN
// SCEnergyCorrectorDRN
//
// Helper Class for applying regression-based energy corrections with DRN implimentation
//
Expand All @@ -10,8 +10,8 @@
//
//--------------------------------------------------------------------------------------------------

#ifndef Progression_EGM_DRN_SCEnergyCorrectorSemiParm_DRN_h
#define Progression_EGM_DRN_SCEnergyCorrectorSemiParm_DRN_h
#ifndef Progression_EGM_DRN_SCEnergyCorrectorDRN_h
#define Progression_EGM_DRN_SCEnergyCorrectorDRN_h

#include "HeterogeneousCore/SonicTriton/interface/TritonEDProducer.h"

Expand Down Expand Up @@ -44,12 +44,12 @@
#include <vector>
#include <random>

class SCEnergyCorrectorSemiParm_DRN {
class SCEnergyCorrectorDRN {
public:
SCEnergyCorrectorSemiParm_DRN();
SCEnergyCorrectorDRN();
//if you want override the default on where conditions are consumed, you need to use
//the other constructor and then call setTokens approprately
SCEnergyCorrectorSemiParm_DRN(const edm::ParameterSet& iConfig, edm::ConsumesCollector cc);
SCEnergyCorrectorDRN(const edm::ParameterSet& iConfig, edm::ConsumesCollector cc);

static void fillPSetDescription(edm::ParameterSetDescription& desc);
static edm::ParameterSetDescription makePSetDescription();
Expand All @@ -62,13 +62,11 @@ class SCEnergyCorrectorSemiParm_DRN {

//std::pair<double, double> getCorrections(const reco::SuperCluster& sc) const;

void make_input(const edm::Event& iEvent, TritonInputMap& iInput, const reco::SuperClusterCollection& inputSCs) const;
TritonOutput<float> get_output(const TritonOutputMap& iOutput);
void makeInput(const edm::Event& iEvent, TritonInputMap& iInput, const reco::SuperClusterCollection& inputSCs) const;
TritonOutput<float> getOutput(const TritonOutputMap& iOutput);

//void modifyObject(reco::SuperCluster& sc) const;

std::vector<float> getRegData(const reco::SuperCluster& sc) const;

private:
const CaloTopology* caloTopo_;
const CaloGeometry* caloGeom_;
Expand All @@ -86,7 +84,7 @@ class SCEnergyCorrectorSemiParm_DRN {
};

template <edm::Transition esTransition>
void SCEnergyCorrectorSemiParm_DRN::setTokens(const edm::ParameterSet& iConfig, edm::ConsumesCollector cc) {
void SCEnergyCorrectorDRN::setTokens(const edm::ParameterSet& iConfig, edm::ConsumesCollector cc) {
tokenEBRecHits_ = cc.consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("ecalRecHitsEB"));
tokenEERecHits_ = cc.consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("ecalRecHitsEE"));
caloGeomToken_ = cc.esConsumes<CaloGeometry, CaloGeometryRecord, esTransition>();
Expand Down
@@ -1,4 +1,4 @@
#include "RecoEcal/EgammaClusterAlgos/interface/SCEnergyCorrectorSemiParm_DRN.h"
#include "RecoEcal/EgammaClusterAlgos/interface/SCEnergyCorrectorDRN.h"

#include "FWCore/Utilities/interface/isFinite.h"
#include "FWCore/Utilities/interface/Transition.h"
Expand All @@ -13,40 +13,40 @@

#include <iostream>

SCEnergyCorrectorSemiParm_DRN::SCEnergyCorrectorSemiParm_DRN()
SCEnergyCorrectorDRN::SCEnergyCorrectorDRN()
: caloTopo_(nullptr),
caloGeom_(nullptr) {}

SCEnergyCorrectorSemiParm_DRN::SCEnergyCorrectorSemiParm_DRN(const edm::ParameterSet& iConfig, edm::ConsumesCollector cc)
: SCEnergyCorrectorSemiParm_DRN() {
SCEnergyCorrectorDRN::SCEnergyCorrectorDRN(const edm::ParameterSet& iConfig, edm::ConsumesCollector cc)
: SCEnergyCorrectorDRN() {
setTokens(iConfig, cc);
}

void SCEnergyCorrectorSemiParm_DRN::fillPSetDescription(edm::ParameterSetDescription& desc) {
void SCEnergyCorrectorDRN::fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<edm::InputTag>("ecalRecHitsEE", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
desc.add<edm::InputTag>("ecalRecHitsEB", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
desc.add<edm::InputTag>("rhoFastJet");
}

edm::ParameterSetDescription SCEnergyCorrectorSemiParm_DRN::makePSetDescription() {
edm::ParameterSetDescription SCEnergyCorrectorDRN::makePSetDescription() {
edm::ParameterSetDescription desc;
fillPSetDescription(desc);
return desc;
}

void SCEnergyCorrectorSemiParm_DRN::setEventSetup(const edm::EventSetup& es) {
void SCEnergyCorrectorDRN::setEventSetup(const edm::EventSetup& es) {
caloTopo_ = &es.getData(caloTopoToken_);
caloGeom_ = &es.getData(caloGeomToken_);
}

void SCEnergyCorrectorSemiParm_DRN::setEvent(const edm::Event& event) {
void SCEnergyCorrectorDRN::setEvent(const edm::Event& event) {
event.getByToken(tokenEBRecHits_, recHitsEB_);
event.getByToken(tokenEERecHits_, recHitsEE_);
event.getByToken(rhoToken_, rhoHandle_);
}

void SCEnergyCorrectorSemiParm_DRN::make_input(const edm::Event& iEvent, TritonInputMap& iInput, const reco::SuperClusterCollection& inputSCs ) const {
//get event-based seed for RNG
void SCEnergyCorrectorDRN::makeInput(const edm::Event& iEvent, TritonInputMap& iInput, const reco::SuperClusterCollection& inputSCs ) const {

std::vector<unsigned> nHits = {};
unsigned totalHits = 0;
unsigned n;
Expand Down Expand Up @@ -96,13 +96,14 @@ void SCEnergyCorrectorSemiParm_DRN::make_input(const edm::Event& iEvent, TritonI
vdata3.push_back(0.0);
++batchNum;
}

// convert to server format
input1.toServer(data1);
input2.toServer(data2);
input3.toServer(data3);
}

TritonOutput<float> SCEnergyCorrectorSemiParm_DRN::get_output(const TritonOutputMap& iOutput) {
TritonOutput<float> SCEnergyCorrectorDRN::getOutput(const TritonOutputMap& iOutput) {
//check the results
const auto& output1 = iOutput.begin()->second;
// convert from server format
Expand Down
Expand Up @@ -12,15 +12,15 @@

#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"

#include "RecoEcal/EgammaClusterAlgos/interface/SCEnergyCorrectorSemiParm_DRN.h"
#include "RecoEcal/EgammaClusterAlgos/interface/SCEnergyCorrectorDRN.h"

#include <sstream>
#include <string>
#include <vector>
#include <random>

/*
* SCEnergyCorrectorProducer_DRN
* SCEnergyCorrectorDRNProducer
*
* Simple producer to generate a set of corrected superclusters with the DRN regression
* Based on RecoEcal/EgammaClusterProducers/SCEnergyCorrectorProducer by S. Harper (RAL/CERN)
Expand All @@ -42,9 +42,9 @@ static float correction(float x){
return exp(-logcorrection(x));
}

class SCEnergyCorrectorProducer_DRN : public TritonEDProducer<> {
class SCEnergyCorrectorDRNProducer : public TritonEDProducer<> {
public:
explicit SCEnergyCorrectorProducer_DRN(const edm::ParameterSet& iConfig);
explicit SCEnergyCorrectorDRNProducer(const edm::ParameterSet& iConfig);

void beginLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& iSetup) override;

Expand All @@ -54,23 +54,23 @@ class SCEnergyCorrectorProducer_DRN : public TritonEDProducer<> {
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
SCEnergyCorrectorSemiParm_DRN energyCorrector_;
SCEnergyCorrectorDRN energyCorrector_;
edm::EDGetTokenT<reco::SuperClusterCollection> inputSCToken_;
};

SCEnergyCorrectorProducer_DRN::SCEnergyCorrectorProducer_DRN(const edm::ParameterSet& iConfig)
: TritonEDProducer<>(iConfig, "SCEnergyCorrectorProducer_DRN"),
SCEnergyCorrectorDRNProducer::SCEnergyCorrectorDRNProducer(const edm::ParameterSet& iConfig)
: TritonEDProducer<>(iConfig, "SCEnergyCorrectorDRNProducer"),
energyCorrector_(iConfig.getParameterSet("correctorCfg"), consumesCollector()),
inputSCToken_(consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("inputSCs")))
{
produces<reco::SuperClusterCollection>();
}

void SCEnergyCorrectorProducer_DRN::beginLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& iSetup) {
void SCEnergyCorrectorDRNProducer::beginLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& iSetup) {
energyCorrector_.setEventSetup(iSetup);
}

void SCEnergyCorrectorProducer_DRN::acquire(edm::Event const& iEvent, edm::EventSetup const& iSetup, Input& iInput){
void SCEnergyCorrectorDRNProducer::acquire(edm::Event const& iEvent, edm::EventSetup const& iSetup, Input& iInput){
auto inputSCs = iEvent.get(inputSCToken_);

if(inputSCs.size()==0){
Expand All @@ -81,15 +81,15 @@ void SCEnergyCorrectorProducer_DRN::acquire(edm::Event const& iEvent, edm::Event
}

energyCorrector_.setEvent(iEvent);
energyCorrector_.make_input(iEvent, iInput, inputSCs);
energyCorrector_.makeInput(iEvent, iInput, inputSCs);
}

void SCEnergyCorrectorProducer_DRN::produce(edm::Event& iEvent, const edm::EventSetup& iSetup, Output const& iOutput){
void SCEnergyCorrectorDRNProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup, Output const& iOutput){
auto inputSCs = iEvent.get(inputSCToken_);
if (inputSCs.size()==0)
return;

const auto& serverout = energyCorrector_.get_output(iOutput);
const auto& serverout = energyCorrector_.getOutput(iOutput);

if(inputSCs.size() ==0){
return;
Expand All @@ -109,12 +109,12 @@ void SCEnergyCorrectorProducer_DRN::produce(edm::Event& iEvent, const edm::Event
auto scHandle = iEvent.put(std::move(corrSCs));
}

void SCEnergyCorrectorProducer_DRN::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
void SCEnergyCorrectorDRNProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::ParameterSetDescription>("correctorCfg", SCEnergyCorrectorSemiParm_DRN::makePSetDescription());
desc.add<edm::ParameterSetDescription>("correctorCfg", SCEnergyCorrectorDRN::makePSetDescription());
TritonClient::fillPSetDescription(desc);
desc.add<edm::InputTag>("inputSCs", edm::InputTag("particleFlowSuperClusterECAL"));
descriptions.add("scEnergyCorrectorProducer_DRN", desc);
descriptions.add("scEnergyCorrectorDRNProducer", desc);
}

DEFINE_FWK_MODULE(SCEnergyCorrectorProducer_DRN);
DEFINE_FWK_MODULE(SCEnergyCorrectorDRNProducer);

0 comments on commit fac11a6

Please sign in to comment.