Commit 3f4dbefd authored by Jacob Julian Kempster's avatar Jacob Julian Kempster Committed by Walter Lampl
Browse files

jFEX Bitwise Offline Software Simulation

parent 6262c425
......@@ -45,7 +45,7 @@ class eSuperCellTowerMapper: public AthAlgTool, virtual public IeSuperCellTowerM
SG::ReadHandleKey<xAOD::TriggerTowerContainer> m_triggerTowerCollectionSGKey {this, "xODTriggerTowers", "xAODTriggerTowers", "xAODTriggerTowers"};
virtual int FindAndConnectTower(/*eTowerContainer**/std::unique_ptr<eTowerContainer> & my_eTowerContainerRaw,CaloSampling::CaloSample sample,const int region, int layer, const int pos_neg, const int eta_index, const int phi_index, Identifier ID, float et, int prov, bool doPrint) override;
virtual int ConnectSuperCellToTower(/*eTowerContainer**/std::unique_ptr<eTowerContainer> & my_eTowerContainerRaw, int iETower, Identifier ID, int iCell, float et, int layer, bool doenergysplit) override;
virtual void ConnectSuperCellToTower(/*eTowerContainer**/std::unique_ptr<eTowerContainer> & my_eTowerContainerRaw, int iETower, Identifier ID, int iCell, float et, int layer, bool doenergysplit) override;
virtual int FindTowerIDForSuperCell(int towereta, int towerphi) override;
virtual void PrintCellSpec(const CaloSampling::CaloSample sample, int layer, const int region, const int eta_index, const int phi_index, const int pos_neg, int iETower, int iCell, int prov, Identifier ID, bool doenergysplit) override;
......
......@@ -46,7 +46,7 @@ namespace LVL1 {
eTower(float eta, float phi, int id_modifier, int posneg);
/** Destructor */
virtual ~eTower();
virtual ~eTower() = default;
/** Clear supercell ET values */
void clearET();
......@@ -61,8 +61,8 @@ namespace LVL1 {
void recordMD_ET(float et, int cell);
/** Get coordinates of tower */
int iEta();
int iPhi();
int iEta() const;
int iPhi() const;
float eta() {return m_eta;};
float phi() {return m_phi;};
float eta() const {return m_eta;};
......@@ -118,7 +118,7 @@ namespace LVL1 {
std::vector<Identifier> getLayerSCIDs(unsigned int layer) const;
/** Apply supercell noise cut **/
bool noiseCut(int et, int layer);
bool noiseCut(int et, int layer) const;
void setPosNeg(int posneg);
......
......@@ -25,7 +25,7 @@ class eTowerBuilder: public AthAlgTool, virtual public IeTowerBuilder {
public:
eTowerBuilder(const std::string& type,const std::string& name,const IInterface* parent);
virtual ~eTowerBuilder();
virtual ~eTowerBuilder() = default;
virtual void init(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) override ;
virtual void execute(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) override ;
......@@ -33,12 +33,12 @@ class eTowerBuilder: public AthAlgTool, virtual public IeTowerBuilder {
private:
virtual void BuildEMBeTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) override ;
virtual void BuildTRANSeTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) override ;
virtual void BuildEMEeTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) override ;
virtual void BuildHECeTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) override ;
virtual void BuildAllTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) override ;
virtual void BuildSingleTower(std::unique_ptr<eTowerContainer> & eTowerContainerRawRaw,float eta, float phi, float keybase, int posneg) override ;
virtual void BuildEMBeTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) const override ;
virtual void BuildTRANSeTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) const override ;
virtual void BuildEMEeTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) const override ;
virtual void BuildHECeTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) const override ;
virtual void BuildAllTowers(std::unique_ptr<eTowerContainer> & eTowerContainerRaw) const override ;
virtual void BuildSingleTower(std::unique_ptr<eTowerContainer> & eTowerContainerRawRaw,float eta, float phi, float keybase, int posneg) const override ;
};
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
/***************************************************************************
jFEXCompression.h - description
-------------------
begin : 07-02-2019
email : Alan.Watson@cern.ch antonio.jacques.costa@cern.ch
***************************************************************************/
#ifndef jFEXCompression_H
#define jFEXCompression_H
#include <array>
namespace LVL1 {
/**
LAr supercell data are received by the jFEX in a 10-bit multi-linear encoded form.
This simple utility class contains 3 functions:
- Compress: encodes a signed integer MeV value
- Expand: decodes a 10 bit unsigned int into a signed integer MeV value
- Threshold: applies a threshold (in MeV) to the compressed code, zeroing if below
- Linearize: decodes a 10 bit unsigned int into the unsigned 16 bit jFEX ET with
least count of 25 MeV. A user-defined threshold (in MeV) can be
applied, but as the jFEX ET is positive a negative threshold is
equivalent to a threshold of 0.
*/
class jFEXCompression {
public:
/** Compress data */
static unsigned int Compress(int Et);
/** Uncompress data */
static int Expand(unsigned int code);
/** Apply threshold to compressed data */
static unsigned int Threshold(unsigned int code, int threshold = -800);
/** Linearize LAr code to jFEX internal format */
static unsigned int Linearize(unsigned int code, int threshold = 0);
private:
/** Maximum ET value that can be encoded */
static const int s_maxET = 1019200;
/** Number of ranges */
static const unsigned int s_nRanges = 6;
/** Step sizes in each range, MeV */
static const int s_steps[s_nRanges];
/** Minimum ET values in each range, MeV */
static const int s_minET[s_nRanges];
/** Minimum code value in each range */
static const int s_minCode[s_nRanges];
/** Indicates no data present */
static const int s_NoData = 0;
/** LAr underflow code */
static const unsigned int s_LArUnderflow = 1;
/** LAr overflow code */
static const unsigned int s_LArOverflow = 1020;
/** Reserved code value */
static const unsigned int s_LArReserved = 1021;
/** Invalid code value */
static const unsigned int s_LArInvalid = 1022;
/** LAr saturated code */
static const unsigned int s_LArSaturated = 1023;
/** Maximum code value */
static const unsigned int s_LArMaxCode = 1023;
/** L1Calo ET digit step */
static const unsigned int s_jFEXstep = 25;
/** L1Calo saturated/overflow */
static const unsigned int s_jFEXOverflow = 0xffff;
/** Error return value */
static const int s_error = -999;
};
}//end of ns
#endif
#ifndef JFEXDRIVER_H
#define JFEXDRIVER_H
// STL
#include <string>
// Athena/Gaudi
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "AthenaBaseComps/AthAlgorithm.h"
#include "CaloEvent/CaloCellContainer.h"
#include "L1CaloFEXSim/jTower.h"
#include "L1CaloFEXSim/jTowerContainer.h"
#include "L1CaloFEXSim/jTowerBuilder.h"
#include "L1CaloFEXSim/jSuperCellTowerMapper.h"
#include "L1CaloFEXToolInterfaces/IjFEXSysSim.h"
#include "L1CaloFEXSim/jFEXSim.h"
#include "L1CaloFEXSim/jTowerContainer.h"
#include "xAODTrigL1Calo/TriggerTowerContainer.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "CaloIdentifier/CaloCell_SuperCell_ID.h"
//#include "L1CaloFEXSim/jFEXOutputCollection.h"
class CaloIdManager;
namespace LVL1 {
class jFEXDriver : public AthAlgorithm
{
public:
//using AthReentrantAlgorithm::AthReentrantAlgorithm;
jFEXDriver(const std::string& name, ISvcLocator* pSvcLocator);
virtual ~jFEXDriver();
virtual StatusCode initialize();
virtual StatusCode execute(/*const EventContext& ctx*/);// const;
StatusCode finalize();
private:
int m_numberOfEvents = 0;
SG::WriteHandleKey<LVL1::jTowerContainer> m_jTowerContainerSGKey {this, "MyETowers", "jTowerContainer", "MyETowers"};
//SG::WriteHandleKey<jFEXOutputCollection> m_jFEXOutputCollectionSGKey {this, "MyOutputs", "jFEXOutputCollection", "MyOutputs"};
SG::ReadHandleKey<CaloCellContainer> m_scellsCollectionSGKey {this, "SCell", "SCell", "SCell"};
ToolHandle<IjTowerBuilder> m_jTowerBuilderTool {this, "jTowerBuilderTool", "LVL1::jTowerBuilder", "Tool that builds jTowers for simulation"};
ToolHandle<IjSuperCellTowerMapper> m_jSuperCellTowerMapperTool {this, "jSuperCellTowerMapperTool", "LVL1::jSuperCellTowerMapper", "Tool that maps supercells to jTowers"};
ToolHandle<IjFEXSysSim> m_jFEXSysSimTool {this, "jFEXSysSimTool", "LVL1::jFEXSysSim", "Tool that creates the jFEX System Simulation"};
std::map<Identifier, std::pair<int,int> > m_cell_to_tower_map;
};
} // end of LVL1 namespace
#endif
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
//***************************************************************************
// jFEXFPGA.h -
// -------------------
// begin : 15 10 2019
// email : jacob.julian.kempster@cern.ch
// ***************************************************************************/
#ifndef jFEXFPGA_H
#define jFEXFPGA_H
#include "AthenaBaseComps/AthAlgTool.h"
#include "AthenaKernel/CLASS_DEF.h"
#include "L1CaloFEXToolInterfaces/IjFEXFPGA.h"
#include "L1CaloFEXSim/jTower.h"
#include "L1CaloFEXSim/jTowerContainer.h"
//#include "L1CaloFEXToolInterfaces/IjFEXtauAlgo.h"
//#include "L1CaloFEXToolInterfaces/IjFEXegAlgo.h"
#include "CaloEvent/CaloCellContainer.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "CaloIdentifier/CaloCell_SuperCell_ID.h"
//#include "L1CaloFEXSim/jFEXOutputCollection.h"
namespace LVL1 {
//Doxygen class description below:
/** The jFEXFPGA class defines the structure of a single jFEX FPGA
Its purpose is:
- to emulate the steps taken in processing data for a single jFEX FPGA in hardware and firmware
- It will need to interact with jTowers and produce the eTOBs. It will be created and handed data by jFEXSim
*/
class jFEXFPGA : public AthAlgTool, virtual public IjFEXFPGA {
public:
/** Constructors */
jFEXFPGA(const std::string& type,const std::string& name,const IInterface* parent);
/** standard Athena-Algorithm method */
virtual StatusCode initialize() override;
/** Destructor */
virtual ~jFEXFPGA();
virtual StatusCode init(int id, int efexid) override ;
virtual StatusCode execute() override ;
virtual void reset() override ;
virtual int ID() override {return m_id;}
virtual void SetTowersAndCells_SG( int [][9] ) override ;
virtual void SetTowersAndCells_SG( int [][8] ) override ;
/** Internal data */
private:
int m_id;
int m_jfexid;
int m_jTowersIDs_Wide [16][9];
int m_jTowersIDs_Thin [16][8];
std::map<int,jTower> m_jTowersColl;
CaloCellContainer m_sCellsCollection;
SG::ReadHandleKey<LVL1::jTowerContainer> m_jFEXFPGA_jTowerContainerKey {this, "MyETowers", "jTowerContainer", "Input container for jTowers"};
//SG::ReadHandleKey<jFEXOutputCollection> m_jFEXFPGA_jFEXOutputCollectionKey {this, "MyOutputs", "jFEXOutputCollection", "Input container for jFEXOutputCollection"};
//ToolHandle<IjFEXtauAlgo> m_jFEXtauAlgoTool {this, "jFEXtauAlgoTool", "LVL1::jFEXtauAlgo", "Tool that runs the jFEX tau algorithm"};
//ToolHandle<IjFEXegAlgo> m_jFEXegAlgoTool {this, "jFEXegAlgoTool", "LVL1::jFEXegAlgo", "Tool that runs the jFEX e/gamma algorithm"};
};
} // end of namespace
//CLASS_DEF( LVL1::jFEXFPGA , 136060357 , 1 )
#endif
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
//***************************************************************************
// jFEXSim.h -
// -------------------
// begin : 22 08 2019
// email : jacob.julian.kempster@cern.ch
// ***************************************************************************/
#ifndef jFEXSim_H
#define jFEXSim_H
#include "AthenaBaseComps/AthAlgTool.h"
#include "L1CaloFEXToolInterfaces/IjFEXSim.h"
#include "AthenaKernel/CLASS_DEF.h"
#include "L1CaloFEXSim/jTower.h"
#include "L1CaloFEXSim/jFEXFPGA.h"
#include "CaloEvent/CaloCellContainer.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "CaloIdentifier/CaloCell_SuperCell_ID.h"
namespace LVL1 {
//Doxygen class description below:
/** The jFEXSim class defines the structure of a single jFEX
Its purpose is:
- to emulate the steps taken in processing data for a single jFEX in hardware and firmware
- It will need to interact with jTowers and produce the eTOBs. It will be created and handed data by jFEXSysSim
*/
class jFEXSim : public AthAlgTool, virtual public IjFEXSim {
public:
/** Constructors */
jFEXSim(const std::string& type,const std::string& name,const IInterface* parent);
/** Destructor */
virtual ~jFEXSim();
/** standard Athena-Algorithm method */
virtual StatusCode initialize() override;
/** standard Athena-Algorithm method */
virtual StatusCode finalize () override;
virtual void init (int id) override ;
virtual void reset () override ;
virtual void execute() override ;
virtual int ID() override {return m_id;}
virtual void SetTowersAndCells_SG(int tmp[16][9]) override;
virtual void SetTowersAndCells_SG(int tmp[16][8]) override;
virtual StatusCode NewExecute(int tmp[16*4][9]) override;
virtual StatusCode NewExecute(int tmp[16*4][8]) override;
/** Internal data */
private:
int m_id;
int m_jTowersIDs_Wide [16*4][9];
int m_jTowersIDs_Thin [16*4][8];
std::map<int,jTower> m_jTowersColl;
CaloCellContainer m_sCellsCollection;
std::vector<jFEXFPGA*> m_jFEXFPGACollection;
ToolHandle<IjFEXFPGA> m_jFEXFPGATool {this, "jFEXFPGATool", "LVL1::jFEXFPGA", "Tool that simulates the FPGA hardware"};
};
} // end of namespace
//CLASS_DEF( LVL1::jFEXSim , 246128035 , 1 )
#endif
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
//***************************************************************************
// jFEXSysSim.h -
// -------------------
// begin : 12 07 2019
// email : alison.elliot@cern.ch, jacob.julian.kempster@cern.ch
// ***************************************************************************/
#ifndef jFEXSysSim_H
#define jFEXSysSim_H
#include "AthenaBaseComps/AthAlgTool.h"
#include "L1CaloFEXToolInterfaces/IjFEXSysSim.h"
#include "AthenaKernel/CLASS_DEF.h"
#include "L1CaloFEXSim/jFEXSim.h"
#include "L1CaloFEXSim/jTower.h"
#include "L1CaloFEXSim/jTowerContainer.h"
#include "CaloEvent/CaloCellContainer.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "CaloIdentifier/CaloCell_SuperCell_ID.h"
namespace LVL1 {
//Doxygen class description below:
/** The jFEXSysSim class defines the structure of the jFEX system
Its purpose is:
- to follow the structure of the 24 jFEXes and their FPGAs in as much
detail as necessary to simulate the output of the system
It will need to interact with jTowers and produce the eTOBs
*/
class jFEXSysSim : public AthAlgTool, virtual public IjFEXSysSim {
public:
/** Constructors */
jFEXSysSim(const std::string& type,const std::string& name,const IInterface* parent);
/** Destructor */
jFEXSysSim&& operator= (const jFEXSysSim& ) = delete;
/** standard Athena-Algorithm method */
virtual StatusCode initialize() override;
/** standard Athena-Algorithm method */
virtual StatusCode finalize () override;
virtual StatusCode execute() override ;
virtual void init() override ;
virtual void cleanup() override;
virtual int calcTowerID(int eta, int phi, int mod) override ;
/** Internal data */
private:
std::vector<jFEXSim*> m_jFEXCollection;
ToolHandle<IjFEXSim> m_jFEXSimTool {this, "jFEXSimTool", "LVL1::jFEXSim", "Tool that creates the jFEX Simulation"};
SG::ReadHandleKey<LVL1::jTowerContainer> m_jTowerContainerSGKey {this, "MyETowers", "jTowerContainer", "Input container for jTowers"};
SG::ReadHandleKey<CaloCellContainer> m_scellsCollectionSGKey {this, "SCell", "SCell", "SCell"};
std::map<int,jTower> m_jTowersColl;
};
} // end of namespace
//CLASS_DEF( LVL1::jFEXSysSim , 141823245 , 1 )
#endif
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef JSUPERCELLTOWERMAPPER_H
#define JSUPERCELLTOWERMAPPER_H
// STL
#include <string>
// Athena/Gaudi
#include "AthenaBaseComps/AthAlgorithm.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "L1CaloFEXToolInterfaces/IjSuperCellTowerMapper.h"
#include "CaloEvent/CaloCellContainer.h"
#include "L1CaloFEXSim/jTower.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "CaloIdentifier/CaloCell_SuperCell_ID.h"
#include "L1CaloFEXSim/jTowerContainer.h"
#include "xAODTrigL1Calo/TriggerTowerContainer.h"
class CaloIdManager;
namespace LVL1 {
class jSuperCellTowerMapper: public AthAlgTool, virtual public IjSuperCellTowerMapper
{
public:
jSuperCellTowerMapper(const std::string& type,const std::string& name,const IInterface* parent);
virtual ~jSuperCellTowerMapper();
/** standard Athena-Algorithm method */
virtual StatusCode initialize() override;
virtual StatusCode AssignSuperCellsToTowers(/*jTowerContainer**/std::unique_ptr<jTowerContainer> & my_jTowerContainerRaw) override;
virtual StatusCode AssignTriggerTowerMapper(/*jTowerContainer**/std::unique_ptr<jTowerContainer> & my_jTowerContainerRaw) override;
virtual void reset() override;
private:
SG::ReadHandleKey<CaloCellContainer> m_scellsCollectionSGKey {this, "SCell", "SCell", "SCell"};
SG::ReadHandleKey<xAOD::TriggerTowerContainer> m_triggerTowerCollectionSGKey {this, "xODTriggerTowers", "xAODTriggerTowers", "xAODTriggerTowers"};
virtual int FindAndConnectTower(/*jTowerContainer**/std::unique_ptr<jTowerContainer> & my_jTowerContainerRaw,CaloSampling::CaloSample sample,const int region, int layer, const int pos_neg, const int eta_index, const int phi_index, Identifier ID, float et, int prov, bool doPrint) override;
virtual void ConnectSuperCellToTower(/*jTowerContainer**/std::unique_ptr<jTowerContainer> & my_jTowerContainerRaw, int iETower, Identifier ID, int iCell, float et, int layer, bool doenergysplit) override;
virtual int FindTowerIDForSuperCell(int towereta, int towerphi) override;
virtual void PrintCellSpec(const CaloSampling::CaloSample sample, int layer, const int region, const int eta_index, const int phi_index, const int pos_neg, int iETower, int iCell, int prov, Identifier ID, bool doenergysplit) override;
};
} // end of LVL1 namespace
#endif
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
//***************************************************************************
// jTower.h - description
// -------------------
// begin : 19 02 2019
// email : Alan.Watson@cern.ch, jacob.julian.kempster@cern.ch
// ***************************************************************************/
#ifndef jTower_H
#define jTower_H
#include <vector>
#include "AthenaKernel/CLASS_DEF.h"
#include "CaloEvent/CaloCellContainer.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "CaloIdentifier/CaloCell_SuperCell_ID.h"
#include "xAODBase/IParticle.h"
#include "xAODCore/AuxStoreAccessorMacros.h"
namespace LVL1 {
//Doxygen class description below:
/** The jTower class is an interface object for jFEX trigger algorithms
The purposes are twofold:
- to provide inputs to the algorithms in a way that reflects the cell
structure within a tower (the basic element of an jFEX algorithm window)
- to hide the details of the individual data sources, e.g. which hadronic
cells are LAr and which are HEC, from the algorithms
It needs to contain supercell ET values and a tower coordinate or identifier
(not yet defined). ET values should be on the jFEX's internal ET scale, not MeV.
This should be a purely transient object, but will need to enter the transient
event store (so class_def etc will be needed before it can be used for real)
*/
class jTower {
public:
/** Constructors */
jTower();
jTower(float eta, float phi, int id_modifier, int posneg);
/** Destructor */
virtual ~jTower() = default;
/** Clear supercell ET values */
void clearET();
/** Clear and resize Identifier value vector */
void clear_EM_scIDs();
void clear_HAD_scIDs();
/** Add to ET of a specified cell in MeV */
void addET(float et, int cell);
/** Add to ET of a specified cell */
void recordMD_ET(float et, int cell);
/** Get coordinates of tower */
int iEta() const;
int iPhi() const;
float eta() {return m_eta;};
float phi() {return m_phi;};
float eta() const {return m_eta;};
float phi() const {return m_phi;};
void setEta(const float thiseta){ m_eta = thiseta; }