292 if (
hit.towerIEta() == -1016 &&
hit.towerIPhi() == -962) {
297 SimpleTowerHit l1Hit;
298 l1Hit.isBarrel =
true;
299 l1Hit.l1egTowerEt =
hit.l1egTowerEt();
300 l1Hit.towerEta =
hit.towerEta();
301 l1Hit.towerPhi =
hit.towerPhi();
302 l1Hit.towerEm =
hit.ecalTowerEt();
303 l1Hit.towerHad =
hit.hcalTowerEt();
304 l1Hit.towerEt = l1Hit.towerEm + l1Hit.towerHad + l1Hit.l1egTowerEt;
305 l1Hit.towerIeta =
hit.towerIEta();
306 l1Hit.towerIphi =
hit.towerIPhi();
312 <<
" TOWERS WITH towerIeta=-1016 AND towerIphi=-962" << std::endl;
317 SimpleTowerHit l1Hit;
318 l1Hit.isBarrel =
false;
319 l1Hit.l1egTowerEt = 0.0;
320 l1Hit.towerEta =
hit.eta();
321 l1Hit.towerPhi =
hit.phi();
322 l1Hit.towerEm =
hit.etEm();
323 l1Hit.towerHad =
hit.etHad();
324 l1Hit.towerEt = l1Hit.towerEm + l1Hit.towerHad;
333 return a.towerEt >
b.towerEt;
337 std::vector<SimpleHGCluster> AllHGClusters;
341 auto& cl3d = *cl3dIt;
346 l1t::PFCluster cluster(cl3d.pt(), cl3d.eta(), cl3d.phi(), cl3d.hOverE());
350 float pt_new = cl3d.iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM);
352 cluster =
l1t::PFCluster(pt_new, cl3d.eta(), cl3d.phi(), hoe_new, isEM);
356 float had_old = cl3d.
pt() - cluster.emEt();
357 float em_new = cl3d.iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM);
358 float pt_new = had_old + em_new;
359 float hoe_new = em_new > 0 ? (had_old / em_new) : -1;
360 cluster =
l1t::PFCluster(pt_new, cl3d.eta(), cl3d.phi(), hoe_new, isEM);
363 float em_new = cl3d.iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM);
364 float hoe_new = em_new > 0 ? (cl3d.pt() / em_new - 1) : -1;
365 cluster =
l1t::PFCluster(cl3d.pt(), cl3d.eta(), cl3d.phi(), hoe_new, isEM);
375 SimpleHGCluster HGCluster;
376 HGCluster.pt = cl3d.pt();
377 HGCluster.eta = cl3d.eta();
378 HGCluster.phi = cl3d.phi();
379 HGCluster.showerlength = cl3d.showerLength();
380 HGCluster.coreshowerlength = cl3d.coreShowerLength();
381 HGCluster.spptot = cl3d.sigmaPhiPhiTot();
382 HGCluster.szz = cl3d.sigmaZZ();
383 HGCluster.srrtot = cl3d.sigmaRRTot();
384 HGCluster.meanz = cl3d.zBarycenter();
386 AllHGClusters.push_back(HGCluster);
390 std::sort(
begin(AllHGClusters),
end(AllHGClusters), [](
const SimpleHGCluster&
a, SimpleHGCluster&
b) {
395 std::vector<SimpleTowerCluster> l1TowerClustersNxM_CB;
396 std::vector<SimpleTowerCluster> l1TowerClustersNxM_CE;
397 std::vector<SimpleHGCluster> HGClusters;
400 std::vector<SimpleTowerCluster> AllL1TowerClustersNxM_CE;
402 bool caloTauSeedingFinished =
false;
404 while (!caloTauSeedingFinished) {
405 SimpleTowerCluster clNxM;
413 l1CaloTower.stale4seed) {
421 caloTauSeedingFinished =
true;
425 clNxM.seedIeta = l1CaloTower.towerIeta;
426 clNxM.seedIphi = l1CaloTower.towerIphi;
427 clNxM.seedEta = l1CaloTower.towerEta;
428 clNxM.seedPhi = l1CaloTower.towerPhi;
429 if (l1CaloTower.isBarrel) {
430 clNxM.barrelSeeded =
true;
433 clNxM.rawEt += l1CaloTower.towerEt;
434 clNxM.towerHits[
seedIdx] = l1CaloTower;
435 l1CaloTower.stale4seed =
true;
436 l1CaloTower.stale =
true;
447 if (clNxM.barrelSeeded && l1CaloTower.isBarrel) {
448 d_iEta =
tower_dIEta(l1CaloTower.towerIeta, clNxM.seedIeta);
449 d_iPhi =
tower_dIPhi(l1CaloTower.towerIphi, clNxM.seedIphi);
451 d_Eta = l1CaloTower.towerEta - clNxM.seedEta;
458 l1CaloTower.stale4seed =
true;
466 l1TowerClustersNxM_CB.push_back(clNxM);
468 AllL1TowerClustersNxM_CE.push_back(clNxM);
475 for (
auto& clNxM : l1TowerClustersNxM_CB) {
478 if (l1CaloTower.stale) {
488 if (l1CaloTower.isBarrel) {
489 d_iEta =
tower_dIEta(l1CaloTower.towerIeta, clNxM.seedIeta);
490 d_iPhi =
tower_dIPhi(l1CaloTower.towerIphi, clNxM.seedIphi);
494 d_Eta = l1CaloTower.towerEta - clNxM.seedEta;
497 int dieta = d_Eta / 0.0807;
498 int diphi = d_Phi / 0.0872;
505 clNxM.rawEt += l1CaloTower.towerEt;
506 clNxM.towerHits[hitIdx] = l1CaloTower;
507 l1CaloTower.stale =
true;
516 for (
auto& clNxM : AllL1TowerClustersNxM_CE) {
518 for (
auto& HGCluster : AllHGClusters) {
521 if (
matched || HGCluster.stale || HGCluster.pt < 4) {
525 float d_Eta = HGCluster.eta - clNxM.seedEta;
527 float d_R2 =
pow(d_Eta, 2) +
pow(d_Phi, 2);
530 HGCluster.stale =
true;
531 HGClusters.push_back(HGCluster);
532 l1TowerClustersNxM_CE.push_back(clNxM);
541 for (
auto& clNxM : l1TowerClustersNxM_CE) {
544 if (l1CaloTower.stale) {
554 if (l1CaloTower.isBarrel) {
555 d_iEta =
tower_dIEta(l1CaloTower.towerIeta, clNxM.seedIeta);
556 d_iPhi =
tower_dIPhi(l1CaloTower.towerIphi, clNxM.seedIphi);
560 d_Eta = l1CaloTower.towerEta - clNxM.seedEta;
563 int dieta = d_Eta / 0.0807;
564 int diphi = d_Phi / 0.0872;
571 clNxM.rawEt += l1CaloTower.towerEt;
572 clNxM.towerHits[hitIdx] = l1CaloTower;
573 l1CaloTower.stale =
true;
582 int batchSize_CB = (
int)(l1TowerClustersNxM_CB.size());
583 tensorflow::TensorShape imageShape_CB({batchSize_CB,
IEta_dim,
IPhi_dim, 2});
584 tensorflow::TensorShape positionShape_CB({batchSize_CB, 2});
585 tensorflow::Tensor TowerClusterImage_CB(tensorflow::DT_FLOAT, imageShape_CB);
586 tensorflow::Tensor TowerClusterPosition_CB(tensorflow::DT_FLOAT, positionShape_CB);
589 for (
auto& clNxM : l1TowerClustersNxM_CB) {
594 TowerClusterImage_CB.tensor<
float, 4>()(clIdx,
eta,
phi, 0) =
595 inputQuantizer(clNxM.towerHits[towerIdx].l1egTowerEt + clNxM.towerHits[towerIdx].towerEm, 0.25, 10);
596 TowerClusterImage_CB.tensor<
float, 4>()(clIdx,
eta,
phi, 1) =
601 TowerClusterPosition_CB.tensor<
float, 2>()(clIdx, 0) = clNxM.seedEta;
602 TowerClusterPosition_CB.tensor<
float, 2>()(clIdx, 1) = clNxM.seedPhi;
612 {
"TowerClusterPosition", TowerClusterPosition_CB}};
613 std::vector<tensorflow::Tensor> CNNmodel_CBoutputs;
615 CNNmodel_CBinputList,
616 {
"TauMinator_CB_conv/middleMan/concat"},
617 &CNNmodel_CBoutputs);
621 std::vector<tensorflow::Tensor> DNN_CBoutputsIdent;
624 {
"TauMinator_CB_ident/sigmoid_IDout/Sigmoid"},
625 &DNN_CBoutputsIdent);
628 std::vector<tensorflow::Tensor> DNN_CBoutputsCalib;
631 {
"TauMinator_CB_calib/LIN_DNNout/Relu"},
632 &DNN_CBoutputsCalib);
636 for (
auto& clNxM : l1TowerClustersNxM_CB) {
637 clNxM.IDscore = DNN_CBoutputsIdent[0].matrix<
float>()(0, clIdx);
638 clNxM.calibPt = DNN_CBoutputsCalib[0].matrix<
float>()(0, clIdx);
644 int batchSize_CE = (
int)(l1TowerClustersNxM_CE.size());
645 tensorflow::TensorShape imageShape_CE({batchSize_CE,
IEta_dim,
IPhi_dim, 2});
646 tensorflow::TensorShape positionShape_CE({batchSize_CE, 2});
647 tensorflow::TensorShape cl3dfeatShape_CE({batchSize_CE, 8});
648 tensorflow::Tensor TowerClusterImage_CE(tensorflow::DT_FLOAT, imageShape_CE);
649 tensorflow::Tensor TowerClusterPosition_CE(tensorflow::DT_FLOAT, positionShape_CE);
650 tensorflow::Tensor Cl3dShapeFeatures_CE(tensorflow::DT_FLOAT, cl3dfeatShape_CE);
653 for (
auto& clNxM : l1TowerClustersNxM_CE) {
655 SimpleHGCluster HGClu = HGClusters[clIdx];
661 TowerClusterImage_CE.tensor<
float, 4>()(clIdx,
eta,
phi, 0) =
662 inputQuantizer(clNxM.towerHits[towerIdx].l1egTowerEt + clNxM.towerHits[towerIdx].towerEm, 0.25, 10);
663 TowerClusterImage_CE.tensor<
float, 4>()(clIdx,
eta,
phi, 1) =
668 TowerClusterPosition_CE.tensor<
float, 2>()(clIdx, 0) = clNxM.seedEta;
669 TowerClusterPosition_CE.tensor<
float, 2>()(clIdx, 1) = clNxM.seedPhi;
672 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 1) =
674 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 2) =
inputScaler(HGClu.showerlength,
"showerlength");
675 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 3) =
inputScaler(HGClu.coreshowerlength,
"coreshowerlength");
676 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 4) =
679 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 6) =
681 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 7) =
692 {
"TowerClusterPosition", TowerClusterPosition_CE},
693 {
"AssociatedCl3dFeatures", Cl3dShapeFeatures_CE}};
694 std::vector<tensorflow::Tensor> CNNmodel_CEoutputs;
696 CNNmodel_CEinputList,
697 {
"TauMinator_CE_conv/middleMan/concat"},
698 &CNNmodel_CEoutputs);
702 std::vector<tensorflow::Tensor> DNN_CEoutputsIdent;
705 {
"TauMinator_CE_ident/sigmoid_IDout/Sigmoid"},
706 &DNN_CEoutputsIdent);
709 std::vector<tensorflow::Tensor> DNN_CEoutputsCalib;
712 {
"TauMinator_CE_calib/LIN_DNNout/Relu"},
713 &DNN_CEoutputsCalib);
717 for (
auto& clNxM : l1TowerClustersNxM_CE) {
718 clNxM.IDscore = DNN_CEoutputsIdent[0].matrix<
float>()(0, clIdx);
719 clNxM.calibPt = DNN_CEoutputsCalib[0].matrix<
float>()(0, clIdx);
725 for (
auto& clNxM : l1TowerClustersNxM_CB) {
753 l1Tau.setTowerIEta(clNxM.seedIeta);
754 l1Tau.setTowerIPhi(clNxM.seedIphi);
755 l1Tau.setRawEt(clNxM.rawEt);
757 L1NNCaloTauCollectionBXV->push_back(0,
l1Tau);
760 for (
auto& clNxM : l1TowerClustersNxM_CE) {
788 l1Tau.setTowerIEta(clNxM.seedIeta);
789 l1Tau.setTowerIPhi(clNxM.seedIphi);
790 l1Tau.setRawEt(clNxM.rawEt);
792 L1NNCaloTauCollectionBXV->push_back(0,
l1Tau);
796 iEvent.put(
std::move(L1NNCaloTauCollectionBXV),
"L1NNCaloTauCollectionBXV");
edm::Handle< l1t::HGCalMulticlusterBxCollection > HGClusterHandle
constexpr double deltaPhi(double phi1, double phi2)
std::vector< NamedTensor > NamedTensorList
StringCutObjectSelector< l1t::HGCalMulticluster > preEmId
double pt() const final
transverse momentum
int tower_dIEta(int &iEta_1, int &iEta_2) const
T const * product() const
edm::Handle< l1t::HGCalTowerBxCollection > hgcalTowersHandle
int endcap_ieta(float &eta) const
int tower_dIPhi(int &iPhi_1, int &iPhi_2) const
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > HGClusterToken
float inputScaler(float inputF, std::string feature)
edm::Handle< l1tp2::CaloTowerCollection > l1CaloTowerHandle
float inputQuantizer(float inputF, float LSB, int nbits)
void setLogging(const std::string &level="3")
int endcap_iphi(float &phi) const
l1tpf::HGC3DClusterEgID VsPuId
edm::EDGetToken hgcalTowersToken
edm::EDGetTokenT< l1tp2::CaloTowerCollection > l1TowersToken
Log< level::Warning, false > LogWarning
float passID(l1t::HGCalMulticluster c, l1t::PFCluster &cpf)
Power< A, B >::type pow(const A &a, const B &b)
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.