Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: FillDescriptions + Barrel TM18 emulator #123

Open
wants to merge 6 commits into
base: L1PF_12_5_X
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions DataFormats/L1TParticleFlow/interface/datatypes.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
#ifndef DataFormats_L1TParticleFlow_datatypes_h
#define DataFormats_L1TParticleFlow_datatypes_h

#if (!defined(__CLANG__)) && defined(__GNUC__) && defined(CMSSW_GIT_HASH)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wint-in-bool-context"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif
#include <ap_int.h>
#if (!defined(__CLANG__)) && defined(__GNUC__) && defined(CMSSW_GIT_HASH)
#pragma GCC diagnostic pop
#endif

#include <ap_int.h>
#include <cassert>
#include <cmath>
Expand Down Expand Up @@ -163,8 +152,14 @@ namespace l1ct {
inline float floatPt(pt_t pt) { return pt.to_float(); }
inline float floatPt(dpt_t pt) { return pt.to_float(); }
inline float floatPt(pt2_t pt2) { return pt2.to_float(); }
inline int intPt(pt_t pt) { return (ap_ufixed<16, 14>(pt) << 2).to_int(); }
inline int intPt(dpt_t pt) { return (ap_fixed<18, 16>(pt) << 2).to_int(); }
inline int intPt(pt_t pt) {
ap_uint<pt_t::width> rawPt = pt.range();
return rawPt.to_int();
}
inline int intPt(dpt_t pt) {
ap_int<dpt_t::width> rawPt = pt.range();
return rawPt.to_int();
}
inline float floatEta(eta_t eta) { return eta.to_float() * ETAPHI_LSB; }
inline float floatPhi(phi_t phi) { return phi.to_float() * ETAPHI_LSB; }
inline float floatEta(tkdeta_t eta) { return eta.to_float() * ETAPHI_LSB; }
Expand All @@ -181,9 +176,9 @@ namespace l1ct {

inline pt_t makePt(int pt) { return ap_ufixed<16, 14>(pt) >> 2; }
inline dpt_t makeDPt(int dpt) { return ap_fixed<18, 16>(dpt) >> 2; }
inline pt_t makePtFromFloat(float pt) { return pt_t(0.25 * round(pt * 4)); }
inline pt_t makePtFromFloat(float pt) { return pt_t(0.25 * std::round(pt * 4)); }
inline dpt_t makeDPtFromFloat(float dpt) { return dpt_t(dpt); }
inline z0_t makeZ0(float z0) { return z0_t(round(z0 / Z0_LSB)); }
inline z0_t makeZ0(float z0) { return z0_t(std::round(z0 / Z0_LSB)); }

inline ap_uint<pt_t::width> ptToInt(pt_t pt) {
// note: this can be synthethized, e.g. when pT is used as intex in a LUT
Expand Down Expand Up @@ -216,7 +211,7 @@ namespace l1ct {
inline float maxAbsPhi() { return ((1 << (phi_t::width - 1)) - 1) * ETAPHI_LSB; }
inline float maxAbsGlbEta() { return ((1 << (glbeta_t::width - 1)) - 1) * ETAPHI_LSB; }
inline float maxAbsGlbPhi() { return ((1 << (glbphi_t::width - 1)) - 1) * ETAPHI_LSB; }
}; // namespace Scales
} // namespace Scales

inline int dr2_int(eta_t eta1, phi_t phi1, eta_t eta2, phi_t phi2) {
ap_int<eta_t::width + 1> deta = (eta1 - eta2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define L1Trigger_Phase2L1ParticleFlow_L1TCorrelatorLayer1PatternFileWriter_h

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "L1Trigger/DemonstratorTools/interface/BoardDataWriter.h"
#include "L1Trigger/DemonstratorTools/interface/utilities.h"

Expand All @@ -12,6 +13,8 @@ class L1TCorrelatorLayer1PatternFileWriter {
L1TCorrelatorLayer1PatternFileWriter(const edm::ParameterSet& iConfig, const l1ct::Event& eventTemplate);
~L1TCorrelatorLayer1PatternFileWriter();

static edm::ParameterSetDescription getParameterSetDescription();

void write(const l1ct::Event& event);
void flush();

Expand Down Expand Up @@ -51,19 +54,30 @@ class L1TCorrelatorLayer1PatternFileWriter {

static Partition parsePartition(const std::string& partition);

static std::unique_ptr<edm::ParameterDescriptionNode> describeTF();
static std::unique_ptr<edm::ParameterDescriptionNode> describeGCT();
static std::unique_ptr<edm::ParameterDescriptionNode> describeHGC();
static std::unique_ptr<edm::ParameterDescriptionNode> describeGMT();
static std::unique_ptr<edm::ParameterDescriptionNode> describeGTT();
static std::unique_ptr<edm::ParameterDescriptionNode> describePuppi();
static std::unique_ptr<edm::ParameterDescriptionNode> describeEG();

void configTimeSlices(const edm::ParameterSet& iConfig,
const std::string& prefix,
unsigned int nSectors,
unsigned int nTimeSlices,
unsigned int linksFactor);
static std::unique_ptr<edm::ParameterDescriptionNode> describeTimeSlices(const std::string& prefix);
void configSectors(const edm::ParameterSet& iConfig,
const std::string& prefix,
unsigned int nSectors,
unsigned int linksFactor);
static std::unique_ptr<edm::ParameterDescriptionNode> describeSectors(const std::string& prefix);
void configLinks(const edm::ParameterSet& iConfig,
const std::string& prefix,
unsigned int linksFactor,
unsigned int offset);
static std::unique_ptr<edm::ParameterDescriptionNode> describeLinks(const std::string& prefix);

void writeTF(const l1ct::Event& event, l1t::demo::EventData& out);
void writeBarrelGCT(const l1ct::Event& event, l1t::demo::EventData& out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {

Expand All @@ -16,6 +17,8 @@ namespace l1ct {
EGInputSelectorEmuConfig(unsigned int emIdMask, unsigned int nHADCALO_IN, unsigned int nEMCALO_OUT, int debug)
: idMask(emIdMask), nHADCALO_IN(nHADCALO_IN), nEMCALO_OUT(nEMCALO_OUT), debug(debug) {}

static edm::ParameterSetDescription getParameterSetDescription();

emid_t idMask;
unsigned int nHADCALO_IN;
unsigned int nEMCALO_OUT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {

Expand Down Expand Up @@ -47,6 +48,7 @@ namespace l1ct {
ap_int<z0_t::width + 1> dZ;
int dRMin2;
int dRMax2;
static edm::ParameterSetDescription getParameterSetDescription();
};

IsoParameters tkIsoParams_tkEle;
Expand All @@ -65,6 +67,7 @@ namespace l1ct {
const double bdtScore_loose_wp; // XGBOOST score
const double bdtScore_tight_wp; // XGBOOST score
const std::string conifer_model;
static edm::ParameterSetDescription getParameterSetDescription();
};

CompIDParameters compIDparams;
Expand Down Expand Up @@ -131,6 +134,8 @@ namespace l1ct {
hwIsoTypeTkEm(hwIsoTypeTkEm),
compIDparams(compIDparams),
debug(debug) {}

static edm::ParameterSetDescription getParameterSetDescription();
};

class PFTkEGAlgoEmulator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ namespace l1ct {
PFTkEGSorterBarrelEmulator(const edm::ParameterSet& iConfig)
: PFTkEGSorterEmulator(iConfig.getParameter<uint32_t>("nObjToSort"),
iConfig.getParameter<uint32_t>("nObjSorted")) {}

static edm::ParameterSetDescription getParameterSetDescription() {
return PFTkEGSorterEmulator::getParameterSetDescription();
}
#endif

~PFTkEGSorterBarrelEmulator() override {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#ifdef CMSSW_GIT_HASH
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#endif

namespace l1ct {
Expand All @@ -22,6 +23,12 @@ namespace l1ct {
: PFTkEGSorterEmulator(iConfig.getParameter<uint32_t>("nObjToSort"),
iConfig.getParameter<uint32_t>("nObjSorted")) {}

static edm::ParameterSetDescription getParameterSetDescription() {
edm::ParameterSetDescription description;
description.add<uint32_t>("nObjToSort");
description.add<uint32_t>("nObjSorted");
return description;
}
#endif

virtual ~PFTkEGSorterEmulator() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {
class HgcalClusterDecoderEmulator {
Expand All @@ -16,6 +17,9 @@ namespace l1ct {
HgcalClusterDecoderEmulator(const edm::ParameterSet &pset);

~HgcalClusterDecoderEmulator();

static edm::ParameterSetDescription getParameterSetDescription();

l1ct::HadCaloObjEmu decode(const ap_uint<256> &in) const;
};
} // namespace l1ct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {
class GMTMuonDecoderEmulator {
public:
GMTMuonDecoderEmulator(float z0Scale, float dxyScale);
GMTMuonDecoderEmulator(const edm::ParameterSet &iConfig);

~GMTMuonDecoderEmulator();

static edm::ParameterSetDescription getParameterSetDescription();

l1ct::MuObjEmu decode(const ap_uint<64> &in) const;

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {
class TrackInputEmulator {
Expand All @@ -27,6 +28,8 @@ namespace l1ct {
bool bitwise = true,
bool slim = true);

static edm::ParameterSetDescription getParameterSetDescription();

std::pair<l1ct::TkObjEmu, bool> decodeTrack(ap_uint<96> tkword, const l1ct::PFRegionEmu &sector) const {
return decodeTrack(tkword, sector, bitwise_, slim_);
}
Expand Down
5 changes: 4 additions & 1 deletion L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo2hgc_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {

Expand All @@ -27,6 +28,8 @@ namespace l1ct {

~PFAlgo2HGCEmulator() override {}

static edm::ParameterSetDescription getParameterSetDescription();

void run(const PFInputRegion& in, OutputRegion& out) const override;

/// moves all objects from out.pfphoton to the beginning of out.pfneutral: nothing to do for this algo
Expand Down
5 changes: 4 additions & 1 deletion L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo3_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {

Expand Down Expand Up @@ -37,6 +38,8 @@ namespace l1ct {

~PFAlgo3Emulator() override {}

static edm::ParameterSetDescription getParameterSetDescription();

void run(const PFInputRegion& in, OutputRegion& out) const override;

void toFirmware(const PFInputRegion& in,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {

Expand Down Expand Up @@ -38,6 +39,7 @@ namespace l1ct {
void loadPtErrBins(
unsigned int nbins, const float absetas[], const float scales[], const float offs[], bool verbose = false);
void loadPtErrBins(const edm::ParameterSet& iConfig);
static void addCaloResolutionParameterSetDescription(edm::ParameterSetDescription& to);

void setDebug(bool debug = true) { debug_ = debug; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {

Expand All @@ -18,6 +19,8 @@ namespace l1ct {

~PFAlgoDummyEmulator() override {}

static edm::ParameterSetDescription getParameterSetDescription();

void run(const PFInputRegion& in, OutputRegion& out) const override;

/// moves all objects from out.pfphoton to the beginning of out.pfneutral: nothing to do for this algo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

namespace edm {
class ParameterSet;
}
class ParameterSetDescription;
} // namespace edm

namespace l1ct {

Expand Down Expand Up @@ -138,6 +139,8 @@ namespace l1ct {

LinPuppiEmulator(const edm::ParameterSet &iConfig);

static edm::ParameterSetDescription getParameterSetDescription();

// charged
void linpuppi_chs_ref(const PFRegionEmu &region,
const PVObjEmu &pv,
Expand Down
Loading