20 return a.
pt() > b.
pt();
41 std::vector<l1t::EGamma> egammas_raw;
43 for(
const auto& cluster : clusters)
49 int iEta = cluster.hwEta();
50 int iPhi = cluster.hwPhi();
70 int seedEt = seed .
hwPt();
71 int towerEtNW = towerNW.
hwPt();
72 int towerEtN = towerN .
hwPt();
73 int towerEtNE = towerNE.
hwPt();
74 int towerEtE = towerE .
hwPt();
75 int towerEtSE = towerSE.
hwPt();
76 int towerEtS = towerS .
hwPt();
77 int towerEtSW = towerSW.
hwPt();
78 int towerEtW = towerW .
hwPt();
79 int towerEtNN = towerNN.
hwPt();
80 int towerEtSS = towerSS.
hwPt();
86 egammas_raw.push_back(cluster);
126 hOverEExtBit = HoE_ext;
130 if(fgBit) qual |= (0x1);
131 if(hOverEBit) qual |= (0x1<<1);
132 if(shapeBit) qual |= (0x1<<2);
133 if(hOverEExtBit) qual |= (0x1<<3);
146 -isoLeftExtension,isoRightExtension,
158 isolBit += (isolBit2 << 1);
160 int hwIsoEnergy = hwEtSum-hwFootPrint;
166 egamma.
setIsoEt((
short int)hwIsoEnergy);
168 egamma.
setNTT((
short int)nrTowers);
184 if(cluster.fgEta()==0) eta = seedEta;
186 else if(cluster.fgEta()==2) eta = seedEta + seedEtaSize*0.251;
187 else if(cluster.fgEta()==1) eta = seedEta - seedEtaSize*0.251;
204 if(EtDown>EtUp) fgPhi = 2;
205 else if(EtUp>EtDown) fgPhi = 1;
208 if(fgPhi==0) phi = seedPhi;
209 else if(fgPhi==2) phi = seedPhi + seedPhiSize*0.251;
210 else if(fgPhi==1) phi = seedPhi - seedPhiSize*0.251;
215 egamma.
setP4(calibP4);
223 std::vector< std::vector<l1t::EGamma> > egEtaPos(
params_->
egEtaCut() , std::vector<l1t::EGamma>(18, tempEG));
224 std::vector< std::vector<l1t::EGamma> > egEtaNeg(
params_->
egEtaCut() , std::vector<l1t::EGamma>(18, tempEG));
225 for (
unsigned int iEG = 0; iEG < egammas_raw.size(); iEG++)
227 int fgBit = egammas_raw.at(iEG).hwQual() & (0x1);
228 int hOverEBit = egammas_raw.at(iEG).hwQual()>>1 & (0x1);
229 int shapeBit = egammas_raw.at(iEG).hwQual()>>2 & (0x1);
230 int hOverEExtBit = egammas_raw.at(iEG).hwQual()>>3 & (0x1);
234 if(!IDcuts)
continue;
235 egammas_raw.at(iEG).setHwQual( 7 );
237 if (egammas_raw.at(iEG).hwEta() > 0) egEtaPos.at( egammas_raw.at(iEG).hwEta()-1).at((72-egammas_raw.at(iEG).hwPhi())/4) = egammas_raw.at(iEG);
238 else egEtaNeg.at( -(egammas_raw.at(iEG).hwEta()+1)).at((72-egammas_raw.at(iEG).hwPhi())/4) = egammas_raw.at(iEG);
243 std::vector<l1t::EGamma> accumEtaPos;
244 std::vector<l1t::EGamma> accumEtaNeg;
249 std::vector<l1t::EGamma>::iterator start_, end_;
250 start_ = egEtaPos.at(ieta).begin();
251 end_ = egEtaPos.at(ieta).end();
252 BitonicSort<l1t::EGamma>(
down, start_, end_);
253 etaPosSorter.
Merge( egEtaPos.at(ieta) , accumEtaPos );
256 start_ = egEtaNeg.at(ieta).begin();
257 end_ = egEtaNeg.at(ieta).end();
258 BitonicSort<l1t::EGamma>(
down, start_, end_);
259 etaNegSorter.
Merge( egEtaNeg.at(ieta) , accumEtaNeg );
267 if (acceg.hwPt() > 0) egammas.push_back(acceg);
271 if (acceg.hwPt() > 0) egammas.push_back(acceg);
281 unsigned int shape = 0;
305 unsigned int iEtaNormed =
abs(iEta);
306 if(iEtaNormed>28) iEtaNormed = 28;
311 return (compressedShape | compressedE | compressedEta);
315 unsigned int iEtaNormed =
abs(iEta);
316 if(iEtaNormed>28) iEtaNormed = 28;
319 return E+compressedShape*256+(iEtaNormed-1)*256*64;
328 int iEta=clus.
hwEta();
329 int iPhi=clus.
hwPhi();
335 int phiSide = iEta>0 ? 1 : -1;
351 return ecalHwFootPrint-ecalHwFootPrint_2x1+ecalhcal_HwFootPrint_2x1;
363 if(nrTowers>255) nrTowers = 255;
364 unsigned int iEtaNormed =
abs(iEta);
365 if(iEtaNormed>28) iEtaNormed = 28;
371 return (compressednTT | compressedE | compressedEta);
378 const unsigned int kMaxAddress = kNrTowersInSum%kTowerGranularity==0 ? (kNrTowersInSum/kTowerGranularity+1)*28*2 :
379 (kNrTowersInSum/kTowerGranularity)*28*2;
381 unsigned int nrTowersNormed = nrTowers/kTowerGranularity;
383 unsigned int iEtaNormed = iEta+28;
384 if(iEta>0) iEtaNormed--;
386 if(
std::abs(iEta)>28 || iEta==0 || nrTowers>kNrTowersInSum)
return kMaxAddress;
387 else return iEtaNormed*(kNrTowersInSum/kTowerGranularity+1)+nrTowersNormed;
396 unsigned int shape = 0;
412 int corrXrawPt = corr*
rawPt;
414 int corrPt = corrXrawPt>>8;
429 unsigned int iEtaNormed =
abs(iEta);
430 if(iEtaNormed>28) iEtaNormed = 28;
435 return (compressedShape | compressedE | compressedEta);
439 unsigned int iEtaNormed =
abs(iEta);
440 if(iEtaNormed>28) iEtaNormed = 28;
444 if(compressedShape>31) compressedShape = 31;
445 return (E-20)+compressedShape*236+(iEtaNormed-1)*236*32;
455 unsigned int shape = 0;
493 unsigned int iEtaNormed =
abs(iEta)-1;
494 if(iEtaNormed>31) iEtaNormed = 31;
495 if(shape>127) shape = 127;
496 unsigned int index = iEtaNormed*128+shape;
505 unsigned int shape = 0;
530 bool denomZeroFlag = ((qual&0x1) > 0);
531 bool eOverHFlag = ((qual&0x2) > 0);
533 if (denomZeroFlag && !eOverHFlag)
535 if (denomZeroFlag && eOverHFlag)
537 if (!denomZeroFlag && !eOverHFlag)
551 bool eOverHFlag = ((qual&0x2) > 0);
553 if(tow.
hwPt()<=10)
return true;
554 else return eOverHFlag;
void setRawEt(short int pt)
unsigned int idShapeLutIndex(int iEta, int E, int shape)
unsigned isoLutIndex(int iEta, unsigned int nrTowers, int E)
void Merge(const std::vector< T > &aInput, std::vector< T > &aOutput)
Stage2Layer2EGammaAlgorithmFirmwareImp1(CaloParamsHelper const *params)
static int offsetIEta(int iEta, int offset)
int returnHoE(const l1t::CaloTower &tow)
unsigned egIsoAreaNrTowersPhi() const
l1t::LUT const * egIsolationLUT2() const
double pt() const final
transverse momentum
int isoCalEgHwFootPrint(const l1t::CaloCluster &, const std::vector< l1t::CaloTower > &)
unsigned egBypassShape() const
unsigned egBypassEGVetos() const
l1t::LUT const * egIsolationLUT() const
l1t::LUT * egCompressShapesLUT()
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
l1t::LUT const * egCalibrationLUT() const
std::string const & egIsolationType() const
bool checkClusterFlag(ClusterFlag flag) const
void setTowerHoE(short int HoE)
unsigned egIsoVetoNrTowersPhi() const
void setNTT(short int ntt)
static int offsetIPhi(int iPhi, int offset)
int pileUpTowerThreshold() const
Abs< T >::type abs(const T &t)
void setFootprintEt(short int fp)
l1t::CaloCluster trimCluster(const l1t::CaloCluster &clus)
l1t::LUT * egTrimmingLUT()
void processEvent(const std::vector< CaloCluster > &clusters, const std::vector< CaloTower > &towers, std::vector< EGamma > &egammas) override
bool idShape(const l1t::CaloCluster &clus, int hwPt)
CaloParamsHelper const * params_
unsigned int returnShape(const l1t::CaloCluster &clus)
double egPUSParam(int ipar) const
std::string const & egShapeIdType() const
void setTowerIEta(short int ieta)
double egMaxPtHOverE() const
unsigned egBypassHoE() const
void setShape(short int s)
void setIsoEt(short int iso)
std::string const & egCalibrationType() const
unsigned int trimmingLutIndex(unsigned int shape, int iEta)
unsigned int calibrationLutIndex(int iEta, int E, int shape)
unsigned egBypassExtHOverE() const
unsigned egBypassECALFG() const
void setTowerIPhi(short int iphi)
bool idHoverE_ext(const l1t::CaloTower tow)
int data(unsigned int address) const
bool operator>(const l1t::Jet &a, l1t::Jet &b)
int calibratedPt(const l1t::CaloCluster &clus, int hwPt)
unsigned egIsoAreaNrTowersEta() const
void setP4(const LorentzVector &p4) final
set 4-momentum
void setClusterFlag(ClusterFlag flag, bool val=true)