296 if (
hit.towerIEta() == -1016 &&
hit.towerIPhi() == -962) {
301 SimpleTowerHit l1Hit;
302 l1Hit.isBarrel =
true;
303 l1Hit.l1egTowerEt =
hit.l1egTowerEt();
304 l1Hit.towerEta =
hit.towerEta();
305 l1Hit.towerPhi =
hit.towerPhi();
306 l1Hit.towerEm =
hit.ecalTowerEt();
307 l1Hit.towerHad =
hit.hcalTowerEt();
308 l1Hit.towerEt = l1Hit.towerEm + l1Hit.towerHad + l1Hit.l1egTowerEt;
309 l1Hit.towerIeta =
hit.towerIEta();
310 l1Hit.towerIphi =
hit.towerIPhi();
316 <<
" TOWERS WITH towerIeta=-1016 AND towerIphi=-962" << std::endl;
321 SimpleTowerHit l1Hit;
322 l1Hit.isBarrel =
false;
323 l1Hit.l1egTowerEt = 0.0;
324 l1Hit.towerEta =
hit.eta();
325 l1Hit.towerPhi =
hit.phi();
326 l1Hit.towerEm =
hit.etEm();
327 l1Hit.towerHad =
hit.etHad();
328 l1Hit.towerEt = l1Hit.towerEm + l1Hit.towerHad;
337 return a.towerEt >
b.towerEt;
341 std::vector<SimpleHGCluster> AllHGClusters;
345 auto& cl3d = *cl3dIt;
350 l1t::PFCluster cluster(cl3d.pt(), cl3d.eta(), cl3d.phi(), cl3d.hOverE());
354 float pt_new = cl3d.iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM);
356 cluster =
l1t::PFCluster(pt_new, cl3d.eta(), cl3d.phi(), hoe_new, isEM);
360 float had_old = cl3d.
pt() - cluster.emEt();
361 float em_new = cl3d.iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM);
362 float pt_new = had_old + em_new;
363 float hoe_new = em_new > 0 ? (had_old / em_new) : -1;
364 cluster =
l1t::PFCluster(pt_new, cl3d.eta(), cl3d.phi(), hoe_new, isEM);
367 float em_new = cl3d.iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM);
368 float hoe_new = em_new > 0 ? (cl3d.pt() / em_new - 1) : -1;
369 cluster =
l1t::PFCluster(cl3d.pt(), cl3d.eta(), cl3d.phi(), hoe_new, isEM);
379 SimpleHGCluster HGCluster;
380 HGCluster.pt = cl3d.pt();
381 HGCluster.eta = cl3d.eta();
382 HGCluster.phi = cl3d.phi();
383 HGCluster.showerlength = cl3d.showerLength();
384 HGCluster.coreshowerlength = cl3d.coreShowerLength();
385 HGCluster.spptot = cl3d.sigmaPhiPhiTot();
386 HGCluster.szz = cl3d.sigmaZZ();
387 HGCluster.srrtot = cl3d.sigmaRRTot();
388 HGCluster.meanz = cl3d.zBarycenter();
390 AllHGClusters.push_back(HGCluster);
394 std::sort(
begin(AllHGClusters),
end(AllHGClusters), [](
const SimpleHGCluster&
a, SimpleHGCluster&
b) {
399 std::vector<SimpleTowerCluster> l1TowerClustersNxM_CB;
400 std::vector<SimpleTowerCluster> l1TowerClustersNxM_CE;
401 std::vector<SimpleHGCluster> HGClusters;
404 std::vector<SimpleTowerCluster> AllL1TowerClustersNxM_CE;
406 bool caloTauSeedingFinished =
false;
408 while (!caloTauSeedingFinished) {
409 SimpleTowerCluster clNxM;
417 l1CaloTower.stale4seed) {
425 caloTauSeedingFinished =
true;
429 clNxM.seedIeta = l1CaloTower.towerIeta;
430 clNxM.seedIphi = l1CaloTower.towerIphi;
431 clNxM.seedEta = l1CaloTower.towerEta;
432 clNxM.seedPhi = l1CaloTower.towerPhi;
433 if (l1CaloTower.isBarrel) {
434 clNxM.barrelSeeded =
true;
437 clNxM.rawEt += l1CaloTower.towerEt;
438 clNxM.towerHits[
seedIdx] = l1CaloTower;
439 l1CaloTower.stale4seed =
true;
440 l1CaloTower.stale =
true;
451 if (clNxM.barrelSeeded && l1CaloTower.isBarrel) {
452 d_iEta =
tower_dIEta(l1CaloTower.towerIeta, clNxM.seedIeta);
453 d_iPhi =
tower_dIPhi(l1CaloTower.towerIphi, clNxM.seedIphi);
455 d_Eta = l1CaloTower.towerEta - clNxM.seedEta;
462 l1CaloTower.stale4seed =
true;
470 l1TowerClustersNxM_CB.push_back(clNxM);
472 AllL1TowerClustersNxM_CE.push_back(clNxM);
479 for (
auto& clNxM : l1TowerClustersNxM_CB) {
482 if (l1CaloTower.stale) {
492 if (l1CaloTower.isBarrel) {
493 d_iEta =
tower_dIEta(l1CaloTower.towerIeta, clNxM.seedIeta);
494 d_iPhi =
tower_dIPhi(l1CaloTower.towerIphi, clNxM.seedIphi);
498 d_Eta = l1CaloTower.towerEta - clNxM.seedEta;
501 int dieta = d_Eta / 0.0807;
502 int diphi = d_Phi / 0.0872;
509 clNxM.rawEt += l1CaloTower.towerEt;
510 clNxM.towerHits[hitIdx] = l1CaloTower;
511 l1CaloTower.stale =
true;
520 for (
auto& clNxM : AllL1TowerClustersNxM_CE) {
522 for (
auto& HGCluster : AllHGClusters) {
525 if (
matched || HGCluster.stale || HGCluster.pt < 4) {
529 float d_Eta = HGCluster.eta - clNxM.seedEta;
531 float d_R2 =
pow(d_Eta, 2) +
pow(d_Phi, 2);
534 HGCluster.stale =
true;
535 HGClusters.push_back(HGCluster);
536 l1TowerClustersNxM_CE.push_back(clNxM);
545 for (
auto& clNxM : l1TowerClustersNxM_CE) {
548 if (l1CaloTower.stale) {
558 if (l1CaloTower.isBarrel) {
559 d_iEta =
tower_dIEta(l1CaloTower.towerIeta, clNxM.seedIeta);
560 d_iPhi =
tower_dIPhi(l1CaloTower.towerIphi, clNxM.seedIphi);
564 d_Eta = l1CaloTower.towerEta - clNxM.seedEta;
567 int dieta = d_Eta / 0.0807;
568 int diphi = d_Phi / 0.0872;
575 clNxM.rawEt += l1CaloTower.towerEt;
576 clNxM.towerHits[hitIdx] = l1CaloTower;
577 l1CaloTower.stale =
true;
585 int batchSize_CB = (
int)(l1TowerClustersNxM_CB.size());
586 tensorflow::TensorShape imageShape_CB({batchSize_CB,
IEta_dim,
IPhi_dim, 2});
587 tensorflow::TensorShape positionShape_CB({batchSize_CB, 2});
588 tensorflow::Tensor TowerClusterImage_CB(tensorflow::DT_FLOAT, imageShape_CB);
589 tensorflow::Tensor TowerClusterPosition_CB(tensorflow::DT_FLOAT, positionShape_CB);
592 for (
auto& clNxM : l1TowerClustersNxM_CB) {
597 TowerClusterImage_CB.tensor<
float, 4>()(clIdx,
eta,
phi, 0) =
598 inputQuantizer(clNxM.towerHits[towerIdx].l1egTowerEt + clNxM.towerHits[towerIdx].towerEm, 0.25, 10);
599 TowerClusterImage_CB.tensor<
float, 4>()(clIdx,
eta,
phi, 1) =
604 TowerClusterPosition_CB.tensor<
float, 2>()(clIdx, 0) = clNxM.seedEta;
605 TowerClusterPosition_CB.tensor<
float, 2>()(clIdx, 1) = clNxM.seedPhi;
615 {
"TowerClusterPosition", TowerClusterPosition_CB}};
616 std::vector<tensorflow::Tensor> CNNmodel_CBoutputs;
618 CNNmodel_CBinputList,
619 {
"TauMinator_CB_conv/middleMan/concat"},
620 &CNNmodel_CBoutputs);
624 std::vector<tensorflow::Tensor> DNN_CBoutputsIdent;
627 {
"TauMinator_CB_ident/sigmoid_IDout/Sigmoid"},
628 &DNN_CBoutputsIdent);
631 std::vector<tensorflow::Tensor> DNN_CBoutputsCalib;
634 {
"TauMinator_CB_calib/LIN_DNNout/Relu"},
635 &DNN_CBoutputsCalib);
639 for (
auto& clNxM : l1TowerClustersNxM_CB) {
640 clNxM.IDscore = DNN_CBoutputsIdent[0].matrix<
float>()(0, clIdx);
641 clNxM.calibPt = DNN_CBoutputsCalib[0].matrix<
float>()(0, clIdx);
647 int batchSize_CE = (
int)(l1TowerClustersNxM_CE.size());
648 tensorflow::TensorShape imageShape_CE({batchSize_CE,
IEta_dim,
IPhi_dim, 2});
649 tensorflow::TensorShape positionShape_CE({batchSize_CE, 2});
650 tensorflow::TensorShape cl3dfeatShape_CE({batchSize_CE, 8});
651 tensorflow::Tensor TowerClusterImage_CE(tensorflow::DT_FLOAT, imageShape_CE);
652 tensorflow::Tensor TowerClusterPosition_CE(tensorflow::DT_FLOAT, positionShape_CE);
653 tensorflow::Tensor Cl3dShapeFeatures_CE(tensorflow::DT_FLOAT, cl3dfeatShape_CE);
656 for (
auto& clNxM : l1TowerClustersNxM_CE) {
658 SimpleHGCluster HGClu = HGClusters[clIdx];
664 TowerClusterImage_CE.tensor<
float, 4>()(clIdx,
eta,
phi, 0) =
665 inputQuantizer(clNxM.towerHits[towerIdx].l1egTowerEt + clNxM.towerHits[towerIdx].towerEm, 0.25, 10);
666 TowerClusterImage_CE.tensor<
float, 4>()(clIdx,
eta,
phi, 1) =
671 TowerClusterPosition_CE.tensor<
float, 2>()(clIdx, 0) = clNxM.seedEta;
672 TowerClusterPosition_CE.tensor<
float, 2>()(clIdx, 1) = clNxM.seedPhi;
675 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 1) =
677 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 2) =
inputScaler(HGClu.showerlength,
"showerlength");
678 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 3) =
inputScaler(HGClu.coreshowerlength,
"coreshowerlength");
679 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 4) =
682 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 6) =
684 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 7) =
695 {
"TowerClusterPosition", TowerClusterPosition_CE},
696 {
"AssociatedCl3dFeatures", Cl3dShapeFeatures_CE}};
697 std::vector<tensorflow::Tensor> CNNmodel_CEoutputs;
699 CNNmodel_CEinputList,
700 {
"TauMinator_CE_conv/middleMan/concat"},
701 &CNNmodel_CEoutputs);
705 std::vector<tensorflow::Tensor> DNN_CEoutputsIdent;
708 {
"TauMinator_CE_ident/sigmoid_IDout/Sigmoid"},
709 &DNN_CEoutputsIdent);
712 std::vector<tensorflow::Tensor> DNN_CEoutputsCalib;
715 {
"TauMinator_CE_calib/LIN_DNNout/Relu"},
716 &DNN_CEoutputsCalib);
720 for (
auto& clNxM : l1TowerClustersNxM_CE) {
721 clNxM.IDscore = DNN_CEoutputsIdent[0].matrix<
float>()(0, clIdx);
722 clNxM.calibPt = DNN_CEoutputsCalib[0].matrix<
float>()(0, clIdx);
728 for (
auto& clNxM : l1TowerClustersNxM_CB) {
756 l1Tau.setTowerIEta(clNxM.seedIeta);
757 l1Tau.setTowerIPhi(clNxM.seedIphi);
758 l1Tau.setRawEt(clNxM.rawEt);
760 L1NNCaloTauCollectionBXV->push_back(0,
l1Tau);
763 for (
auto& clNxM : l1TowerClustersNxM_CE) {
791 l1Tau.setTowerIEta(clNxM.seedIeta);
792 l1Tau.setTowerIPhi(clNxM.seedIphi);
793 l1Tau.setRawEt(clNxM.rawEt);
795 L1NNCaloTauCollectionBXV->push_back(0,
l1Tau);
799 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)
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.