Skip to content

Commit

Permalink
Merge pull request #36337 from hgc-tpg/hgc-tpg-integration-211202
Browse files Browse the repository at this point in the history
[HGCAL trigger] Migration to new code structure - First pass
  • Loading branch information
cmsbuild committed Feb 17, 2022
2 parents 97eaa02 + fc77fa5 commit 72a3ef1
Show file tree
Hide file tree
Showing 67 changed files with 3,182 additions and 479 deletions.
43 changes: 43 additions & 0 deletions L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h
@@ -0,0 +1,43 @@
#ifndef __L1Trigger_L1THGCal_HGCalAlgoWrapperBase_h__
#define __L1Trigger_L1THGCal_HGCalAlgoWrapperBase_h__

#include "L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBaseT.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/L1THGCal/interface/HGCalCluster.h"
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h"

#include "DataFormats/L1THGCal/interface/HGCalTowerMap.h"

typedef HGCalAlgoWrapperBaseT<
std::pair<const std::vector<edm::Ptr<l1t::HGCalCluster>>, const std::vector<std::pair<GlobalPoint, double>>>,
std::pair<l1t::HGCalMulticlusterBxCollection&, l1t::HGCalClusterBxCollection&>,
std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&>>
HGCalHistoClusteringWrapperBase;

typedef HGCalAlgoWrapperBaseT<std::vector<edm::Ptr<l1t::HGCalTowerMap>>,
l1t::HGCalTowerBxCollection,
std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&>>
HGCalTowerMapsWrapperBase;

typedef HGCalAlgoWrapperBaseT<l1t::HGCalMulticlusterBxCollection,
l1t::HGCalMulticlusterBxCollection,
std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&>>
HGCalStage2FilteringWrapperBase;

typedef HGCalAlgoWrapperBaseT<std::vector<edm::Ptr<l1t::HGCalTriggerCell>>,
std::vector<edm::Ptr<l1t::HGCalTriggerCell>>,
std::tuple<const HGCalTriggerGeometryBase* const, const unsigned&, const uint32_t&>>
HGCalStage1TruncationWrapperBase;

#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory<HGCalHistoClusteringWrapperBase*(const edm::ParameterSet&)>
HGCalHistoClusteringWrapperBaseFactory;
typedef edmplugin::PluginFactory<HGCalTowerMapsWrapperBase*(const edm::ParameterSet&)> HGCalTowerMapsWrapperBaseFactory;
typedef edmplugin::PluginFactory<HGCalStage2FilteringWrapperBase*(const edm::ParameterSet&)>
HGCalStage2FilteringWrapperBaseFactory;
typedef edmplugin::PluginFactory<HGCalStage1TruncationWrapperBase*(const edm::ParameterSet&)>
HGCalStage1TruncationWrapperBaseFactory;

#endif
23 changes: 23 additions & 0 deletions L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBaseT.h
@@ -0,0 +1,23 @@
#ifndef __L1Trigger_L1THGCal_HGCalAlgoWrapperBaseT_h__
#define __L1Trigger_L1THGCal_HGCalAlgoWrapperBaseT_h__

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include <string>

template <typename InputCollection, typename OutputCollection, typename Tparam>
class HGCalAlgoWrapperBaseT {
public:
HGCalAlgoWrapperBaseT(const edm::ParameterSet& conf) : name_(conf.getParameter<std::string>("AlgoName")) {}

virtual ~HGCalAlgoWrapperBaseT() {}

virtual void configure(const Tparam& parameters) = 0;
virtual void process(const InputCollection& inputCollection, OutputCollection& outputCollection) const = 0;

const std::string& name() const { return name_; }

private:
const std::string name_;
};

#endif
10 changes: 7 additions & 3 deletions L1Trigger/L1THGCal/interface/HGCalProcessorBase.h
Expand Up @@ -19,24 +19,28 @@ typedef HGCalProcessorBaseT<HGCalDigiCollection, l1t::HGCalTriggerCellBxCollecti
typedef HGCalProcessorBaseT<edm::Handle<l1t::HGCalTriggerCellBxCollection>,
std::tuple<l1t::HGCalTriggerCellBxCollection,
l1t::HGCalTriggerSumsBxCollection,
l1t::HGCalConcentratorDataBxCollection> >
l1t::HGCalConcentratorDataBxCollection>>
HGCalConcentratorProcessorBase;
typedef HGCalProcessorBaseT<edm::Handle<l1t::HGCalTriggerCellBxCollection>, l1t::HGCalClusterBxCollection>
HGCalBackendLayer1ProcessorBase;
typedef HGCalProcessorBaseT<std::pair<uint32_t, std::vector<edm::Ptr<l1t::HGCalTriggerCell>>>,
std::vector<edm::Ptr<l1t::HGCalTriggerCell>>>
HGCalBackendStage1ProcessorBase;
typedef HGCalProcessorBaseT<edm::Handle<l1t::HGCalClusterBxCollection>,
std::pair<l1t::HGCalMulticlusterBxCollection, l1t::HGCalClusterBxCollection> >
std::pair<l1t::HGCalMulticlusterBxCollection, l1t::HGCalClusterBxCollection>>
HGCalBackendLayer2ProcessorBase;
typedef HGCalProcessorBaseT<edm::Handle<l1t::HGCalTriggerSumsBxCollection>, l1t::HGCalTowerMapBxCollection>
HGCalTowerMapProcessorBase;
typedef HGCalProcessorBaseT<
std::pair<edm::Handle<l1t::HGCalTowerMapBxCollection>, edm::Handle<l1t::HGCalClusterBxCollection> >,
std::pair<edm::Handle<l1t::HGCalTowerMapBxCollection>, edm::Handle<l1t::HGCalClusterBxCollection>>,
l1t::HGCalTowerBxCollection>
HGCalTowerProcessorBase;

#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory<HGCalVFEProcessorBase*(const edm::ParameterSet&)> HGCalVFEProcessorBaseFactory;
typedef edmplugin::PluginFactory<HGCalConcentratorProcessorBase*(const edm::ParameterSet&)> HGCalConcentratorFactory;
typedef edmplugin::PluginFactory<HGCalBackendLayer1ProcessorBase*(const edm::ParameterSet&)> HGCalBackendLayer1Factory;
typedef edmplugin::PluginFactory<HGCalBackendStage1ProcessorBase*(const edm::ParameterSet&)> HGCalBackendStage1Factory;
typedef edmplugin::PluginFactory<HGCalBackendLayer2ProcessorBase*(const edm::ParameterSet&)> HGCalBackendLayer2Factory;
typedef edmplugin::PluginFactory<HGCalTowerMapProcessorBase*(const edm::ParameterSet&)> HGCalTowerMapFactory;
typedef edmplugin::PluginFactory<HGCalTowerProcessorBase*(const edm::ParameterSet&)> HGCalTowerFactory;
Expand Down
24 changes: 24 additions & 0 deletions L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1Processor.h
@@ -0,0 +1,24 @@
#ifndef __L1Trigger_L1THGCal_HGCalBackendLayer1Processor_h__
#define __L1Trigger_L1THGCal_HGCalBackendLayer1Processor_h__

#include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h"

#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
#include "DataFormats/L1THGCal/interface/HGCalCluster.h"

#include "L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl.h"
#include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h"

class HGCalBackendLayer1Processor : public HGCalBackendLayer1ProcessorBase {
public:
HGCalBackendLayer1Processor(const edm::ParameterSet& conf);

void run(const edm::Handle<l1t::HGCalTriggerCellBxCollection>& collHandle,
l1t::HGCalClusterBxCollection& collCluster2D) override;

private:
std::unique_ptr<HGCalClusteringDummyImpl> clusteringDummy_;
std::unique_ptr<HGCalStage1TruncationImpl> truncation_;
};

#endif
25 changes: 25 additions & 0 deletions L1Trigger/L1THGCal/interface/backend/HGCalBackendStage1Processor.h
@@ -0,0 +1,25 @@
#ifndef __L1Trigger_L1THGCal_HGCalBackendStage1Processor_h__
#define __L1Trigger_L1THGCal_HGCalBackendStage1Processor_h__

#include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h"
#include "L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h"

#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
#include "DataFormats/L1THGCal/interface/HGCalCluster.h"

#include "L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl.h"
#include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h"

class HGCalBackendStage1Processor : public HGCalBackendStage1ProcessorBase {
public:
HGCalBackendStage1Processor(const edm::ParameterSet& conf);

void run(const std::pair<uint32_t, std::vector<edm::Ptr<l1t::HGCalTriggerCell>>>& fpga_id_tcs,
std::vector<edm::Ptr<l1t::HGCalTriggerCell>>& truncated_tcs) override;

private:
std::unique_ptr<HGCalStage1TruncationWrapperBase> truncationWrapper_;
const edm::ParameterSet conf_;
};

#endif
61 changes: 61 additions & 0 deletions L1Trigger/L1THGCal/interface/backend/HGCalCluster_SA.h
@@ -0,0 +1,61 @@
#ifndef L1Trigger_L1THGCal_HGCalCluster_SA_h
#define L1Trigger_L1THGCal_HGCalCluster_SA_h

#include <vector>

namespace l1thgcfirmware {

class HGCalCluster {
public:
HGCalCluster(float x,
float y,
float z,
int zside,
unsigned int layer,
float eta,
float phi,
float pt,
float mipPt,
unsigned int index_cmssw)
: x_(x),
y_(y),
z_(z),
zside_(zside),
layer_(layer),
eta_(eta),
phi_(phi),
pt_(pt),
mipPt_(mipPt),
index_cmssw_(index_cmssw) {}

~HGCalCluster() = default;

float x() const { return x_; }
float y() const { return y_; }
float z() const { return z_; }
float zside() const { return zside_; }
unsigned int layer() const { return layer_; }
float eta() const { return eta_; }
float phi() const { return phi_; }
float pt() const { return pt_; }
float mipPt() const { return mipPt_; }
unsigned int index_cmssw() const { return index_cmssw_; }

private:
float x_;
float y_;
float z_;
int zside_;
unsigned int layer_;
float eta_;
float phi_;
float pt_;
float mipPt_;
unsigned int index_cmssw_;
};

typedef std::vector<HGCalCluster> HGCalClusterSACollection;

} // namespace l1thgcfirmware

#endif
@@ -0,0 +1,56 @@
#ifndef __L1Trigger_L1THGCal_HGCalHistoCluteringConfig_SA_h__
#define __L1Trigger_L1THGCal_HGCalHistoCluteringConfig_SA_h__

#include <vector>

namespace l1thgcfirmware {

class ClusterAlgoConfig {
public:
ClusterAlgoConfig(const double midRadius,
const double dr,
const std::vector<double>& dr_byLayer_coefficientA,
const std::vector<double>& dr_byLayer_coefficientB,
const float ptC3dThreshold)
: midRadius_(midRadius),
dr_(dr),
dr_byLayer_coefficientA_(dr_byLayer_coefficientA),
dr_byLayer_coefficientB_(dr_byLayer_coefficientB),
ptC3dThreshold_(ptC3dThreshold) {}

void setParameters(double midRadius,
double dr,
const std::vector<double>& dr_byLayer_coefficientA,
const std::vector<double>& dr_byLayer_coefficientB,
float ptC3dThreshold) {
midRadius_ = midRadius;
dr_ = dr;
dr_byLayer_coefficientA_ = dr_byLayer_coefficientA;
dr_byLayer_coefficientB_ = dr_byLayer_coefficientB;
ptC3dThreshold_ = ptC3dThreshold;
}

void setParameters(const ClusterAlgoConfig& newConfig) {
setParameters(newConfig.midRadius(),
newConfig.dr(),
newConfig.dr_byLayer_coefficientA(),
newConfig.dr_byLayer_coefficientB(),
newConfig.ptC3dThreshold());
}
double midRadius() const { return midRadius_; }
double dr() const { return dr_; }
const std::vector<double>& dr_byLayer_coefficientA() const { return dr_byLayer_coefficientA_; }
const std::vector<double>& dr_byLayer_coefficientB() const { return dr_byLayer_coefficientB_; }
float ptC3dThreshold() const { return ptC3dThreshold_; }

private:
double midRadius_;
double dr_;
std::vector<double> dr_byLayer_coefficientA_;
std::vector<double> dr_byLayer_coefficientB_;
float ptC3dThreshold_;
};

} // namespace l1thgcfirmware

#endif
33 changes: 33 additions & 0 deletions L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl_SA.h
@@ -0,0 +1,33 @@
#ifndef __L1Trigger_L1THGCal_HGCalHistoClusteringImplSA_h__
#define __L1Trigger_L1THGCal_HGCalHistoClusteringImplSA_h__

#include "L1Trigger/L1THGCal/interface/backend/HGCalCluster_SA.h"
#include "L1Trigger/L1THGCal/interface/backend/HGCalSeed_SA.h"
#include "L1Trigger/L1THGCal/interface/backend/HGCalMulticluster_SA.h"
#include "L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringConfig_SA.h"

#include <string>
#include <vector>
#include <memory>

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

void runAlgorithm() const;

std::vector<l1thgcfirmware::HGCalMulticluster> clusterSeedMulticluster_SA(
const std::vector<l1thgcfirmware::HGCalCluster>& clusters,
const std::vector<l1thgcfirmware::HGCalSeed>& seeds,
std::vector<l1thgcfirmware::HGCalCluster>& rejected_clusters,
const l1thgcfirmware::ClusterAlgoConfig& configuration) const;

void finalizeClusters_SA(const std::vector<l1thgcfirmware::HGCalMulticluster>&,
const std::vector<l1thgcfirmware::HGCalCluster>&,
std::vector<l1thgcfirmware::HGCalMulticluster>&,
std::vector<l1thgcfirmware::HGCalCluster>&,
const l1thgcfirmware::ClusterAlgoConfig& configuration) const;
};

#endif
57 changes: 57 additions & 0 deletions L1Trigger/L1THGCal/interface/backend/HGCalMulticluster_SA.h
@@ -0,0 +1,57 @@
#ifndef L1Trigger_L1THGCal_HGCalMulticluster_SA_h
#define L1Trigger_L1THGCal_HGCalMulticluster_SA_h

#include "L1Trigger/L1THGCal/interface/backend/HGCalCluster_SA.h"

#include <vector>

namespace l1thgcfirmware {

class HGCalMulticluster {
public:
HGCalMulticluster()
: centre_x_(0),
centre_y_(0),
centre_z_(0),
centreProj_x_(0),
centreProj_y_(0),
centreProj_z_(0),
mipPt_(0),
sumPt_() {}

HGCalMulticluster(const l1thgcfirmware::HGCalCluster& tc, float fraction = 1.);

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

~HGCalMulticluster() = default;

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

unsigned size() const { return constituents_.size(); }

float sumPt() const { return sumPt_; }

private:
// Could replace this with own simple implementation of GlobalPoint?
// Or just a struct?
float centre_x_;
float centre_y_;
float centre_z_;

float centreProj_x_;
float centreProj_y_;
float centreProj_z_;

float mipPt_;
float sumPt_;

std::vector<l1thgcfirmware::HGCalCluster> constituents_;

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

typedef std::vector<HGCalMulticluster> HGCalMulticlusterSACollection;

} // namespace l1thgcfirmware

#endif
28 changes: 28 additions & 0 deletions L1Trigger/L1THGCal/interface/backend/HGCalSeed_SA.h
@@ -0,0 +1,28 @@
#ifndef L1Trigger_L1THGCal_HGCalSeed_SA_h
#define L1Trigger_L1THGCal_HGCalSeed_SA_h

namespace l1thgcfirmware {

class HGCalSeed {
public:
HGCalSeed(float x, float y, float z, float energy) : x_(x), y_(y), z_(z), energy_(energy) {}

~HGCalSeed(){};

float x() const { return x_; }
float y() const { return y_; }
float z() const { return z_; }
float energy() const { return energy_; }

private:
float x_;
float y_;
float z_;
float energy_;
};

typedef std::vector<HGCalSeed> HGCalSeedSACollection;

} // namespace l1thgcfirmware

#endif

0 comments on commit 72a3ef1

Please sign in to comment.