Skip to content

Commit

Permalink
Implement comments PR#36337
Browse files Browse the repository at this point in the history
  • Loading branch information
jbsauvan committed Feb 15, 2022
1 parent b36ebff commit fc77fa5
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 56 deletions.
2 changes: 1 addition & 1 deletion L1Trigger/L1THGCal/interface/backend/HGCalCluster_SA.h
Expand Up @@ -28,7 +28,7 @@ namespace l1thgcfirmware {
mipPt_(mipPt),
index_cmssw_(index_cmssw) {}

~HGCalCluster(){};
~HGCalCluster() = default;

float x() const { return x_; }
float y() const { return y_; }
Expand Down
Expand Up @@ -12,8 +12,8 @@

class HGCalHistoClusteringImplSA {
public:
HGCalHistoClusteringImplSA();
~HGCalHistoClusteringImplSA() {}
HGCalHistoClusteringImplSA() = default;
~HGCalHistoClusteringImplSA() = default;

void runAlgorithm() const;

Expand Down
8 changes: 2 additions & 6 deletions L1Trigger/L1THGCal/interface/backend/HGCalMulticluster_SA.h
Expand Up @@ -10,8 +10,7 @@ namespace l1thgcfirmware {
class HGCalMulticluster {
public:
HGCalMulticluster()
: hOverEValid_(false),
centre_x_(0),
: centre_x_(0),
centre_y_(0),
centre_z_(0),
centreProj_x_(0),
Expand All @@ -24,7 +23,7 @@ namespace l1thgcfirmware {

void addConstituent(const l1thgcfirmware::HGCalCluster& tc, bool updateCentre = true, float fraction = 1.);

~HGCalMulticluster(){};
~HGCalMulticluster() = default;

const std::vector<l1thgcfirmware::HGCalCluster>& constituents() const { return constituents_; }

Expand All @@ -33,9 +32,6 @@ namespace l1thgcfirmware {
float sumPt() const { return sumPt_; }

private:
float hOverE_;
bool hOverEValid_;

// Could replace this with own simple implementation of GlobalPoint?
// Or just a struct?
float centre_x_;
Expand Down
Expand Up @@ -9,8 +9,8 @@

class HGCalSortingTruncationImplSA {
public:
HGCalSortingTruncationImplSA();
~HGCalSortingTruncationImplSA() {}
HGCalSortingTruncationImplSA() = default;
~HGCalSortingTruncationImplSA() = default;

void sortAndTruncate_SA(const std::vector<l1thgcfirmware::HGCalMulticluster>& inputMulticlusters,
std::vector<l1thgcfirmware::HGCalMulticluster>& outputMulticlusters,
Expand Down
Expand Up @@ -11,8 +11,8 @@

class HGCalStage1TruncationImplSA {
public:
HGCalStage1TruncationImplSA();
~HGCalStage1TruncationImplSA() {}
HGCalStage1TruncationImplSA() = default;
~HGCalStage1TruncationImplSA() = default;

void runAlgorithm() const;

Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1THGCal/interface/backend/HGCalTowerMapImpl_SA.h
Expand Up @@ -6,8 +6,8 @@

class HGCalTowerMapImplSA {
public:
HGCalTowerMapImplSA() {}
~HGCalTowerMapImplSA() {}
HGCalTowerMapImplSA() = default;
~HGCalTowerMapImplSA() = default;

void runAlgorithm(const std::vector<l1thgcfirmware::HGCalTowerMap>& inputTowerMaps_SA,
std::vector<l1thgcfirmware::HGCalTower>& outputTowers_SA) const;
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1THGCal/interface/backend/HGCalTowerMap_SA.h
Expand Up @@ -10,10 +10,10 @@ namespace l1thgcfirmware {

class HGCalTowerMap {
public:
HGCalTowerMap(){};
HGCalTowerMap() = default;
HGCalTowerMap(const std::vector<l1thgcfirmware::HGCalTowerCoord>& tower_ids);

~HGCalTowerMap(){};
~HGCalTowerMap() = default;

HGCalTowerMap& operator+=(const HGCalTowerMap& map);

Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1THGCal/interface/backend/HGCalTower_SA.h
Expand Up @@ -7,11 +7,11 @@ namespace l1thgcfirmware {

class HGCalTower {
public:
HGCalTower() {}
HGCalTower() = default;
HGCalTower(double etEm, double etHad, float eta, float phi, uint32_t rawId)
: etEm_(etEm), etHad_(etHad), eta_(eta), phi_(phi), id_(rawId) {}

~HGCalTower(){};
~HGCalTower() = default;

double etEm() const { return etEm_; }
double etHad() const { return etHad_; }
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1THGCal/interface/backend/HGCalTriggerCell_SA.h
Expand Up @@ -7,7 +7,7 @@ namespace l1thgcfirmware {

class HGCalTriggerCell {
public:
HGCalTriggerCell(){};
HGCalTriggerCell() = default;

HGCalTriggerCell(float x,
float y,
Expand All @@ -30,7 +30,7 @@ namespace l1thgcfirmware {
mipPt_(mipPt),
index_cmssw_(index_cmssw) {}

~HGCalTriggerCell(){};
~HGCalTriggerCell() = default;

float x() const { return x_; }
float y() const { return y_; }
Expand Down
6 changes: 3 additions & 3 deletions L1Trigger/L1THGCal/plugins/HGCalBackendStage1Producer.cc
Expand Up @@ -23,16 +23,16 @@
class HGCalBackendStage1Producer : public edm::stream::EDProducer<> {
public:
HGCalBackendStage1Producer(const edm::ParameterSet&);
~HGCalBackendStage1Producer() override {}
~HGCalBackendStage1Producer() override = default;

void beginRun(const edm::Run&, const edm::EventSetup&) override;
void produce(edm::Event&, const edm::EventSetup&) override;

private:
// inputs
edm::EDGetToken input_cell_, input_sums_;
const edm::EDGetToken input_cell_;
edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
edm::ESGetToken<HGCalTriggerGeometryBase, CaloGeometryRecord> triggerGeomToken_;
const edm::ESGetToken<HGCalTriggerGeometryBase, CaloGeometryRecord> triggerGeomToken_;

std::unique_ptr<HGCalBackendStage1ProcessorBase> backendProcess_;

Expand Down
Expand Up @@ -15,7 +15,9 @@
class HGCalBackendLayer2Processor3DClusteringSA : public HGCalBackendLayer2ProcessorBase {
public:
HGCalBackendLayer2Processor3DClusteringSA(const edm::ParameterSet& conf)
: HGCalBackendLayer2ProcessorBase(conf), conf_(conf) {
: HGCalBackendLayer2ProcessorBase(conf),
distributor_(conf.getParameterSet("DistributionParameters")),
conf_(conf) {
multiclusteringHistoSeeding_ = std::make_unique<HGCalHistoSeedingImpl>(
conf.getParameterSet("C3d_parameters").getParameterSet("histoMax_C3d_seeding_parameters"));

Expand Down Expand Up @@ -57,10 +59,8 @@ class HGCalBackendLayer2Processor3DClusteringSA : public HGCalBackendLayer2Proce
uint32_t stage1_fpga = geometry()->getStage1FpgaFromModule(module);
HGCalTriggerGeometryBase::geom_set possible_stage2_fpgas = geometry()->getStage2FpgasFromStage1Fpga(stage1_fpga);

HGCalStage2ClusterDistribution distributor(conf_.getParameterSet("DistributionParameters"));

HGCalTriggerGeometryBase::geom_set stage2_fpgas =
distributor.getStage2FPGAs(stage1_fpga, possible_stage2_fpgas, tc_ptr);
distributor_.getStage2FPGAs(stage1_fpga, possible_stage2_fpgas, tc_ptr);

for (auto& fpga : stage2_fpgas) {
tcs_per_fpga[fpga].push_back(tc_ptr);
Expand Down Expand Up @@ -121,6 +121,7 @@ class HGCalBackendLayer2Processor3DClusteringSA : public HGCalBackendLayer2Proce

std::vector<std::unique_ptr<HGCalTriggerClusterInterpreterBase>> energy_interpreters_;

HGCalStage2ClusterDistribution distributor_;
const edm::ParameterSet conf_;
};

Expand Down
Expand Up @@ -14,7 +14,7 @@
class HGCalSortingTruncationWrapper : public HGCalStage2FilteringWrapperBase {
public:
HGCalSortingTruncationWrapper(const edm::ParameterSet& conf);
~HGCalSortingTruncationWrapper() override {}
~HGCalSortingTruncationWrapper() override = default;

void configure(
const std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&>& configuration) override;
Expand Down
Expand Up @@ -10,7 +10,7 @@
class HGCalStage1TruncationWrapper : public HGCalStage1TruncationWrapperBase {
public:
HGCalStage1TruncationWrapper(const edm::ParameterSet& conf);
~HGCalStage1TruncationWrapper() override {}
~HGCalStage1TruncationWrapper() override = default;

void configure(
const std::tuple<const HGCalTriggerGeometryBase* const, const unsigned&, const uint32_t&>& configuration) override;
Expand Down
Expand Up @@ -19,7 +19,7 @@
class HGCalTowerMapsWrapper : public HGCalTowerMapsWrapperBase {
public:
HGCalTowerMapsWrapper(const edm::ParameterSet& conf);
~HGCalTowerMapsWrapper() override {}
~HGCalTowerMapsWrapper() override = default;

void configure(const std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&>& parameters) override;

Expand Down
Expand Up @@ -112,5 +112,5 @@
)

hgcalBackEndLayer1ProducerHFNose = hgcalBackEndLayer1Producer.clone(
InputTriggerCells = cms.InputTag('hgcalConcentratorProducerHFNose:HGCalConcentratorProcessorSelection')
InputTriggerCells = 'hgcalConcentratorProducerHFNose:HGCalConcentratorProcessorSelection'
)
17 changes: 6 additions & 11 deletions L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl_SA.cc
Expand Up @@ -3,12 +3,6 @@
#include <map>
#include <cmath>

HGCalHistoClusteringImplSA::HGCalHistoClusteringImplSA() {}

// void HGCalHistoClusteringImplSA::runAlgorithm() const {

// }

std::vector<l1thgcfirmware::HGCalMulticluster> HGCalHistoClusteringImplSA::clusterSeedMulticluster_SA(
const std::vector<l1thgcfirmware::HGCalCluster>& clusters,
const std::vector<l1thgcfirmware::HGCalSeed>& seeds,
Expand All @@ -26,7 +20,8 @@ std::vector<l1thgcfirmware::HGCalMulticluster> HGCalHistoClusteringImplSA::clust
double radiusCoefficientB =
configuration.dr_byLayer_coefficientB().empty() ? 0 : configuration.dr_byLayer_coefficientB()[clu.layer()];

double minDist = radiusCoefficientA + radiusCoefficientB * (configuration.midRadius() - std::abs(clu.eta()));
double minDistSqrd = radiusCoefficientA + radiusCoefficientB * (configuration.midRadius() - std::abs(clu.eta()));
minDistSqrd *= minDistSqrd;

std::vector<std::pair<int, double>> targetSeedsEnergy;

Expand All @@ -39,11 +34,11 @@ std::vector<l1thgcfirmware::HGCalMulticluster> HGCalHistoClusteringImplSA::clust

double seedEnergy = seed.energy();

double d = sqrt((clu.x() - seed.x()) * (clu.x() - seed.x()) + (clu.y() - seed.y()) * (clu.y() - seed.y()));
double d = (clu.x() - seed.x()) * (clu.x() - seed.x()) + (clu.y() - seed.y()) * (clu.y() - seed.y());

if (d < minDist) {
if (d < minDistSqrd) {
// NearestNeighbour
minDist = d;
minDistSqrd = d;

if (targetSeedsEnergy.empty()) {
targetSeedsEnergy.emplace_back(iseed, seedEnergy);
Expand Down Expand Up @@ -107,4 +102,4 @@ void HGCalHistoClusteringImplSA::finalizeClusters_SA(
}
}
}
}
}
@@ -1,7 +1,5 @@
#include "L1Trigger/L1THGCal/interface/backend/HGCalSortingTruncationImpl_SA.h"

HGCalSortingTruncationImplSA::HGCalSortingTruncationImplSA() {}

void HGCalSortingTruncationImplSA::sortAndTruncate_SA(
const std::vector<l1thgcfirmware::HGCalMulticluster>& inputMulticlusters,
std::vector<l1thgcfirmware::HGCalMulticluster>& outputMulticlusters,
Expand Down
10 changes: 6 additions & 4 deletions L1Trigger/L1THGCal/src/backend/HGCalStage1TruncationImpl.cc
Expand Up @@ -30,10 +30,12 @@ void HGCalStage1TruncationImpl::run(uint32_t fpga_id,
double x = position.x();
double y = position.y();
double z = position.z();
double roverz = std::sqrt(x * x + y * y) / std::abs(z);
roverz = (roverz < roz_min_ ? roz_min_ : roverz);
roverz = (roverz > roz_max_ ? roz_max_ : roverz);
unsigned roverzbin = (roz_bin_size_ > 0. ? unsigned((roverz - roz_min_) / roz_bin_size_) : 0);
unsigned roverzbin = 0;
if (roz_bin_size_ > 0.) {
double roverz = std::sqrt(x * x + y * y) / std::abs(z) - roz_min_;
roverz = std::clamp(roverz, 0., roz_max_ - roz_min_);
roverzbin = unsigned(roverz / roz_bin_size_);
}
double phi = rotatedphi(x, y, z, sector120);
unsigned phibin = phiBin(roverzbin, phi);
unsigned packed_bin = packBin(roverzbin, phibin);
Expand Down
13 changes: 6 additions & 7 deletions L1Trigger/L1THGCal/src/backend/HGCalStage1TruncationImpl_SA.cc
@@ -1,8 +1,6 @@
#include "L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl_SA.h"
#include <cmath>

HGCalStage1TruncationImplSA::HGCalStage1TruncationImplSA() {}

unsigned HGCalStage1TruncationImplSA::run(const l1thgcfirmware::HGCalTriggerCellSACollection& tcs_in,
const l1thgcfirmware::Stage1TruncationConfig& theConf,
l1thgcfirmware::HGCalTriggerCellSACollection& tcs_out) const {
Expand All @@ -25,11 +23,12 @@ unsigned HGCalStage1TruncationImplSA::run(const l1thgcfirmware::HGCalTriggerCell
double x = tc.x();
double y = tc.y();
double z = tc.z();
double roverz = std::sqrt(x * x + y * y) / std::abs(z);
roverz = (roverz < rozmin ? rozmin : roverz);
roverz = (roverz > rozmax ? rozmax : roverz);

unsigned roverzbin = (roz_bin_size > 0. ? unsigned((roverz - rozmin) / roz_bin_size) : 0);
unsigned roverzbin = 0;
if (roz_bin_size > 0.) {
double roverz = std::sqrt(x * x + y * y) / std::abs(z) - rozmin;
roverz = std::clamp(roverz, 0., rozmax - rozmin);
roverzbin = unsigned(roverz / roz_bin_size);
}
double phi = rotatedphi(x, y, z, sector120);
int phibin = phiBin(roverzbin, phi, phiedges);
if (phibin < 0)
Expand Down

0 comments on commit fc77fa5

Please sign in to comment.