2 #include <TLorentzVector.h> 28 static std::unique_ptr<tensorflow::SessionCache> initializeGlobalCache(
const edm::ParameterSet&);
32 std::unique_ptr<TauNNId> fTauNNId_;
40 std::unique_ptr<l1t::PFTauCollection>& iTaus);
44 std::unique_ptr<PFTauCollection>& outputTaus);
60 : fSeedPt_(
cfg.getParameter<double>(
"seedpt")),
61 fConeSize_(
cfg.getParameter<double>(
"conesize")),
62 fTauSize_(
cfg.getParameter<double>(
"tausize")),
63 fMaxTaus_(
cfg.getParameter<
int>(
"maxtaus")),
64 fNParticles_(
cfg.getParameter<
int>(
"nparticles")),
65 fHW(
cfg.getParameter<
bool>(
"HW")),
66 fEMSeed(
cfg.getParameter<
bool>(
"emseed")),
67 fDebug(
cfg.getParameter<
bool>(
"debug")),
74 fTauNNId_ = std::make_unique<TauNNId>(lNNFile.find(
"v0") == std::string::npos ?
"input_1:0" :
"dense_1_input:0",
79 produces<l1t::PFTauCollection>(
"L1PFTausNN");
85 return std::make_unique<tensorflow::SessionCache>(
graphPath);
91 auto lTaus = std::make_unique<l1t::PFTauCollection>();
101 lTaus->push_back(
dummy);
107 std::unique_ptr<l1t::PFTauCollection>& iTaus) {
109 std::vector<unique_ptr<l1t::PFCandidate>> pfChargedHadrons_sort_v;
110 std::vector<unique_ptr<l1t::PFCandidate>> pfChargedHadrons_seeds_v;
111 for (
const auto& l1PFCand :
parts)
114 pfChargedHadrons_sort_v.push_back(std::make_unique<l1t::PFCandidate>(l1PFCand));
116 if (pfChargedHadrons_sort_v.empty())
119 pfChargedHadrons_sort_v.begin(),
120 pfChargedHadrons_sort_v.end(),
121 [](std::unique_ptr<l1t::PFCandidate>&
i, std::unique_ptr<l1t::PFCandidate>&
j) {
return (
i->pt() >
j->pt()); });
123 pfChargedHadrons_seeds_v.push_back(
std::move(pfChargedHadrons_sort_v[0]));
124 for (
unsigned int i0 = 1; i0 < pfChargedHadrons_sort_v.size(); i0++) {
126 for (
unsigned int i1 = 0;
i1 < pfChargedHadrons_seeds_v.size();
i1++) {
132 pfChargedHadrons_seeds_v.push_back(
std::move(pfChargedHadrons_sort_v[i0]));
133 if (
int(pfChargedHadrons_seeds_v.size()) >
fMaxTaus_ - 1)
136 for (
unsigned int i0 = 0; i0 < pfChargedHadrons_seeds_v.size(); i0++) {
137 addTau(*(pfChargedHadrons_seeds_v[i0]),
parts, iTaus);
144 std::unique_ptr<l1t::PFTauCollection>& outputTaus) {
151 for (
const auto& l1PFCand : iParts) {
163 dxy = l1PFCand.dxy();
166 pfTauCands.push_back(l1PFCand);
173 float* lNNVector =
fTauNNId_->NNVectorVar();
178 outputTaus->push_back(l1PFTau);
183 desc.add<
std::string>(
"NNFileName",
"L1Trigger/Phase2L1ParticleFlow/data/tau_3layer.pb");
184 desc.add<
double>(
"tausize", 0.1);
185 desc.add<
int>(
"maxtaus", 5);
186 desc.add<
int>(
"nparticles", 10);
187 desc.add<
double>(
"conesize", 0.4);
188 desc.add<
double>(
"seedpt", 20);
189 desc.add<
bool>(
"HW",
true);
190 desc.add<
bool>(
"emseed",
true);
191 desc.add<
bool>(
"debug",
false);
193 descriptions.
add(
"L1NNTauProducer",
desc);
198 std::unique_ptr<l1t::PFTauCollection>& iTaus) {
215 for (
unsigned i0 = 0; i0 <
parts.size(); i0++) {
224 input2_t d1r2 = d1eta * d1eta + d1phi * d1phi;
227 p1z_tot = p1z_tot + tmppt * (1 - d1r2 * half);
228 p1y_tot = p1y_tot + tmppt * d1phi;
229 p1x_tot = p1x_tot + tmppt * d1eta;
230 p1_tot = p1_tot + tmppt;
241 input2_t tmpmass1 = (p1_tot * p1_tot - p1x_tot * p1x_tot - p1y_tot * p1y_tot - p1z_tot * p1z_tot);
253 for (
unsigned i0 = 0; i0 < 80; i0++)
254 pNNVec[i0] =
float(lNNVector[i0]);
267 l1ctTau.
hwRawId = ap_uint<10>(
NN * 1024);
281 l1PFTau.
setZ0(
float(
z0) * 0.05);
286 iTaus->push_back(l1PFTau);
290 std::unique_ptr<l1t::PFTauCollection>& iTaus) {
293 std::vector<l1t::PFCandidate>
work;
300 std::vector<l1t::PFCandidate>
seeds;
306 part.id() == lSeed) &&
319 std::vector<l1t::PFCandidate> particlesInCone;
325 work.erase(std::remove_if(
void set_encodedTau(l1gt::PackedTau encodedTau)
glbeta_t makeGlbEta(float eta)
float floatPhi(phi_t phi)
float floatEta(eta_t eta)
static constexpr float track_trigger_eta_max
std::string fullPath() const
L1NNTauProducer(const edm::ParameterSet &, const tensorflow::SessionCache *)
static constexpr float etaphi_base
std::unique_ptr< TauNNIdHW > fTauNNIdHW_
std::vector< l1t::PFCandidate > PFCandidateCollection
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
glbphi_t makeGlbPhi(float phi)
ap_fixed< 12, 6 > detaphi_t
void makeTau_HW(const l1t::PFCandidate &seed, l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)
edm::EDGetTokenT< vector< l1t::PFCandidate > > fL1PFToken_
std::array< uint64_t, 2 > PackedTau
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
ap_fixed< 16, 8 > input_t
void addTau(const l1t::PFCandidate &iCand, const l1t::PFCandidateCollection &iParts, std::unique_ptr< PFTauCollection > &outputTaus)
std::unique_ptr< TauNNId > fTauNNId_
constexpr Matriplex::idx_t NN
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
~L1NNTauProducer() override
void setLogging(const std::string &level="3")
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static std::unique_ptr< tensorflow::SessionCache > initializeGlobalCache(const edm::ParameterSet &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void process_HW(const l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)
ap_fixed< 24, 12 > input2_t
ap_fixed< 16, 8 > result_t
bool inCone(l1t::PFCandidate seed, l1t::PFCandidate part, detaphi_t cone2)
static void globalEndJob(const tensorflow::SessionCache *)
void process_SW(const l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)