ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1::gFEXJetAlgo Class Reference

#include <gFEXJetAlgo.h>

Inheritance diagram for LVL1::gFEXJetAlgo:
Collaboration diagram for LVL1::gFEXJetAlgo:

Public Member Functions

 gFEXJetAlgo (const std::string &type, const std::string &name, const IInterface *parent)
 Constructors.
virtual StatusCode initialize () override
 standard Athena-Algorithm method
virtual void pileUpCalculation (gTowersType &twrs, int rhoThreshold_Max, int inputScale, int &PUCp, int &PUC_JWJ) const override
virtual std::vector< std::unique_ptr< gFEXJetTOB > > largeRfinder (const gTowersType &Atwr, const gTowersType &Btwr, const gTowersType &CNtwr, const gTowersType &Asat, const gTowersType &Bsat, const gTowersType &CNsat, int pucA, int pucB, int pucC, int gLJ_seedThrA, int gLJ_seedThrB, int gLJ_seedThrC, int gJ_ptMinToTopoCounts1, int gJ_ptMinToTopoCounts2, int jetThreshold, int gLJ_ptMinToTopoCounts1, int gLJ_ptMinToTopoCounts2, std::array< uint32_t, 7 > &ATOB1_dat, std::array< uint32_t, 7 > &ATOB2_dat, std::array< uint32_t, 7 > &BTOB1_dat, std::array< uint32_t, 7 > &BTOB2_dat, std::array< uint32_t, 7 > &CTOB1_dat, std::array< uint32_t, 7 > &CTOB2_dat) const override
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

virtual void singleHalf (const gTowersType &twrs, gTowersType &FPGAsum) const
virtual void InternalPartialAB (const gTowersType &twrs, gTowersPartialSums &lps, gTowersPartialSums &rps) const
virtual void addInternalLin (gTowersType &jets, gTowersPartialSums &partial) const
virtual void addInternalRin (gTowersType &jets, gTowersPartialSums &partial) const
virtual void pileUpCorrectionAB (gTowersType &jets, int puc) const
virtual void ZeroNegative (gTowersType &jets) const
virtual void SaturateJets (gTowersType &jets, const gTowersType &sat, int fpga) const
virtual void SaturateBlocks (gTowersType &gBlkSum, const gTowersType &sat, int fpga) const
virtual void gBlockAB (const gTowersType &twrs, gTowersType &gBlkSum, gTowersType &hasSeed, int seedThreshold) const
virtual void blkOutAB (gTowersType &blocks, std::array< int, 32 > &jetOutL, std::array< int, 32 > &etaIndL, std::array< int, 32 > &jetOutR, std::array< int, 32 > &etaIndR) const
virtual void gBlockMax2 (const gTowersType &gBlkSum, int BjetColumn, int localColumn, std::array< int, 3 > &gBlockV, std::array< int, 3 > &gBlockEta, std::array< int, 3 > &gBlockPhi) const
virtual void gBlockMax192 (const gTowersJetEngine &gBlkSum, std::array< int, 3 > &gBlockVp, std::array< int, 3 > &gBlockEtap, std::array< int, 3 > &gBlockPhip, int index) const
virtual void gBlockVetoAB (gTowersType &jets, gTowersType &hasSeed) const
virtual void RemotePartialAB (const gTowersType &twrs, gTowersPartialSums &lps, gTowersPartialSums &rps) const
virtual void RemotePartialCN (const gTowersJetEngine &twrs, gTowersPartialSums &rps) const
virtual void RemotePartialCP (const gTowersJetEngine &twrs, gTowersPartialSums &lps) const
virtual void addRemoteRin (gTowersType &jets, const gTowersPartialSums &partial, int ps_upper, int ps_lower, int ps_shift) const
virtual void addRemoteLin (gTowersType &jets, const gTowersPartialSums &partial, int ps_upper, int ps_lower, int ps_shift) const
virtual void addRemoteCNin (gTowersType &jets, const gTowersPartialSums &partial, int ps_upper, int ps_lower, int ps_shift) const
virtual void addRemoteCPin (gTowersType &jets, const gTowersPartialSums &partial, int ps_upper, int ps_lower, int ps_shift) const
virtual void gJetVetoAB (gTowersType &twrs, int jet_threshold) const
virtual void jetOutAB (const gTowersType &jets, std::array< int, 32 > &jetOutL, std::array< int, 32 > &etaIndL, std::array< int, 32 > &jetOutR, std::array< int, 32 > &etaIndR) const
virtual void gJetTOBgen (const std::array< int, FEXAlgoSpaceDefs::ABCrows > &jetOut, const std::array< int, FEXAlgoSpaceDefs::ABCrows > &etaInd, int TOBnum, int jetThreshold, std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > &gJetTOBs, std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > &gJetTOBv, std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > &gJetTOBeta, std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > &gJetTOBphi) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< LVL1::gTowerContainerm_gFEXJetAlgo_gTowerContainerKey {this, "MyGTowers", "gTowerContainer", "Input container for gTowers"}
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 31 of file gFEXJetAlgo.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ gFEXJetAlgo()

LVL1::gFEXJetAlgo::gFEXJetAlgo ( const std::string & type,
const std::string & name,
const IInterface * parent )

Constructors.

Definition at line 21 of file gFEXJetAlgo.cxx.

21 :
22 AthAlgTool(type, name, parent)
23 {
24 declareInterface<IgFEXJetAlgo>(this);
25 }
AthAlgTool()
Default constructor:

Member Function Documentation

◆ addInternalLin()

void LVL1::gFEXJetAlgo::addInternalLin ( gTowersType & jets,
gTowersPartialSums & partial ) const
privatevirtual

Definition at line 913 of file gFEXJetAlgo.cxx.

913 {
914 // add parial sums for left side of FPGA
915 for(unsigned int irow=0;irow<FEXAlgoSpaceDefs::ABCrows;irow++){
916 for(unsigned int ipartial= 0; ipartial <FEXAlgoSpaceDefs::n_partial; ipartial++){
917 jets[irow][2+ipartial] = jets[irow][2+ipartial] + partial[irow][ipartial];
918 }
919 }
920}
static constexpr int ABCrows
static constexpr int n_partial

◆ addInternalRin()

void LVL1::gFEXJetAlgo::addInternalRin ( gTowersType & jets,
gTowersPartialSums & partial ) const
privatevirtual

Definition at line 923 of file gFEXJetAlgo.cxx.

923 {
924 // add parial sums for right side of FPGA
925 for(unsigned int irow=0;irow<FEXAlgoSpaceDefs::ABCrows;irow++){
926 for(unsigned int ipartial= 0; ipartial <FEXAlgoSpaceDefs::n_partial; ipartial++){
927 jets[irow][6+ipartial] = jets[irow][6+ipartial] + partial[irow][ipartial];
928 }
929 }
930}

◆ addRemoteCNin()

void LVL1::gFEXJetAlgo::addRemoteCNin ( gTowersType & jets,
const gTowersPartialSums & partial,
int ps_upper,
int ps_lower,
int ps_shift ) const
privatevirtual

Definition at line 1320 of file gFEXJetAlgo.cxx.

1321 {
1322
1323 int rows = partial.size();
1324 int cols = partial[0].size();
1325 // add partial sums
1326 for(int irow=0; irow < rows; irow++){
1327 for(int ipartial= 0; ipartial <cols; ipartial++){
1328 // current behavior
1329 int truncPart = -1;
1330 if( partial[irow][ipartial] > ps_upper ) {
1331 truncPart = ps_upper;
1332 } else if ( partial[irow][ipartial] < ps_lower ) {
1333 truncPart = ps_lower;
1334 } else {
1335 truncPart = partial[irow][ipartial];
1336 }
1337
1338 truncPart = (truncPart >> ps_shift );
1339 truncPart = (truncPart << ps_shift );
1340
1341 jets[irow][ipartial+2] = jets[irow][ipartial+2] + truncPart;
1342
1343 }
1344 }
1345}

◆ addRemoteCPin()

void LVL1::gFEXJetAlgo::addRemoteCPin ( gTowersType & jets,
const gTowersPartialSums & partial,
int ps_upper,
int ps_lower,
int ps_shift ) const
privatevirtual

Definition at line 1347 of file gFEXJetAlgo.cxx.

1348 {
1349
1350 int rows = partial.size();
1351 int cols = partial[0].size();
1352 // add partial sums
1353 for(int irow=0;irow<rows;irow++){
1354 for(int ipartial= 0; ipartial <cols; ipartial++){
1355 int truncPart = -1;
1356 if( partial[irow][ipartial] > ps_upper ) {
1357 truncPart = ps_upper;
1358 } else if ( partial[irow][ipartial] < ps_lower ) {
1359 truncPart = ps_lower;
1360 } else {
1361 truncPart = partial[irow][ipartial];
1362 }
1363
1364 truncPart = (truncPart >> ps_shift );
1365 truncPart = (truncPart << ps_shift );
1366
1367 jets[irow][ipartial+6] = jets[irow][ipartial+6] + truncPart;
1368
1369 }
1370 }
1371}

◆ addRemoteLin()

void LVL1::gFEXJetAlgo::addRemoteLin ( gTowersType & jets,
const gTowersPartialSums & partial,
int ps_upper,
int ps_lower,
int ps_shift ) const
privatevirtual

Definition at line 1293 of file gFEXJetAlgo.cxx.

1294 {
1295
1296 int rows = partial.size();
1297 int cols = partial[0].size();
1298 // add partial sums
1299 for(int irow=0;irow<rows;irow++){
1300 for(int ipartial= 0; ipartial <cols; ipartial++){
1301 // current behavior
1302 int truncPart = -1;
1303 if( partial[irow][ipartial] > ps_upper ) {
1304 truncPart = ps_upper;
1305 } else if ( partial[irow][ipartial] < ps_lower ) {
1306 truncPart = ps_lower;
1307 } else {
1308 truncPart = partial[irow][ipartial];
1309 }
1310 // change LSB from 200 MeV to 1600 MeV and then back to 200 MeV.
1311 truncPart = (truncPart >> ps_shift );
1312 truncPart = (truncPart << ps_shift );
1313
1314 jets[irow][ipartial] = jets[irow][ipartial] + truncPart;
1315 }
1316 }
1317}

◆ addRemoteRin()

void LVL1::gFEXJetAlgo::addRemoteRin ( gTowersType & jets,
const gTowersPartialSums & partial,
int ps_upper,
int ps_lower,
int ps_shift ) const
privatevirtual

Definition at line 1265 of file gFEXJetAlgo.cxx.

1266 {
1267
1268 // See https://gitlab.cern.ch/atlas-l1calo/gfex/firmware/-/blob/kw-dev/jwj_verif/common/jet_finder/HDL/ab_encode.vhd
1269
1270 int rows = partial.size();
1271 int cols = partial[0].size();
1272 // add partial sums
1273 for(int irow=0;irow<rows;irow++){
1274 for(int ipartial= 0; ipartial <cols; ipartial++){
1275 // current behavior
1276 int truncPart = -1;
1277 if( partial[irow][ipartial] > ps_upper ) {
1278 truncPart = ps_upper;
1279 } else if ( partial[irow][ipartial] < ps_lower ) {
1280 truncPart = ps_lower;
1281 } else {
1282 truncPart = partial[irow][ipartial];
1283 }
1284 // change LSB from 200 MeV to 1600 MeV and then back to 200 MeV.
1285 truncPart = (truncPart >> ps_shift );
1286 truncPart = (truncPart << ps_shift );
1287
1288 jets[irow][8+ipartial] = jets[irow][8+ipartial] + truncPart;
1289 }
1290 }
1291}

◆ blkOutAB()

void LVL1::gFEXJetAlgo::blkOutAB ( gTowersType & blocks,
std::array< int, 32 > & jetOutL,
std::array< int, 32 > & etaIndL,
std::array< int, 32 > & jetOutR,
std::array< int, 32 > & etaIndR ) const
privatevirtual

Definition at line 1061 of file gFEXJetAlgo.cxx.

1061 {
1062
1063 // find maximum in each jet engine for gBlocks (not done in hardware)
1064
1065 //loop over left engines
1066 for(unsigned int ieng=0; ieng<FEXAlgoSpaceDefs::ABCrows; ieng++){
1067 for(unsigned int localEta = 0; localEta<6; localEta++){
1068 if( blocks[ieng][localEta] > jetOutL[ieng] ){
1069 jetOutL[ieng] = blocks[ieng][localEta];
1070 etaIndL[ieng] = localEta;
1071 }
1072 }
1073 }
1074 // loop over right engines
1075 for(unsigned int ieng=0; ieng<FEXAlgoSpaceDefs::ABCrows; ieng++){
1076 for(unsigned int localEta = 0; localEta<6; localEta++){
1077 if( blocks[ieng][localEta+6] > jetOutR[ieng] ) {
1078 jetOutR[ieng] = blocks[ieng][localEta+6];
1079 etaIndR[ieng] = localEta;
1080 }
1081 }
1082 }
1083}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ gBlockAB()

void LVL1::gFEXJetAlgo::gBlockAB ( const gTowersType & twrs,
gTowersType & gBlkSum,
gTowersType & hasSeed,
int seedThreshold ) const
privatevirtual

Definition at line 1014 of file gFEXJetAlgo.cxx.

1014 {
1015
1016 int rows = twrs.size();
1017 int cols = twrs[0].size();
1018 for( int irow = 0; irow < rows; irow++ ){
1019 for(int jcolumn = 0; jcolumn<cols; jcolumn++){
1020 // zero jet sum here
1021 gBlkSum[irow][jcolumn] = 0;
1022 int krowUp = (irow + 1)%32;
1023 int krowDn = (irow - 1 +32)%32;
1024 if( (jcolumn == 0) || (jcolumn == 6) ) {
1025 //left edge case
1026 gBlkSum[irow][jcolumn] =
1027 twrs[irow][jcolumn] + twrs[krowUp][jcolumn] + twrs[krowDn][jcolumn] +
1028 twrs[irow][jcolumn+1] + twrs[krowUp][jcolumn+1] + twrs[krowDn][jcolumn+1];
1029 } else if( (jcolumn == 5) || (jcolumn == 11)) {
1030 // right edge case
1031 gBlkSum[irow][jcolumn] =
1032 twrs[irow][jcolumn] + twrs[krowUp][jcolumn] + twrs[krowDn][jcolumn] +
1033 twrs[irow][jcolumn-1] + twrs[krowUp][jcolumn-1] + twrs[krowDn][jcolumn-1];
1034 } else{
1035 // normal case
1036 gBlkSum[irow][jcolumn] =
1037 twrs[irow][jcolumn] + twrs[krowUp][jcolumn] + twrs[krowDn][jcolumn] +
1038 twrs[irow][jcolumn-1] + twrs[krowUp][jcolumn-1] + twrs[krowDn][jcolumn-1] +
1039 twrs[irow][jcolumn+1] + twrs[krowUp][jcolumn+1] + twrs[krowDn][jcolumn+1];
1040 }
1041
1042 if( gBlkSum[irow][jcolumn] > seedThreshold) {
1043 hasSeed[irow][jcolumn] = 1;
1044 } else {
1045 hasSeed[irow][jcolumn] = 0;
1046 }
1047
1048 if ( gBlkSum[irow][jcolumn] < 0 )
1049 gBlkSum[irow][jcolumn] = 0;
1050
1051 // was bits 11+3 downto 3, now is 11 downto 0
1052 if ( gBlkSum[irow][jcolumn] > FEXAlgoSpaceDefs::gBlockMax ) {
1053 gBlkSum[irow][jcolumn] = FEXAlgoSpaceDefs::gBlockMax;
1054 }
1055 }
1056 }
1057}
static constexpr int gBlockMax

◆ gBlockMax192()

void LVL1::gFEXJetAlgo::gBlockMax192 ( const gTowersJetEngine & gBlkSum,
std::array< int, 3 > & gBlockVp,
std::array< int, 3 > & gBlockEtap,
std::array< int, 3 > & gBlockPhip,
int index ) const
privatevirtual

Definition at line 1125 of file gFEXJetAlgo.cxx.

1129 {
1130 // gBLKSum are the sums
1131 // gBlockVp is the returned value for the max block
1132 // gBlockEtap is the eta in the local corrdinate system
1133 // gBlockPhip is the phi (global and local are the same)
1134
1135 int inpv[192]{};
1136 int maxv1[96]{};
1137 int maxv2[48]{};
1138 int maxv3[24]{};
1139 int maxv4[12]{};
1140 int maxv5[6]{};
1141 int maxv6[3]{};
1142
1143 int inpi[192]{};
1144 int maxi1[96]{};
1145 int maxi2[48]{};
1146 int maxi3[24]{};
1147 int maxi4[12]{};
1148 int maxi5[6]{};
1149 int maxi6[3]{};
1150
1151 int maxvall;
1152 int maxiall;
1153
1154
1155 // ABCcolumnsEng is 6 in hardware
1156 int maxv = 0;
1157
1158 for(unsigned int icolumn = 0; icolumn<FEXAlgoSpaceDefs::ABCcolumnsEng; icolumn++){
1159 for(unsigned int irow = 0; irow<FEXAlgoSpaceDefs::ABCrows; irow++){
1160 inpv[irow + icolumn*FEXAlgoSpaceDefs::ABCrows] = gBlkSum[irow][icolumn];
1161 inpi[irow + icolumn*FEXAlgoSpaceDefs::ABCrows] = irow + icolumn*FEXAlgoSpaceDefs::ABCrows;
1162
1163 if( gBlkSum[irow][icolumn] > maxv){
1164 maxv = gBlkSum[irow][icolumn];
1165 }
1166 }
1167 }
1168
1169 for(int i = 0; i<96; i++){
1170 if( inpv[2*i+1] > inpv[2*i] ) {
1171 maxv1[i] = inpv[2*i+1];
1172 maxi1[i] = inpi[2*i+1];
1173 } else {
1174 maxv1[i] = inpv[2*i];
1175 maxi1[i] = inpi[2*i];
1176 }
1177 }
1178
1179 for(int i = 0; i<48; i++){
1180 if( maxv1[2*i+1] > maxv1[2*i] ) {
1181 maxv2[i] = maxv1[2*i+1];
1182 maxi2[i] = maxi1[2*i+1];
1183 } else {
1184 maxv2[i] = maxv1[2*i];
1185 maxi2[i] = maxi1[2*i];
1186 }
1187 }
1188
1189 for(int i = 0; i<24; i++){
1190 if( maxv2[2*i+1] > maxv2[2*i] ) {
1191 maxv3[i] = maxv2[2*i+1];
1192 maxi3[i] = maxi2[2*i+1];
1193 } else {
1194 maxv3[i] = maxv2[2*i];
1195 maxi3[i] = maxi2[2*i];
1196 }
1197 }
1198
1199 for(int i = 0; i<12; i++){
1200 if( maxv3[2*i+1] > maxv3[2*i] ) {
1201 maxv4[i] = maxv3[2*i+1];
1202 maxi4[i] = maxi3[2*i+1];
1203 } else {
1204 maxv4[i] = maxv3[2*i];
1205 maxi4[i] = maxi3[2*i];
1206 }
1207 }
1208
1209 for(int i = 0; i<6; i++){
1210 if( maxv4[2*i+1] > maxv4[2*i] ) {
1211 maxv5[i] = maxv4[2*i+1];
1212 maxi5[i] = maxi4[2*i+1];
1213 } else {
1214 maxv5[i] = maxv4[2*i];
1215 maxi5[i] = maxi4[2*i];
1216 }
1217 }
1218
1219 for(int i = 0; i<3; i++){
1220 if( maxv5[2*i+1] > maxv5[2*i] ) {
1221 maxv6[i] = maxv5[2*i+1];
1222 maxi6[i] = maxi5[2*i+1];
1223 } else {
1224 maxv6[i] = maxv5[2*i];
1225 maxi6[i] = maxi5[2*i];
1226 }
1227 }
1228
1229 if( ( maxv6[1] > maxv6[0] ) && ( maxv6[1] > maxv6[2] ) ) {
1230 maxvall = maxv6[1];
1231 maxiall = maxi6[1];
1232 } else {
1233 if( maxv6[0] > maxv6[2] ){
1234 maxvall = maxv6[0];
1235 maxiall = maxi6[0];
1236 } else {
1237 maxvall = maxv6[2];
1238 maxiall = maxi6[2];
1239 }
1240 }
1241
1242
1243 gBlockVp[index] = maxvall ;
1244 gBlockEtap[index] = maxiall/32;
1245 gBlockPhip[index] = maxiall%32;
1246
1247}
static constexpr int ABCcolumnsEng
str index
Definition DeMoScan.py:362

◆ gBlockMax2()

void LVL1::gFEXJetAlgo::gBlockMax2 ( const gTowersType & gBlkSum,
int BjetColumn,
int localColumn,
std::array< int, 3 > & gBlockV,
std::array< int, 3 > & gBlockEta,
std::array< int, 3 > & gBlockPhi ) const
privatevirtual

Definition at line 1086 of file gFEXJetAlgo.cxx.

1086 {
1087 // gBlkSum are the 9 or 6 gTower sums
1088 // BjetColumn is the Block Column -- 0 for CN, 1, 2 for A 3, 4 for B and 5 for CP
1089 // gBlockV is the array of values currently 2
1090 // gBlockEta is the eta in global
1091
1092 gTowersJetEngine gBlkSumC;
1093
1094 // copy the correct column
1095 for( int irow = 0; irow<FEXAlgoSpaceDefs::ABCrows; irow++){
1096 for( int icolumn =0; icolumn<FEXAlgoSpaceDefs::ABCcolumnsEng; icolumn++){
1097 gBlkSumC[irow][icolumn] = gBlkSum[irow][icolumn + localColumn*FEXAlgoSpaceDefs::ABCcolumnsEng];
1098 }
1099 }
1100
1101 gBlockMax192(gBlkSumC, gBlockV, gBlockEta, gBlockPhi, 0);
1102
1103 for(int i = -1; i<2; i++){
1104 int iGlobal = i + gBlockPhi[0];
1105 // map row number in to 0-31
1106 if ( iGlobal < 0 ) iGlobal = iGlobal + 32;
1107 if ( iGlobal > 31 ) iGlobal = iGlobal - 32;
1108 // don't do anything outside of the six columsn
1109 for( int j = -1; j<2; j++){
1110 int jGlobal = j + gBlockEta[0];
1111 if( (jGlobal > -1) && (jGlobal < 6) ) {
1112 gBlkSumC[iGlobal][jGlobal] = 0;
1113 }
1114 }
1115 }
1116
1117 gBlockMax192(gBlkSumC, gBlockV, gBlockEta, gBlockPhi, 1);
1118
1119 // need to wait until the end for this!
1120 gBlockEta[0] = gBlockEta[0] + 2 + 6*BjetColumn;
1121 gBlockEta[1] = gBlockEta[1] + 2 + 6*BjetColumn;
1122}
virtual void gBlockMax192(const gTowersJetEngine &gBlkSum, std::array< int, 3 > &gBlockVp, std::array< int, 3 > &gBlockEtap, std::array< int, 3 > &gBlockPhip, int index) const
std::array< std::array< int, 6 >, 32 > gTowersJetEngine
Definition gFEXJetAlgo.h:28
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ gBlockVetoAB()

void LVL1::gFEXJetAlgo::gBlockVetoAB ( gTowersType & jets,
gTowersType & hasSeed ) const
privatevirtual

Definition at line 1250 of file gFEXJetAlgo.cxx.

1250 {
1251 int rows = jets.size();
1252 int cols = jets[0].size();
1253 for( int irow = 0; irow < rows; irow++ ){
1254 for(int jcolumn = 0; jcolumn < cols; jcolumn++){
1255 if( hasSeed[irow][jcolumn] == 0 ) {
1256 // set to negative value as in hardware
1257 // https://gitlab.cern.ch/atlas-l1calo/gfex/firmware/-/blob/devel/common/jet_finder/HDL/jet_eng.vhd#L561
1258 jets[irow][jcolumn] = 0XFFFFF000;
1259 }
1260 }
1261 }
1262}

◆ gJetTOBgen()

void LVL1::gFEXJetAlgo::gJetTOBgen ( const std::array< int, FEXAlgoSpaceDefs::ABCrows > & jetOut,
const std::array< int, FEXAlgoSpaceDefs::ABCrows > & etaInd,
int TOBnum,
int jetThreshold,
std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > & gJetTOBs,
std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > & gJetTOBv,
std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > & gJetTOBeta,
std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > & gJetTOBphi ) const
privatevirtual

Definition at line 1484 of file gFEXJetAlgo.cxx.

1489 {
1490
1491 int jetOutZS[FEXAlgoSpaceDefs::ABCrows]{};
1492 // apply the tobthreshold to the values
1493 //note that jetThreshold is not a configurable parameter in firmware, it is used to check that jet values are positive
1494 for( int irow =0; irow<FEXAlgoSpaceDefs::ABCrows; irow++){
1495 if( jetOut[irow] > jetThreshold ) {
1496 jetOutZS[irow] = jetOut[irow];
1497 } else {
1498 jetOutZS[irow] = 0 ;
1499 }
1500 }
1501
1502
1503 // offset of TOBs according to official format
1504 int etaOff[FEXAlgoSpaceDefs::gJetTOBfib] = {8,14,20,26,2,32};
1505
1506 // see tob_gen.vhd
1507 int l1mv[16]{};
1508 int l1met[16]{};
1509 int l1mphi[16]{};
1510
1511 int l2mv[8]{};
1512 int l2met[8]{};
1513 int l2mphi[8]{};
1514
1515 int l3mv[4]{};
1516 int l3met[4]{};
1517 int l3mphi[4]{};
1518
1519 int l4mv[2]{};
1520 int l4met[2]{};
1521 int l4mphi[2]{};
1522
1523 for(int i=0; i<16; i++){
1524 if( jetOut[2*i + 1] > jetOutZS[2*i] ){
1525 l1mv[i] = jetOutZS[2*i + 1];
1526 l1met[i] = etaInd[2*i + 1];
1527 l1mphi[i] = 2*i + 1;
1528 } else {
1529 l1mv[i] = jetOutZS[2*i ];
1530 l1met[i] = etaInd[2*i ];
1531 l1mphi[i] = 2*i ;
1532 }
1533 }
1534
1535 for(int i=0; i<8; i++){
1536 if( l1mv[2*i + 1] > l1mv[2*i] ){
1537 l2mv[i] = l1mv[ 2*i + 1 ];
1538 l2met[i] = l1met[ 2*i + 1];
1539 l2mphi[i] = l1mphi[2*i + 1];
1540 } else {
1541 l2mv[i] = l1mv[ 2*i ];
1542 l2met[i] = l1met[ 2*i ];
1543 l2mphi[i] = l1mphi[2*i ];
1544 }
1545 }
1546
1547 for(int i=0; i<4; i++){
1548 if( l2mv[2*i + 1] > l2mv[2*i] ){
1549 l3mv[i] = l2mv[ 2*i + 1];
1550 l3met[i] = l2met[ 2*i + 1];
1551 l3mphi[i] = l2mphi[2*i + 1];
1552 } else {
1553 l3mv[i] = l2mv[2*i ];
1554 l3met[i] = l2met[2*i ];
1555 l3mphi[i] = l2mphi[2*i ];
1556 }
1557 }
1558
1559 for(int i=0; i<2; i++){
1560 if( l3mv[2*i + 1] > l3mv[2*i] ){
1561 l4mv[i] = l3mv[ 2*i + 1];
1562 l4met[i] = l3met[ 2*i + 1];
1563 l4mphi[i] = l3mphi[2*i + 1];
1564 } else {
1565 l4mv[i] = l3mv[2*i ];
1566 l4met[i] = l3met[2*i ];
1567 l4mphi[i] = l3mphi[2*i ];
1568 }
1569 }
1570
1571 if( l4mv[1] > l4mv[0] ){
1572 if(l4mv[1] > jetThreshold){
1573 gJetTOBv[TOBnum] = l4mv[1];
1574 gJetTOBeta[TOBnum] = l4met[1] + etaOff[TOBnum];
1575 gJetTOBphi[TOBnum] = l4mphi[1];
1576 gJetTOBs[TOBnum] = 1;
1577 } else {
1578 gJetTOBv[TOBnum] = l4mv[1];
1579 gJetTOBeta[TOBnum] = l4met[1] + etaOff[TOBnum];
1580 gJetTOBphi[TOBnum] = l4mphi[1];
1581 gJetTOBs[TOBnum] = 0;
1582 }
1583 } else {
1584 if(l4mv[0] > jetThreshold){
1585 gJetTOBv[TOBnum] = l4mv[0];
1586 gJetTOBeta[TOBnum] = l4met[0] + etaOff[TOBnum];
1587 gJetTOBphi[TOBnum] = l4mphi[0];
1588 gJetTOBs[TOBnum] = 1;
1589 } else {
1590 gJetTOBv[TOBnum] = l4mv[0];
1591 gJetTOBeta[TOBnum] = l4met[0] + etaOff[TOBnum];
1592 gJetTOBphi[TOBnum] = l4mphi[0];
1593 gJetTOBs[TOBnum] = 0;
1594 }
1595 }
1596
1597}
static constexpr int gJetTOBfib

◆ gJetVetoAB()

void LVL1::gFEXJetAlgo::gJetVetoAB ( gTowersType & twrs,
int jet_threshold ) const
privatevirtual

Definition at line 1374 of file gFEXJetAlgo.cxx.

1374 {
1375 int rows = twrs.size();
1376 int cols = twrs[0].size();
1377 for( int irow = 0; irow < rows; irow++ ){
1378 for(int jcolumn = 0; jcolumn<cols; jcolumn++){
1379 if( twrs[irow][jcolumn] < jet_threshold+1 ) {
1380 twrs[irow][jcolumn] = 0;
1381 }
1382 }
1383 }
1384}

◆ initialize()

StatusCode LVL1::gFEXJetAlgo::initialize ( )
overridevirtual

standard Athena-Algorithm method

Definition at line 28 of file gFEXJetAlgo.cxx.

28 {
29
31
32 return StatusCode::SUCCESS;
33
34}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadHandleKey< LVL1::gTowerContainer > m_gFEXJetAlgo_gTowerContainerKey

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & LVL1::IgFEXJetAlgo::interfaceID ( )
inlinestaticinherited

Definition at line 45 of file IgFEXJetAlgo.h.

46 {
47 return IID_IgFEXJetAlgo;
48 }
static const InterfaceID IID_IgFEXJetAlgo("LVL1::IgFEXJetAlgo", 1, 0)

◆ InternalPartialAB()

void LVL1::gFEXJetAlgo::InternalPartialAB ( const gTowersType & twrs,
gTowersPartialSums & lps,
gTowersPartialSums & rps ) const
privatevirtual

Definition at line 846 of file gFEXJetAlgo.cxx.

846 {
847
848 // Computes partial sums for FPGA A or B
849 // twrs are the 32 x 12 = 284 gTowers in FPGA A or B
850 //
851 // lps: partial sum for left hand side of FPGA
852 // rps: partial sum for right half of the FPGA
853
854 // NOTE rps is available first
855
856 // number of rows above/below for right partial sum
857 // when sending to the right send values for largest partial sum first, i.e. for column 6
858 unsigned int NUpDwnR[4][4] = { {2,3,4,4}, {0,2,3,4}, {0,0,2,3}, {0,0,0,2} };
859
860 // number of rows above or below for left partial sum
861 // when sending to the left send values for smallest partial sumn first (i.e. for column 2 )
862 unsigned int NUpDwnL[4][4] = { {2,0,0,0}, {3,2,0,0}, {4,3,2,0}, {4,4,3,2} };
863
864
865 // Do partial sum for output to right side FPGA first
866 // for the right partial sum this starts from the right-most value first
867 for(unsigned int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
868 for(unsigned int rcolumn = 0; rcolumn<FEXAlgoSpaceDefs::n_partial; rcolumn++){
869 // start calculating right partial sums for remote column rcolumn
870 rps[irow][rcolumn] = 0;
871 for(unsigned int lcolumn = 0; lcolumn<FEXAlgoSpaceDefs::n_partial; lcolumn++){
872 // add in any energy from towers in this row
873 // no need of modular arithmetic
874 if ( NUpDwnR[rcolumn][lcolumn] > 0 ) {
875 // this is partial sum for the right half of the FPGA -- columns 2,3,4,5
876 rps[irow][rcolumn] = rps[irow][rcolumn] + twrs[irow][lcolumn+2];
877 }
878 // now add rup1, rup2, rup3, rup4, ldn1, ldn2, ln3, ln4 -- use a loop instead of enumeratin in firmware
879 for(unsigned int rowOff = 1 ; rowOff < NUpDwnR[rcolumn][lcolumn]+1; rowOff++){
880 int rowModUp = (irow + rowOff)%32;
881 int rowModDn = (irow - rowOff + 32 )%32;
882 // this is partial sum for the right half of the FPGA -- columns 2,3,4,5
883 rps[irow][rcolumn] = rps[irow][rcolumn] + twrs[rowModUp][lcolumn+2] + twrs[rowModDn][lcolumn+2];
884 }
885 }
886 }
887 }
888 // do partial sum for output to left half of the FPGA second
889 // for the left partial sum this starts also with the right most column -- which is the smallest sum
890 for(unsigned int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
891 for(unsigned int rcolumn = 0; rcolumn<FEXAlgoSpaceDefs::n_partial; rcolumn++){
892 // start calculating right partial sums for remote column rcolumn
893 lps[irow][rcolumn] = 0;
894 for(unsigned int lcolumn = 0; lcolumn<FEXAlgoSpaceDefs::n_partial; lcolumn++){
895 // add in any energy from towers in this row
896 // no need of modular arithmetic
897 if ( NUpDwnL[rcolumn][lcolumn] > 0 ) {
898 lps[irow][rcolumn] = lps[irow][rcolumn] + twrs[irow][lcolumn+6];
899 }
900 // now add rup1, rup2, rup3, rup4, ldn1, ldn2, ln3, ln4 -- use a loop instead of enumeratin in firmware
901 for(unsigned int rowOff = 1 ; rowOff < NUpDwnL[rcolumn][lcolumn]+1; rowOff++){
902 int rowModUp = (irow + rowOff)%32;
903 int rowModDn = (irow - rowOff + 32 )%32;
904 // this is partial sum for the left half of the FPGA -- columns 6,7,8,9
905 lps[irow][rcolumn] = lps[irow][rcolumn] + twrs[rowModUp][lcolumn+6] + twrs[rowModDn][lcolumn+6];
906 }
907 }
908 }
909 }
910}

◆ jetOutAB()

void LVL1::gFEXJetAlgo::jetOutAB ( const gTowersType & jets,
std::array< int, 32 > & jetOutL,
std::array< int, 32 > & etaIndL,
std::array< int, 32 > & jetOutR,
std::array< int, 32 > & etaIndR ) const
privatevirtual

Definition at line 1387 of file gFEXJetAlgo.cxx.

1389 {
1390 // find maximum in each jet engine or either gJets and requires corresponding gBlock be above threhsold
1391 //loop over left engines
1392 for(int ieng=0; ieng<FEXAlgoSpaceDefs::ABCrows; ieng++){
1393 jetOutL[ieng] = 0;
1394 etaIndL[ieng] = 0;
1395 for(int localEta = 0; localEta<6; localEta++){
1396 if( jets[ieng][localEta] > jetOutL[ieng] ){
1397 jetOutL[ieng] = jets[ieng][localEta];
1398 etaIndL[ieng] = localEta;
1399 }
1400 }
1401 // truncation and mapping from 12 to 15 bits
1402 // https://gitlab.cern.ch/atlas-l1calo/gfex/firmware/-/blob/kw-dev/jet_finder_abc/common/jet_finder/HDL/jet_eng.vhd#L561
1403 // https://gitlab.cern.ch/atlas-l1calo/gfex/firmware/-/blob/kw-dev/jet_finder_abc/common/jet_finder/HDL/jet_eng.vhd#L561
1404 // Turncate to 15 bits as in VHDL (Corresponds to 13 TeV)
1405
1406 if( jetOutL[ieng] > FEXAlgoSpaceDefs::gJetMax ) jetOutL[ieng] = FEXAlgoSpaceDefs::gJetMax;
1407 if( jetOutL[ieng] < 0 ) jetOutL[ieng] = 0;
1408 }
1409 // loop over right engines
1410 for(int ieng=0; ieng<FEXAlgoSpaceDefs::ABCrows; ieng++){
1411 jetOutR[ieng] = 0;
1412 etaIndR[ieng] = 0;
1413 for(int localEta = 0; localEta < 6; localEta++){
1414 if( jets[ieng][localEta+6] > jetOutR[ieng] ){
1415 jetOutR[ieng] = jets[ieng][localEta+6];
1416 etaIndR[ieng] = localEta;
1417 }
1418 }
1419 // Turncate to 15 bits as in VHDL (orresponds to 13 TeV)
1420 if( jetOutR[ieng] > FEXAlgoSpaceDefs::gJetMax ) jetOutR[ieng] = FEXAlgoSpaceDefs::gJetMax;
1421 if( jetOutR[ieng] < 0 ) jetOutR[ieng] = 0;
1422 // https://gitlab.cern.ch/atlas-l1calo/gfex/firmware/-/blob/kw-dev/jet_finder_abc/common/jet_finder/HDL/jet_finder_abc.vhd#L1103
1423 // https://gitlab.cern.ch/atlas-l1calo/gfex/firmware/-/blob/kw-dev/jet_finder_abc/common/jet_finder/HDL/jet_finder_abc.vhd#L1119
1424
1425 }
1426
1427}
static constexpr int gJetMax

◆ largeRfinder()

std::vector< std::unique_ptr< gFEXJetTOB > > LVL1::gFEXJetAlgo::largeRfinder ( const gTowersType & Atwr,
const gTowersType & Btwr,
const gTowersType & CNtwr,
const gTowersType & Asat,
const gTowersType & Bsat,
const gTowersType & CNsat,
int pucA,
int pucB,
int pucC,
int gLJ_seedThrA,
int gLJ_seedThrB,
int gLJ_seedThrC,
int gJ_ptMinToTopoCounts1,
int gJ_ptMinToTopoCounts2,
int jetThreshold,
int gLJ_ptMinToTopoCounts1,
int gLJ_ptMinToTopoCounts2,
std::array< uint32_t, 7 > & ATOB1_dat,
std::array< uint32_t, 7 > & ATOB2_dat,
std::array< uint32_t, 7 > & BTOB1_dat,
std::array< uint32_t, 7 > & BTOB2_dat,
std::array< uint32_t, 7 > & CTOB1_dat,
std::array< uint32_t, 7 > & CTOB2_dat ) const
overridevirtual

Define a vector to be filled with all the TOBs of one event

Implements LVL1::IgFEXJetAlgo.

Definition at line 38 of file gFEXJetAlgo.cxx.

50 {
51
52 // Arrays for gJets
53 // s = status (1 if above threshold)
54 // v = value 200 MeV LSB
55 // eta and phi are bin numbers
56 std::array<int, FEXAlgoSpaceDefs::gJetTOBfib> gTOBsat = {{0,0,0,0,0,0}};
57 std::array<int, FEXAlgoSpaceDefs::gJetTOBfib> gJetTOBs = {{0,0,0,0,0,0}};
58 std::array<int, FEXAlgoSpaceDefs::gJetTOBfib> gJetTOBv = {{0,0,0,0,0,0}};
59 std::array<int, FEXAlgoSpaceDefs::gJetTOBfib> gJetTOBeta = {{0,0,0,0,0,0}};
60 std::array<int, FEXAlgoSpaceDefs::gJetTOBfib> gJetTOBphi = {{0,0,0,0,0,0}};
61
62 // Arrays for gBlocks (so far only 2 gBlocks per fiber)
63 // first index is for the fiber number (A 0 and 1, B 0 and 1, C P and C N )
64 // second index is for leading, sub-leading, and sub-sub-leading (not used)
65 std::array<std::array<int, 3>, FEXAlgoSpaceDefs::BTOBFIB> gBlockTOBv = {{ {{0,0,0}}, {{0,0,0}}, {{0,0,0}}, {{0,0,0}}, {{0,0,0}}, {{0,0,0}} }};
66 std::array<std::array<int, 3>, FEXAlgoSpaceDefs::BTOBFIB> gBlockTOBeta = {{ {{0,0,0}}, {{0,0,0}}, {{0,0,0}}, {{0,0,0}}, {{0,0,0}}, {{0,0,0}} }};
67 std::array<std::array<int, 3>, FEXAlgoSpaceDefs::BTOBFIB> gBlockTOBphi = {{ {{0,0,0}}, {{0,0,0}}, {{0,0,0}}, {{0,0,0}}, {{0,0,0}}, {{0,0,0}} }};
68
69
70 //Alternate format for FPGC C (split in two)
71
72 gTowersJetEngine CNtwr;
73 gTowersJetEngine CPtwr;
74
75 for(int irow=0; irow<FEXAlgoSpaceDefs::ABCrows; irow++){
76 for(int jcolumn=0;jcolumn<FEXAlgoSpaceDefs::ABCcolumnsEng;jcolumn++){
77 CNtwr[irow][jcolumn] = Ctwr[irow][jcolumn] ;
78 CPtwr[irow][jcolumn] = Ctwr[irow][jcolumn+FEXAlgoSpaceDefs::ABCcolumnsEng] ;
79 }
80
81 for(unsigned int jcolumn=0;jcolumn<FEXAlgoSpaceDefs::ABcolumns;jcolumn++){
82
83 if( jcolumn < 6 ) {
84 // TOB1
85 if( Asat[irow][jcolumn] == 1 ) gTOBsat[0] = 1;
86 if( Bsat[irow][jcolumn] == 1 ) gTOBsat[2] = 1;
87 if( Csat[irow][jcolumn] == 1 ) gTOBsat[4] = 1;
88 } else {
89 //TOB2
90 if( Asat[irow][jcolumn] == 1 ) gTOBsat[1] = 1;
91 if( Bsat[irow][jcolumn] == 1 ) gTOBsat[3] = 1;
92 if( Csat[irow][jcolumn] == 1 ) gTOBsat[5] = 1;
93 }
94 }
95 }
96
97
98
99 gTowersType AjetsAlt;
100 singleHalf(Atwr,AjetsAlt);
101
102 gTowersPartialSums AlpsAltOut;
103 gTowersPartialSums ArpsAltOut;
104
105 InternalPartialAB(Atwr, AlpsAltOut, ArpsAltOut);
106
107 gTowersType BjetsAlt;
108 singleHalf(Btwr,BjetsAlt);
109
110 gTowersPartialSums BlpsAltOut;
111 gTowersPartialSums BrpsAltOut;
112
113 InternalPartialAB(Btwr, BlpsAltOut, BrpsAltOut);
114
115 gTowersType CjetsAlt;
116 singleHalf(Ctwr,CjetsAlt);
117
118 // Add the left local partial sum (zero if right column)
119 addInternalLin(AjetsAlt, AlpsAltOut);
120 addInternalLin(BjetsAlt, BlpsAltOut);
121
122 pileUpCorrectionAB(AjetsAlt,pucA);
123 pileUpCorrectionAB(BjetsAlt,pucB);
124 pileUpCorrectionAB(CjetsAlt,pucC);
125
126 // If the local sum is less than zero set it to zero
127 ZeroNegative(AjetsAlt);
128 ZeroNegative(BjetsAlt);
129 ZeroNegative(CjetsAlt);
130
131 // Add the right local partial sum (zero if right column)
132 addInternalRin(AjetsAlt, ArpsAltOut);
133 addInternalRin(BjetsAlt, BrpsAltOut);
134
135 for(unsigned int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
136 for(unsigned int icolumn =0; icolumn<FEXAlgoSpaceDefs::ABcolumns; icolumn++){
137 // set 18 bits on
138 if (Asat[irow][icolumn] != 0){
139 }
140 }
141 }
142
143 SaturateJets( AjetsAlt, Asat, 0 );
144 SaturateJets( BjetsAlt, Bsat, 1 );
145 SaturateJets( CjetsAlt, Csat, 2 );
146
147 gTowersType AjetsRestricted;
148 gTowersType BjetsRestricted;
149 gTowersType CjetsRestricted;
150
151
152 for(int irow=0; irow<FEXAlgoSpaceDefs::ABCrows; irow++){
153 for(int icolumn=0; icolumn<FEXAlgoSpaceDefs::ABcolumns; icolumn++){
154 AjetsRestricted[irow][icolumn] = AjetsAlt[irow][icolumn];
155 BjetsRestricted[irow][icolumn] = BjetsAlt[irow][icolumn];
156 CjetsRestricted[irow][icolumn] = CjetsAlt[irow][icolumn];
157 }
158 }
159
160 // find gBlocks
161 gTowersType gBLKA;
162 gTowersType hasSeedA;
163 gBlockAB(Atwr, gBLKA, hasSeedA, gLJ_seedThrA);
164
165 SaturateBlocks(gBLKA, Asat, 0);
166
167 // TODO: Temporary fix to match FW saturation eta-alignment bug.
168 // In firmware, seed_ovf forces et9 to max positive → have_seed=1 unconditionally.
169 // The same −1 eta shift applies: overflow at col K forces have_seed at col K-1.
170 // @see jet_eng.vhd lines 849-870: seed_ovf → et9=max → have_seed=1
171 // Revert this block when the FW saturation alignment is fixed.
172 for(unsigned int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++){
173 for(unsigned int icol = 0; icol < FEXAlgoSpaceDefs::ABcolumns; icol++){
174 if(Asat[irow][icol] && (icol % 6 != 0)) hasSeedA[irow][icol - 1] = 1;
175 }
176 }
177
178 gTowersType gBLKB;
179 gTowersType hasSeedB;
180 gBlockAB(Btwr, gBLKB, hasSeedB, gLJ_seedThrB);
181 SaturateBlocks(gBLKB, Bsat, 1);
182
183 // TODO: Temporary fix to match FW saturation eta-alignment bug.
184 // Revert this block when the FW saturation alignment is fixed.
185 for(unsigned int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++){
186 for(unsigned int icol = 0; icol < FEXAlgoSpaceDefs::ABcolumns; icol++){
187 if(Bsat[irow][icol] && (icol % 6 != 0) && icol != 11) hasSeedB[irow][icol - 1] = 1;
188 }
189 }
190
191 gTowersType gBLKC;
192 gTowersType hasSeedC;
193 gBlockAB(Ctwr, gBLKC, hasSeedC, gLJ_seedThrC);
194 SaturateBlocks(gBLKC, Csat, 2);
195
196 // TODO: Temporary fix to match FW saturation eta-alignment bug.
197 // Revert this block when the FW saturation alignment is fixed.
198 for(unsigned int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++){
199 for(unsigned int icol = 0; icol < FEXAlgoSpaceDefs::ABcolumns; icol++){
200 if(Csat[irow][icol] && (icol % 6 != 0) && (icol % 6 != 5)) hasSeedC[irow][icol - 1] = 1;
201 }
202 }
203
204 // sorting by jet engine -- not done in FPGA
205 std::array<int, 32> AgBlockOutL{};
206 std::array<int, 32> AgBlockEtaIndL{};
207 std::array<int, 32> AgBlockOutR{};
208 std::array<int, 32> AgBlockEtaIndR{};
209 blkOutAB(gBLKA, AgBlockOutL, AgBlockEtaIndL, AgBlockOutR, AgBlockEtaIndR);
210
211 std::array<int, 32> BgBlockOutL{};
212 std::array<int, 32> BgBlockEtaIndL{};
213 std::array<int, 32> BgBlockOutR{};
214 std::array<int, 32> BgBlockEtaIndR{};
215 blkOutAB(gBLKB, BgBlockOutL, BgBlockEtaIndL, BgBlockOutR, BgBlockEtaIndR);
216
217 std::array<int, 32> CgBlockOutL{};
218 std::array<int, 32> CgBlockEtaIndL{};
219 std::array<int, 32> CgBlockOutR{};
220 std::array<int, 32> CgBlockEtaIndR{};
221 blkOutAB(gBLKC, CgBlockOutL, CgBlockEtaIndL, CgBlockOutR, CgBlockEtaIndR) ;
222
223 // sorting by 192 blocks 0 = left, 1 = right
224 // second index is column number, the eta value is 2 + 6*column number + local eta
225
226 // find the leading and subleading gBlock in the left column of FPGA A
227 gBlockMax2(gBLKA, 1, 0, gBlockTOBv[0], gBlockTOBeta[0], gBlockTOBphi[0]);
228 // find the leading and subleading gBlock in the right column of FPGA A
229 gBlockMax2(gBLKA, 2, 1, gBlockTOBv[1], gBlockTOBeta[1], gBlockTOBphi[1]);
230
231 // find the leading and subleading gBlock in the left column of FPGA B
232 gBlockMax2(gBLKB, 3, 0, gBlockTOBv[2], gBlockTOBeta[2], gBlockTOBphi[2]);
233 // find the leading and subleading gBlock in the right column of FPGA B
234 gBlockMax2(gBLKB, 4, 1, gBlockTOBv[3], gBlockTOBeta[3], gBlockTOBphi[3]);
235
236 // find the leading and subleading gBlock in the CN column of FPGA C
237 gBlockMax2( gBLKC, 0, 0, gBlockTOBv[4], gBlockTOBeta[4], gBlockTOBphi[4]);
238 // find the leading and subleading gBlock in the CP column of FPGA C
239 gBlockMax2( gBLKC, 5, 1, gBlockTOBv[5], gBlockTOBeta[5], gBlockTOBphi[5]);
240
241 // in hardware vetos happen before remote sums come in.
242 gBlockVetoAB(AjetsRestricted, hasSeedA);
243 gBlockVetoAB(BjetsRestricted, hasSeedB);
244 gBlockVetoAB(CjetsRestricted, hasSeedC);
245
246 // calculate A & B remote partial sums first
247 gTowersPartialSums RAlps_out, RArps_out;
248 RemotePartialAB(Atwr, RAlps_out, RArps_out);
249
250 gTowersPartialSums RBlps_out, RBrps_out;
251 RemotePartialAB(Btwr, RBlps_out, RBrps_out);
252
253 gTowersPartialSums RCNrps_out, RCPlps_out;
254 RemotePartialCN(CNtwr, RCNrps_out);
255 RemotePartialCP(CPtwr, RCPlps_out);
256
257
259
260 // input partial sums from FPGA B to A (lps_out -> rps_in)
262
263 // input partial sums from FPGA B to A (lps_out -> rps_in)
265
266 }
267
269
271
273
274 }
275
276// this are added into the jets you have to truncate to the number of bits on the interFPGA communication
277
279
281
283
284 }
285
286 // Emulate firmware sum69o_del_ovf: after remote partial sums are added,
287 // re-saturate jets whose input towers were saturated.
288 // In firmware (jet_eng.vhd), sum69o_del_ovf = delayK(dat_ovf_in, SUM69O_DEL_DELAY)
289 // overrides sum69o_del to max positive *instead of* adding remote_ps.
290 // Without this, the simulation adds remote_ps on top of an already-max jet value,
291 // biasing the max-finder (jetOutAB) toward columns that receive remote partial sums
292 // and shifting the reported eta.
293 // The same -1 eta shift as SaturateJets applies here.
294 SaturateJets( AjetsRestricted, Asat, 0 );
295 SaturateJets( BjetsRestricted, Bsat, 1 );
296 SaturateJets( CjetsRestricted, Csat, 2 );
297
298 //Emulate switch to unsigned values by zeroing everything below the jet threshold
299 //https://gitlab.cern.ch/atlas-l1calo/gfex/firmware/-/blob/devel/common/jet_finder/HDL/jet_eng.vhd#L550
300
301 gJetVetoAB(AjetsRestricted, jetThreshold);
302 gJetVetoAB(BjetsRestricted, jetThreshold);
303 gJetVetoAB(CjetsRestricted, jetThreshold);
304
305 std::array<int, 32> AjetOutL;
306 std::array<int, 32> AetaIndL;
307 std::array<int, 32> AjetOutR;
308 std::array<int, 32> AetaIndR;
309
310
311 jetOutAB(AjetsRestricted, AjetOutL, AetaIndL, AjetOutR, AetaIndR);
312
313 std::array<int, 32> BjetOutL;
314 std::array<int, 32> BetaIndL;
315 std::array<int, 32> BjetOutR;
316 std::array<int, 32> BetaIndR;
317
318 jetOutAB(BjetsRestricted, BjetOutL, BetaIndL, BjetOutR, BetaIndR);
319
320 std::array<int, 32> CNjetOut;
321 std::array<int, 32> CNetaInd;
322 std::array<int, 32> CPjetOut;
323 std::array<int, 32> CPetaInd;
324
325 jetOutAB(CjetsRestricted, CNjetOut, CNetaInd, CPjetOut, CPetaInd);
326
327 gJetTOBgen(AjetOutL, AetaIndL, 0, jetThreshold, gJetTOBs, gJetTOBv, gJetTOBeta, gJetTOBphi);
328 gJetTOBgen(AjetOutR, AetaIndR, 1, jetThreshold, gJetTOBs, gJetTOBv, gJetTOBeta, gJetTOBphi);
329
330 gJetTOBgen(BjetOutL, BetaIndL, 2, jetThreshold, gJetTOBs, gJetTOBv, gJetTOBeta, gJetTOBphi);
331 gJetTOBgen(BjetOutR, BetaIndR, 3, jetThreshold, gJetTOBs, gJetTOBv, gJetTOBeta, gJetTOBphi);
332
333 gJetTOBgen(CNjetOut, CNetaInd, 4, jetThreshold, gJetTOBs, gJetTOBv, gJetTOBeta, gJetTOBphi);
334 gJetTOBgen(CPjetOut, CPetaInd, 5, jetThreshold, gJetTOBs, gJetTOBv, gJetTOBeta, gJetTOBphi);
335
337 std::vector<std::unique_ptr<gFEXJetTOB>> tobs_v;
338 tobs_v.resize(14);
339
340 // fill in TOBs
341 ATOB1_dat[0] = 0;
342 BTOB1_dat[0] = 0;
343 CTOB1_dat[0] = 0;
344
345 ATOB2_dat[0] = (( pucA & 0x0000FFFF ) << 8);
346 BTOB2_dat[0] = (( pucB & 0x0000FFFF ) << 8);
347 CTOB2_dat[0] = (( pucC & 0x0000FFFF ) << 8);
348
349 // //First available TOBs are the gRho for each central FPGA
350 tobs_v[0] = std::make_unique<gFEXJetTOB>();
351 tobs_v[0]->setWord(ATOB2_dat[0]);
352 tobs_v[0]->setET(pucA);
353 tobs_v[0]->setEta(0);
354 tobs_v[0]->setPhi(0);
355 tobs_v[0]->setTobID(0);
356 tobs_v[0]->setStatus(1);//is 1 only if rho calculation is valid, but rho is not calculated at the moment
357
358 tobs_v[1] = std::make_unique<gFEXJetTOB>();
359 tobs_v[1]->setWord(BTOB2_dat[0]);
360 tobs_v[1]->setET(pucB);
361 tobs_v[1]->setEta(0);
362 tobs_v[1]->setPhi(0);
363 tobs_v[1]->setTobID(0);
364 tobs_v[1]->setStatus(1);//is 1 only if rho calculation is valid, but rho is not calculated at the moment
365
366 // leading gBlocks (available first and go in first TOB value)
367 // TOBs 2-5 are leading gBlocks
368 ATOB1_dat[1] = 0x00000001; //set the TOB ID in the corresponding slot (LSB)
369 if( gBlockTOBv[0][0] > gJ_ptMinToTopoCounts2 ) ATOB1_dat[1] = ATOB1_dat[1] | 0x00000080;//status
370 ATOB1_dat[1] = ATOB1_dat[1] | ( ( gBlockTOBv[0][0] & 0x00000FFF ) << 8);
371 ATOB1_dat[1] = ATOB1_dat[1] | ( ( gBlockTOBeta[0][0] & 0x0000003F ) <<20);
372 ATOB1_dat[1] = ATOB1_dat[1] | ( ( gBlockTOBphi[0][0] & 0x0000001F ) <<26);
373
374 tobs_v[2] = std::make_unique<gFEXJetTOB>();
375 tobs_v[2]->setWord(ATOB1_dat[1]);
376 tobs_v[2]->setET(gBlockTOBv[0][0]);
377 tobs_v[2]->setEta(gBlockTOBeta[0][0]);
378 tobs_v[2]->setPhi(gBlockTOBphi[0][0]);
379 tobs_v[2]->setTobID(1);
380 if( gBlockTOBv[0][0] > gJ_ptMinToTopoCounts2 ) tobs_v[2]->setStatus(1);
381 else tobs_v[2]->setStatus(0);
382
383 ATOB2_dat[1] = 0x00000002;
384 if( gBlockTOBv[1][0] > gJ_ptMinToTopoCounts1 ) ATOB2_dat[1] = ATOB2_dat[1] | 0x00000080;
385 ATOB2_dat[1] = ATOB2_dat[1] | ( ( gBlockTOBv[1][0] & 0x00000FFF ) << 8);
386 ATOB2_dat[1] = ATOB2_dat[1] | ( ( gBlockTOBeta[1][0] & 0x0000003F ) <<20);
387 ATOB2_dat[1] = ATOB2_dat[1] | ( ( gBlockTOBphi[1][0] & 0x0000001F ) <<26);
388
389 tobs_v[3] = std::make_unique<gFEXJetTOB>();
390 tobs_v[3]->setWord(ATOB2_dat[1]);
391 tobs_v[3]->setET(gBlockTOBv[1][0]);
392 tobs_v[3]->setEta(gBlockTOBeta[1][0]);
393 tobs_v[3]->setPhi(gBlockTOBphi[1][0]);
394 tobs_v[3]->setTobID(2);
395 if( gBlockTOBv[1][0] > gJ_ptMinToTopoCounts1 ) tobs_v[3]->setStatus(1);
396 else tobs_v[3]->setStatus(0);
397
398
399 BTOB1_dat[1] = 0x00000001;
400 if( gBlockTOBv[2][0] > gJ_ptMinToTopoCounts1 ) BTOB1_dat[1] = BTOB1_dat[1] | 0x00000080;
401 BTOB1_dat[1] = BTOB1_dat[1] | ( ( gBlockTOBv[2][0] & 0x00000FFF ) << 8);
402 BTOB1_dat[1] = BTOB1_dat[1] | ( ( gBlockTOBeta[2][0] & 0x0000003F ) <<20);
403 BTOB1_dat[1] = BTOB1_dat[1] | ( ( gBlockTOBphi[2][0] & 0x0000001F) <<26);
404
405 tobs_v[4] = std::make_unique<gFEXJetTOB>();
406 tobs_v[4]->setWord(BTOB1_dat[1]);
407 tobs_v[4]->setET(gBlockTOBv[2][0]);
408 tobs_v[4]->setEta(gBlockTOBeta[2][0]);
409 tobs_v[4]->setPhi(gBlockTOBphi[2][0]);
410 tobs_v[4]->setTobID(1);
411 if( gBlockTOBv[2][0] > gJ_ptMinToTopoCounts1 ) tobs_v[4]->setStatus(1);
412 else tobs_v[4]->setStatus(0);
413
414
415 BTOB2_dat[1] = 0x00000002;
416 if( gBlockTOBv[3][0] > gJ_ptMinToTopoCounts2 ) BTOB2_dat[1] = BTOB2_dat[1] | 0x00000080;
417 BTOB2_dat[1] = BTOB2_dat[1] | ( ( gBlockTOBv[3][0] & 0x00000FFF ) << 8);
418 BTOB2_dat[1] = BTOB2_dat[1] | ( ( gBlockTOBeta[3][0] & 0x0000003F ) <<20);
419 BTOB2_dat[1] = BTOB2_dat[1] | ( ( gBlockTOBphi[3][0] & 0x0000001F ) <<26);
420
421 tobs_v[5] = std::make_unique<gFEXJetTOB>();
422 tobs_v[5]->setWord(BTOB2_dat[1]);
423 tobs_v[5]->setET(gBlockTOBv[3][0]);
424 tobs_v[5]->setEta(gBlockTOBeta[3][0]);
425 tobs_v[5]->setPhi(gBlockTOBphi[3][0]);
426 tobs_v[5]->setTobID(2);
427 if( gBlockTOBv[3][0] > gJ_ptMinToTopoCounts2 ) tobs_v[5]->setStatus(1);
428 else tobs_v[5]->setStatus(0);
429
430
431 CTOB1_dat[1] = 0x00000001;
432 if( gBlockTOBv[4][0] > gJ_ptMinToTopoCounts1 ) CTOB1_dat[1] = CTOB1_dat[1] | 0x00000080;
433 CTOB1_dat[1] = CTOB1_dat[1] | ( ( gBlockTOBv[4][0] & 0x00000FFF ) << 8);
434 CTOB1_dat[1] = CTOB1_dat[1] | ( ( gBlockTOBeta[4][0] & 0x0000003F ) <<20);
435 CTOB1_dat[1] = CTOB1_dat[1] | ( ( gBlockTOBphi[4][0] & 0x0000001F) <<26);
436
437
438 CTOB2_dat[1] = 0x00000002;
439 if( gBlockTOBv[5][0] > gJ_ptMinToTopoCounts2) CTOB2_dat[1] = CTOB2_dat[1] | 0x00000080;
440 CTOB2_dat[1] = CTOB2_dat[1] | ( ( gBlockTOBv[5][0] & 0x00000FFF ) << 8);
441 CTOB2_dat[1] = CTOB2_dat[1] | ( ( gBlockTOBeta[5][0] & 0x0000003F ) <<20);
442 CTOB2_dat[1] = CTOB2_dat[1] | ( ( gBlockTOBphi[5][0] & 0x0000001F ) <<26);
443
444
445 // subleading gBlocks
446 // TOBs 6-9 are subleading gBlocks
447 ATOB1_dat[2] = 0x00000003;
448 if( gBlockTOBv[0][1] > gJ_ptMinToTopoCounts2 ) ATOB1_dat[2] = ATOB1_dat[2] | 0x00000080;
449 ATOB1_dat[2] = ATOB1_dat[2] | ( ( gBlockTOBv[0][1] & 0x00000FFF ) << 8);
450 ATOB1_dat[2] = ATOB1_dat[2] | ( ( gBlockTOBeta[0][1] & 0x0000003F ) <<20);
451 ATOB1_dat[2] = ATOB1_dat[2] | ( ( gBlockTOBphi[0][1] & 0x0000001F ) <<26);
452
453 tobs_v[6] = std::make_unique<gFEXJetTOB>();
454 tobs_v[6]->setWord(ATOB1_dat[2]);
455 tobs_v[6]->setET(gBlockTOBv[0][1]);
456 tobs_v[6]->setEta(gBlockTOBeta[0][1]);
457 tobs_v[6]->setPhi(gBlockTOBphi[0][1]);
458 tobs_v[6]->setTobID(3);
459 if( gBlockTOBv[0][1] > gJ_ptMinToTopoCounts2 ) tobs_v[6]->setStatus(1);
460 else tobs_v[6]->setStatus(0);
461
462
463 ATOB2_dat[2] = 0x00000004;
464 if( gBlockTOBv[1][1] > gJ_ptMinToTopoCounts1 ) ATOB2_dat[2] = ATOB2_dat[2] | 0x00000080;
465 ATOB2_dat[2] = ATOB2_dat[2] | ( ( gBlockTOBv[1][1] & 0x00000FFF ) << 8);
466 ATOB2_dat[2] = ATOB2_dat[2] | ( ( gBlockTOBeta[1][1] & 0x0000003F ) <<20);
467 ATOB2_dat[2] = ATOB2_dat[2] | ( ( gBlockTOBphi[1][1] & 0x0000001F ) <<26);
468
469 tobs_v[7] = std::make_unique<gFEXJetTOB>();
470 tobs_v[7]->setWord(ATOB2_dat[2]);
471 tobs_v[7]->setET(gBlockTOBv[1][1]);
472 tobs_v[7]->setEta(gBlockTOBeta[1][1]);
473 tobs_v[7]->setPhi(gBlockTOBphi[1][1]);
474 tobs_v[7]->setTobID(4);
475 if( gBlockTOBv[1][1] > gJ_ptMinToTopoCounts1 ) tobs_v[7]->setStatus(1);
476 else tobs_v[7]->setStatus(0);
477
478
479 BTOB1_dat[2] = 0x00000003;
480 if( gBlockTOBv[2][1] > gJ_ptMinToTopoCounts1 ) BTOB1_dat[2] = BTOB1_dat[2] | 0x00000080;
481 BTOB1_dat[2] = BTOB1_dat[2] | ( ( gBlockTOBv[2][1] & 0x00000FFF ) << 8);
482 BTOB1_dat[2] = BTOB1_dat[2] | ( ( gBlockTOBeta[2][1] & 0x0000003F ) <<20);
483 BTOB1_dat[2] = BTOB1_dat[2] | ( ( gBlockTOBphi[2][1] & 0x0000001F ) <<26);
484
485 tobs_v[8] = std::make_unique<gFEXJetTOB>();
486 tobs_v[8]->setWord(BTOB1_dat[2]);
487 tobs_v[8]->setET(gBlockTOBv[2][1]);
488 tobs_v[8]->setEta(gBlockTOBeta[2][1]);
489 tobs_v[8]->setPhi(gBlockTOBphi[2][1]);
490 tobs_v[8]->setTobID(3);
491 if( gBlockTOBv[2][1] > gJ_ptMinToTopoCounts1 ) tobs_v[8]->setStatus(1);
492 else tobs_v[8]->setStatus(0);
493
494
495 BTOB2_dat[2] = 0x00000004;
496 if( gBlockTOBv[3][1] > gJ_ptMinToTopoCounts2 ) BTOB2_dat[2] = BTOB2_dat[2] | 0x00000080;
497 BTOB2_dat[2] = BTOB2_dat[2] | ( ( gBlockTOBv[3][1] & 0x00000FFF ) << 8);
498 BTOB2_dat[2] = BTOB2_dat[2] | ( ( gBlockTOBeta[3][1] & 0x0000003F ) <<20);
499 BTOB2_dat[2] = BTOB2_dat[2] | ( ( gBlockTOBphi[3][1] & 0x0000001F ) <<26);
500
501 tobs_v[9] = std::make_unique<gFEXJetTOB>();
502 tobs_v[9]->setWord(BTOB2_dat[2]);
503 tobs_v[9]->setET(gBlockTOBv[3][1]);
504 tobs_v[9]->setEta(gBlockTOBeta[3][1]);
505 tobs_v[9]->setPhi(gBlockTOBphi[3][1]);
506 tobs_v[9]->setTobID(4);
507 if( gBlockTOBv[3][1] > gJ_ptMinToTopoCounts2 ) tobs_v[9]->setStatus(1);
508 else tobs_v[9]->setStatus(0);
509
510
511 CTOB1_dat[2] = 0x00000003;
512 if( gBlockTOBv[4][1] > gJ_ptMinToTopoCounts1 ) CTOB1_dat[2] = CTOB1_dat[2] | 0x00000080;
513 CTOB1_dat[2] = CTOB1_dat[2] | ( ( gBlockTOBv[4][1] & 0x00000FFF ) << 8);
514 CTOB1_dat[2] = CTOB1_dat[2] | ( ( gBlockTOBeta[4][1] & 0x0000003F ) <<20);
515 CTOB1_dat[2] = CTOB1_dat[2] | ( ( gBlockTOBphi[4][1] & 0x0000001F ) <<26);
516
517 CTOB2_dat[2] = 0x00000004;
518 if( gBlockTOBv[5][1] > gJ_ptMinToTopoCounts2 ) CTOB2_dat[2] = CTOB2_dat[2] | 0x00000080;
519 CTOB2_dat[2] = CTOB2_dat[2] | ( ( gBlockTOBv[5][1] & 0x00000FFF ) << 8);
520 CTOB2_dat[2] = CTOB2_dat[2] | ( ( gBlockTOBeta[5][1] & 0x0000003F ) <<20);
521 CTOB2_dat[2] = CTOB2_dat[2] | ( ( gBlockTOBphi[5][1] & 0x0000001F ) <<26);
522
523
524 // finally the main event -- lead gJET
525 // according the specification https://docs.google.com/spreadsheets/d/15YVVtGofhXMtV7jXRFzWO0FVUtUAjS-X-aQjh3FKE_w/edit#gid=523371660
526 // we should have an lsb of 3.2 GeV -- so ignore lower 4 bits.
527
528 // TOBs 10-13 are leading gJets
529 // shift is done before sorting as in firmware!
530 int tobvShift = 8;
531 int tobvMask = 0x00000FFF;
532
533
534 ATOB1_dat[3] = 0x00000005;
535 if( gJetTOBv[0] > gLJ_ptMinToTopoCounts2 ) ATOB1_dat[3] = ATOB1_dat[3] | 0x00000080;
536 ATOB1_dat[3] = ATOB1_dat[3] | ( ( gJetTOBv[0] & tobvMask) << tobvShift);
537 ATOB1_dat[3] = ATOB1_dat[3] | ( ( gJetTOBeta[0] & 0x0000003F ) <<20);
538 ATOB1_dat[3] = ATOB1_dat[3] | ( ( gJetTOBphi[0] & 0x0000001F ) <<26);
539
540 tobs_v[10] = std::make_unique<gFEXJetTOB>();
541 tobs_v[10]->setWord(ATOB1_dat[3]);
542 tobs_v[10]->setET(gJetTOBv[0]);
543 tobs_v[10]->setEta(gJetTOBeta[0]);
544 tobs_v[10]->setPhi(gJetTOBphi[0]);
545 tobs_v[10]->setTobID(5);
546 if(gJetTOBv[0] > gLJ_ptMinToTopoCounts2 ) tobs_v[10]->setStatus(1);
547 else tobs_v[10]->setStatus(0);
548
549
550 ATOB2_dat[3] = 0x00000006;
551 if( gJetTOBv[1] > gLJ_ptMinToTopoCounts1 ) ATOB2_dat[3] = ATOB2_dat[3] | 0x00000080;
552 ATOB2_dat[3] = ATOB2_dat[3] | ( ( gJetTOBv[1] & tobvMask ) << tobvShift);
553 ATOB2_dat[3] = ATOB2_dat[3] | ( ( gJetTOBeta[1] & 0x0000003F ) <<20);
554 ATOB2_dat[3] = ATOB2_dat[3] | ( ( gJetTOBphi[1] & 0x0000001F ) <<26);
555
556 tobs_v[11] = std::make_unique<gFEXJetTOB>();
557 tobs_v[11]->setWord(ATOB2_dat[3]);
558 tobs_v[11]->setET(gJetTOBv[1]);
559 tobs_v[11]->setEta(gJetTOBeta[1]);
560 tobs_v[11]->setPhi(gJetTOBphi[1]);
561 tobs_v[11]->setTobID(6);
562 if( gJetTOBv[1] > gLJ_ptMinToTopoCounts1 ) tobs_v[11]->setStatus(1);
563 else tobs_v[11]->setStatus(0);
564
565
566 BTOB1_dat[3] = 0x00000005;
567 if( gJetTOBv[2] > gLJ_ptMinToTopoCounts1 ) BTOB1_dat[3] = BTOB1_dat[3] | 0x00000080;
568 BTOB1_dat[3] = BTOB1_dat[3] | ( ( gJetTOBv[2] & tobvMask) << tobvShift);
569 BTOB1_dat[3] = BTOB1_dat[3] | ( ( gJetTOBeta[2] & 0x0000003F ) <<20);
570 BTOB1_dat[3] = BTOB1_dat[3] | ( ( gJetTOBphi[2] & 0x0000001F ) <<26);
571
572 tobs_v[12] = std::make_unique<gFEXJetTOB>();
573 tobs_v[12]->setWord(BTOB1_dat[3]);
574 tobs_v[12]->setET(gJetTOBv[2]);
575 tobs_v[12]->setEta(gJetTOBeta[2]);
576 tobs_v[12]->setPhi(gJetTOBphi[2]);
577 tobs_v[12]->setTobID(5);
578 if( gJetTOBv[2] > gLJ_ptMinToTopoCounts1 ) tobs_v[12]->setStatus(1);
579 else tobs_v[12]->setStatus(0);
580
581
582 BTOB2_dat[3] = 0x00000006;
583 if( gJetTOBv[3] > gLJ_ptMinToTopoCounts2 ) BTOB2_dat[3] = BTOB2_dat[3] | 0x00000080;
584 BTOB2_dat[3] = BTOB2_dat[3] | ( ( gJetTOBv[3] & tobvMask ) << tobvShift);
585 BTOB2_dat[3] = BTOB2_dat[3] | ( ( gJetTOBeta[3] & 0x0000003F ) <<20);
586 BTOB2_dat[3] = BTOB2_dat[3] | ( ( gJetTOBphi[3] & 0x0000001F ) <<26);
587
588 tobs_v[13] = std::make_unique<gFEXJetTOB>();
589 tobs_v[13]->setWord(BTOB2_dat[3]);
590 tobs_v[13]->setET(gJetTOBv[3]);
591 tobs_v[13]->setEta(gJetTOBeta[3]);
592 tobs_v[13]->setPhi(gJetTOBphi[3]);
593 tobs_v[13]->setTobID(6);
594 if( gJetTOBv[3] > gLJ_ptMinToTopoCounts2 ) tobs_v[13]->setStatus(1);
595 else tobs_v[13]->setStatus(0);
596
597 // // CECILIA - TO BE CHECKED
598 CTOB1_dat[3] = 0x00000005;
599 if( gJetTOBv[4] > gLJ_ptMinToTopoCounts1 ) CTOB1_dat[3] = CTOB1_dat[3] | 0x00000080;
600 CTOB1_dat[3] = CTOB1_dat[3] | ( ( gJetTOBv[4] & tobvMask) << tobvShift);
601 CTOB1_dat[3] = CTOB1_dat[3] | ( ( gJetTOBeta[4] & 0x0000003F ) <<20);
602 CTOB1_dat[3] = CTOB1_dat[3] | ( ( gJetTOBphi[4] & 0x0000001F ) <<26);
603
604 CTOB2_dat[3] = 0x00000006;
605 if( gJetTOBv[5] > gLJ_ptMinToTopoCounts2 ) CTOB2_dat[3] = CTOB2_dat[3] | 0x00000080;
606 CTOB2_dat[3] = CTOB2_dat[3] | ( ( gJetTOBv[5] & tobvMask ) << tobvShift);
607 CTOB2_dat[3] = CTOB2_dat[3] | ( ( gJetTOBeta[5] & 0x0000003F ) <<20);
608 CTOB2_dat[3] = CTOB2_dat[3] | ( ( gJetTOBphi[5] & 0x0000001F ) <<26);
609
610
611// saturation currently not set in firmware
612//
613//
614 bool setSat = 0;
615 if ( setSat) {
616 if( gTOBsat[0] ) {
617 ATOB1_dat[1] = ( ATOB1_dat[1] | 0x80000000 );
618 ATOB1_dat[3] = ( ATOB1_dat[3] | 0x80000000 );
619 }
620
621 if( gTOBsat[1] ) {
622 ATOB2_dat[1] = ( ATOB2_dat[1] | 0x80000000 );
623 ATOB2_dat[3] = ( ATOB2_dat[3] | 0x80000000 );
624 }
625
626 if( gTOBsat[2] ) {
627 BTOB1_dat[1] = ( BTOB1_dat[1] | 0x80000000 );
628 BTOB1_dat[3] = ( BTOB1_dat[3] | 0x80000000 );
629 }
630
631 if( gTOBsat[3] ) {
632 BTOB2_dat[1] = ( BTOB2_dat[1] | 0x80000000 );
633 BTOB2_dat[3] = ( BTOB2_dat[3] | 0x80000000 );
634 }
635
636 if( gTOBsat[4] ) {
637 CTOB1_dat[1] = ( CTOB1_dat[1] | 0x80000000 );
638 CTOB1_dat[3] = ( CTOB1_dat[3] | 0x80000000 );
639 }
640
641 if( gTOBsat[5] ) {
642 CTOB2_dat[1] = ( CTOB2_dat[1] | 0x80000000 );
643 CTOB2_dat[3] = ( CTOB2_dat[3] | 0x80000000 );
644 }
645 }
646
647 // zero tob 4 word
648
649 ATOB1_dat[4] = 0 ;
650 ATOB2_dat[4] = 0 ;
651 BTOB1_dat[4] = 0 ;
652 BTOB2_dat[4] = 0 ;
653 CTOB1_dat[4] = 0 ;
654 CTOB2_dat[4] = 0 ;
655
656
657 // add seven bits as in the hardware of BCID in 6th TOB word ( index 5)
658 int BCID = 0;
659
660 ATOB1_dat[5] = ( (BCID&0x0000007F)<<8 ) ;
661 ATOB2_dat[5] = ( (BCID&0x0000007F)<<8 ) ;
662 BTOB1_dat[5] = ( (BCID&0x0000007F)<<8 ) ;
663 BTOB2_dat[5] = ( (BCID&0x0000007F)<<8 ) ;
664 CTOB1_dat[5] = ( (BCID&0x0000007F)<<8 ) ;
665 CTOB2_dat[5] = ( (BCID&0x0000007F)<<8 ) ;
666
667 // 3 is gFEX FEX number, set CRC to zero for now
668 int CRC = 0;
669
670
671 ATOB1_dat[6] = 0x000000BC | ( (BCID&0x0000000F)<<8 ) | (3<<12) | (CRC<<23);
672 ATOB2_dat[6] = 0x000000BC | ( (BCID&0x0000000F)<<8 ) | (3<<12) | (CRC<<23);
673 BTOB1_dat[6] = 0x000000BC | ( (BCID&0x0000000F)<<8 ) | (3<<12) | (CRC<<23);
674 BTOB2_dat[6] = 0x000000BC | ( (BCID&0x0000000F)<<8 ) | (3<<12) | (CRC<<23);
675 CTOB1_dat[6] = 0x000000BC | ( (BCID&0x0000000F)<<8 ) | (3<<12) | (CRC<<23);
676 CTOB2_dat[6] = 0x000000BC | ( (BCID&0x0000000F)<<8 ) | (3<<12) | (CRC<<23);
677
678
679
680 return tobs_v;
681
682}
static constexpr int PS_UPPER_AB
static constexpr int BTOBFIB
static constexpr bool ENABLE_INTER_AB
static constexpr bool ENABLE_INTER_ABC
static constexpr bool ENABLE_INTER_C
static constexpr int PS_SHIFT_C
static constexpr int PS_LOWER_C
static constexpr int ABcolumns
static constexpr int PS_SHIFT_AB
static constexpr int PS_LOWER_AB
static constexpr int PS_UPPER_C
virtual void gBlockMax2(const gTowersType &gBlkSum, int BjetColumn, int localColumn, std::array< int, 3 > &gBlockV, std::array< int, 3 > &gBlockEta, std::array< int, 3 > &gBlockPhi) const
virtual void gBlockVetoAB(gTowersType &jets, gTowersType &hasSeed) const
virtual void pileUpCorrectionAB(gTowersType &jets, int puc) const
virtual void addRemoteCPin(gTowersType &jets, const gTowersPartialSums &partial, int ps_upper, int ps_lower, int ps_shift) const
virtual void ZeroNegative(gTowersType &jets) const
virtual void addRemoteLin(gTowersType &jets, const gTowersPartialSums &partial, int ps_upper, int ps_lower, int ps_shift) const
virtual void gJetVetoAB(gTowersType &twrs, int jet_threshold) const
virtual void blkOutAB(gTowersType &blocks, std::array< int, 32 > &jetOutL, std::array< int, 32 > &etaIndL, std::array< int, 32 > &jetOutR, std::array< int, 32 > &etaIndR) const
virtual void InternalPartialAB(const gTowersType &twrs, gTowersPartialSums &lps, gTowersPartialSums &rps) const
virtual void RemotePartialCN(const gTowersJetEngine &twrs, gTowersPartialSums &rps) const
virtual void addRemoteRin(gTowersType &jets, const gTowersPartialSums &partial, int ps_upper, int ps_lower, int ps_shift) const
virtual void SaturateJets(gTowersType &jets, const gTowersType &sat, int fpga) const
virtual void singleHalf(const gTowersType &twrs, gTowersType &FPGAsum) const
virtual void RemotePartialCP(const gTowersJetEngine &twrs, gTowersPartialSums &lps) const
virtual void gBlockAB(const gTowersType &twrs, gTowersType &gBlkSum, gTowersType &hasSeed, int seedThreshold) const
virtual void gJetTOBgen(const std::array< int, FEXAlgoSpaceDefs::ABCrows > &jetOut, const std::array< int, FEXAlgoSpaceDefs::ABCrows > &etaInd, int TOBnum, int jetThreshold, std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > &gJetTOBs, std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > &gJetTOBv, std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > &gJetTOBeta, std::array< int, FEXAlgoSpaceDefs::gJetTOBfib > &gJetTOBphi) const
virtual void addRemoteCNin(gTowersType &jets, const gTowersPartialSums &partial, int ps_upper, int ps_lower, int ps_shift) const
virtual void SaturateBlocks(gTowersType &gBlkSum, const gTowersType &sat, int fpga) const
virtual void addInternalRin(gTowersType &jets, gTowersPartialSums &partial) const
virtual void jetOutAB(const gTowersType &jets, std::array< int, 32 > &jetOutL, std::array< int, 32 > &etaIndL, std::array< int, 32 > &jetOutR, std::array< int, 32 > &etaIndR) const
virtual void addInternalLin(gTowersType &jets, gTowersPartialSums &partial) const
virtual void RemotePartialAB(const gTowersType &twrs, gTowersPartialSums &lps, gTowersPartialSums &rps) const
std::array< std::array< int, 12 >, 32 > gTowersType
Definition IgFEXFPGA.h:25
std::array< std::array< int, 4 >, 32 > gTowersPartialSums
Definition gFEXJetAlgo.h:29

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ pileUpCalculation()

void LVL1::gFEXJetAlgo::pileUpCalculation ( gTowersType & twrs,
int rhoThreshold_Max,
int inputScale,
int & PUCp,
int & PUC_JWJ ) const
overridevirtual

Implements LVL1::IgFEXJetAlgo.

Definition at line 1430 of file gFEXJetAlgo.cxx.

1430 {
1431 // input are 50 MeV "fine" scale towers (i.e. inputScale = 1)
1432 // to use 200 MeV towers use inputScale = 4
1433 // PUCp output is the pileup correction for 69 towers at 200 MeV energy scale
1434
1435 int rows = twrs.size();
1436 int cols = twrs[0].size();
1437 int pucSum = 0;
1438 int pucSumJWJ = 0;
1439 int nSum = 0;
1440 for(int irow=0; irow<rows; irow++){
1441 for( int icolumn=0; icolumn<cols; icolumn++){
1442 int fineGT = twrs[irow][icolumn]*inputScale;
1443 // set floor and ceiling here (currently 255 and -256 )
1446
1447 if( fineGT < rhoThreshold_Max ) {
1448 pucSum = pucSum + fineGT;
1449 nSum = nSum + 1;
1450 }
1451 }
1452 }
1453 // in firmware this is done with a lookup table see https://gitlab.cern.ch/atlas-l1calo/gfex/firmware/-/blob/devel/common/jet_finder/HDL/inv_lut19.vhd
1454 // See also https://gitlab.cern.ch/atlas-l1calo/gfex/firmware/-/blob/devel/common/jet_finder/HDL/gt_build_all_AB.vhd#L1471
1455
1456 // oneOverN is stored as a 32 bit number in inv_lut19
1457 unsigned int oneOverNTab = 69<<25;
1458 unsigned int JWJoneOverNTab = 69<<25;
1459 if( nSum > 0 && nSum < 385 ) {
1460 oneOverNTab = FEXAlgoSpaceDefs::inv19[nSum];
1461 JWJoneOverNTab = FEXAlgoSpaceDefs::jwjinv19[nSum];
1462 } else {
1463 oneOverNTab = 0;
1464 JWJoneOverNTab = 0;
1465 }
1466
1467 int oneOverN = oneOverNTab;
1468 int JWJoneOverN = JWJoneOverNTab;
1469
1470 // largest value should be 255*2^14 ~ 2^22 -- should easily fit in int -- try expliciting putting in int here.
1471 pucSumJWJ = pucSum * JWJoneOverN;
1472 pucSum = pucSum * oneOverN;
1473
1474 // PUChres = pucSum;
1475
1476 // current system 19 bits in table (69*4096 is max value) sign exten
1477 pucSum = ( pucSum >> 14);
1478 pucSumJWJ = ( pucSumJWJ >> 16);
1479 PUCp = pucSum;
1480 PUC_JWJ = pucSumJWJ;
1481
1482}
static constexpr std::array< unsigned int, 513 > jwjinv19
static constexpr std::array< unsigned int, 385 > inv19
static constexpr int fineCeiling
static constexpr int fineFloor

◆ pileUpCorrectionAB()

void LVL1::gFEXJetAlgo::pileUpCorrectionAB ( gTowersType & jets,
int puc ) const
privatevirtual

Definition at line 933 of file gFEXJetAlgo.cxx.

933 {
934 int rows = jets.size();
935 int cols = jets[0].size();
936 for(int irow=0;irow<rows;irow++){
937 for(int icolumn=0;icolumn<cols;icolumn++){
938 jets[irow][icolumn] = jets[irow][icolumn] - puc;
939 }
940 }
941}

◆ RemotePartialAB()

void LVL1::gFEXJetAlgo::RemotePartialAB ( const gTowersType & twrs,
gTowersPartialSums & lps,
gTowersPartialSums & rps ) const
privatevirtual

Definition at line 685 of file gFEXJetAlgo.cxx.

685 {
686
687 // Computes partial sums for FPGA A or B
688 // twrs are the 32 x 12 = 284 gTowers in FPGA A or B
689
690 // number of rows above/below for right partial sum
691 // when sending to the right send values for largest partial sum first, i.e. for column 0
692 typedef std::array<std::array<int, 4>, 4> gTowersNeighbours;
693 gTowersNeighbours NUpDwnR = {{ {{2,3,4,4}}, {{0,2,3,4}}, {{0,0,2,3}}, {{0,0,0,2}} }};
694
695 // number of rows above or below for left partial sum
696 // when sending to the left send values for smallest partial sum first (i.e. for column 8 )
697 gTowersNeighbours NUpDwnL = {{ {{2,0,0,0}}, {{3,2,0,0}}, {{4,3,2,0}}, {{4,4,3,2}} }};
698
699 // Do partial sum for output to right FPGA first
700 for( int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
701 for(int rcolumn = 0; rcolumn<FEXAlgoSpaceDefs::n_partial; rcolumn++){
702 // start calculating right partial sums for remote column rcolumn
703 rps[irow][rcolumn] = 0;
704 for(int lcolumn = 0; lcolumn<FEXAlgoSpaceDefs::n_partial; lcolumn++){
705 // add in any energy from towers in this row
706 // no need of modular arithmetic
707 if ( NUpDwnR[rcolumn][lcolumn] > 0 ) {
708 rps[irow][rcolumn] = rps[irow][rcolumn] + twrs[irow][lcolumn+8];
709 }
710 // now add rup1, rup2, rup3, rup4, ldn1, ldn2, ln3, ln4 -- use a loop instead of enumeratin in firmware
711 for( int rowOff = 1 ; rowOff < NUpDwnR[rcolumn][lcolumn]+1; rowOff++){
712 int rowModUp = (irow + rowOff)%32;
713 int rowModDn = (irow - rowOff + 32 )%32;
714 // printf("row %d remote column %d local column %d rowOff %d rowModUp %d rowModDn %d \n",
715 rps[irow][rcolumn] = rps[irow][rcolumn] + twrs[rowModUp][lcolumn+8] + twrs[rowModDn][lcolumn+8];
716 }
717 }
718 }
719 }
720
721 // do partial sum for output to left FPGA second
722 for( int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
723 for(int rcolumn = 0; rcolumn<FEXAlgoSpaceDefs::n_partial; rcolumn++){
724 // start calculating right partial sums for remote column rcolumn
725 lps[irow][rcolumn] = 0;
726 for(int lcolumn = 0; lcolumn<FEXAlgoSpaceDefs::n_partial; lcolumn++){
727 // add in any energy from towers in this row
728 // no need of modular arithmetic
729 if ( NUpDwnL[rcolumn][lcolumn] > 0 ) {
730 lps[irow][rcolumn] = lps[irow][rcolumn] + twrs[irow][lcolumn];
731 }
732 // now add rup1, rup2, rup3, rup4, ldn1, ldn2, ln3, ln4 -- use a loop instead of enumeratin in firmware
733 for( int rowOff = 1 ; rowOff < NUpDwnL[rcolumn][lcolumn]+1; rowOff++){
734 int rowModUp = (irow + rowOff)%32;
735 int rowModDn = (irow - rowOff + 32 )%32;
736 lps[irow][rcolumn] = lps[irow][rcolumn] + twrs[rowModUp][lcolumn] + twrs[rowModDn][lcolumn];
737 }
738 }
739 }
740 }
741
742}

◆ RemotePartialCN()

void LVL1::gFEXJetAlgo::RemotePartialCN ( const gTowersJetEngine & twrs,
gTowersPartialSums & rps ) const
privatevirtual

Definition at line 745 of file gFEXJetAlgo.cxx.

745 {
746
747 typedef std::array<std::array<int, 4>, 4> gTowersNeighbours;
748 gTowersNeighbours NUpDwnR = {{ {{2,3,4,4}}, {{0,2,3,4}}, {{0,0,2,3}}, {{0,0,0,2}} }};
749
750 // same as AB for right partial sum
751 // starts from the righ most partial sum -- largest partial sum
752 for( int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
753 for(int rcolumn = 0; rcolumn<FEXAlgoSpaceDefs::n_partial; rcolumn++){
754 rps[irow][rcolumn] = 0;
755 for(int lcolumn = 0; lcolumn<FEXAlgoSpaceDefs::n_partial; lcolumn++){
756 if ( NUpDwnR[rcolumn][lcolumn] > 0 ) {
757 rps[irow][rcolumn] = rps[irow][rcolumn] + twrs[irow][lcolumn+2];
758 }
759 for( int rowOff = 1 ; rowOff < NUpDwnR[rcolumn][lcolumn]+1; rowOff++){
760 int rowModUp = (irow + rowOff)%32;
761 int rowModDn = (irow - rowOff + 32 )%32;
762 rps[irow][rcolumn] = rps[irow][rcolumn] + twrs[rowModUp][lcolumn+2] + twrs[rowModDn][lcolumn+2];
763 }
764 }
765 }
766 }
767}

◆ RemotePartialCP()

void LVL1::gFEXJetAlgo::RemotePartialCP ( const gTowersJetEngine & twrs,
gTowersPartialSums & lps ) const
privatevirtual

Definition at line 770 of file gFEXJetAlgo.cxx.

770 {
771
772 typedef std::array<std::array<int, 4>, 4> gTowersNeighbours;
773 gTowersNeighbours NUpDwnL = {{ {{2,0,0,0}}, {{3,2,0,0}}, {{4,3,2,0}}, {{4,4,3,2}} }};
774 // do partial sum for output to left FPGA second
775 for( int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
776 for(int rcolumn = 0; rcolumn<FEXAlgoSpaceDefs::n_partial; rcolumn++){
777 // start calculating right partial sums for remote column rcolumn
778 lps[irow][rcolumn] = 0;
779 for(int lcolumn = 0; lcolumn<FEXAlgoSpaceDefs::n_partial; lcolumn++){
780 // add in any energy from towers in this row
781 // no need of modular arithmetic
782 if ( NUpDwnL[rcolumn][lcolumn] > 0 ) {
783 lps[irow][rcolumn] = lps[irow][rcolumn] + twrs[irow][lcolumn];
784 }
785 for( int rowOff = 1 ; rowOff < NUpDwnL[rcolumn][lcolumn]+1; rowOff++){
786 int rowModUp = (irow + rowOff)%32;
787 int rowModDn = (irow - rowOff + 32 )%32;
788 lps[irow][rcolumn] = lps[irow][rcolumn] + twrs[rowModUp][lcolumn] + twrs[rowModDn][lcolumn];
789 }
790 }
791 }
792 }
793}

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ SaturateBlocks()

void LVL1::gFEXJetAlgo::SaturateBlocks ( gTowersType & gBlkSum,
const gTowersType & sat,
int fpga ) const
privatevirtual

Definition at line 987 of file gFEXJetAlgo.cxx.

987 {
988 // TODO: Temporary fix to match FW saturation eta-alignment bug.
989 // In firmware, seed_ovf = delayK(dat_ovf_in, SEED_OVF_DELAY=10).
990 // dat_ovf_in for col K arrives at clock K; seed_ovf fires at clock K+10.
991 // et9 for col J is computed at clock 11+J (SEED_DLY+J).
992 // So overflow at col K fires during et9 for col K+10-11 = K-1.
993 // First column (icol%6==0) is always skipped (pulse falls in dead/gap).
994 // Last column skipping is FPGA-specific (see SaturateJets comments):
995 // FPGA A: no last-col skip (cols 5,11 regular).
996 // FPGA B: skip col 11 only (extended).
997 // FPGA C: skip all last cols (all extended).
998 // @see jet_eng.vhd lines 849-863: seed_ovf forces et9/seed_out to max
999 // @see delayK.vhd: DLY FFs with combinatorial in/out
1000 // Revert this to use icol (not icol-1) when the FW saturation alignment is fixed.
1001 for(unsigned int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
1002 for(unsigned int icol = 0; icol < FEXAlgoSpaceDefs::ABcolumns; icol++){
1003 if(sat[irow][icol] && (icol % 6 != 0)){
1004 if (fpga == 1 && icol == 11) continue; // FPGA B col 11 extended
1005 if (fpga == 2 && icol % 6 == 5) continue; // FPGA C all last cols extended
1006 gBlkSum[irow][icol - 1] = 0x00000fff;
1007 }
1008 }
1009 }
1010}

◆ SaturateJets()

void LVL1::gFEXJetAlgo::SaturateJets ( gTowersType & jets,
const gTowersType & sat,
int fpga ) const
privatevirtual

Definition at line 954 of file gFEXJetAlgo.cxx.

954 {
955 // TODO: Temporary fix to match FW saturation eta-alignment bug.
956 // In firmware, sum69_ovf = delayK(dat_ovf_in, SUM69_OVF_DELAY=16).
957 // dat_ovf_in for col K arrives at clock K; sum69_ovf fires at clock K+16.
958 // sum69o for col J is computed at clock 17+J (LPS_A_DLY+J).
959 // So overflow at col K fires during sum69o for col K+16-17 = K-1.
960 // Engine-boundary columns:
961 // - First column (local col 0 = global 0,6): K-1 falls in the dead/gap
962 // phase of the serialiser → no valid target, skip (icol%6 != 0).
963 // - Last column (local col 5 = global 5,11): the override is gated by
964 // have_seed_d5 in jet_eng.vhd. For extended columns the seed is
965 // computed from regular etower+htower only (the extended xetower
966 // contribution is added after the seed stage via lps_a), so the seed
967 // typically fails and the override is blocked. This is FPGA-specific:
968 // FPGA A (fpga=0): cols 5,11 are regular → override goes through.
969 // FPGA B (fpga=1): col 11 is extended (xetower+xhtower) → skip.
970 // col 5 is regular → override goes through.
971 // FPGA C (fpga=2): all columns extended → skip all last cols.
972 // @see jet_eng.vhd: sum69_ovf forces sum69o to max positive
973 // @see jet_eng.vhd: have_seed_d5 gates delm_din, blocking override
974 // @see delayK.vhd: DLY FFs with combinatorial in/out
975 // Revert this to use icol (not icol-1) when the FW saturation alignment is fixed.
976 for(unsigned int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
977 for(unsigned int icol = 0; icol < FEXAlgoSpaceDefs::ABcolumns; icol++){
978 if(sat[irow][icol] && (icol % 6 != 0)){
979 if (fpga == 1 && icol == 11) continue; // FPGA B col 11 extended
980 if (fpga == 2 && icol % 6 == 5) continue; // FPGA C all last cols extended
981 jets[irow][icol - 1] = 0x0003ffff;
982 }
983 }
984 }
985}

◆ singleHalf()

void LVL1::gFEXJetAlgo::singleHalf ( const gTowersType & twrs,
gTowersType & FPGAsum ) const
privatevirtual

Definition at line 796 of file gFEXJetAlgo.cxx.

796 {
797 // Finds jets in a single FPGA
798 // This version only gives sum in the right or left half of the FPGA
799
800 // Number of up and down FPGAs to add
801 std::array<int, 9> NUpDwn = {{2,3,4,4,4,4,4,3,2}};
802
803 // Evaluate jet centered on each possible eta and phi gTower
804 for( int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
805 for(int jcolumn = 0; jcolumn<FEXAlgoSpaceDefs::ABcolumns; jcolumn++){
806 // zero jet sum here
807 FPGAsum[irow][jcolumn] = 0;
808
809 // local column goes from 0 to 8
810 for(int localColumn = 0; localColumn<9; localColumn++){
811 int sumColumn = jcolumn + localColumn - 4;
812
813 // calculate min and max columns for FPGA half
814 int lmin = 0;
815 int lmax = 5;
816
817 if( jcolumn > 5 ) {
818 lmin = 6;
819 lmax = 11;
820 }
821
822 // check if tower to be summed is actually in FPGA
823 if( (sumColumn >= lmin) && (sumColumn <= lmax) ) {
824
825 // sum tower in the same row as jet center
826 FPGAsum[irow][jcolumn] = FPGAsum[irow][jcolumn] + twrs[irow][sumColumn];
827
828 // add rows above and below according NUpDwn
829 // localRow goes from 1 to 2, 1 to 3 or 1 to 4
830 for(int localRow = 1; localRow<=NUpDwn[localColumn]; localRow++){
831 int krowUp = (irow + localRow);
832 if( krowUp > 31 ) krowUp = krowUp - 32;
833 int krowDn = (irow - localRow);
834 if( krowDn < 0 ) krowDn = krowDn + 32;
835 FPGAsum[irow][jcolumn] = FPGAsum[irow][jcolumn] +
836 twrs[krowUp][sumColumn] +
837 twrs[krowDn][sumColumn];
838 }
839 }
840 }
841 }
842 }
843}

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ ZeroNegative()

void LVL1::gFEXJetAlgo::ZeroNegative ( gTowersType & jets) const
privatevirtual

Definition at line 944 of file gFEXJetAlgo.cxx.

944 {
945 for(unsigned int irow = 0; irow < FEXAlgoSpaceDefs::ABCrows; irow++ ){
946 for(unsigned int icolumn =0; icolumn<FEXAlgoSpaceDefs::ABcolumns; icolumn++){
947 if(jets[irow][icolumn] < 0) jets[irow][icolumn] = 0;
948 }
949 }
950}

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_gFEXJetAlgo_gTowerContainerKey

SG::ReadHandleKey<LVL1::gTowerContainer> LVL1::gFEXJetAlgo::m_gFEXJetAlgo_gTowerContainerKey {this, "MyGTowers", "gTowerContainer", "Input container for gTowers"}
private

Definition at line 112 of file gFEXJetAlgo.h.

112{this, "MyGTowers", "gTowerContainer", "Input container for gTowers"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: