CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
l1t::Stage2Layer2TauAlgorithmFirmwareImp1 Class Reference

#include <Stage2Layer2TauAlgorithmFirmware.h>

Inheritance diagram for l1t::Stage2Layer2TauAlgorithmFirmwareImp1:
l1t::Stage2Layer2TauAlgorithm

Public Member Functions

void processEvent (const std::vector< CaloCluster > &clusters, const std::vector< CaloTower > &towers, std::vector< Tau > &taus) override
 
 Stage2Layer2TauAlgorithmFirmwareImp1 (CaloParamsHelper const *params)
 
 ~Stage2Layer2TauAlgorithmFirmwareImp1 () override
 
- Public Member Functions inherited from l1t::Stage2Layer2TauAlgorithm
virtual ~Stage2Layer2TauAlgorithm ()
 

Private Member Functions

unsigned int calibLutIndex (int ieta, int Et, int hasEM, int isMerged)
 
int calibratedPt (const l1t::CaloCluster &clus, const std::vector< l1t::CaloTower > &towers, int hwPt, bool isMerged)
 
void dosorting (std::vector< l1t::Tau > &taus)
 
bool is3x3Maximum (const l1t::CaloTower &tower, const std::vector< CaloTower > &towers, l1t::CaloStage2Nav &caloNav)
 
int isoCalTauHwFootPrint (const l1t::CaloCluster &, const std::vector< l1t::CaloTower > &)
 
unsigned int isoLutIndex (int Et, int hweta, unsigned int nrTowers)
 
void loadCalibrationLuts ()
 
std::vector< std::unique_ptr< l1t::CaloCluster > > makeSecClusters (const std::vector< l1t::CaloTower > &towers, std::vector< int > &sites, const l1t::CaloCluster &mainCluster, l1t::CaloStage2Nav &caloNav)
 
void merging (const std::vector< l1t::CaloCluster > &clusters, const std::vector< l1t::CaloTower > &towers, std::vector< l1t::Tau > &taus)
 
unsigned int trimMainLutIndex (int neighPos, bool isWe)
 

Static Private Member Functions

static bool compareTowers (l1t::CaloTower TT1, l1t::CaloTower TT2)
 

Private Attributes

std::vector< std::vector< float > > coefficients_
 
float offsetBarrelEH_
 
float offsetBarrelH_
 
float offsetEndcapsEH_
 
float offsetEndcapsH_
 
CaloParamsHelper const * params_
 

Detailed Description

Author
:

Description:

Definition at line 24 of file Stage2Layer2TauAlgorithmFirmware.h.

Constructor & Destructor Documentation

l1t::Stage2Layer2TauAlgorithmFirmwareImp1::Stage2Layer2TauAlgorithmFirmwareImp1 ( CaloParamsHelper const *  params)
l1t::Stage2Layer2TauAlgorithmFirmwareImp1::~Stage2Layer2TauAlgorithmFirmwareImp1 ( )
override

Definition at line 30 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

30  {
31 }

Member Function Documentation

unsigned int l1t::Stage2Layer2TauAlgorithmFirmwareImp1::calibLutIndex ( int  ieta,
int  Et,
int  hasEM,
int  isMerged 
)
private

Definition at line 675 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References funct::abs(), l1t::LUT::data(), params_, l1t::CaloParamsHelper::tauCompressLUT(), and globals_cff::x1.

Referenced by calibratedPt().

676 {
677  int absieta = abs(ieta);
678  if (absieta > 28) absieta = 28;
679  if (Et > 255) Et = 255;
680 
681  unsigned int compressedEta = params_->tauCompressLUT()->data(absieta);
682  unsigned int compressedEt = params_->tauCompressLUT()->data((0x1<<5)+Et);
683 
684  unsigned int address = (compressedEta<<7)+(compressedEt<<2)+(hasEM<<1)+isMerged;//2 bits eta, 5 bits et, 1 bit hasEM, 1 bis isMerged
685  // unsigned int address = (compressedEt<<4)+(compressedEta<<2)+(hasEM<<1)+isMerged;
686  return address;
687 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int data(unsigned int address) const
Definition: LUT.h:46
int l1t::Stage2Layer2TauAlgorithmFirmwareImp1::calibratedPt ( const l1t::CaloCluster clus,
const std::vector< l1t::CaloTower > &  towers,
int  hwPt,
bool  isMerged 
)
private

Definition at line 689 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References calibLutIndex(), l1t::CaloTools::caloEta(), corr, l1t::LUT::data(), l1t::CaloTools::getTower(), l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwQual(), training_settings::idx, params_, jets_cff::rawPt, and l1t::CaloParamsHelper::tauCalibrationLUT().

Referenced by merging().

690 {
691  // get seed tower
692  const l1t::CaloTower& seedTT = l1t::CaloTools::getTower(towers, CaloTools::caloEta(clus.hwEta()), clus.hwPhi());
693  int qual = seedTT.hwQual();
694  bool denomZeroFlag = ((qual&0x1) > 0);
695  bool eOverHFlag = ((qual&0x2) > 0);
696  int hasEM = (eOverHFlag || !denomZeroFlag);
697  int isMergedI = (isMerged ? 1 : 0);
698 
699  unsigned int idx = calibLutIndex(clus.hwEta(), hwPt, hasEM, isMergedI);
700  unsigned int corr = params_->tauCalibrationLUT()->data(idx);
701 
702  // now apply calibration factor: corrPt = rawPt * (corr[LUT] + 0.5)
703  // where corr[LUT] is an integer mapped to the range [0, 2]
704  int rawPt = hwPt;
705  if (rawPt > 8191) rawPt = 8191; // 13 bits for uncalibrated E
706 
707  int corrXrawPt = corr*rawPt; // 17 bits
708  int calibPt = (corrXrawPt>>9); // (10 bits) = (7 bits) + (9 bits)
709  if (calibPt > 4095) calibPt = 4095; // 12 bit in output
710 
711  return calibPt;
712 }
unsigned int calibLutIndex(int ieta, int Et, int hasEM, int isMerged)
int hwPhi() const
Definition: L1Candidate.h:50
int hwEta() const
Definition: L1Candidate.h:49
int hwQual() const
Definition: L1Candidate.h:51
JetCorrectorParameters corr
Definition: classes.h:5
static int caloEta(int ietaMP)
Definition: CaloTools.cc:210
static const l1t::CaloTower & getTower(const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
Definition: CaloTools.cc:37
l1t::LUT * tauCalibrationLUT()
int data(unsigned int address) const
Definition: LUT.h:46
bool l1t::Stage2Layer2TauAlgorithmFirmwareImp1::compareTowers ( l1t::CaloTower  TT1,
l1t::CaloTower  TT2 
)
staticprivate

Definition at line 487 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References funct::abs(), l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwPhi(), and l1t::L1Candidate::hwPt().

488 {
489  // 1. compare hwPt (for the moment no switch with E and H only, always use E+H)
490  if (TT1.hwPt() < TT2.hwPt()) return true;
491  if (TT1.hwPt() > TT2.hwPt()) return false;
492 
493  // 2. if equal pT, most central -- eta is in the range -32, 32 with ieta = 0 skipped
494  if (abs(TT1.hwEta()) > abs(TT2.hwEta())) return true;
495  if (abs(TT1.hwEta()) < abs(TT2.hwEta())) return false;
496 
497  // 3. if equal eta, compare phi (arbitrary)
498  return (TT1.hwPhi() < TT2.hwPhi()); // towers towards S are favored (remember: N --> smaller phi, S --> larger phi)
499 }
int hwPhi() const
Definition: L1Candidate.h:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int hwEta() const
Definition: L1Candidate.h:49
int hwPt() const
Definition: L1Candidate.h:48
void l1t::Stage2Layer2TauAlgorithmFirmwareImp1::dosorting ( std::vector< l1t::Tau > &  taus)
private

Definition at line 385 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References down, l1t::CaloParamsHelper::isoTauEtaMax(), AccumulatingSort< T >::Merge(), and params_.

Referenced by processEvent().

386 {
387  // prepare content to be sorted -- each phi ring contains 18 elements, with Et = 0 if no candidate exists
389  l1t::Tau tempTau (emptyP4, 0, 0, 0, 0);
390  std::vector< std::vector<l1t::Tau> > tauEtaPos( params_->isoTauEtaMax() , std::vector<l1t::Tau>(18, tempTau));
391  std::vector< std::vector<l1t::Tau> > tauEtaNeg( params_->isoTauEtaMax() , std::vector<l1t::Tau>(18, tempTau));
392 
393  for (unsigned int iTau = 0; iTau < taus.size(); iTau++)
394  {
395 
396  if (taus.at(iTau).hwEta() > 0) tauEtaPos.at( taus.at(iTau).hwEta()-1).at((72-taus.at(iTau).hwPhi())/4) = taus.at(iTau);
397  else tauEtaNeg.at( -(taus.at(iTau).hwEta()+1)).at((72-taus.at(iTau).hwPhi())/4) = taus.at(iTau);
398 
399  }
400 
401 
402 
403 
404  AccumulatingSort <l1t::Tau> etaPosSorter(6);
405  AccumulatingSort <l1t::Tau> etaNegSorter(6);
406  std::vector<l1t::Tau> accumEtaPos;
407  std::vector<l1t::Tau> accumEtaNeg;
408 
409  for( int ieta = 0 ; ieta < params_->isoTauEtaMax() ; ++ieta)
410  {
411  // eta +
412  std::vector<l1t::Tau>::iterator start_, end_;
413  start_ = tauEtaPos.at(ieta).begin();
414  end_ = tauEtaPos.at(ieta).end();
415  BitonicSort<l1t::Tau>(down, start_, end_);
416  etaPosSorter.Merge( tauEtaPos.at(ieta) , accumEtaPos );
417 
418  // eta -
419  start_ = tauEtaNeg.at(ieta).begin();
420  end_ = tauEtaNeg.at(ieta).end();
421  BitonicSort<l1t::Tau>(down, start_, end_);
422  etaNegSorter.Merge( tauEtaNeg.at(ieta) , accumEtaNeg );
423 
424 
425  }
426 
427  // put all 12 candidates in the original tau vector, removing zero energy ones
428  taus.clear();
429  for (l1t::Tau acctau : accumEtaPos)
430  {
431  if (acctau.hwPt() > 0) taus.push_back(acctau);
432  }
433  for (l1t::Tau acctau : accumEtaNeg)
434  {
435  if (acctau.hwPt() > 0) taus.push_back(acctau);
436  }
437 }
Definition: Tau.h:21
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
bool l1t::Stage2Layer2TauAlgorithmFirmwareImp1::is3x3Maximum ( const l1t::CaloTower tower,
const std::vector< CaloTower > &  towers,
l1t::CaloStage2Nav caloNav 
)
private

Definition at line 502 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References l1t::CaloTools::getTower(), l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwPt(), RecoTauDiscriminantConfiguration::mask, l1t::CaloStage2Nav::offsetIEta(), and l1t::CaloStage2Nav::offsetIPhi().

Referenced by merging().

503 {
504  int iEta = tower.hwEta();
505  int iPhi = tower.hwPhi();
506 
507  // 1 : >
508  // 2 : >=
509  int mask [3][3] = {
510  { 1,2,2 },
511  { 1,0,2 },
512  { 1,1,2 },
513  };
514 
515  bool vetoTT = false; // false if it is a local max i.e. no veto
516  for (int deta = -1; deta < 2; deta++)
517  {
518  for (int dphi = -1; dphi < 2; dphi++)
519  {
520  int iEtaNeigh = caloNav.offsetIEta(iEta, deta);
521  int iPhiNeigh = caloNav.offsetIPhi(iPhi, dphi);
522  const l1t::CaloTower& towerNeigh = l1t::CaloTools::getTower(towers, iEtaNeigh, iPhiNeigh);
523  if ( mask[2-(dphi+1)][deta +1] == 0 ) continue;
524  if ( mask[2-(dphi+1)][deta +1] == 1 ) vetoTT = (tower.hwPt() < towerNeigh.hwPt());
525  if ( mask[2-(dphi+1)][deta +1] == 2 ) vetoTT = (tower.hwPt() <= towerNeigh.hwPt());
526 
527  if (vetoTT) break;
528  }
529  if (vetoTT) break;
530  }
531 
532  return (!vetoTT); // negate because I ask if is a local maxima
533 }
static int offsetIEta(int iEta, int offset)
Definition: CaloStage2Nav.h:44
int hwPhi() const
Definition: L1Candidate.h:50
static int offsetIPhi(int iPhi, int offset)
Definition: CaloStage2Nav.h:33
int hwEta() const
Definition: L1Candidate.h:49
int hwPt() const
Definition: L1Candidate.h:48
static const l1t::CaloTower & getTower(const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
Definition: CaloTools.cc:37
int l1t::Stage2Layer2TauAlgorithmFirmwareImp1::isoCalTauHwFootPrint ( const l1t::CaloCluster ,
const std::vector< l1t::CaloTower > &   
)
private
unsigned int l1t::Stage2Layer2TauAlgorithmFirmwareImp1::isoLutIndex ( int  Et,
int  hweta,
unsigned int  nrTowers 
)
private

Definition at line 714 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References funct::abs(), l1t::LUT::data(), params_, l1t::CaloParamsHelper::tauCompressLUT(), and globals_cff::x1.

Referenced by merging().

715 {
716  // normalize to limits
717  int aeta = abs(hweta);
718 
719  // input bits (NB: must be THE SAME in the input LUT for the compression)
720  // int etaBits = 6 --> 64
721  // int etBits = 13 --> 8192
722  // int nTTBits = 10 --> 1024
723  if (Et >= 255) Et = 255; // 8 bit for the input of compression LUT
724  if (aeta >= 31) aeta = 31;
725  if (nrTowers >= 1023) nrTowers = 1023;
726 
727  // get compressed value
728  // NB: these also must MATCH the values in the LUT --> fix when new compression scheme is used
729  // ultimately, the same compresison LUT as calibration will be used
730  // etaCmprBits = 2;
731  // EtCmprBits = 4;//changed from 3, transparent to user
732  // nTTCmprBits = 3;
733 
734  int etaCmpr = params_->tauCompressLUT()->data(aeta);
735  int etCmpr = params_->tauCompressLUT()->data((0x1<<5)+Et);//offset: 5 bits from ieta
736  int nTTCmpr = params_->tauCompressLUT()->data((0x1<<5)+(0x1<<8)+nrTowers);//offset non-compressed: 5 bits from ieta, 8 bits from iEt
737 
738 
739  // get the address -- NOTE: this also depends on the compression scheme!
740 
741  unsigned int address = ( (etaCmpr << 10) | (etCmpr << 5) | nTTCmpr );//ordering compressed: 2 bits iEta, 5 bits iEt, 5 bits nTT
742 
743  return address;
744 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int data(unsigned int address) const
Definition: LUT.h:46
void l1t::Stage2Layer2TauAlgorithmFirmwareImp1::loadCalibrationLuts ( )
private

Definition at line 443 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References coefficients_, l1t::LUT::data(), objects.autophobj::float, lumiPlot::lut, fftjetcommon_cfi::maxScale, fftjetcommon_cfi::minScale, l1t::LUT::nrBitsAddress(), l1t::LUT::nrBitsData(), offsetBarrelEH_, offsetBarrelH_, offsetEndcapsEH_, offsetEndcapsH_, params_, findQualityFiles::size, and l1t::CaloParamsHelper::tauCalibrationLUT().

Referenced by Stage2Layer2TauAlgorithmFirmwareImp1().

444 {
445  float minScale = 0.;
446  float maxScale = 2.;
447  float minScaleEta = 0.5;
448  float maxScaleEta = 1.5;
449  offsetBarrelEH_ = 0.5;
450  offsetBarrelH_ = 1.5;
451  offsetEndcapsEH_ = 0.;
452  offsetEndcapsH_ = 1.5;
453 
454  // In the combined calibration LUT, upper 3-bits are used as LUT index:
455  // (0=BarrelA, 1=BarrelB, 2=BarrelC, 3=EndCapA, 4=EndCapA, 5=EndCapA, 6=Eta)
456  enum {LUT_UPPER = 3};
457  enum {LUT_OFFSET = 0x80};
459  unsigned int size = (1 << lut->nrBitsData());
460  unsigned int nBins = (1 << (lut->nrBitsAddress() - LUT_UPPER));
461 
462 
463  std::vector<float> emptyCoeff;
464  emptyCoeff.resize(nBins,0.);
465  float binSize = (maxScale-minScale)/(float)size;
466  for(unsigned iLut=0; iLut < 6; ++iLut ) {
467  coefficients_.push_back(emptyCoeff);
468  for(unsigned addr=0;addr<nBins;addr++) {
469  float y = (float)lut->data(iLut*LUT_OFFSET + addr);
470  coefficients_[iLut][addr] = minScale + binSize*y;
471  }
472  }
473 
474  size = (1 << lut->nrBitsData());
475  nBins = (1 << 6); // can't auto-extract this now due to combined LUT.
476 
477  emptyCoeff.resize(nBins,0.);
478  binSize = (maxScaleEta-minScaleEta)/(float)size;
479  coefficients_.push_back(emptyCoeff);
480  for(unsigned addr=0;addr<nBins;addr++) {
481  float y = (float)lut->data(6*LUT_OFFSET + addr);
482  coefficients_.back()[addr] = minScaleEta + binSize*y;
483  }
484 
485 }
size
Write out results.
unsigned int nrBitsData() const
Definition: LUT.h:51
unsigned int nrBitsAddress() const
Definition: LUT.h:50
Definition: LUT.h:29
l1t::LUT * tauCalibrationLUT()
int data(unsigned int address) const
Definition: LUT.h:46
std::vector< std::unique_ptr< l1t::CaloCluster > > l1t::Stage2Layer2TauAlgorithmFirmwareImp1::makeSecClusters ( const std::vector< l1t::CaloTower > &  towers,
std::vector< int > &  sites,
const l1t::CaloCluster mainCluster,
l1t::CaloStage2Nav caloNav 
)
private

Definition at line 535 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References constexpr, l1t::CaloParamsHelper::egNeighbourThreshold(), l1t::CaloTools::getTower(), l1t::L1Candidate::hwEta(), l1t::CaloTower::hwEtEm(), l1t::CaloTower::hwEtHad(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwPt(), l1t::CaloCluster::INCLUDE_E, l1t::CaloCluster::INCLUDE_N, l1t::CaloCluster::INCLUDE_NE, l1t::CaloCluster::INCLUDE_NN, l1t::CaloCluster::INCLUDE_NW, l1t::CaloCluster::INCLUDE_S, l1t::CaloCluster::INCLUDE_SE, l1t::CaloCluster::INCLUDE_SS, l1t::CaloCluster::INCLUDE_SW, l1t::CaloCluster::INCLUDE_W, eostools::move(), l1t::CaloStage2Nav::offsetIEta(), l1t::CaloStage2Nav::offsetIPhi(), params_, and l1t::CaloParamsHelper::towerLsbSum().

Referenced by merging().

536 {
537  constexpr int neigEta [8] = {0, -1, 0, 1, -1, 0, 1, 0};
538  constexpr int neigPhi [8] = {3, 2, 2, 2, -2, -2, -2, -3};
539  int clusterThreshold = floor(params_->egNeighbourThreshold()/params_->towerLsbSum());
540 
541  int iEtamain = mainCluster.hwEta();
542  int iPhimain = mainCluster.hwPhi();
543 
544  std::vector<unique_ptr<CaloCluster>> secClusters;
545  for (unsigned int isite = 0; isite < sites.size(); isite++)
546  {
547  // build full cluster at this site
548  const int siteNumber = sites.at(isite);
549  int iSecEta = caloNav.offsetIEta(iEtamain, neigEta[siteNumber]);
550  int iSecPhi = caloNav.offsetIPhi(iPhimain, neigPhi[siteNumber]);
551 
552  const l1t::CaloTower& towerSec = l1t::CaloTools::getTower(towers, iSecEta, iSecPhi);
553 
554  math::XYZTLorentzVector emptyP4;
555  auto secondaryCluster = std::make_unique<l1t::CaloCluster> ( emptyP4, towerSec.hwPt(), towerSec.hwEta(), towerSec.hwPhi() ) ;
556 
557  secondaryCluster->setHwPtEm(towerSec.hwEtEm());
558  secondaryCluster->setHwPtHad(towerSec.hwEtHad());
559  secondaryCluster->setHwSeedPt(towerSec.hwPt());
560  secondaryCluster->setHwPt(towerSec.hwPt());
561 
562  int iSecEtaP = caloNav.offsetIEta(iSecEta, 1);
563  int iSecEtaM = caloNav.offsetIEta(iSecEta, -1);
564  int iSecPhiP = caloNav.offsetIPhi(iSecPhi, 1);
565  int iSecPhiP2 = caloNav.offsetIPhi(iSecPhi, 2);
566  int iSecPhiM = caloNav.offsetIPhi(iSecPhi, -1);
567  int iSecPhiM2 = caloNav.offsetIPhi(iSecPhi, -2);
568  const l1t::CaloTower& towerNW = l1t::CaloTools::getTower(towers, iSecEtaM, iSecPhiM);
569  const l1t::CaloTower& towerN = l1t::CaloTools::getTower(towers, iSecEta , iSecPhiM);
570  const l1t::CaloTower& towerNE = l1t::CaloTools::getTower(towers, iSecEtaP, iSecPhiM);
571  const l1t::CaloTower& towerE = l1t::CaloTools::getTower(towers, iSecEtaP, iSecPhi );
572  const l1t::CaloTower& towerSE = l1t::CaloTools::getTower(towers, iSecEtaP, iSecPhiP);
573  const l1t::CaloTower& towerS = l1t::CaloTools::getTower(towers, iSecEta , iSecPhiP);
574  const l1t::CaloTower& towerSW = l1t::CaloTools::getTower(towers, iSecEtaM, iSecPhiP);
575  const l1t::CaloTower& towerW = l1t::CaloTools::getTower(towers, iSecEtaM, iSecPhi );
576  const l1t::CaloTower& towerNN = l1t::CaloTools::getTower(towers, iSecEta , iSecPhiM2);
577  const l1t::CaloTower& towerSS = l1t::CaloTools::getTower(towers, iSecEta , iSecPhiP2);
578 
579  // just use E+H for clustering
580  int towerEtNW = towerNW.hwPt();
581  int towerEtN = towerN .hwPt();
582  int towerEtNE = towerNE.hwPt();
583  int towerEtE = towerE .hwPt();
584  int towerEtSE = towerSE.hwPt();
585  int towerEtS = towerS .hwPt();
586  int towerEtSW = towerSW.hwPt();
587  int towerEtW = towerW .hwPt();
588  int towerEtNN = towerNN.hwPt();
589  int towerEtSS = towerSS.hwPt();
590 
591  int towerEtEmNW = towerNW.hwEtEm();
592  int towerEtEmN = towerN .hwEtEm();
593  int towerEtEmNE = towerNE.hwEtEm();
594  int towerEtEmE = towerE .hwEtEm();
595  int towerEtEmSE = towerSE.hwEtEm();
596  int towerEtEmS = towerS .hwEtEm();
597  int towerEtEmSW = towerSW.hwEtEm();
598  int towerEtEmW = towerW .hwEtEm();
599  int towerEtEmNN = towerNN.hwEtEm();
600  int towerEtEmSS = towerSS.hwEtEm();
601  //
602  int towerEtHadNW = towerNW.hwEtHad();
603  int towerEtHadN = towerN .hwEtHad();
604  int towerEtHadNE = towerNE.hwEtHad();
605  int towerEtHadE = towerE .hwEtHad();
606  int towerEtHadSE = towerSE.hwEtHad();
607  int towerEtHadS = towerS .hwEtHad();
608  int towerEtHadSW = towerSW.hwEtHad();
609  int towerEtHadW = towerW .hwEtHad();
610  int towerEtHadNN = towerNN.hwEtHad();
611  int towerEtHadSS = towerSS.hwEtHad();
612 
613 
614  if(towerEtNW < clusterThreshold) secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_NW, false);
615  if(towerEtN < clusterThreshold)
616  {
617  secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_N , false);
618  secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_NN, false);
619  }
620  if(towerEtNE < clusterThreshold) secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_NE, false);
621  if(towerEtE < clusterThreshold) secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_E , false);
622  if(towerEtSE < clusterThreshold) secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_SE, false);
623  if(towerEtS < clusterThreshold)
624  {
625  secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_S , false);
626  secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_SS, false);
627  }
628  if(towerEtSW < clusterThreshold) secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_SW, false);
629  if(towerEtW < clusterThreshold) secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_W , false);
630  if(towerEtNN < clusterThreshold) secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_NN, false);
631  if(towerEtSS < clusterThreshold) secondaryCluster->setClusterFlag(CaloCluster::INCLUDE_SS, false);
632 
633 
634  // compute cluster energy according to cluster flags
635  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_NW)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtNW);
636  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_N)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtN);
637  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_NE)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtNE);
638  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_E)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtE);
639  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_SE)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtSE);
640  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_S)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtS);
641  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_SW)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtSW);
642  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_W)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtW);
643  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_NN)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtNN);
644  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_SS)) secondaryCluster->setHwPt(secondaryCluster->hwPt() + towerEtSS);
645  //
646  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_NW)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmNW);
647  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_N)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmN);
648  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_NE)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmNE);
649  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_E)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmE);
650  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_SE)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmSE);
651  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_S)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmS);
652  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_SW)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmSW);
653  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_W)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmW);
654  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_NN)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmNN);
655  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_SS)) secondaryCluster->setHwPtEm(secondaryCluster->hwPtEm() + towerEtEmSS);
656  //
657  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_NW)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadNW);
658  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_N)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadN);
659  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_NE)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadNE);
660  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_E)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadE);
661  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_SE)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadSE);
662  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_S)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadS);
663  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_SW)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadSW);
664  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_W)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadW);
665  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_NN)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadNN);
666  if(secondaryCluster->checkClusterFlag(CaloCluster::INCLUDE_SS)) secondaryCluster->setHwPtHad(secondaryCluster->hwPtHad() + towerEtHadSS);
667 
668  // save this cluster in the vector
669  secClusters.emplace_back (std::move(secondaryCluster));
670  }
671  return secClusters;
672 }
static int offsetIEta(int iEta, int offset)
Definition: CaloStage2Nav.h:44
int hwPhi() const
Definition: L1Candidate.h:50
int hwEtEm() const
Definition: CaloTower.cc:64
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
static int offsetIPhi(int iPhi, int offset)
Definition: CaloStage2Nav.h:33
int hwEta() const
Definition: L1Candidate.h:49
double egNeighbourThreshold() const
int hwPt() const
Definition: L1Candidate.h:48
static const l1t::CaloTower & getTower(const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
Definition: CaloTools.cc:37
double towerLsbSum() const
int hwEtHad() const
Definition: CaloTower.cc:69
def move(src, dest)
Definition: eostools.py:511
#define constexpr
void l1t::Stage2Layer2TauAlgorithmFirmwareImp1::merging ( const std::vector< l1t::CaloCluster > &  clusters,
const std::vector< l1t::CaloTower > &  towers,
std::vector< l1t::Tau > &  taus 
)
private

Definition at line 44 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References funct::abs(), l1t::CaloTools::calHwEtSum(), calibratedPt(), l1t::CaloTools::calNrTowers(), l1t::CaloTools::CALO, l1t::CaloCluster::checkClusterFlag(), l1t::LUT::data(), l1t::CaloParamsHelper::egSeedThreshold(), PVValHelper::eta, spr::find(), l1t::CaloTools::getTower(), l1t::L1Candidate::hwPt(), l1t::L1Candidate::hwQual(), training_settings::idx, l1t::CaloCluster::INCLUDE_E, l1t::CaloCluster::INCLUDE_N, l1t::CaloCluster::INCLUDE_NE, l1t::CaloCluster::INCLUDE_NN, l1t::CaloCluster::INCLUDE_NW, l1t::CaloCluster::INCLUDE_S, l1t::CaloCluster::INCLUDE_SE, l1t::CaloCluster::INCLUDE_SS, l1t::CaloCluster::INCLUDE_SW, l1t::CaloCluster::INCLUDE_W, is3x3Maximum(), l1t::Tau::isMerged(), isoLutIndex(), l1t::CaloParamsHelper::isoTauEtaMax(), makeSecClusters(), l1t::CaloStage2Nav::offsetIEta(), l1t::CaloStage2Nav::offsetIPhi(), params_, l1t::CaloParamsHelper::pileUpTowerThreshold(), l1t::Tau::rawEt(), SurveyInfoScenario_cff::seed, UEAnalysisJets_cfi::seedThreshold, l1t::CaloCluster::setClusterFlag(), l1t::Tau::setHasEM(), l1t::L1Candidate::setHwIso(), l1t::L1Candidate::setHwPt(), l1t::Tau::setIsMerged(), l1t::Tau::setIsoEt(), l1t::Tau::setNTT(), reco::LeafCandidate::setP4(), l1t::Tau::setRawEt(), l1t::Tau::setTowerIEta(), l1t::Tau::setTowerIPhi(), metsig::tau, l1t::CaloParamsHelper::tauIsoAreaNrTowersEta(), l1t::CaloParamsHelper::tauIsoAreaNrTowersPhi(), l1t::CaloParamsHelper::tauIsolationLUT(), l1t::CaloParamsHelper::tauLsb(), l1t::CaloParamsHelper::tauPUSParam(), l1t::CaloTools::towerEta(), l1t::CaloTools::towerEtaSize(), l1t::CaloParamsHelper::towerLsbSum(), l1t::CaloTools::towerPhi(), l1t::CaloTools::towerPhiSize(), and l1t::CaloCluster::TRIM_LEFT.

Referenced by processEvent().

47 {
48 
49  // navigator
50  l1t::CaloStage2Nav caloNav;
51 
52  // this is common to all taus in this event
53  const int nrTowers = CaloTools::calNrTowers(-1*params_->tauPUSParam(1),params_->tauPUSParam(1),1,72,towers,1+params_->pileUpTowerThreshold(),999,CaloTools::CALO);
54 
55  for (const auto& mainCluster : clusters){
56 
57  // loop only on valid clusters
58  // by construction of the clustering, they are local maxima in the 9x3 jet window
59  if (mainCluster.isValid()){
60 
61  if (abs(mainCluster.hwEta()) > params_->isoTauEtaMax()) continue; // limit in main seed position in firmware
62 
63  taus.emplace_back(mainCluster);
64  l1t::Tau& tau = taus.back();
65 
66  int iEta = mainCluster.hwEta();
67  int iPhi = mainCluster.hwPhi();
68  int iEtaP = caloNav.offsetIEta(iEta, 1);
69  int iEtaM = caloNav.offsetIEta(iEta, -1);
70  int iPhiP = caloNav.offsetIPhi(iPhi, 1);
71  int iPhiM = caloNav.offsetIPhi(iPhi, -1);
72  int iPhiP2 = caloNav.offsetIPhi(iPhi, 2);
73  int iPhiP3 = caloNav.offsetIPhi(iPhi, 3);
74  int iPhiM2 = caloNav.offsetIPhi(iPhi, -2);
75  int iPhiM3 = caloNav.offsetIPhi(iPhi, -3);
76 
77  // get list of neighbor seeds and determine the highest E one
78  std::vector<l1t::CaloTower> satellites;
79  const l1t::CaloTower& towerN2 = l1t::CaloTools::getTower(towers, iEta, iPhiM2);
80  const l1t::CaloTower& towerN3 = l1t::CaloTools::getTower(towers, iEta, iPhiM3);
81  const l1t::CaloTower& towerN2W = l1t::CaloTools::getTower(towers, iEtaM, iPhiM2);
82  const l1t::CaloTower& towerN2E = l1t::CaloTools::getTower(towers, iEtaP, iPhiM2);
83  const l1t::CaloTower& towerS2 = l1t::CaloTools::getTower(towers, iEta, iPhiP2);
84  const l1t::CaloTower& towerS3 = l1t::CaloTools::getTower(towers, iEta, iPhiP3);
85  const l1t::CaloTower& towerS2W = l1t::CaloTools::getTower(towers, iEtaM, iPhiP2);
86  const l1t::CaloTower& towerS2E = l1t::CaloTools::getTower(towers, iEtaP, iPhiP2);
87 
89 
90  std::vector<int> sites; // numbering of the secondary cluster sites (seed positions)
91  // get only local max, also ask that they are above seed threshold
92  // FIXME : in firmware N --> larger phi but apparently only for these secondaries ... sigh ...
93  // might need to revert ; ALSO check EAST / WEST
94  // or at least check that everything is coherent here
95  if (is3x3Maximum(towerN2, towers, caloNav) && towerN2.hwPt() >= seedThreshold && !mainCluster.checkClusterFlag(CaloCluster::INCLUDE_NN))
96  sites.push_back(5);
97  if (is3x3Maximum(towerN3, towers, caloNav) && towerN3.hwPt() >= seedThreshold)
98  sites.push_back(7);
99  if (is3x3Maximum(towerN2W, towers, caloNav) && towerN2W.hwPt() >= seedThreshold)
100  sites.push_back(4);
101  if (is3x3Maximum(towerN2E, towers, caloNav) && towerN2E.hwPt() >= seedThreshold)
102  sites.push_back(6);
103  if (is3x3Maximum(towerS2, towers, caloNav) && towerS2.hwPt() >= seedThreshold && !mainCluster.checkClusterFlag(CaloCluster::INCLUDE_SS))
104  sites.push_back(2);
105  if (is3x3Maximum(towerS3, towers, caloNav) && towerS3.hwPt() >= seedThreshold)
106  sites.push_back(0);
107  if (is3x3Maximum(towerS2W, towers, caloNav) && towerS2W.hwPt() >= seedThreshold)
108  sites.push_back(1);
109  if (is3x3Maximum(towerS2E, towers, caloNav) && towerS2E.hwPt() >= seedThreshold)
110  sites.push_back(3);
111 
112 
113  // find neighbor with highest energy, with some preference that is defined as in the firmware
114  // Remember: the maxima requirement is already applied
115  // For the four towers in a T
116  // If cluster 0 is on a maxima, use that
117  // Else if cluster 2 is on a maxima, use that
118  // Else if both clusters 1 & 3 are both on maxima: Use the highest energy cluster
119  // Else if cluster 1 is on a maxima, use that
120  // Else if cluster 3 is on a maxima, use that
121  // Else there is no candidate
122  // Similarly for south
123  // Then if N>S, use N
124  // else S
125  auto secClusters = makeSecClusters (towers, sites, mainCluster, caloNav);
126  l1t::CaloCluster* secMaxN = nullptr;
127  l1t::CaloCluster* secMaxS = nullptr;
128  l1t::CaloCluster* secondaryCluster = nullptr;
129 
130  std::vector<int>::iterator isNeigh0 = find(sites.begin(), sites.end(), 0);
131  std::vector<int>::iterator isNeigh1 = find(sites.begin(), sites.end(), 1);
132  std::vector<int>::iterator isNeigh2 = find(sites.begin(), sites.end(), 2);
133  std::vector<int>::iterator isNeigh3 = find(sites.begin(), sites.end(), 3);
134  std::vector<int>::iterator isNeigh4 = find(sites.begin(), sites.end(), 4);
135  std::vector<int>::iterator isNeigh5 = find(sites.begin(), sites.end(), 5);
136  std::vector<int>::iterator isNeigh6 = find(sites.begin(), sites.end(), 6);
137  std::vector<int>::iterator isNeigh7 = find(sites.begin(), sites.end(), 7);
138 
139  // N neighbor --------------------------------------------------
140  if (isNeigh0 != sites.end()) secMaxN = secClusters.at(isNeigh0 - sites.begin()).get();
141  else if (isNeigh2 != sites.end()) secMaxN = secClusters.at(isNeigh2 - sites.begin()).get();
142 
143  else if ( isNeigh1 != sites.end() && isNeigh3 != sites.end() ) {
144 
145  if ((secClusters.at(isNeigh1 - sites.begin()))->hwPt() == (secClusters.at(isNeigh3 - sites.begin()))->hwPt()) {
146  // same E --> take 1
147  if(mainCluster.hwEta()>0) secMaxN = secClusters.at(isNeigh1 - sites.begin()).get();
148  else secMaxN = secClusters.at(isNeigh3 - sites.begin()).get();
149  }
150 
151  else {
152  if ((secClusters.at(isNeigh1 - sites.begin()))->hwPt() > (secClusters.at(isNeigh3 - sites.begin()))->hwPt()){
153  secMaxN = secClusters.at(isNeigh1 - sites.begin()).get();
154  }
155  else secMaxN = secClusters.at(isNeigh3 - sites.begin()).get();
156  }
157 
158  }
159 
160  else if (isNeigh1 != sites.end()) secMaxN = secClusters.at(isNeigh1 - sites.begin()).get();
161  else if (isNeigh3 != sites.end()) secMaxN = secClusters.at(isNeigh3 - sites.begin()).get();
162 
163  // S neighbor --------------------------------------------------
164  if (isNeigh7 != sites.end()) secMaxS = secClusters.at(isNeigh7 - sites.begin()).get();
165  else if (isNeigh5 != sites.end()) secMaxS = secClusters.at(isNeigh5 - sites.begin()).get();
166 
167  else if (isNeigh4 != sites.end() && isNeigh6 != sites.end() ) {
168 
169  if ((secClusters.at(isNeigh4 - sites.begin()))->hwPt() == (secClusters.at(isNeigh6 - sites.begin()))->hwPt()){
170  // same E --> take 1
171  if(mainCluster.hwEta()>0) secMaxN = secClusters.at(isNeigh4 - sites.begin()).get();
172  else secMaxN = secClusters.at(isNeigh6 - sites.begin()).get();
173  }
174 
175  else {
176  if ((secClusters.at(isNeigh4 - sites.begin()))->hwPt() > (secClusters.at(isNeigh6 - sites.begin()))->hwPt()) secMaxS = secClusters.at(isNeigh4 - sites.begin()).get();
177  else secMaxS = secClusters.at(isNeigh6 - sites.begin()).get();
178  }
179 
180  }
181 
182  else if (isNeigh4 != sites.end()) secMaxS = secClusters.at(isNeigh4 - sites.begin()).get();
183  else if (isNeigh6 != sites.end()) secMaxS = secClusters.at(isNeigh6 - sites.begin()).get();
184 
185  // N vs S neighbor --------------------------------------------------
186  if (secMaxN != nullptr && secMaxS != nullptr) {
187  if (secMaxN->hwPt() > secMaxS->hwPt()) secondaryCluster = secMaxN;
188  else secondaryCluster = secMaxS;
189  }
190  else {
191  if (secMaxN != nullptr) secondaryCluster = secMaxN;
192  else if (secMaxS != nullptr) secondaryCluster = secMaxS;
193  }
194 
195 
196  // trim primary cluster to remove overlap of TT
197  int neigEta [8] = {0, -1, 0, 1, -1, 0, 1, 0};
198  int neigPhi [8] = {3, 2, 2, 2, -2, -2, -2, -3};
199 
200  vector <pair<int, int> > TTPos (10); // numbering of TT in cluster; <iEta, iPhi>
201  TTPos.at(0) = make_pair (-1, 1); // SW
202  TTPos.at(1) = make_pair (0, 1); // S
203  TTPos.at(2) = make_pair (1, 1); // SE
204  TTPos.at(3) = make_pair (1, 0); // E
205  TTPos.at(4) = make_pair (1, -1); // NE
206  TTPos.at(5) = make_pair (0, -1); // N
207  TTPos.at(6) = make_pair (-1, -1); // NW
208  TTPos.at(7) = make_pair (-1, 0); // W
209  TTPos.at(8) = make_pair (0, 2); // SS
210  TTPos.at(9) = make_pair (0, -2); // NN
211 
212  vector <CaloCluster::ClusterFlag> TTPosRemap (10); // using geographical notation
213  TTPosRemap.at(0) = CaloCluster::INCLUDE_SW;
214  TTPosRemap.at(1) = CaloCluster::INCLUDE_S;
215  TTPosRemap.at(2) = CaloCluster::INCLUDE_SE;
216  TTPosRemap.at(3) = CaloCluster::INCLUDE_E;
217  TTPosRemap.at(4) = CaloCluster::INCLUDE_NE;
218  TTPosRemap.at(5) = CaloCluster::INCLUDE_N;
219  TTPosRemap.at(6) = CaloCluster::INCLUDE_NW;
220  TTPosRemap.at(7) = CaloCluster::INCLUDE_W;
221  TTPosRemap.at(8) = CaloCluster::INCLUDE_SS;
222  TTPosRemap.at(9) = CaloCluster::INCLUDE_NN;
223 
224 
225  // loop over TT of secondary cluster, if there is overlap remove this towers from main cluster
226  l1t::CaloCluster mainClusterTrim = mainCluster;
227  int secondaryClusterHwPt = 0;
228 
229  if(!secClusters.empty()){
230 
231  secondaryClusterHwPt = secondaryCluster->hwPt();
232 
233  int iSecIdxPosition = find_if (secClusters.begin(), secClusters.end(), [&](auto const& element) { return element.get() ==secondaryCluster;}) - secClusters.begin();
234  int secondaryClusterSite = sites.at(iSecIdxPosition);
235 
236  for (unsigned int iTT = 0; iTT < TTPos.size(); iTT++) {
237 
238  //get this TT in the "frame" of the main
239  int thisTTinMainEta = neigEta[secondaryClusterSite] + TTPos.at(iTT).first;
240  int thisTTinMainPhi = neigPhi[secondaryClusterSite] + TTPos.at(iTT).second;
241  pair<int, int> thisTT = make_pair (thisTTinMainEta, thisTTinMainPhi);
242  // check if main cluster has this tower included; if true, switch it off
243  auto thisTTItr = find (TTPos.begin(), TTPos.end(), thisTT);
244  if (thisTTItr != TTPos.end()){
245  int idx = thisTTItr - TTPos.begin();
246  if (secondaryCluster->checkClusterFlag (TTPosRemap.at(iTT)) ) mainClusterTrim.setClusterFlag (TTPosRemap.at(idx), false);
247  }
248 
249  }
250 
251  }
252 
253  // re-compute main cluster energy + position
254  const l1t::CaloTower& seed = l1t::CaloTools::getTower(towers, iEta , iPhi );
255  const l1t::CaloTower& towerNW = l1t::CaloTools::getTower(towers, iEtaM, iPhiM);
256  const l1t::CaloTower& towerN = l1t::CaloTools::getTower(towers, iEta , iPhiM);
257  const l1t::CaloTower& towerNE = l1t::CaloTools::getTower(towers, iEtaP, iPhiM);
258  const l1t::CaloTower& towerE = l1t::CaloTools::getTower(towers, iEtaP, iPhi );
259  const l1t::CaloTower& towerSE = l1t::CaloTools::getTower(towers, iEtaP, iPhiP);
260  const l1t::CaloTower& towerS = l1t::CaloTools::getTower(towers, iEta , iPhiP);
261  const l1t::CaloTower& towerSW = l1t::CaloTools::getTower(towers, iEtaM, iPhiP);
262  const l1t::CaloTower& towerW = l1t::CaloTools::getTower(towers, iEtaM, iPhi );
263  const l1t::CaloTower& towerNN = l1t::CaloTools::getTower(towers, iEta , iPhiM2);
264  const l1t::CaloTower& towerSS = l1t::CaloTools::getTower(towers, iEta , iPhiP2);
265 
266  int seedEt = seed .hwPt();
267  int towerEtNW = towerNW.hwPt();
268  int towerEtN = towerN .hwPt();
269  int towerEtNE = towerNE.hwPt();
270  int towerEtE = towerE .hwPt();
271  int towerEtSE = towerSE.hwPt();
272  int towerEtS = towerS .hwPt();
273  int towerEtSW = towerSW.hwPt();
274  int towerEtW = towerW .hwPt();
275  int towerEtNN = towerNN.hwPt();
276  int towerEtSS = towerSS.hwPt();
277 
278 
279  // Recompute hw energy from towers
280  tau.setHwPt(seedEt);
281  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_NW)) tau.setHwPt(tau.hwPt() + towerEtNW);
282  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_N)) tau.setHwPt(tau.hwPt() + towerEtN);
283  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_NE)) tau.setHwPt(tau.hwPt() + towerEtNE);
284  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_E)) tau.setHwPt(tau.hwPt() + towerEtE);
285  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_SE)) tau.setHwPt(tau.hwPt() + towerEtSE);
286  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_S)) tau.setHwPt(tau.hwPt() + towerEtS);
287  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_SW)) tau.setHwPt(tau.hwPt() + towerEtSW);
288  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_W)) tau.setHwPt(tau.hwPt() + towerEtW);
289  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_NN)) tau.setHwPt(tau.hwPt() + towerEtNN);
290  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_SS)) tau.setHwPt(tau.hwPt() + towerEtSS);
291 
292  //Merging
293  tau.setRawEt(tau.hwPt()+secondaryClusterHwPt);
294  tau.setIsMerged(secondaryClusterHwPt>0);
295 
296  // ==================================================================
297  // Energy calibration
298  // ==================================================================
299  // Corrections function of ieta, ET, and cluster shape
300  int calibPt = calibratedPt(mainCluster, towers, tau.rawEt(), tau.isMerged());
301  tau.setHwPt(calibPt);
302 
303  // isolation
304  int isoLeftExtension = params_->tauIsoAreaNrTowersEta();
305  int isoRightExtension = params_->tauIsoAreaNrTowersEta();
306  if(mainCluster.checkClusterFlag(CaloCluster::TRIM_LEFT))
307  isoRightExtension++;
308  else
309  isoLeftExtension++;
310 
311  int isolBit = 0;
312  int tauHwFootprint = tau.rawEt();
313  unsigned int LUTaddress = isoLutIndex(tauHwFootprint, mainCluster.hwEta(), nrTowers);
314  int hwEtSum = CaloTools::calHwEtSum(iEta,iPhi,towers,-isoLeftExtension,isoRightExtension,
316  int hwIsoEnergy = hwEtSum - tauHwFootprint;
317  if (hwIsoEnergy < 0) hwIsoEnergy = 0; // just in case the cluster is outside the window? should be very rare
318 
319  isolBit = (((hwIsoEnergy < (params_->tauIsolationLUT()->data(LUTaddress))) || (params_->tauIsolationLUT()->data(LUTaddress)>255)) ? 1 : 0);
320  //int isolBit2 = (((hwIsoEnergy < (params_->tauIsolationLUT2()->data(LUTaddress))) || (params_->tauIsolationLUT2()->data(LUTaddress)>255)) ? 1 : 0);
321  //isolBit += (isolBit2 << 1);
322  tau.setHwIso(isolBit);
323 
324  // development vars
325  tau.setTowerIPhi(iPhi);
326  tau.setTowerIEta(iEta);
327  int qual = seed.hwQual();
328  bool denomZeroFlag = ((qual&0x1) > 0);
329  bool eOverHFlag = ((qual&0x2) > 0);
330  int hasEM = (eOverHFlag || !denomZeroFlag);
331  tau.setHasEM(hasEM > 0);
332  tau.setIsoEt((short int) hwIsoEnergy);
333  tau.setNTT((short int) nrTowers);
334 
335  // Physical eta/phi. Computed from ieta/iphi of the seed tower and the fine-grain position within the seed
336  double eta = 0.;
337  double phi = 0.;
338  double seedEta = CaloTools::towerEta(iEta);
339  double seedEtaSize = CaloTools::towerEtaSize(iEta);
340  double seedPhi = CaloTools::towerPhi(iEta, iPhi);
341  double seedPhiSize = CaloTools::towerPhiSize(iEta);
342  if(mainCluster.fgEta()==0) eta = seedEta; // center
343  else if(mainCluster.fgEta()==2) eta = seedEta + seedEtaSize*0.251; // center + 1/4
344  else if(mainCluster.fgEta()==1) eta = seedEta - seedEtaSize*0.251; // center - 1/4
345 
346  //fgPhi is recomputed after trimming
347  int fgPhi = 0;
348 
349  int EtUp = 0;
350  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_NE)) EtUp += towerEtNE;
351  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_N)) EtUp += towerEtN;
352  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_NW)) EtUp += towerEtNW;
353  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_NN)) EtUp += towerEtNN;
354  int EtDown = 0;
355  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_SE)) EtDown += towerEtSE;
356  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_S)) EtDown += towerEtS;
357  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_SW)) EtDown += towerEtSW;
358  if(mainClusterTrim.checkClusterFlag(CaloCluster::INCLUDE_SS)) EtDown += towerEtSS;
359  //
360  if(EtDown>EtUp) fgPhi = 2;
361  else if(EtUp>EtDown) fgPhi = 1;
362 
363  if(fgPhi==0) phi = seedPhi; // center
364  else if(fgPhi==2) phi = seedPhi + seedPhiSize*0.251; // center + 1/4
365  else if(fgPhi==1) phi = seedPhi - seedPhiSize*0.251; // center - 1/4
366 
367  // Set 4-vector
368  math::PtEtaPhiMLorentzVector calibP4((double)calibPt*params_->tauLsb(), eta, phi, 0.);
369  tau.setP4(calibP4);
370 
371  // delete all sec clusters that were allocated with new
372  secClusters.clear();
373 
374 
375  }
376 
377  } // end loop on clusters
378 
379 
380 }
static float towerEta(int ieta)
Definition: CaloTools.cc:171
static float towerPhi(int ieta, int iphi)
Definition: CaloTools.cc:179
void setHasEM(bool hasEM)
Definition: Tau.h:21
static int offsetIEta(int iEta, int offset)
Definition: CaloStage2Nav.h:44
void setRawEt(short int et)
static float towerEtaSize(int ieta)
Definition: CaloTools.cc:186
static int calHwEtSum(int iEta, int iPhi, const std::vector< l1t::CaloTower > &towers, int localEtaMin, int localEtaMax, int localPhiMin, int localPhiMax, SubDet etMode=CALO)
Definition: CaloTools.cc:109
unsigned tauIsoAreaNrTowersPhi() const
unsigned tauIsoAreaNrTowersEta() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
double egSeedThreshold() const
bool checkClusterFlag(ClusterFlag flag) const
Definition: CaloCluster.cc:66
bool is3x3Maximum(const l1t::CaloTower &tower, const std::vector< CaloTower > &towers, l1t::CaloStage2Nav &caloNav)
static int offsetIPhi(int iPhi, int offset)
Definition: CaloStage2Nav.h:33
bool isMerged() const
static size_t calNrTowers(int iEtaMin, int iEtaMax, int iPhiMin, int iPhiMax, const std::vector< l1t::CaloTower > &towers, int minHwEt, int maxHwEt, SubDet etMode=CALO)
Definition: CaloTools.cc:139
int pileUpTowerThreshold() const
double tauLsb() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::unique_ptr< l1t::CaloCluster > > makeSecClusters(const std::vector< l1t::CaloTower > &towers, std::vector< int > &sites, const l1t::CaloCluster &mainCluster, l1t::CaloStage2Nav &caloNav)
int calibratedPt(const l1t::CaloCluster &clus, const std::vector< l1t::CaloTower > &towers, int hwPt, bool isMerged)
int hwQual() const
Definition: L1Candidate.h:51
static float towerPhiSize(int ieta)
Definition: CaloTools.cc:193
short int rawEt() const
void setHwIso(int iso)
Definition: L1Candidate.h:45
int hwPt() const
Definition: L1Candidate.h:48
double tauPUSParam(int ipar) const
void setNTT(short int ntt)
void setTowerIEta(short int ieta)
static const l1t::CaloTower & getTower(const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
Definition: CaloTools.cc:37
double towerLsbSum() const
void setHwPt(int pt)
Definition: L1Candidate.h:41
int data(unsigned int address) const
Definition: LUT.h:46
l1t::LUT * tauIsolationLUT()
void setP4(const LorentzVector &p4) final
set 4-momentum
void setIsoEt(short int et)
void setClusterFlag(ClusterFlag flag, bool val=true)
Definition: CaloCluster.cc:19
void setTowerIPhi(short int iphi)
void setIsMerged(bool isMerged)
unsigned int isoLutIndex(int Et, int hweta, unsigned int nrTowers)
void l1t::Stage2Layer2TauAlgorithmFirmwareImp1::processEvent ( const std::vector< CaloCluster > &  clusters,
const std::vector< CaloTower > &  towers,
std::vector< Tau > &  taus 
)
overridevirtual

Implements l1t::Stage2Layer2TauAlgorithm.

Definition at line 33 of file Stage2Layer2TauAlgorithmFirmwareImp1.cc.

References dosorting(), and merging().

35  {
36 
37  // fill L1 candidates collections from clusters, merging neighbour clusters
38  merging (clusters, towers, taus);
39  //FIXME: TO DO
40  // isolation (taus);
41  dosorting(taus);
42 }
void merging(const std::vector< l1t::CaloCluster > &clusters, const std::vector< l1t::CaloTower > &towers, std::vector< l1t::Tau > &taus)
unsigned int l1t::Stage2Layer2TauAlgorithmFirmwareImp1::trimMainLutIndex ( int  neighPos,
bool  isWe 
)
private

Member Data Documentation

std::vector<std::vector<float> > l1t::Stage2Layer2TauAlgorithmFirmwareImp1::coefficients_
private

Definition at line 45 of file Stage2Layer2TauAlgorithmFirmware.h.

Referenced by loadCalibrationLuts().

float l1t::Stage2Layer2TauAlgorithmFirmwareImp1::offsetBarrelEH_
private

Definition at line 47 of file Stage2Layer2TauAlgorithmFirmware.h.

Referenced by loadCalibrationLuts().

float l1t::Stage2Layer2TauAlgorithmFirmwareImp1::offsetBarrelH_
private

Definition at line 48 of file Stage2Layer2TauAlgorithmFirmware.h.

Referenced by loadCalibrationLuts().

float l1t::Stage2Layer2TauAlgorithmFirmwareImp1::offsetEndcapsEH_
private

Definition at line 49 of file Stage2Layer2TauAlgorithmFirmware.h.

Referenced by loadCalibrationLuts().

float l1t::Stage2Layer2TauAlgorithmFirmwareImp1::offsetEndcapsH_
private

Definition at line 50 of file Stage2Layer2TauAlgorithmFirmware.h.

Referenced by loadCalibrationLuts().

CaloParamsHelper const* l1t::Stage2Layer2TauAlgorithmFirmwareImp1::params_
private