30 const std::vector<l1t::CaloTower>&
towers,
31 std::vector<l1t::Tau> & taus) {
33 merging(clusters, towers, taus);
46 std::vector<l1t::CaloCluster> tmpClusters(clusters);
48 for (
auto itr = tmpClusters.begin(); itr != tmpClusters.end(); ++itr ) {
51 int iEta = mainCluster.
hwEta();
52 int iPhi = mainCluster.
hwPhi();
70 std::list<l1t::CaloCluster> satellites;
71 if(clusterN2 .isValid()) satellites.push_back(clusterN2);
72 if(clusterN3 .isValid()) satellites.push_back(clusterN3);
73 if(clusterN2W.
isValid()) satellites.push_back(clusterN2W);
74 if(clusterN2E.
isValid()) satellites.push_back(clusterN2E);
75 if(clusterS2 .isValid()) satellites.push_back(clusterS2);
76 if(clusterS3 .isValid()) satellites.push_back(clusterS3);
77 if(clusterS2W.
isValid()) satellites.push_back(clusterS2W);
78 if(clusterS2E.
isValid()) satellites.push_back(clusterS2E);
80 if(satellites.size()>0) {
84 if(secondaryCluster>mainCluster) {
88 if(secondaryCluster.
hwPhi()==iPhiP2 || secondaryCluster.
hwPhi()==iPhiP3) {
91 else if(secondaryCluster.
hwPhi()==iPhiM2 || secondaryCluster.
hwPhi()==iPhiM3) {
95 if(secondaryCluster.
hwEta()==iEtaP) {
98 else if(secondaryCluster.
hwEta()==iEta || secondaryCluster.
hwEta()==iEtaM) {
106 if(secondaryCluster.
hwPhi()==iPhiP2 || secondaryCluster.
hwPhi()==iPhiP3) {
109 else if(secondaryCluster.
hwPhi()==iPhiM2 || secondaryCluster.
hwPhi()==iPhiM3) {
113 if(secondaryCluster.
hwEta()==iEtaP) {
116 else if(secondaryCluster.
hwEta()==iEta || secondaryCluster.
hwEta()==iEtaM) {
125 for (
auto itr = tmpClusters.begin(); itr != tmpClusters.end(); ++itr ) {
126 if( itr->isValid() ){
128 int iEta = mainCluster.
hwEta();
129 int iPhi = mainCluster.
hwPhi();
138 if (mainCluster.
fgEta()==0) eta = seedEta;
139 else if(mainCluster.
fgEta()==2) eta = seedEta + seedEtaSize*0.25;
140 else if(mainCluster.
fgEta()==1) eta = seedEta - seedEtaSize*0.25;
141 if (mainCluster.
fgPhi()==0) phi = seedPhi;
142 else if(mainCluster.
fgPhi()==2) phi = seedPhi + seedPhiSize*0.25;
143 else if(mainCluster.
fgPhi()==1) phi = seedPhi - seedPhiSize*0.25;
164 std::list<l1t::CaloCluster> satellites;
165 if(clusterN2 .isValid()) satellites.push_back(clusterN2);
166 if(clusterN3 .isValid()) satellites.push_back(clusterN3);
167 if(clusterN2W.
isValid()) satellites.push_back(clusterN2W);
168 if(clusterN2E.
isValid()) satellites.push_back(clusterN2E);
169 if(clusterS2 .isValid()) satellites.push_back(clusterS2);
170 if(clusterS3 .isValid()) satellites.push_back(clusterS3);
171 if(clusterS2W.
isValid()) satellites.push_back(clusterS2W);
172 if(clusterS2E.
isValid()) satellites.push_back(clusterS2E);
175 if(satellites.size()>0) {
180 if(mainCluster>secondaryCluster) {
181 bool canBeMerged =
true;
182 bool mergeUp = (secondaryCluster.
hwPhi()==iPhiM2 || secondaryCluster.
hwPhi()==iPhiM3);
183 bool mergeLeft = (secondaryCluster.
hwEta()==iEtaM);
184 bool mergeRight = (secondaryCluster.
hwEta()==iEtaP);
207 hwEtSum =
CaloTools::calHwEtSum(iEtaP,iPhiP,towers,-1*params_->tauIsoAreaNrTowersEta(),params_->tauIsoAreaNrTowersEta(),
208 -1*params_->tauIsoAreaNrTowersPhi(),params_->tauIsoAreaNrTowersPhi(),params_->tauPUSParam(2),
CaloTools::CALO);
231 hwEtSum =
CaloTools::calHwEtSum(iEtaM,iPhiP,towers,-1*params_->tauIsoAreaNrTowersEta(),params_->tauIsoAreaNrTowersEta(),
232 -1*params_->tauIsoAreaNrTowersPhi(),params_->tauIsoAreaNrTowersPhi(),params_->tauPUSParam(2),
CaloTools::CALO);
252 hwEtSum =
CaloTools::calHwEtSum(iEta,iPhiP,towers,-1*params_->tauIsoAreaNrTowersEta(),params_->tauIsoAreaNrTowersEta(),
253 -1*params_->tauIsoAreaNrTowersPhi(),params_->tauIsoAreaNrTowersPhi(),params_->tauPUSParam(2),
CaloTools::CALO);
277 hwEtSum =
CaloTools::calHwEtSum(iEtaM,iPhiP,towers,-1*params_->tauIsoAreaNrTowersEta(),params_->tauIsoAreaNrTowersEta(),
278 -1*params_->tauIsoAreaNrTowersPhi(),params_->tauIsoAreaNrTowersPhi(),params_->tauPUSParam(2),
CaloTools::CALO);
299 hwEtSum =
CaloTools::calHwEtSum(iEtaM,iPhiM,towers,-1*params_->tauIsoAreaNrTowersEta(),params_->tauIsoAreaNrTowersEta(),
300 -1*params_->tauIsoAreaNrTowersPhi(),params_->tauIsoAreaNrTowersPhi(),params_->tauPUSParam(2),
CaloTools::CALO);
321 hwEtSum =
CaloTools::calHwEtSum(iEta,iPhiM,towers,-1*params_->tauIsoAreaNrTowersEta(),params_->tauIsoAreaNrTowersEta(),
322 -1*params_->tauIsoAreaNrTowersPhi(),params_->tauIsoAreaNrTowersPhi(),params_->tauPUSParam(2),
CaloTools::CALO);
345 unsigned int lutAddress = isoLutIndex(calibPt, nrTowers);
347 isolBit = hwEtSum-hwFootPrint <= (params_->tauIsolationLUT()->data(lutAddress));
348 taus.back().setHwIso(isolBit);
352 double calibPt = calibratedPt(mainCluster.
hwPtEm(), mainCluster.
hwPtHad(), mainCluster.
hwEta());
360 -1*params_->tauIsoAreaNrTowersPhi(),params_->tauIsoAreaNrTowersPhi(),params_->tauPUSParam(2),
CaloTools::CALO);
362 int hwFootPrint = isoCalTauHwFootPrint(mainCluster,towers);
366 unsigned int lutAddress = isoLutIndex(calibPt, nrTowers);
368 isolBit = hwEtSum-hwFootPrint <= params_->tauIsolationLUT()->data(lutAddress);
369 taus.back().setHwIso(isolBit);
373 bool canBeKept =
false;
374 bool mergeUp = (secondaryCluster.
hwPhi()==iPhiM2 || secondaryCluster.
hwPhi()==iPhiM3);
375 bool mergeLeft = (secondaryCluster.
hwEta()==iEtaM);
376 bool mergeRight = (secondaryCluster.
hwEta()==iEtaP);
383 double calibPt = calibratedPt(mainCluster.
hwPtEm(), mainCluster.
hwPtHad(), mainCluster.
hwEta());
391 -1*params_->tauIsoAreaNrTowersPhi(),params_->tauIsoAreaNrTowersPhi(),params_->tauPUSParam(2),
CaloTools::CALO);
393 int hwFootPrint = isoCalTauHwFootPrint(mainCluster,towers);
397 unsigned int lutAddress = isoLutIndex(calibPt, nrTowers);
399 isolBit = hwEtSum-hwFootPrint <= params_->tauIsolationLUT()->data(lutAddress);
400 taus.back().setHwIso(isolBit);
406 double calibPt = calibratedPt(mainCluster.
hwPtEm(), mainCluster.
hwPtHad(), mainCluster.
hwEta());
414 -1*params_->tauIsoAreaNrTowersPhi(),params_->tauIsoAreaNrTowersPhi(),params_->tauPUSParam(2),
CaloTools::CALO);
416 int hwFootPrint = isoCalTauHwFootPrint(mainCluster,towers);
420 unsigned int lutAddress = isoLutIndex(calibPt, nrTowers);
422 isolBit = hwEtSum-hwFootPrint <= params_->tauIsolationLUT()->data(lutAddress);
423 taus.back().setHwIso(isolBit);
434 int iEta=clus.
hwEta();
435 int iPhi=clus.
hwPhi();
437 return totHwFootPrint;
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;
456 enum {LUT_UPPER = 3};
457 enum {LUT_OFFSET = 0x80};
460 unsigned int nBins = (1 << (lut->
nrBitsAddress() - LUT_UPPER));
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;
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;
492 unsigned int nBins = coefficients_[0].size();
493 double e = (double)hwPtEm*params_->tauLsb();
494 double h = (double)hwPtHad*params_->tauLsb();
496 int ilutOffset = (
barrel) ? 0: 3;
497 unsigned int ibin=(
unsigned int)(floor(e+h));
498 if (ibin >= nBins -1) ibin = nBins-1;
500 double offset = (
barrel) ? offsetBarrelEH_ : offsetEndcapsEH_;
501 calibPt = e*coefficients_[ilutOffset][ibin] + h*coefficients_[1+ilutOffset][ibin] +
offset;
504 double offset = (
barrel) ? offsetBarrelH_ : offsetEndcapsH_;
505 calibPt = h*coefficients_[2+ilutOffset][ibin]+
offset;
509 if(ieta<-28) ieta=-28;
511 ibin = (ieta>0 ? ieta+27 : ieta+28);
512 calibPt *= coefficients_.back()[ibin];
521 const unsigned int kTowerGranularity=params_->tauPUSParam(0);
522 unsigned int nrTowersNormed = nrTowers/kTowerGranularity;
524 if (nrTowersNormed > 1023) nrTowersNormed = 1023;
525 int kTowerOffs = 256*nrTowersNormed;
527 if (Et > 255) Et = 255;
529 return (kTowerOffs + Et);
unsigned int isoLutIndex(int Et, unsigned int nrTowers)
static int offsetIEta(int iEta, int offset)
virtual void processEvent(const std::vector< CaloCluster > &clusters, const std::vector< CaloTower > &towers, std::vector< Tau > &taus)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
bool checkClusterFlag(ClusterFlag flag) const
unsigned int nrBitsData() const
static int offsetIPhi(int iPhi, int offset)
void loadCalibrationLuts()
double calibratedPt(int hwPtEm, int hwPtHad, int ieta)
int isoCalTauHwFootPrint(const l1t::CaloCluster &, const std::vector< l1t::CaloTower > &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Stage2Layer2TauAlgorithmFirmwareImp1(CaloParamsHelper *params)
unsigned int nrBitsAddress() const
void merging(const std::vector< l1t::CaloCluster > &clusters, const std::vector< l1t::CaloTower > &towers, std::vector< l1t::Tau > &taus)
Geom::Phi< T > phi() const
int data(unsigned int address) const
virtual ~Stage2Layer2TauAlgorithmFirmwareImp1()
tuple size
Write out results.
void setClusterFlag(ClusterFlag flag, bool val=true)