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;
586 int batchSize_CB = (
int)(l1TowerClustersNxM_CB.size());
587 tensorflow::TensorShape imageShape_CB({batchSize_CB,
IEta_dim,
IPhi_dim, 2});
588 tensorflow::TensorShape positionShape_CB({batchSize_CB, 2});
589 tensorflow::Tensor TowerClusterImage_CB(tensorflow::DT_FLOAT, imageShape_CB);
590 tensorflow::Tensor TowerClusterPosition_CB(tensorflow::DT_FLOAT, positionShape_CB);
593 for (
auto& clNxM : l1TowerClustersNxM_CB) {
598 TowerClusterImage_CB.tensor<
float, 4>()(clIdx,
eta,
phi, 0) =
599 inputQuantizer(clNxM.towerHits[towerIdx].l1egTowerEt + clNxM.towerHits[towerIdx].towerEm, 0.25, 10);
600 TowerClusterImage_CB.tensor<
float, 4>()(clIdx,
eta,
phi, 1) =
605 TowerClusterPosition_CB.tensor<
float, 2>()(clIdx, 0) = clNxM.seedEta;
606 TowerClusterPosition_CB.tensor<
float, 2>()(clIdx, 1) = clNxM.seedPhi;
616 {
"TowerClusterPosition", TowerClusterPosition_CB}};
617 std::vector<tensorflow::Tensor> CNNmodel_CBoutputs;
619 CNNmodel_CBinputList,
620 {
"TauMinator_CB_conv/middleMan/concat"},
621 &CNNmodel_CBoutputs);
625 std::vector<tensorflow::Tensor> DNN_CBoutputsIdent;
628 {
"TauMinator_CB_ident/sigmoid_IDout/Sigmoid"},
629 &DNN_CBoutputsIdent);
632 std::vector<tensorflow::Tensor> DNN_CBoutputsCalib;
635 {
"TauMinator_CB_calib/LIN_DNNout/Relu"},
636 &DNN_CBoutputsCalib);
640 for (
auto& clNxM : l1TowerClustersNxM_CB) {
641 clNxM.IDscore = DNN_CBoutputsIdent[0].matrix<
float>()(0, clIdx);
642 clNxM.calibPt = DNN_CBoutputsCalib[0].matrix<
float>()(0, clIdx);
648 int batchSize_CE = (
int)(l1TowerClustersNxM_CE.size());
649 tensorflow::TensorShape imageShape_CE({batchSize_CE,
IEta_dim,
IPhi_dim, 2});
650 tensorflow::TensorShape positionShape_CE({batchSize_CE, 2});
651 tensorflow::TensorShape cl3dfeatShape_CE({batchSize_CE, 8});
652 tensorflow::Tensor TowerClusterImage_CE(tensorflow::DT_FLOAT, imageShape_CE);
653 tensorflow::Tensor TowerClusterPosition_CE(tensorflow::DT_FLOAT, positionShape_CE);
654 tensorflow::Tensor Cl3dShapeFeatures_CE(tensorflow::DT_FLOAT, cl3dfeatShape_CE);
657 for (
auto& clNxM : l1TowerClustersNxM_CE) {
659 SimpleHGCluster HGClu = HGClusters[clIdx];
665 TowerClusterImage_CE.tensor<
float, 4>()(clIdx,
eta,
phi, 0) =
666 inputQuantizer(clNxM.towerHits[towerIdx].l1egTowerEt + clNxM.towerHits[towerIdx].towerEm, 0.25, 10);
667 TowerClusterImage_CE.tensor<
float, 4>()(clIdx,
eta,
phi, 1) =
672 TowerClusterPosition_CE.tensor<
float, 2>()(clIdx, 0) = clNxM.seedEta;
673 TowerClusterPosition_CE.tensor<
float, 2>()(clIdx, 1) = clNxM.seedPhi;
676 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 1) =
678 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 2) =
inputScaler(HGClu.showerlength,
"showerlength");
679 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 3) =
inputScaler(HGClu.coreshowerlength,
"coreshowerlength");
680 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 4) =
683 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 6) =
685 Cl3dShapeFeatures_CE.tensor<
float, 2>()(clIdx, 7) =
696 {
"TowerClusterPosition", TowerClusterPosition_CE},
697 {
"AssociatedCl3dFeatures", Cl3dShapeFeatures_CE}};
698 std::vector<tensorflow::Tensor> CNNmodel_CEoutputs;
700 CNNmodel_CEinputList,
701 {
"TauMinator_CE_conv/middleMan/concat"},
702 &CNNmodel_CEoutputs);
706 std::vector<tensorflow::Tensor> DNN_CEoutputsIdent;
709 {
"TauMinator_CE_ident/sigmoid_IDout/Sigmoid"},
710 &DNN_CEoutputsIdent);
713 std::vector<tensorflow::Tensor> DNN_CEoutputsCalib;
716 {
"TauMinator_CE_calib/LIN_DNNout/Relu"},
717 &DNN_CEoutputsCalib);
721 for (
auto& clNxM : l1TowerClustersNxM_CE) {
722 clNxM.IDscore = DNN_CEoutputsIdent[0].matrix<
float>()(0, clIdx);
723 clNxM.calibPt = DNN_CEoutputsCalib[0].matrix<
float>()(0, clIdx);
729 for (
auto& clNxM : l1TowerClustersNxM_CB) {
757 l1Tau.setTowerIEta(clNxM.seedIeta);
758 l1Tau.setTowerIPhi(clNxM.seedIphi);
759 l1Tau.setRawEt(clNxM.rawEt);
761 L1NNCaloTauCollectionBXV->push_back(0,
l1Tau);
764 for (
auto& clNxM : l1TowerClustersNxM_CE) {
792 l1Tau.setTowerIEta(clNxM.seedIeta);
793 l1Tau.setTowerIPhi(clNxM.seedIphi);
794 l1Tau.setRawEt(clNxM.rawEt);
796 L1NNCaloTauCollectionBXV->push_back(0,
l1Tau);
800 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.