2 #include <TLorentzVector.h> 28 static std::unique_ptr<tensorflow::SessionCache> initializeGlobalCache(
const edm::ParameterSet&);
33 std::unique_ptr<TauNNId> fTauNNId_;
41 std::unique_ptr<l1t::PFTauCollection>& iTaus);
45 std::unique_ptr<PFTauCollection>& outputTaus);
61 : fSeedPt_(
cfg.getParameter<double>(
"seedpt")),
62 fConeSize_(
cfg.getParameter<double>(
"conesize")),
63 fTauSize_(
cfg.getParameter<double>(
"tausize")),
64 fMaxTaus_(
cfg.getParameter<
int>(
"maxtaus")),
65 fNParticles_(
cfg.getParameter<
int>(
"nparticles")),
66 fHW(
cfg.getParameter<
bool>(
"HW")),
67 fEMSeed(
cfg.getParameter<
bool>(
"emseed")),
68 fDebug(
cfg.getParameter<
bool>(
"debug")),
75 fTauNNId_ = std::make_unique<TauNNId>(lNNFile.find(
"v0") == std::string::npos ?
"input_1:0" :
"dense_1_input:0",
80 produces<l1t::PFTauCollection>(
"L1PFTausNN");
86 return std::make_unique<tensorflow::SessionCache>(
graphPath);
92 auto lTaus = std::make_unique<l1t::PFTauCollection>();
104 std::unique_ptr<l1t::PFTauCollection>& iTaus) {
106 std::vector<unique_ptr<l1t::PFCandidate>> pfChargedHadrons_sort_v;
107 std::vector<unique_ptr<l1t::PFCandidate>> pfChargedHadrons_seeds_v;
108 for (
const auto& l1PFCand :
parts)
111 pfChargedHadrons_sort_v.push_back(std::make_unique<l1t::PFCandidate>(l1PFCand));
113 if (pfChargedHadrons_sort_v.empty())
116 pfChargedHadrons_sort_v.begin(),
117 pfChargedHadrons_sort_v.end(),
118 [](std::unique_ptr<l1t::PFCandidate>&
i, std::unique_ptr<l1t::PFCandidate>&
j) {
return (
i->pt() >
j->pt()); });
120 pfChargedHadrons_seeds_v.push_back(
std::move(pfChargedHadrons_sort_v[0]));
121 for (
unsigned int i0 = 1; i0 < pfChargedHadrons_sort_v.size(); i0++) {
123 for (
unsigned int i1 = 0;
i1 < pfChargedHadrons_seeds_v.size();
i1++) {
129 pfChargedHadrons_seeds_v.push_back(
std::move(pfChargedHadrons_sort_v[i0]));
130 if (
int(pfChargedHadrons_seeds_v.size()) >
fMaxTaus_ - 1)
133 for (
unsigned int i0 = 0; i0 < pfChargedHadrons_seeds_v.size(); i0++) {
134 addTau(*(pfChargedHadrons_seeds_v[i0]),
parts, iTaus);
141 std::unique_ptr<l1t::PFTauCollection>& outputTaus) {
148 for (
const auto& l1PFCand : iParts) {
160 dxy = l1PFCand.dxy();
163 pfTauCands.push_back(l1PFCand);
170 float* lNNVector =
fTauNNId_->NNVectorVar();
175 outputTaus->push_back(l1PFTau);
180 desc.add<
std::string>(
"NNFileName",
"L1Trigger/Phase2L1ParticleFlow/data/tau_3layer.pb");
181 desc.add<
double>(
"tausize", 0.1);
182 desc.add<
int>(
"maxtaus", 5);
183 desc.add<
int>(
"nparticles", 10);
184 desc.add<
double>(
"conesize", 0.4);
185 desc.add<
double>(
"seedpt", 20);
186 desc.add<
bool>(
"HW",
true);
187 desc.add<
bool>(
"emseed",
true);
188 desc.add<
bool>(
"debug",
false);
190 descriptions.
add(
"L1NNTauProducer",
desc);
195 std::unique_ptr<l1t::PFTauCollection>& iTaus) {
213 for (
unsigned i0 = 0; i0 <
parts.size(); i0++) {
222 input2_t d1r2 = d1eta * d1eta + d1phi * d1phi;
225 p1z_tot = p1z_tot + tmppt * (1 - d1r2 * half);
226 p1y_tot = p1y_tot + tmppt * d1phi;
227 p1x_tot = p1x_tot + tmppt * d1eta;
228 p1_tot = p1_tot + tmppt;
239 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]);
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
ap_fixed< 24, 12 > input2_t
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.
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
ap_fixed< 16, 10 > input_t
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_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
bool inCone(l1t::PFCandidate seed, l1t::PFCandidate part, detaphi_t cone2)
static void globalEndJob(const tensorflow::SessionCache *)
result_t nn_pt_correction
void process_SW(const l1t::PFCandidateCollection &parts, std::unique_ptr< l1t::PFTauCollection > &iTaus)
constexpr float etaphi_base