Commit e710a868 authored by Alan Watson's avatar Alan Watson Committed by Walter Lampl
Browse files

Update eFEX EDM objects to final formats.

parent 4e76d1b7
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
// $Id: eFexEMRoIAuxContainer_v1.cxx 2019-07-01 13:04:25Z watsona $
// Updated 2021-09-08 for (hopefully) final TOB formats
// Local include(s):
#include "xAODTrigger/versions/eFexEMRoIAuxContainer_v1.h"
......@@ -12,10 +12,8 @@ namespace xAOD {
eFexEMRoIAuxContainer_v1::eFexEMRoIAuxContainer_v1()
: AuxContainerBase() {
AUX_VARIABLE( Word0);
AUX_VARIABLE( Word1);
AUX_VARIABLE( eFexNumber);
AUX_VARIABLE( shelfNumber);
AUX_VARIABLE( word0);
AUX_VARIABLE( word1);
AUX_VARIABLE( RetaEnv);
AUX_VARIABLE( RetaCore);
AUX_VARIABLE( RhadHad);
......
......@@ -24,12 +24,40 @@ namespace xAOD {
}
void eFexEMRoI_v1::initialize( uint8_t eFexNumber, uint8_t shelf, uint32_t word0, uint32_t word1 ) {
void eFexEMRoI_v1::initialize( unsigned int eFexNumber, unsigned int shelf, uint32_t word0 ) {
// xTOBs will have eFEX and Shelf numbers in word 1
// To save space, use the second word of this object, which is not part of a TOB, to store these values
uint32_t word1 = 0;
word1 |= (eFexNumber&s_eFexMask)<<s_eFexBit;
word1 |= (shelf&s_shelfMask)<<s_shelfBit;
setWord0( word0 );
setWord1( word1 );
/** Quantities derived from TOB data, stored for convenience */
setEt( etTOB()*s_tobEtScale );
float etaVal = iEta()*s_towerEtaWidth + (seed()+0.5)*s_towerEtaWidth/4;
setEta( etaVal );
float phiVal = iPhi() * M_PI/32. + M_PI/64.;
if (phiVal > M_PI) phiVal = phiVal - 2.*M_PI;
setPhi( phiVal );
/** If the object is a TOB then the isTOB should be true.
For xTOB default is false, but should be set by the user if a matching TOB is found */
if (type() == TOB) setIsTOB(1);
else setIsTOB(0);
return;
}
/// xTOB initialize method
void eFexEMRoI_v1::initialize( uint32_t word0, uint32_t word1 ) {
// xTOBs will have eFEX and Shelf numbers in word 1
// So all we need to do is set the TOB words
setWord0( word0 );
setWord1( word1 );
seteFexNumber( eFexNumber );
setShelfNumber( shelf );
/** Quantities derived from TOB data, stored for convenience */
setEt( etTOB()*s_tobEtScale );
......@@ -49,14 +77,10 @@ namespace xAOD {
/// Raw data words
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexEMRoI_v1, uint32_t, Word0,
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexEMRoI_v1, uint32_t, word0,
setWord0 )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexEMRoI_v1, uint32_t, Word1,
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexEMRoI_v1, uint32_t, word1,
setWord1 )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexEMRoI_v1, uint8_t, eFexNumber,
seteFexNumber )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexEMRoI_v1, uint8_t, shelfNumber,
setShelfNumber )
/// Only calculable externally
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexEMRoI_v1, uint16_t, RetaCore,
......@@ -88,42 +112,52 @@ namespace xAOD {
/// Methods to decode data from the TOB/RoI and return to the user
/// eFEX number
unsigned int eFexEMRoI_v1::eFexNumber() const {
return (word1() >> s_eFexBit) & s_eFexMask;
}
/// Shelf number
unsigned int eFexEMRoI_v1::shelfNumber() const {
return (word1() >> s_shelfBit) & s_shelfMask;
}
/// TOB or xTOB?
eFexEMRoI_v1::ObjectType eFexEMRoI_v1::type() const {
if (Word1() == 0) return TOB;
else return xTOB;
if (etXTOB() == 0) return TOB;
else return xTOB;
}
/// Hardware coordinate elements
unsigned int eFexEMRoI_v1::fpga() const {
return (Word0() >> s_fpgaBit) & s_fpgaMask;
return (word0() >> s_fpgaBit) & s_fpgaMask;
}
unsigned int eFexEMRoI_v1::fpgaEta() const {
return (Word0() >> s_etaBit) & s_etaMask;
return (word0() >> s_etaBit) & s_etaMask;
}
unsigned int eFexEMRoI_v1::fpgaPhi() const {
return (Word0() >> s_phiBit) & s_phiMask;
return (word0() >> s_phiBit) & s_phiMask;
}
unsigned int eFexEMRoI_v1::UpNotDown() const {
return (Word0() >> s_updownBit) & s_updownMask;
return (word0() >> s_updownBit) & s_updownMask;
}
unsigned int eFexEMRoI_v1::seed() const {
return (Word0() >> s_seedBit) & s_seedMask;
return (word0() >> s_seedBit) & s_seedMask;
}
unsigned int eFexEMRoI_v1::seedMax() const {
return (Word0() >> s_maxBit) & s_maxMask;
return (word0() >> s_maxBit) & s_maxMask;
}
/// Raw ET on TOB scale (100 MeV/count)
unsigned int eFexEMRoI_v1::etTOB() const {
// Data content = TOB
if (Word1() == 0) {
return (Word0() >> s_etBit) & s_etMask;
if (etXTOB() == 0) {
return (word0() >> s_etBit) & s_etMask;
}
// Data Content = xTOB. Need to remove lower bits and cap range
else {
......@@ -135,40 +169,34 @@ namespace xAOD {
/// Full precision ET (25 MeV/count, only available if object is an xTOB
unsigned int eFexEMRoI_v1::etXTOB() const {
/// If the object is not an xTOB return 0 as high-precision ET unavailable
if (Word1() == 0) {
//return etTOB()*s_tobEtScale/s_xTobEtScale;
return 0;
}
else {
return (Word1() >> s_etBit) & s_etFullMask;
}
/// If the object is not an xTOB this will return 0
return (word1() >> s_etBit) & s_etFullMask;
}
/// Results of the 3 jet discriminant algorithms
unsigned int eFexEMRoI_v1::RetaThresholds() const {
return (Word0() >> s_veto1Bit) & s_veto1Mask;
return (word0() >> s_veto1Bit) & s_veto1Mask;
}
unsigned int eFexEMRoI_v1::RhadThresholds() const {
return (Word0() >> s_veto2Bit) & s_veto2Mask;
return (word0() >> s_veto2Bit) & s_veto2Mask;
}
unsigned int eFexEMRoI_v1::WstotThresholds() const {
return (Word0() >> s_veto3Bit) & s_veto3Mask;
return (word0() >> s_veto3Bit) & s_veto3Mask;
}
unsigned int eFexEMRoI_v1::bcn4() const {
return (Word1() >> s_bcn4Bit) & s_bcn4Mask;
return (word1() >> s_bcn4Bit) & s_bcn4Mask;
}
/// Return single 32-bit TOB word from an xTOB
uint32_t eFexEMRoI_v1::tobWord() const {
// Do something sensible if called for a TOB
if (Word1() == 0) return Word0();
if (etXTOB() == 0) return word0();
// When called for xTOB
else {
uint32_t word = Word0() + etTOB();
uint32_t word = word0() + etTOB();
return word;
}
}
......
......@@ -12,14 +12,14 @@ namespace xAOD {
AUX_VARIABLE( word0);
AUX_VARIABLE( word1);
AUX_VARIABLE( eFexNumber);
AUX_VARIABLE( fCoreNumerator);
AUX_VARIABLE( fCoreDenominator);
AUX_VARIABLE( fHadNumerator);
AUX_VARIABLE( fHadDenominator);
AUX_VARIABLE( et);
AUX_VARIABLE( eta);
AUX_VARIABLE( phi);
AUX_VARIABLE( isTOB);
AUX_VARIABLE( thrPattern);
}
} // namespace xAOD
......@@ -18,30 +18,32 @@ namespace xAOD {
const float eFexTauRoI_v1::s_tobEtScale = 100.;
const float eFexTauRoI_v1::s_xTobEtScale = 25.;
const float eFexTauRoI_v1::s_towerEtaWidth = 0.1;
const float eFexTauRoI_v1::s_minEta = -2.5;
eFexTauRoI_v1::eFexTauRoI_v1()
: SG::AuxElement() {
}
void eFexTauRoI_v1::initialize( uint8_t eFexNumber, uint8_t shelf, uint32_t word0, uint32_t word1 ) {
void eFexTauRoI_v1::initialize( unsigned int eFexNumber, unsigned int shelf, uint32_t word0 ) {
// xTOBs will have eFEX and Shelf numbers in word 1
// To save space, use the second word of this object, which is not part of a TOB, to store these values
uint32_t word1 = 0;
word1 |= (eFexNumber&s_eFexMask)<<s_eFexBit;
word1 |= (shelf&s_shelfMask)<<s_shelfBit;
setWord0( word0 );
setWord1( word1 );
seteFexNumber( eFexNumber );
setShelfNumber( shelf );
/** Quantities derived from TB data, stored for convenience */
/** Quantities derived from TOB data, stored for convenience */
setEt( etTOB()*s_tobEtScale );
float etaVal = s_minEta + iEta()*s_towerEtaWidth + (seed()+0.5)*s_towerEtaWidth/4;
float etaVal = iEta()*s_towerEtaWidth + (seed()+0.5)*s_towerEtaWidth/4;
setEta( etaVal );
float phiVal = iPhi() * M_PI/32. + M_PI/64.;
if (phiVal > M_PI) phiVal = phiVal - 2.*M_PI;
setPhi( phiVal );
/** If the object is a TOB then the isTOB should be true.
For xTOB default is false, but should be set if a matching TOB is found */
For xTOB default is false, but should be set by the user if a matching TOB is found */
if (type() == TOB) setIsTOB(1);
else setIsTOB(0);
......@@ -49,24 +51,44 @@ namespace xAOD {
}
void eFexTauRoI_v1::initialize( uint32_t word0, uint32_t word1 ) {
// xTOBs will have eFEX and Shelf numbers in word 1
// So all we need to do is set the TOB words
setWord0( word0 );
setWord1( word1 );
/** Quantities derived from TOB data, stored for convenience */
setEt( etTOB()*s_tobEtScale );
float etaVal = iEta()*s_towerEtaWidth + (seed()+0.5)*s_towerEtaWidth/4;
setEta( etaVal );
float phiVal = iPhi() * M_PI/32. + M_PI/64.;
if (phiVal > M_PI) phiVal = phiVal - 2.*M_PI;
setPhi( phiVal );
/** If the object is a TOB then the isTOB should be true.
For xTOB default is false, but should be set by the user if a matching TOB is found */
if (type() == TOB) setIsTOB(1);
else setIsTOB(0);
return;
}
/// Raw data words
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, uint32_t, word0,
setWord0 )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, uint32_t, word1,
setWord1 )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, uint8_t, eFexNumber,
seteFexNumber )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, uint8_t, shelfNumber,
setShelfNumber )
/// Only calculable externally
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, uint16_t, fCoreNumerator,
setFCoreNumerator )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, uint16_t, fCoreDenominator,
setFCoreDenominator )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, uint32_t, thrPattern,
setThrPattern )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, uint16_t, fHadNumerator,
setFHadNumerator )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, uint16_t, fHadDenominator,
setFHadDenominator )
/// Should be set for xTOB if there is a matching TOB
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( eFexTauRoI_v1, char, isTOB,
......@@ -83,6 +105,16 @@ namespace xAOD {
/// Methods to decode data from the TOB/RoI and return to the user
/// eFEX number
unsigned int eFexTauRoI_v1::eFexNumber() const {
return (word1() >> s_eFexBit) & s_eFexMask;
}
/// Shelf number
unsigned int eFexTauRoI_v1::shelfNumber() const {
return (word1() >> s_shelfBit) & s_shelfMask;
}
/// TOB or xTOB?
eFexTauRoI_v1::ObjectType eFexTauRoI_v1::type() const {
if (word1() == 0) return TOB;
......@@ -117,7 +149,7 @@ namespace xAOD {
/// Raw ET on TOB scale (100 MeV/count)
unsigned int eFexTauRoI_v1::etTOB() const {
// Data content = TOB
if (word1() == 0) {
if (etXTOB() == 0) {
return (word0() >> s_etBit) & s_etMask;
}
// Data Content = xTOB. Need to remove lower bits and cap range
......@@ -142,7 +174,7 @@ namespace xAOD {
return (word0() >> s_veto1Bit) & s_veto1Mask;
}
unsigned int eFexTauRoI_v1::tauTwoThresholds() const {
unsigned int eFexTauRoI_v1::fHadThresholds() const {
return (word0() >> s_veto2Bit) & s_veto2Mask;
}
......@@ -151,17 +183,13 @@ namespace xAOD {
}
unsigned int eFexTauRoI_v1::bcn4() const {
/// If the object is not an xTOB return 0
if (word1() == 0) return 0;
else {
return (word1() >> s_bcn4Bit) & s_bcn4Mask;
}
return (word1() >> s_bcn4Bit) & s_bcn4Mask;
}
/// Return single 32-bit TOB word from a TOB or xTOB
uint32_t eFexTauRoI_v1::tobWord() const {
// Do something sensible if called for a TOB
if (word1() == 0) return word0();
if (etXTOB() == 0) return word0();
// When called for xTOB
else {
uint32_t word = word0() + etTOB();
......@@ -180,7 +208,7 @@ namespace xAOD {
/// Methods that decode the eFEX number
/// Return phi index in the range 0-63
unsigned int eFexTauRoI_v1::iPhi() const {
int eFexTauRoI_v1::iPhi() const {
/// Calculate octant (0-7) from eFEX and shelf numbers
unsigned int octant = int(eFexNumber()/3) + shelfNumber()*s_shelfPhiWidth;
......@@ -192,17 +220,36 @@ namespace xAOD {
return index;
}
/// Return an eta index in the range 0-49
/// Note that this may not be the final format!
/// And you need to combine with the seed() value to get full eta precision
unsigned int eFexTauRoI_v1::iEta() const {
/// Return an eta index in the range -25 -> +24
/// Value corresponds to 10*lower eta edge of tower
/// Note that this may not be the final format!
/// And you need to combine with the seed() value to get full eta precision
int eFexTauRoI_v1::iEta() const {
/// With appropriate constants this should work in one line...
unsigned int index = (eFexNumber()%3)*s_eFexEtaWidth + fpga()*s_fpgaEtaWidth + fpgaEta();
/// With appropriate constants this should work in one line...
int index = s_minEta + (eFexNumber()%3)*s_eFexEtaWidth + fpga()*s_fpgaEtaWidth + fpgaEta();
/// Return value
return index;
}
/// Return phi index in the range used by L1Topo (0->127)
int eFexTauRoI_v1::iPhiTopo() const {
/// Topo use pi/64 steps. Ours are pi/32, so we simply return 2* our integer index
return iPhi()*2;
return index;
}
/// Return an eta index in the range used by L1Topo (-100->+99)
int eFexTauRoI_v1::iEtaTopo() const {
/// This returns e/g seed position as an integer index.
/// Value corresponds to 4*lower eta edge of supercell (so 0 means 0.0 -> 0.025)
return iEta()*4 + seed();
}
} // namespace xAOD
......@@ -37,10 +37,8 @@ namespace xAOD {
eFexEMRoIAuxContainer_v1();
private:
std::vector< uint32_t > Word0;
std::vector< uint32_t > Word1;
std::vector< uint8_t > eFexNumber;
std::vector< uint8_t > shelfNumber;
std::vector< uint32_t > word0;
std::vector< uint32_t > word1;
std::vector< uint16_t > RetaEnv;
std::vector< uint16_t > RetaCore;
std::vector< uint16_t > RhadHad;
......
......@@ -37,7 +37,10 @@ namespace xAOD {
eFexEMRoI_v1();
/// Initialise the object with its most important properties
void initialize( uint8_t eFexNumber, uint8_t shelf, uint32_t Word0, uint32_t Word1 = 0 );
/// TOB initialiser
void initialize( unsigned int eFexNumber, unsigned int shelf, uint32_t word0 );
/// xTOB initialiser
void initialize( uint32_t word0, uint32_t word1 );
/// Object types
enum ObjectType {
......@@ -46,22 +49,12 @@ namespace xAOD {
};
/// The "raw" 32-bit words describing the e/gamma candidate
uint32_t Word0() const;
uint32_t Word1() const;
uint32_t word0() const;
uint32_t word1() const;
/// Set the "raw" 32-bit words describing the e/gamma candidate
void setWord0( uint32_t value );
void setWord1( uint32_t value );
/// The eFEX number
uint8_t eFexNumber() const;
/// Set the eFEX number
void seteFexNumber( uint8_t value );
/// The shelf number
uint8_t shelfNumber() const;
/// Set the shelf number
void setShelfNumber( uint8_t value );
/// TOB ET (decoded from TOB, stored for convenience)
float et() const; /// floating point value (MeV, TOB scale)
void setEt( float value); /// setter for the above
......@@ -114,6 +107,11 @@ namespace xAOD {
/// Object type (TOB or xTOB)
ObjectType type() const;
// Shelf number
unsigned int shelfNumber() const;
// eFEX number
unsigned int eFexNumber() const;
/// FPGA number
unsigned int fpga() const;
......@@ -174,6 +172,8 @@ namespace xAOD {
static const int s_etBit = 0;
static const int s_etBitXTOB = 3;
static const int s_bcn4Bit = 28;
static const int s_shelfBit = 24;
static const int s_eFexBit = 20;
// Data masks
static const int s_fpgaMask = 0x3;
......@@ -188,6 +188,8 @@ namespace xAOD {
static const int s_etMask = 0xfff;
static const int s_etFullMask = 0xffff;
static const int s_bcn4Mask = 0xf;
static const int s_eFexMask = 0xf;
static const int s_shelfMask = 0xf;
// For decoding coordinates
//
static const int s_numPhi = 64;
......
......@@ -35,16 +35,15 @@ namespace xAOD {
private:
std::vector< uint32_t > word0;
std::vector< uint32_t > word1;
std::vector< uint8_t > eFexNumber;
std::vector< uint8_t > shelfNumber;
std::vector< uint16_t > fCoreNumerator;
std::vector< uint16_t > fCoreDenominator;
std::vector< uint16_t > fHadNumerator;
std::vector< uint16_t > fHadDenominator;
std::vector< float > et;
std::vector< float > eta;
std::vector< float > phi;
std::vector< char > isTOB;
std::vector< uint32_t > thrPattern;
}; // class eFexTauRoIAuxContainer_v1
......
......@@ -33,7 +33,8 @@ namespace xAOD {
eFexTauRoI_v1();
/// Initialise the object with its most important properties
void initialize( uint8_t eFexNumber, uint8_t shelf, uint32_t word0, uint32_t word1 = 0 );
void initialize( unsigned int eFexNumber, unsigned int shelf, uint32_t word0 );
void initialize( uint32_t word0, uint32_t word1 );
/// Object types
enum ObjectType {
......@@ -48,15 +49,11 @@ namespace xAOD {
void setWord0( uint32_t value );
void setWord1( uint32_t value );
/// The eFEX number
uint8_t eFexNumber() const;
/// Set the eFEX number
void seteFexNumber( uint8_t value );
// Shelf number (decoded from second xTOB word)
unsigned int shelfNumber() const;
/// The shelf number
uint8_t shelfNumber() const;
/// Set the shelf number
void setShelfNumber( uint8_t value );
// eFEX number (decoded from second xTOB word)
unsigned int eFexNumber() const;
/// TOB ET (decoded from TOB, stored for convenience)
float et() const; /// floating point value (MeV, TOB scale)
......@@ -65,14 +62,17 @@ namespace xAOD {
/// Eta Coordinates (decoded from TOB, stored for convenience)
float eta() const; /// Floating point, full precision (0.025)
void setEta( float value); /// setter for the above
unsigned int iEta() const; /// getter for integer eta index (0-49)
int iEta() const; /// getter for integer eta index (-25->24)
unsigned int seed() const; /// Seed supercell index within central tower (0 -> 3)
/// Phi coordinates
float phi() const; /// Floating point, ATLAS phi convention (-pi -> pi)
void setPhi( float value); /// Setter for the above
unsigned int iPhi() const; /// Getter for integer phi index (0-63)
int iPhi() const; /// Getter for integer phi index (0-63)
/// Getters for Topo coordinate indices
int iEtaTopo() const;
int iPhiTopo() const;
/// Jet Discriminants
/// Derived floating point values (not used in actual algorithm)
......@@ -83,15 +83,15 @@ namespace xAOD {
uint16_t fCoreDenominator() const;
void setFCoreNumerator( uint16_t value);
void setFCoreDenominator( uint16_t value);
uint16_t fHadNumerator() const;
uint16_t fHadDenominator() const;
void setFHadNumerator( uint16_t value);
void setFHadDenominator( uint16_t value);
/// Is this one a TOB (or xTOB partner of a TOB)?
char isTOB() const;
void setIsTOB( char value);
/// Pattern of thresholds passed
uint32_t thrPattern() const;
void setThrPattern( uint32_t value);
/// Return TOB word corresponding to this TOB or xTOB
uint32_t tobWord() const;
......@@ -124,7 +124,7 @@ namespace xAOD {
unsigned int fCoreThresholds() const;
/// Tau Condition 2 (none) results
unsigned int tauTwoThresholds() const;
unsigned int fHadThresholds() const;
/// Tau Condition 3 (none) results
unsigned int tauThreeThresholds() const;
......@@ -141,7 +141,6 @@ namespace xAOD {
static const float s_tobEtScale;
static const float s_xTobEtScale;
static const float s_towerEtaWidth;
static const float s_minEta;
/** Constants used in decoding TOB words
......@@ -162,6 +161,8 @@ namespace xAOD {
static const int s_etBit = 0;
static const int s_etBitXTOB = 3;
static const int s_bcn4Bit = 28;
static const int s_shelfBit = 24;
static const int s_eFexBit = 20;