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>();
100 if (lTaus->empty()) {
102 lTaus->push_back(
dummy);
108 std::unique_ptr<l1t::PFTauCollection>& iTaus) {
110 std::vector<unique_ptr<l1t::PFCandidate>> pfChargedHadrons_sort_v;
111 std::vector<unique_ptr<l1t::PFCandidate>> pfChargedHadrons_seeds_v;
112 for (
const auto& l1PFCand :
parts)
115 pfChargedHadrons_sort_v.push_back(std::make_unique<l1t::PFCandidate>(l1PFCand));
117 if (pfChargedHadrons_sort_v.empty())
120 pfChargedHadrons_sort_v.begin(),
121 pfChargedHadrons_sort_v.end(),
122 [](std::unique_ptr<l1t::PFCandidate>&
i, std::unique_ptr<l1t::PFCandidate>&
j) {
return (
i->pt() >
j->pt()); });
124 pfChargedHadrons_seeds_v.push_back(
std::move(pfChargedHadrons_sort_v[0]));
125 for (
unsigned int i0 = 1; i0 < pfChargedHadrons_sort_v.size(); i0++) {
127 for (
unsigned int i1 = 0;
i1 < pfChargedHadrons_seeds_v.size();
i1++) {
133 pfChargedHadrons_seeds_v.push_back(
std::move(pfChargedHadrons_sort_v[i0]));
134 if (
int(pfChargedHadrons_seeds_v.size()) >
fMaxTaus_ - 1)
137 for (
unsigned int i0 = 0; i0 < pfChargedHadrons_seeds_v.size(); i0++) {
138 addTau(*(pfChargedHadrons_seeds_v[i0]),
parts, iTaus);
145 std::unique_ptr<l1t::PFTauCollection>& outputTaus) {
152 for (
const auto& l1PFCand : iParts) {
164 dxy = l1PFCand.dxy();
167 pfTauCands.push_back(l1PFCand);
174 float* lNNVector =
fTauNNId_->NNVectorVar();
179 outputTaus->push_back(l1PFTau);
184 desc.add<
std::string>(
"NNFileName",
"L1Trigger/Phase2L1ParticleFlow/data/tau_3layer.pb");
185 desc.add<
double>(
"tausize", 0.1);
186 desc.add<
int>(
"maxtaus", 5);
187 desc.add<
int>(
"nparticles", 10);
188 desc.add<
double>(
"conesize", 0.4);
189 desc.add<
double>(
"seedpt", 20);
190 desc.add<
bool>(
"HW",
true);
191 desc.add<
bool>(
"emseed",
true);
192 desc.add<
bool>(
"debug",
false);
194 descriptions.
add(
"L1NNTauProducer",
desc);
199 std::unique_ptr<l1t::PFTauCollection>& iTaus) {
217 for (
unsigned i0 = 0; i0 <
parts.size(); i0++) {
226 input2_t d1r2 = d1eta * d1eta + d1phi * d1phi;
229 p1z_tot = p1z_tot + tmppt * (1 - d1r2 * half);
230 p1y_tot = p1y_tot + tmppt * d1phi;
231 p1x_tot = p1x_tot + tmppt * d1eta;
232 p1_tot = p1_tot + tmppt;
243 input2_t tmpmass1 = (p1_tot * p1_tot - p1x_tot * p1x_tot - p1y_tot * p1y_tot - p1z_tot * p1z_tot);
257 for (
unsigned i0 = 0; i0 < 80; i0++)
258 pNNVec[i0] =
float(lNNVector[i0]);
285 l1PFTau.
setZ0(
float(
z0) * 0.05);
290 iTaus->push_back(l1PFTau);
294 std::unique_ptr<l1t::PFTauCollection>& iTaus) {
297 std::vector<l1t::PFCandidate>
work;
304 std::vector<l1t::PFCandidate>
seeds;
310 part.id() == lSeed) &&
323 std::vector<l1t::PFCandidate> particlesInCone;
329 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
ap_fixed< 16, 6 > input_t
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)
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)