Commit 2dd5f689 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'ExpandeFEXTau' into 'master'

Expand  eFEX tau

See merge request atlas/athena!46592
parents d18a1d7a 6a07b08d
......@@ -32,7 +32,7 @@ namespace LVL1 {
/** Destructor */
virtual ~eFEXFormTOBs();
virtual uint32_t formTauTOBWord(int &, int &, int &, unsigned int &) override;
virtual uint32_t formTauTOBWord(int &, int &, 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;
......
......@@ -76,7 +76,12 @@ private:
std::vector<float> m_eg_RhadDen;
// values from the tau algorithm
std::vector<float> m_tau_Iso;
std::vector<float> m_tau_realIso;
std::vector<float> m_tau_isoCore;
std::vector<float> m_tau_isoEnv;
std::vector<float> m_tau_isoWP;
std::vector<float> m_tau_seed;
std::vector<float> m_tau_und;
std::vector<float> m_tau_Et;
std::vector<float> m_tau_Eta;
std::vector<float> m_tau_Phi;
......
......@@ -48,7 +48,8 @@ namespace LVL1 {
virtual bool isCentralTowerSeed() override;
virtual eFEXtauTOB* getTauTOB() override;
virtual float getIso() override;
virtual void getRCore(std::vector<unsigned int> & rCoreVec) override;
virtual float getRealIso() override;
virtual unsigned int getEt() override;
virtual unsigned int getBitwiseEt() override;
......@@ -61,6 +62,7 @@ namespace LVL1 {
void setSupercellSeed();
void setUnDAndOffPhi();
bool getUnD();
unsigned int getSeed();
unsigned int m_em0cells[3][3];
unsigned int m_em1cells[12][3];
......
......@@ -98,6 +98,7 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
ATH_CHECK(l1Menu.isValid());
auto & thr_eEM = l1Menu->thrExtraInfo().eEM();
auto & thr_eTAU = l1Menu->thrExtraInfo().eTAU();
for(int ieta = 1; ieta < 5; ieta++) {
for(int iphi = 1; iphi < 9; iphi++) {
......@@ -212,7 +213,6 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
}
}
// --------------- TAU -------------
for(int ieta = 1; ieta < 5; ieta++)
{
......@@ -229,14 +229,53 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
if (!m_eFEXtauAlgoTool->isCentralTowerSeed()){ continue; }
// the minimum energy to send to topo (not eta dependent yet, but keep inside loop as it will be eventually?)
unsigned int ptTauMinToTopoCounts = 0;
ptTauMinToTopoCounts = thr_eTAU.ptMinToTopoCounts();
// Get Et of eFEX tau object in internal units (25 MeV)
unsigned int eTauTobEt = 0;
eTauTobEt = m_eFEXtauAlgoTool->getEt();
// thresholds from Trigger menu
auto iso_loose = thr_eTAU.isolation(TrigConf::Selection::WP::LOOSE, ieta);
auto iso_medium = thr_eTAU.isolation(TrigConf::Selection::WP::MEDIUM, ieta);
auto iso_tight = thr_eTAU.isolation(TrigConf::Selection::WP::TIGHT, ieta);
std::vector<unsigned int> threshRCore;
threshRCore.push_back(iso_loose.rCore_fw());
threshRCore.push_back(iso_medium.rCore_fw());
threshRCore.push_back(iso_tight.rCore_fw());
// Get isolation values
std::vector<unsigned int> rCoreVec;
m_eFEXtauAlgoTool->getRCore(rCoreVec);
// Set isolation WP
unsigned int rCoreWP = 0;
// Isolation bitshift value
unsigned int RcoreBitS = 3;
SetIsoWP(rCoreVec,threshRCore,rCoreWP,RcoreBitS);
// Currently only one WP defined for tau iso, decided to set as Medium WP for freedom to add looser and tighter WPs in the future
if (rCoreWP > 2) {
rCoreWP = 1;
}
unsigned int seed = 0;
seed = m_eFEXtauAlgoTool->getSeed();
// 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();
int eta_ind = ieta; // No need to offset eta index with new 0-5 convention
int phi_ind = iphi - 1;
uint32_t tobword = m_eFEXFormTOBsTool->formTauTOBWord(m_id, eta_ind, phi_ind, eTauTobEt);
uint32_t tobword = m_eFEXFormTOBsTool->formTauTOBWord(m_id, eta_ind, phi_ind, eTauTobEt, rCoreWP, seed, und, ptTauMinToTopoCounts);
if ( tobword != 0 ) m_tauTobwords.push_back(tobword);
// for plotting
......@@ -248,7 +287,12 @@ StatusCode eFEXFPGA::execute(eFEXOutputCollection* inputOutputCollection){
const LVL1::eTower * centerTower = jk_eFEXFPGA_eTowerContainer->findTower(m_eTowersIDs[iphi][ieta]);
inputOutputCollection->addValue_tau("FloatEta", centerTower->eta() * centerTower->getPosNeg());
inputOutputCollection->addValue_tau("FloatPhi", centerTower->phi());
inputOutputCollection->addValue_tau("Iso", m_eFEXtauAlgoTool->getIso());
inputOutputCollection->addValue_tau("IsoCore", rCoreVec[0]);
inputOutputCollection->addValue_tau("IsoEnv", rCoreVec[1]);
inputOutputCollection->addValue_tau("RealIso", m_eFEXtauAlgoTool->getRealIso());
inputOutputCollection->addValue_tau("IsoWP", rCoreWP);
inputOutputCollection->addValue_tau("Seed", seed);
inputOutputCollection->addValue_tau("UnD", und);
inputOutputCollection->fill_tau();
}
......
......@@ -31,8 +31,9 @@ StatusCode eFEXFormTOBs::initialize()
return StatusCode::SUCCESS;
}
uint32_t eFEXFormTOBs::formTauTOBWord(int & fpga, int & eta, int & phi, unsigned int & et)
uint32_t eFEXFormTOBs::formTauTOBWord(int & fpga, int & eta, int & phi, unsigned int & et, unsigned int & iso, unsigned int & seed, unsigned int & und, unsigned int & ptMinTopo)
{
uint32_t tobWord = 0;
//rescale from 25 MeV eFEX steps to 100 MeV for the TOB
......@@ -43,12 +44,11 @@ uint32_t eFEXFormTOBs::formTauTOBWord(int & fpga, int & eta, int & phi, unsigned
if (etTob > 0xfff) etTob = 0xfff;
// Create bare minimum tob word with et, eta, phi, and fpga index, bitshifted to the appropriate locations
tobWord = tobWord + (fpga << 30) + (eta << 27) + (phi << 24) + etTob;
tobWord = tobWord + (fpga << 30) + (eta << 27) + (phi << 24) + (iso << 18) + (seed << 16) + (und << 15) + etTob;
ATH_MSG_DEBUG("Tau tobword: " << std::bitset<32>(tobWord) );
// Some arbitrary cut so that we're not flooded with tobs, to be taken from the Trigger menu in the future!
unsigned int minEtThreshold = 30;
unsigned int minEtThreshold = ptMinTopo;
if (etTob < minEtThreshold) return 0;
else return tobWord;
}
......
......@@ -63,7 +63,12 @@ StatusCode LVL1::eFEXNtupleWriter::initialize () {
m_myTree->Branch ("eg_rhadnum", &m_eg_RhadNum);
m_myTree->Branch ("eg_rhadden", &m_eg_RhadDen);
m_myTree->Branch ("eg_haveSeed", &m_eg_haveseed);
m_myTree->Branch ("tau_Iso", &m_tau_Iso);
m_myTree->Branch ("tau_RealIso", &m_tau_realIso);
m_myTree->Branch ("tau_IsoCore", &m_tau_isoCore);
m_myTree->Branch ("tau_IsoEnv", &m_tau_isoEnv);
m_myTree->Branch ("tau_IsoWP", &m_tau_isoWP);
m_myTree->Branch ("tau_Seed", &m_tau_seed);
m_myTree->Branch ("tau_UnD", &m_tau_und);
m_myTree->Branch ("tau_Et", &m_tau_Et);
m_myTree->Branch ("tau_Eta", &m_tau_Eta);
m_myTree->Branch ("tau_Phi", &m_tau_Phi);
......@@ -117,7 +122,12 @@ StatusCode LVL1::eFEXNtupleWriter::finalize () {
}
StatusCode LVL1::eFEXNtupleWriter::loadtauAlgoVariables(SG::ReadHandle<LVL1::eFEXOutputCollection> eFEXOutputCollectionobj) {
m_tau_Iso.clear();
m_tau_realIso.clear();
m_tau_isoCore.clear();
m_tau_isoEnv.clear();
m_tau_isoWP.clear();
m_tau_seed.clear();
m_tau_und.clear();
m_tau_Et.clear();
m_tau_Eta.clear();
m_tau_Phi.clear();
......@@ -132,7 +142,12 @@ StatusCode LVL1::eFEXNtupleWriter::loadtauAlgoVariables(SG::ReadHandle<LVL1::eFE
m_tau_Phi.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["Phi"]);
m_tau_floatEta.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["FloatEta"]);
m_tau_floatPhi.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["FloatPhi"]);
m_tau_Iso.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["Iso"]);
m_tau_realIso.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["RealIso"]);
m_tau_isoCore.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["IsoCore"]);
m_tau_isoEnv.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["IsoEnv"]);
m_tau_isoWP.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["IsoWP"]);
m_tau_seed.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["Seed"]);
m_tau_und.push_back((*(eFEXOutputCollectionobj->get_tau(i)))["UnD"]);
}
return StatusCode::SUCCESS;
}
......
......@@ -63,7 +63,7 @@ LVL1::eFEXtauTOB *LVL1::eFEXtauAlgo::getTauTOB()
unsigned int et = getEt();
tob->setEt(et);
tob->setBitwiseEt(getBitwiseEt());
tob->setIso(getIso());
tob->setIso(getRealIso());
tob->setSeedUnD(getUnD());
return tob;
}
......@@ -75,23 +75,22 @@ void LVL1::eFEXtauAlgo::buildLayers()
SG::ReadHandle<eTowerContainer> jk_eFEXtauAlgo_eTowerContainer(m_eFEXtauAlgo_eTowerContainerKey/*,ctx*/);
for(unsigned int ieta = 0; ieta < 3; ieta++)
{
for(unsigned int iphi = 0; iphi < 3; iphi++)
{
for(unsigned int iphi = 0; iphi < 3; iphi++)
{
const LVL1::eTower * tmpTower = jk_eFEXtauAlgo_eTowerContainer->findTower(m_eFexalgoTowerID[iphi][ieta]);
m_twrcells[ieta][iphi] = tmpTower->getTotalET();
m_em0cells[ieta][iphi] = tmpTower->getLayerTotalET(0);
m_em3cells[ieta][iphi] = tmpTower->getLayerTotalET(3);
m_hadcells[ieta][iphi] = tmpTower->getLayerTotalET(4);
for(unsigned int i = 0; i < 4; i++)
{
m_em1cells[4 * ieta + i][iphi] = tmpTower->getET(1, i);
m_em2cells[4 * ieta + i][iphi] = tmpTower->getET(2, i);
}
}
{
m_em1cells[4 * ieta + i][iphi] = tmpTower->getET(1, i);
m_em2cells[4 * ieta + i][iphi] = tmpTower->getET(2, i);
}
}
}
m_cellsSet = true;
}
// Check if central tower qualifies as a seed tower for the tau algorithm
......@@ -107,8 +106,8 @@ bool LVL1::eFEXtauAlgo::isCentralTowerSeed()
// Get central tower ET
unsigned int centralET = m_twrcells[1][1];
// Enforce minimum of 1 GeV in central tower
if (centralET < 1000.){
// Enforce minimum of 1 GeV in central tower = 40 in 25 MeV increments
if (centralET < 40){
out = false;
}
......@@ -124,11 +123,12 @@ bool LVL1::eFEXtauAlgo::isCentralTowerSeed()
// Cells to the up and right must have strictly lesser ET
if (((beta == 0) && (bphi == 0)) || ((beta == 1) && (bphi == 0)) || ((beta == 2) && (bphi == 0)) || ((beta == 2) && (bphi == 1)))
{
if (centralET <= m_twrcells[beta][bphi]){
out = false;
}
}
{
if (centralET <= m_twrcells[beta][bphi])
{
out = false;
}
}
}
}
......@@ -190,8 +190,43 @@ unsigned int LVL1::eFEXtauAlgo::getEt()
return out;
}
// Calculate isolation variable
float LVL1::eFEXtauAlgo::getIso()
void LVL1::eFEXtauAlgo::getRCore(std::vector<unsigned int> & rCoreVec)
{
if (m_cellsSet == false){
ATH_MSG_DEBUG("Layers not built, cannot calculate isolation.");
}
unsigned int core = 0;
core += m_em2cells[m_seed][1];
core += m_em2cells[m_seed + 1][1];
core += m_em2cells[m_seed - 1][1];
core += m_em2cells[m_seed][m_offPhi];
core += m_em2cells[m_seed + 1][m_offPhi];
core += m_em2cells[m_seed - 1][m_offPhi];
unsigned int env = 0;
env += m_em2cells[m_seed + 2][1];
env += m_em2cells[m_seed - 2][1];
env += m_em2cells[m_seed + 3][1];
env += m_em2cells[m_seed - 3][1];
env += m_em2cells[m_seed + 4][1];
env += m_em2cells[m_seed - 4][1];
env += m_em2cells[m_seed + 2][m_offPhi];
env += m_em2cells[m_seed - 2][m_offPhi];
env += m_em2cells[m_seed + 3][m_offPhi];
env += m_em2cells[m_seed - 3][m_offPhi];
env += m_em2cells[m_seed + 4][m_offPhi];
env += m_em2cells[m_seed - 4][m_offPhi];
rCoreVec.push_back(core);
rCoreVec.push_back(env);
}
// Calculate float isolation variable
float LVL1::eFEXtauAlgo::getRealIso()
{
if (m_cellsSet == false){
ATH_MSG_DEBUG("Layers not built, cannot accurately calculate isolation.");
......@@ -221,7 +256,7 @@ float LVL1::eFEXtauAlgo::getIso()
isoOuter += m_em2cells[m_seed + 4][m_offPhi];
isoOuter += m_em2cells[m_seed - 4][m_offPhi];
float out = isoOuter ? (float)isoInner / (float)isoOuter : (float)isoInner;
float out = isoOuter ? (float)isoInner / (float)isoOuter : 0;
return out;
}
......@@ -279,3 +314,7 @@ bool LVL1::eFEXtauAlgo::getUnD()
return m_und;
}
unsigned int LVL1::eFEXtauAlgo::getSeed()
{
return m_seed;
}
......@@ -26,7 +26,7 @@ Interface definition for eFEXFormTOBs
public:
static const InterfaceID& interfaceID( ) ;
virtual uint32_t formTauTOBWord(int &, int &, int &, unsigned int &) = 0;
virtual uint32_t formTauTOBWord(int &, int &, int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &) = 0;
virtual uint32_t formEmTOBWord(int &, int &, int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &, unsigned int &) = 0;
......
......@@ -33,9 +33,12 @@ Interface definition for eFEXtauAlgo
virtual bool isCentralTowerSeed() = 0;
virtual eFEXtauTOB* getTauTOB() = 0;
virtual float getIso() = 0;
virtual void getRCore(std::vector<unsigned int> & rCoreVec) = 0;
virtual float getRealIso() = 0;
virtual unsigned int getEt() = 0;
virtual unsigned int getBitwiseEt() = 0;
virtual bool getUnD() = 0;
virtual unsigned int getSeed() = 0;
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment