36 for(
const auto& cluster : clusters)
42 int iEta = cluster.hwEta();
43 int iPhi = cluster.hwPhi();
62 int seedEt = seed .
hwEtEm();
63 int towerEtNW = towerNW.
hwEtEm();
64 int towerEtN = towerN .
hwEtEm();
65 int towerEtNE = towerNE.
hwEtEm();
66 int towerEtE = towerE .
hwEtEm();
67 int towerEtSE = towerSE.
hwEtEm();
68 int towerEtS = towerS .
hwEtEm();
69 int towerEtSW = towerSW.
hwEtEm();
70 int towerEtW = towerW .
hwEtEm();
71 int towerEtNN = towerNN.
hwEtEm();
72 int towerEtSS = towerSS.
hwEtEm();
75 egammas.push_back(cluster);
97 bool hOverEBit = idHOverE(cluster, egamma.
hwPt());
98 bool shapeBit = idShape(cluster, egamma.
hwPt());
99 bool fgBit = !(cluster.hwSeedPt()>6 && cluster.fgECAL());
101 if(fgBit) qual |= (0x1);
102 if(hOverEBit) qual |= (0x1<<1);
103 if(shapeBit) qual |= (0x1<<2);
109 -1*params_->egIsoAreaNrTowersEta(),params_->egIsoAreaNrTowersEta(),
110 -1*params_->egIsoAreaNrTowersPhi(),params_->egIsoAreaNrTowersPhi(),
111 params_->egPUSParam(2));
112 int hwFootPrint = isoCalEgHwFootPrint(cluster,towers);
115 params_->egPUSParam(1),
117 unsigned int lutAddress = isoLutIndex(egamma.
hwEta(), nrTowers);
119 int isolBit = hwEtSum-hwFootPrint <= params_->egIsolationLUT()->data(lutAddress);
127 int calibPt = calibratedPt(cluster, egamma.
hwPt());
136 if(cluster.fgEta()==0) eta = seedEta;
137 else if(cluster.fgEta()==2) eta = seedEta + seedEtaSize*0.25;
138 else if(cluster.fgEta()==1) eta = seedEta - seedEtaSize*0.25;
139 if(cluster.fgPhi()==0) phi = seedPhi;
140 else if(cluster.fgPhi()==2) phi = seedPhi + seedPhiSize*0.25;
141 else if(cluster.fgPhi()==1) phi = seedPhi - seedPhiSize*0.25;
145 egamma.
setP4(calibP4);
155 unsigned int lutAddress = idHOverELutIndex(clus.
hwEta(), hwPt);
156 bool hOverEBit = ( clus.
hOverE() <= params_->egMaxHOverELUT()->data(lutAddress) );
157 hOverEBit |= ( clus.
hwPt()>=floor(params_->egMaxPtHOverE()/params_->egLsb()) );
165 unsigned int iEtaNormed =
abs(iEta);
166 if(iEtaNormed>28) iEtaNormed = 28;
168 return E+(iEtaNormed-1)*256;
175 unsigned int shape = 0;
187 unsigned int lutAddress = idShapeLutIndex(clus.
hwEta(), hwPt, shape);
188 bool shapeBit = params_->egShapeIdLUT()->data(lutAddress);
196 unsigned int iEtaNormed =
abs(iEta);
197 if(iEtaNormed>28) iEtaNormed = 28;
199 unsigned int compressedShape = params_->egCompressShapesLUT()->data(shape);
200 return E+compressedShape*256+(iEtaNormed-1)*256*64;
208 int iEta=clus.
hwEta();
209 int iPhi=clus.
hwPhi();
215 int phiSide = iEta>0 ? 1 : -1;
218 -1*params_->egIsoVetoNrTowersPhi(),params_->egIsoVetoNrTowersPhi(),
221 -1*params_->egIsoVetoNrTowersPhi(),params_->egIsoVetoNrTowersPhi(),
225 return ecalHwFootPrint+hcalHwFootPrint;
233 const unsigned int kNrTowersInSum=72*params_->egPUSParam(1)*2;
234 const unsigned int kTowerGranularity=params_->egPUSParam(0);
235 const unsigned int kMaxAddress = kNrTowersInSum%kTowerGranularity==0 ? (kNrTowersInSum/kTowerGranularity+1)*28*2 :
236 (kNrTowersInSum/kTowerGranularity)*28*2;
238 unsigned int nrTowersNormed = nrTowers/kTowerGranularity;
240 unsigned int iEtaNormed = iEta+28;
241 if(iEta>0) iEtaNormed--;
243 if(
std::abs(iEta)>28 || iEta==0 || nrTowers>kNrTowersInSum)
return kMaxAddress;
244 else return iEtaNormed*(kNrTowersInSum/kTowerGranularity+1)+nrTowersNormed;
252 unsigned int shape = 0;
264 unsigned int lutAddress = calibrationLutIndex(clus.
hwEta(), hwPt, shape);
265 int corr = params_->egCalibrationLUT()->data(lutAddress);
268 int corrXrawPt = corr*rawPt;
270 int addPt = corrXrawPt>>9;
271 int remainder = corrXrawPt & 0x1FF;
272 if(remainder>=0x100) addPt += 1;
273 int corrPt = rawPt + addPt;
274 if(corrPt>255) corrPt = 255;
282 unsigned int iEtaNormed =
abs(iEta);
283 if(iEtaNormed>28) iEtaNormed = 28;
286 unsigned int compressedShape = params_->egCompressShapesLUT()->data(shape);
287 if(compressedShape>31) compressedShape = 31;
288 return (E-20)+compressedShape*236+(iEtaNormed-1)*236*32;
297 unsigned int shape = 0;
309 unsigned int lutAddress = trimmingLutIndex(shape, clus.
hwEta());
310 unsigned int shapeTrim = params_->egTrimmingLUT()->data(lutAddress);
335 unsigned int iEtaNormed =
abs(iEta)-1;
336 if(iEtaNormed>31) iEtaNormed = 31;
337 if(shape>127) shape = 127;
338 unsigned int index = iEtaNormed*128+shape;
unsigned int idShapeLutIndex(int iEta, int E, int shape)
virtual void processEvent(const std::vector< CaloCluster > &clusters, const std::vector< CaloTower > &towers, std::vector< EGamma > &egammas)
bool idHOverE(const l1t::CaloCluster &clus, int hwPt)
static int offsetIEta(int iEta, int offset)
virtual void setP4(const LorentzVector &p4)
set 4-momentum
int isoCalEgHwFootPrint(const l1t::CaloCluster &, const std::vector< l1t::CaloTower > &)
unsigned isoLutIndex(int iEta, unsigned int nrTowers)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
bool checkClusterFlag(ClusterFlag flag) const
static int offsetIPhi(int iPhi, int offset)
Abs< T >::type abs(const T &t)
l1t::CaloCluster trimCluster(const l1t::CaloCluster &clus)
bool idShape(const l1t::CaloCluster &clus, int hwPt)
Geom::Phi< T > phi() const
unsigned int trimmingLutIndex(unsigned int shape, int iEta)
unsigned int calibrationLutIndex(int iEta, int E, int shape)
Stage2Layer2EGammaAlgorithmFirmwareImp1(CaloParamsHelper *params)
unsigned int idHOverELutIndex(int iEta, int E)
virtual ~Stage2Layer2EGammaAlgorithmFirmwareImp1()
int calibratedPt(const l1t::CaloCluster &clus, int hwPt)
void setClusterFlag(ClusterFlag flag, bool val=true)