Commit 1586833b authored by Alan Watson's avatar Alan Watson Committed by Marija Vranjes Milosavljevic
Browse files

Fixes to add eEM and eTAU xTOB production to the simulation

Fixes to add eEM and eTAU xTOB production to the simulation
parent a8485df8
......@@ -55,18 +55,17 @@ namespace LVL1 {
virtual void SetTowersAndCells_SG( int [][6] ) override ;
virtual void SetIsoWP(std::vector<unsigned int> &, std::vector<unsigned int> &, unsigned int &, unsigned int &) override ;
virtual std::vector <eFEXegTOB> getEmTOBs() override ;
virtual std::vector <eFEXtauTOB> getTauTOBs() override ;
virtual std::vector <std::unique_ptr<eFEXegTOB>> getEmTOBs() override ;
virtual std::vector <std::unique_ptr<eFEXtauTOB>> getTauTOBs() override ;
/** Internal data */
private:
const unsigned int m_eFexStep = 25;
template <class TOBObjectClass> static bool TOBetSort(const TOBObjectClass& i, const TOBObjectClass& j ) {return (((i.getTobword() >> 0 ) & 0xfff)>((j.getTobword() >> 0 ) & 0xfff)); }
int m_id;
int m_efexid;
std::vector< eFEXegTOB > m_emTobObjects;
std::vector< eFEXtauTOB > m_tauTobObjects;
std::vector< std::unique_ptr<eFEXegTOB> > m_emTobObjects;
std::vector< std::unique_ptr<eFEXtauTOB> > m_tauTobObjects;
int m_eTowersIDs [10][6];
SG::ReadHandleKey<TrigConf::L1Menu> m_l1MenuKey{
......
......@@ -47,9 +47,9 @@ namespace LVL1 {
virtual StatusCode execute() override;
/** Create and fill a new fillEmEDM object (corresponding to this window), and return a pointer to it */
virtual void fillEmEDM(std::unique_ptr<xAOD::eFexEMRoIContainer> &container, uint8_t eFEXNumber, const eFEXegTOB& tobObject) override;
virtual void fillEmEDM(std::unique_ptr<xAOD::eFexEMRoIContainer> &container, uint8_t eFEXNumber, const std::unique_ptr<eFEXegTOB> &tobObject, bool xTOB=false) override;
/** Create and fill a new fillTauEDM object (corresponding to this window), and return a pointer to it */
virtual void fillTauEDM(std::unique_ptr<xAOD::eFexTauRoIContainer> &container, uint8_t eFEXNumber, const eFEXtauTOB& tobObject) override;
virtual void fillTauEDM(std::unique_ptr<xAOD::eFexTauRoIContainer> &container, uint8_t eFEXNumber, const std::unique_ptr<eFEXtauTOB> &tobObject, bool xTOB=false) override;
/** Internal data */
private:
......
......@@ -33,13 +33,28 @@ namespace LVL1 {
virtual ~eFEXFormTOBs();
virtual uint32_t formTauTOBWord(int &, int &, int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &) override;
virtual std::vector<uint32_t> formTauxTOBWords(int &, int &, int &, int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &) override;
virtual uint32_t formEmTOBWord(int &, int &, int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &) override;
virtual uint32_t formEmTOBWord(int &, int &, int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &) override;
virtual std::vector<uint32_t> formEmxTOBWords(int &, int &, int &, int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &) override;
/** Internal data */
private:
const unsigned int m_eFexStep = 25;
const unsigned int m_eFexTobStep = 100;
const unsigned int m_tobETshift = 2;
const unsigned int m_fpgaShift = 30;
const unsigned int m_etaShift = 27;
const unsigned int m_phiShift = 24;
const unsigned int m_rhadShift = 22;
const unsigned int m_wstotShift = 20;
const unsigned int m_retaShift = 18;
const unsigned int m_seedShift = 16;
const unsigned int m_undShift = 15;
const unsigned int m_maxShift = 14;
const unsigned int m_shelfShift = 24;
const unsigned int m_efexShift = 20;
const unsigned int m_taurhadShift = 20;
const unsigned int m_taurcoreShift = 18;
};
} // end of namespace
......
......@@ -59,21 +59,19 @@ namespace LVL1 {
virtual StatusCode NewExecute(int tmp[10][18], eFEXOutputCollection* inputOutputCollection) override;
virtual std::vector<eFEXegTOB> getEmTOBs() override;
virtual std::vector<eFEXtauTOB> getTauTOBs() override;
virtual std::vector<std::unique_ptr<eFEXegTOB>> getEmTOBs() override;
virtual std::vector<std::unique_ptr<eFEXtauTOB>> getTauTOBs() override;
/** Internal data */
private:
template <class TOBObjectClass> static bool TOBetSort(const TOBObjectClass& i, const TOBObjectClass& j ) {return (((i.getTobword() >> 0 ) & 0xfff)>((j.getTobword() >> 0 ) & 0xfff)); }
int m_id;
int m_eTowersIDs [10][18];
//std::map<int,eTower> m_eTowersColl;
CaloCellContainer m_sCellsCollection;
std::vector<eFEXFPGA*> m_eFEXFPGACollection;
std::vector<std::vector<eFEXegTOB> > m_emTobObjects;
std::vector<std::vector<eFEXtauTOB> > m_tauTobObjects;
std::vector<std::vector<std::unique_ptr<eFEXegTOB>> > m_emTobObjects;
std::vector<std::vector<std::unique_ptr<eFEXtauTOB>> > m_tauTobObjects;
ToolHandle<IeFEXFPGA> m_eFEXFPGATool {this, "eFEXFPGATool", "LVL1::eFEXFPGA", "Tool that simulates the FPGA hardware"};
......
......@@ -67,11 +67,19 @@ namespace LVL1 {
/** Internal data */
private:
// TOB sorting function
template <class TOBObjectClass> static bool TOBetSort(const TOBObjectClass& i, const TOBObjectClass& j ) {return (((i->getTobword() >> 0 ) & 0xfff)>((j->getTobword() >> 0 ) & 0xfff)); }
// EM TOBs and xTOBS
std::unique_ptr< xAOD::eFexEMRoIContainer > m_eContainer;
std::unique_ptr< xAOD::eFexEMRoIAuxContainer > m_eAuxContainer;
std::unique_ptr< xAOD::eFexEMRoIContainer > m_xeContainer;
std::unique_ptr< xAOD::eFexEMRoIAuxContainer > m_xeAuxContainer;
// Tau TOBs and xTOBs
std::unique_ptr< xAOD::eFexTauRoIContainer > m_tauContainer;
std::unique_ptr< xAOD::eFexTauRoIAuxContainer > m_tauAuxContainer;
std::unique_ptr< xAOD::eFexTauRoIContainer > m_xtauContainer;
std::unique_ptr< xAOD::eFexTauRoIAuxContainer > m_xtauAuxContainer;
std::vector<eFEXSim*> m_eFEXCollection;
......@@ -81,16 +89,18 @@ namespace LVL1 {
SG::ReadHandleKey<LVL1::eTowerContainer> m_eTowerContainerSGKey {this, "MyETowers", "eTowerContainer", "Input container for eTowers"};
SG::WriteHandleKey< xAOD::eFexEMRoIContainer > m_eFexOutKey {this,"Key_eFexEMOutputContainer","L1_eEMRoI","Output eFexEM container"};
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauOutKey {this,"Key_eFexTauOutputContainer","L1_eTauRoI","Output eFexTau container"};
SG::WriteHandleKey< xAOD::eFexEMRoIContainer > m_eFexOutKey {this,"Key_eFexEMOutputContainer","L1_eEMRoI","Output eFexEM TOB container"};
SG::WriteHandleKey< xAOD::eFexEMRoIContainer > m_eFexEMxTOBOutKey {this,"Key_eFexEMxTOBOutputContainer","L1_eEMxRoI","Output eFexEM xTOB container"};
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauOutKey {this,"Key_eFexTauOutputContainer","L1_eTauRoI","Output eFexTau TOB container"};
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauxTOBOutKey {this,"Key_eFexTauxTOBOutputContainer","L1_eTauxRoI","Output eFexTau xTOB container"};
ToolHandle<IeFEXFPGATowerIdProvider> m_eFEXFPGATowerIdProviderTool {this, "eFEXFPGATowerIdProviderTool", "LVL1::eFEXFPGATowerIdProvider", "Tool that provides tower-FPGA mapping"};
ToolHandle<IeFEXFPGA> m_eFEXFPGATool {this, "eFEXFPGATool", "LVL1::eFEXFPGA", "Tool that simulates the FPGA hardware"};
//std::map<int,eTower> m_eTowersColl;
std::map<int, std::vector<eFEXegTOB> > m_allEmTobObjects;
std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> > m_allEmTobObjects;
std::map<int, std::vector<eFEXtauTOB> > m_allTauTobObjects;
std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> > m_allTauTobObjects;
};
......
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
//***************************************************************************
// eFEXTOBMatching - description
// ------------------------------
// Small utility function to identify xTOBs that correspond to TOBs
// begin : 12 08 2022
// email : Alan.Watson@CERN.CH
// ***************************************************************************/
#include <set>
namespace LVL1 {
template <typename T> void matchTOBs(T& TOBs, T& xTOBs) {
// Use a std::set of TOB coordinate fields to match TOBs and xTOBs
std::set<uint32_t> tobCoords;
// Fill maps with coordinates of TOBs
for (auto t : *TOBs) {
uint32_t coord = t->word0()>>16;
tobCoords.insert(coord);
}
// Set isTOB flag for xTOBs whose coordinate fields match a TOB
for (auto t : *xTOBs) {
uint32_t coord = t->word0()>>16;
if (tobCoords.find(coord) != tobCoords.end()) t->setIsTOB(1);
}
}
} // end of namespace bracket
......@@ -56,6 +56,7 @@ namespace LVL1 {
virtual void getWindowET(int layer, int jPhi, int SCID, unsigned int &) override;
virtual bool hasSeed() override {return m_hasSeed;};
virtual unsigned int getSeed() override {return m_seedID;};
virtual unsigned int getUnD() override {return m_seed_UnD;};
virtual void getCoreEMTowerET(unsigned int & et) override;
virtual void getCoreHADTowerET(unsigned int & et) override;
private:
......
......@@ -34,6 +34,8 @@ namespace LVL1 {
bool m_seed_UnD;
unsigned int m_seed;
uint32_t m_tobword;
uint32_t m_xtobword0;
uint32_t m_xtobword1;
public:
eFEXegTOB();
......@@ -55,21 +57,25 @@ namespace LVL1 {
inline unsigned int getWstotNum() const {return m_Wstot_Num;}
inline unsigned int getWstotDen() const {return m_Wstot_Den;}
inline uint32_t getTobword() const {return m_tobword;}
inline uint32_t getxTobword0() const {return m_xtobword0;}
inline uint32_t getxTobword1() const {return m_xtobword1;}
unsigned int setEta(unsigned int);
unsigned int setPhi(unsigned int);
unsigned int setET(unsigned int);
unsigned int setFPGAID(unsigned int);
unsigned int seteFEXID(unsigned int);
bool setSeedUnD(bool);
unsigned int setSeed(unsigned int);
unsigned int setRetaCore(unsigned int);
unsigned int setRetaEnv(unsigned int);
unsigned int setRhadEM(unsigned int);
unsigned int setRhadHad(unsigned int);
unsigned int setWstotNum(unsigned int);
unsigned int setWstotDen(unsigned int);
uint32_t setTobword(uint32_t);
void setEta(unsigned int);
void setPhi(unsigned int);
void setET(unsigned int);
void setFPGAID(unsigned int);
void seteFEXID(unsigned int);
void setSeedUnD(bool);
void setSeed(unsigned int);
void setRetaCore(unsigned int);
void setRetaEnv(unsigned int);
void setRhadEM(unsigned int);
void setRhadHad(unsigned int);
void setWstotNum(unsigned int);
void setWstotDen(unsigned int);
void setTobword(uint32_t);
void setxTobword0(uint32_t);
void setxTobword1(uint32_t);
};
} // end of namespace
......
......@@ -34,6 +34,8 @@ namespace LVL1 {
bool m_seed_und;
unsigned int m_seed;
uint32_t m_tobword;
uint32_t m_xtobword0;
uint32_t m_xtobword1;
public:
eFEXtauTOB();
......@@ -45,7 +47,7 @@ namespace LVL1 {
inline unsigned int getBitwiseEt() const {return m_bitwise_et;}
inline float getIso() const {return m_iso;}
inline unsigned int getFPGAID() const {return m_fpga_id;}
inline unsigned int getEFEXID() const {return m_efex_id;}
inline unsigned int geteFEXID() const {return m_efex_id;}
// if seed is above (higher phi) central supercell of the seed
inline bool getSeedUnD() const {return m_seed_und;}
// seed index in eta
......@@ -55,21 +57,25 @@ namespace LVL1 {
inline unsigned int getRhadCore() const {return m_rhad_core;}
inline unsigned int getRhadEnv() const {return m_rhad_env;}
inline uint32_t getTobword() const {return m_tobword;}
inline uint32_t getxTobword0() const {return m_xtobword0;}
inline uint32_t getxTobword1() const {return m_xtobword1;}
unsigned int setEta(unsigned int);
unsigned int setPhi(unsigned int);
unsigned int setEt(unsigned int);
unsigned int setBitwiseEt(unsigned int);
float setIso(unsigned int);
unsigned int setFPGAID(unsigned int);
unsigned int seteFEXID(unsigned int);
bool setSeedUnD(bool);
unsigned int setSeed(unsigned int);
unsigned int setRcoreCore(unsigned int);
unsigned int setRcoreEnv(unsigned int);
unsigned int setRhadCore(unsigned int);
unsigned int setRhadEnv(unsigned int);
uint32_t setTobword(uint32_t);
void setEta(unsigned int);
void setPhi(unsigned int);
void setEt(unsigned int);
void setBitwiseEt(unsigned int);
void setIso(unsigned int);
void setFPGAID(unsigned int);
void seteFEXID(unsigned int);
void setSeedUnD(bool);
void setSeed(unsigned int);
void setRcoreCore(unsigned int);
void setRcoreEnv(unsigned int);
void setRhadCore(unsigned int);
void setRhadEnv(unsigned int);
void setTobword(uint32_t);
void setxTobword0(uint32_t);
void setxTobword1(uint32_t);
};
} // end of namespace
......
......@@ -129,13 +129,14 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
ieta < 5 ? m_eTowersIDs[iphi+1][ieta+1] : 0},
};
ATH_CHECK( m_eFEXegAlgoTool->safetyTest() );
m_eFEXegAlgoTool->setup(tobtable, m_efexid, m_id, ieta);
// ignore any tobs without a seed, move on to the next window
if (m_eFEXegAlgoTool->hasSeed() == false) continue;
unsigned int seed = 0;
seed = m_eFEXegAlgoTool->getSeed();
unsigned int seed = m_eFEXegAlgoTool->getSeed();
unsigned int und = (m_eFEXegAlgoTool->getUnD() ? 1 : 0);
// the minimum energy to send to topo (not eta dependent yet, but keep inside loop as it will be eventually?)
unsigned int ptMinToTopoCounts = 0;
......@@ -201,8 +202,9 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
int eta_ind = ieta; // No need to offset eta index with new 0-5 convention
int phi_ind = iphi - 1;
//form the egamma tob word
uint32_t tobword = m_eFEXFormTOBsTool->formEmTOBWord(m_id,eta_ind,phi_ind,RhadWP,WstotWP,RetaWP,seed,eEMTobEt,ptMinToTopoCounts);
//form the egamma tob word and xTOB words
uint32_t tobword = m_eFEXFormTOBsTool->formEmTOBWord(m_id,eta_ind,phi_ind,RhadWP,WstotWP,RetaWP,seed,und,eEMTobEt,ptMinToTopoCounts);
std::vector<uint32_t> xtobwords = m_eFEXFormTOBsTool->formEmxTOBWords(m_efexid,m_id,eta_ind,phi_ind,RhadWP,WstotWP,RetaWP,seed,und,eEMTobEt,ptMinToTopoCounts);
std::unique_ptr<eFEXegTOB> tmp_tob = m_eFEXegAlgoTool->geteFEXegTOB();
......@@ -211,10 +213,11 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
tmp_tob->setEta(ieta);
tmp_tob->setPhi(iphi);
tmp_tob->setTobword(tobword);
if ( (tobword != 0) && (eEMTobEt != 0) ) m_emTobObjects.push_back(*tmp_tob);
tmp_tob->setxTobword0(xtobwords[0]);
tmp_tob->setxTobword1(xtobwords[1]);
// for plotting
if (inputOutputCollection->getdooutput()) {
if (inputOutputCollection->getdooutput() && (tobword != 0) && (eEMTobEt != 0)) {
inputOutputCollection->addeFexNumber(m_efexid);
inputOutputCollection->addEMtob(tobword);
inputOutputCollection->addValue_eg("WstotNum", tmp_tob->getWstotNum());
......@@ -240,6 +243,10 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
inputOutputCollection->fill_eg();
}
// Now we've finished with that object we can move it into the class results store
if ( (tobword != 0) && (eEMTobEt != 0) ) m_emTobObjects.push_back(std::move(tmp_tob));
}
}
......@@ -320,22 +327,23 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
// Seed as returned is supercell value within 3x3 area, here want it within central cell
seed = seed - 4;
unsigned int und = 0;
und = m_eFEXtauAlgoTool->getUnD();
unsigned int und = (m_eFEXtauAlgoTool->getUnD() ? 1 : 0);
int eta_ind = ieta; // No need to offset eta index with new 0-5 convention
int phi_ind = iphi - 1;
// Form the tau tob word
// Form the tau TOB word and xTOB words
uint32_t tobword = m_eFEXFormTOBsTool->formTauTOBWord(m_id, eta_ind, phi_ind, eTauTobEt, rHadWP, rCoreWP, seed, und, ptTauMinToTopoCounts);
std::vector<uint32_t> xtobwords = m_eFEXFormTOBsTool->formTauxTOBWords(m_efexid, m_id, eta_ind, phi_ind, eTauTobEt, rHadWP, rCoreWP, seed, und, ptTauMinToTopoCounts);
std::unique_ptr<eFEXtauTOB> tmp_tau_tob = m_eFEXtauAlgoTool->getTauTOB();
tmp_tau_tob->setFPGAID(m_id);
tmp_tau_tob->seteFEXID(m_efexid);
tmp_tau_tob->setEta(ieta);
tmp_tau_tob->setPhi(iphi);
tmp_tau_tob->setTobword(tobword);
if ( tobword != 0 ) m_tauTobObjects.push_back(*tmp_tau_tob);
tmp_tau_tob->setxTobword0(xtobwords[0]);
tmp_tau_tob->setxTobword1(xtobwords[1]);
// for plotting
if ((inputOutputCollection->getdooutput()) && ( tobword != 0 )) {
......@@ -367,6 +375,9 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
inputOutputCollection->fill_tau();
}
// Now we've finished with that object we can move it into the class results store
if ( tobword != 0 ) m_tauTobObjects.push_back(std::move(tmp_tau_tob));
}
}
......@@ -376,8 +387,11 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
std::vector<eFEXegTOB> eFEXFPGA::getEmTOBs()
std::vector<std::unique_ptr<eFEXegTOB>> eFEXFPGA::getEmTOBs()
{
// TOB sorting moved to eFEXSysSim to simplify xTOB production
// But leave this here in case more subtle requirement is uncovered in future
/*
auto tobsSort = m_emTobObjects;
ATH_MSG_DEBUG("number of tobs: " <<tobsSort.size() << " in FPGA: " << m_id << " before truncation");
......@@ -388,11 +402,28 @@ std::vector<eFEXegTOB> eFEXFPGA::getEmTOBs()
// return the top 6 highest ET TOBs from the FPGA
if (tobsSort.size() > 6) tobsSort.resize(6);
return tobsSort;
*/
/* Returning a vector of unique_pointers means this class will lose ownership.
This shouldn't be an issue since all this class does is create and return the
objects, but you should bear it in mind if you make changes */
// This copy seems to be needed - it won't let me pass m_emTobOjects directly (to do with being a class member?)
std::vector<std::unique_ptr<eFEXegTOB>> tobsSort;
tobsSort.clear();
for(auto &j : m_emTobObjects){
tobsSort.push_back(std::move(j));
}
return tobsSort;
}
std::vector<eFEXtauTOB> eFEXFPGA::getTauTOBs()
std::vector<std::unique_ptr<eFEXtauTOB>> eFEXFPGA::getTauTOBs()
{
// TOB sorting moved to eFEXSysSim to simplify xTOB production
// But leave this here in case more subtle requirement is uncovered in future
/*
auto tobsSort = m_tauTobObjects;
ATH_MSG_DEBUG("number of tobs: " <<tobsSort.size() << " in FPGA: " << m_id << " before truncation");
......@@ -403,6 +434,20 @@ std::vector<eFEXtauTOB> eFEXFPGA::getTauTOBs()
// return the top 6 highest ET TOBs from the FPGA
if (tobsSort.size() > 6) tobsSort.resize(6);
return tobsSort;
*/
/* Returning a vector of unique_pointers means this class will lose ownership.
This shouldn't be an issue since all this class does is create and return the
objects, but you should bear it in mind if you make changes */
// This copy seems to be needed - it won't let me pass m_tauTobOjects directly (to do with being a class member?)
std::vector<std::unique_ptr<eFEXtauTOB>> tobsSort;
tobsSort.clear();
for(auto &j : m_tauTobObjects){
tobsSort.push_back(std::move(j));
}
return tobsSort;
}
......
......@@ -42,58 +42,60 @@ namespace LVL1 {
return StatusCode::SUCCESS;
}
void eFEXFillEDM::fillEmEDM(std::unique_ptr<xAOD::eFexEMRoIContainer> &container, uint8_t eFexNum, const eFEXegTOB& tobObject)
{
uint32_t tobWord0 = tobObject.getTobword();
// Only needed for xTOBs, which aren't filled yet
// uint32_t tobWord1 = 0;
// Translate eFEX index into Shelf+eFEX:
uint8_t shelf = int(eFexNum/12);
uint8_t eFEX = eFexNum%12;
// Now create the object and fill it
xAOD::eFexEMRoI* myEmEDM = new xAOD::eFexEMRoI();
void eFEXFillEDM::fillEmEDM(std::unique_ptr<xAOD::eFexEMRoIContainer> &container, uint8_t eFexNum, const std::unique_ptr<eFEXegTOB>& tobObject, bool xTOB)
{
// Create the object and fill it
xAOD::eFexEMRoI* myEmEDM = new xAOD::eFexEMRoI();
container->push_back(myEmEDM);
myEmEDM->initialize(eFEX, shelf, tobWord0);
myEmEDM->setRetaCore(tobObject.getRetaCore());
myEmEDM->setRetaEnv(tobObject.getRetaEnv());
myEmEDM->setRhadEM(tobObject.getRhadEM());
myEmEDM->setRhadHad(tobObject.getRhadHad());
myEmEDM->setWstotNumerator(tobObject.getWstotNum());
myEmEDM->setWstotDenominator(tobObject.getWstotDen());
ATH_MSG_DEBUG(" setting eFEX Number: " << +myEmEDM->eFexNumber() << " shelf: " << +myEmEDM->shelfNumber() << " et: " << myEmEDM->et() << " eta: " << myEmEDM->eta() << " phi: " << myEmEDM->phi() << " input eFexNum: " << +eFexNum << " TOB word: " << tobWord0 << MSG::dec );
// Initialise either xTOB or TOB object as requested
if (xTOB)
myEmEDM->initialize(tobObject->getxTobword0(), tobObject->getxTobword1());
else {
// For TOB we must translate eFEX index into Shelf+eFEX and add these when initialising
uint8_t shelf = int(eFexNum/12);
uint8_t eFEX = eFexNum%12;
myEmEDM->initialize(eFEX, shelf, tobObject->getTobword());
}
// Supplementary information is the same either way
myEmEDM->setRetaCore(tobObject->getRetaCore());
myEmEDM->setRetaEnv(tobObject->getRetaEnv());
myEmEDM->setRhadEM(tobObject->getRhadEM());
myEmEDM->setRhadHad(tobObject->getRhadHad());
myEmEDM->setWstotNumerator(tobObject->getWstotNum());
myEmEDM->setWstotDenominator(tobObject->getWstotDen());
ATH_MSG_DEBUG(" setting Type: " << myEmEDM->type() << " eFEX Number: " << +myEmEDM->eFexNumber() << " shelf: " << +myEmEDM->shelfNumber() << " et: " << myEmEDM->et() << " MeV, " << myEmEDM->etTOB() << " TOB, " << myEmEDM->etXTOB() << " xTOB, eta: " << myEmEDM->eta() << " phi: " << myEmEDM->phi() << " input eFexNum: " << +eFexNum << " TOB word: " << tobObject->getTobword() << MSG::dec );
}
void eFEXFillEDM::fillTauEDM(std::unique_ptr<xAOD::eFexTauRoIContainer> &container, uint8_t eFexNum, const eFEXtauTOB& tobObject)
void eFEXFillEDM::fillTauEDM(std::unique_ptr<xAOD::eFexTauRoIContainer> &container, uint8_t eFexNum, const std::unique_ptr<eFEXtauTOB>& tobObject, bool xTOB)
{
uint32_t tobWord0 = tobObject.getTobword();
// Only needed for xTOBs, which aren't filled yet
// uint32_t tobWord1 = 0;
// Translate eFEX index into Shelf+eFEX:
uint8_t shelf = int(eFexNum/12);
uint8_t eFEX = eFexNum%12;
// Create the object and fill it:
xAOD::eFexTauRoI* myTauEDM = new xAOD::eFexTauRoI();
container->push_back(myTauEDM);
myTauEDM->initialize(eFEX, shelf, tobWord0);
// Initialise either xTOB or TOB object as requested
if (xTOB)
myTauEDM->initialize(tobObject->getxTobword0(), tobObject->getxTobword1());
else {
// For TOB we must translate eFEX index into Shelf+eFEX and add these when initialising
uint8_t shelf = int(eFexNum/12);
uint8_t eFEX = eFexNum%12;
myTauEDM->initialize(eFEX, shelf, tobObject->getTobword());
}
// There is some ambiguity in what 'numerator'/'denominator' mean in each of the tau isolation
// variables rCore and rHad below, since in the more 'physical' definition, we would consider core/(core+env),
// whereas in the firmware we calculate core/env. Here, I store core->numerator, env->denominator.
// Provided we remember this when using them, we can then calculate either the 'physical' or the 'firmware' values.
myTauEDM->setRCoreNumerator(tobObject.getRcoreCore());
myTauEDM->setRCoreDenominator(tobObject.getRcoreEnv());
myTauEDM->setRHadNumerator(tobObject.getRhadCore());
myTauEDM->setRHadDenominator(tobObject.getRhadEnv());
ATH_MSG_DEBUG(" setting tau eFEX Number: " << +myTauEDM->eFexNumber() << " shelf: " << +myTauEDM->shelfNumber() << " et: " << myTauEDM->et() << " eta: " << myTauEDM->eta() << " phi: " << myTauEDM->phi() << " input eFexNum: " << +eFexNum << " TOB word: " << tobWord0 << MSG::dec);
myTauEDM->setRCoreNumerator(tobObject->getRcoreCore());
myTauEDM->setRCoreDenominator(tobObject->getRcoreEnv());
myTauEDM->setRHadNumerator(tobObject->getRhadCore());
myTauEDM->setRHadDenominator(tobObject->getRhadEnv());
ATH_MSG_DEBUG(" setting tau eFEX Number: " << +myTauEDM->eFexNumber() << " shelf: " << +myTauEDM->shelfNumber() << " et: " << myTauEDM->et() << " eta: " << myTauEDM->eta() << " phi: " << myTauEDM->phi() << " input eFexNum: " << +eFexNum << " TOB word: " << tobObject->getTobword() << MSG::dec);
}
......
......@@ -37,43 +37,96 @@ uint32_t eFEXFormTOBs::formTauTOBWord(int & fpga, int & eta, int & phi, unsigned
uint32_t tobWord = 0;
//rescale from eFEX scale (25 MeV) to TOB scale (100 MeV)
unsigned int etTob = 0;
etTob = et*m_eFexStep/m_eFexTobStep;
// Do this using a bit shift to keep this 100% integer
unsigned int etTob = (et>>m_tobETshift);
// If ET < minimum value return empty TOB
if (etTob < ptMinTopo) return tobWord;
// Truncate at 12 bits, set to max value of 4095, 0xfff, or 111111111111
if (etTob > 0xfff) etTob = 0xfff;