Skip to content
Snippets Groups Projects
Commit 7a216faf authored by Junpei Maeda's avatar Junpei Maeda
Browse files

reduce memory usage, fix to undefined address of LUT, and move initial value to header

parent cb7db94c
No related branches found
No related tags found
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!39430Optimization of TGCTriggerDbAlg to reduce memory usage, to fix undefined address of LUTs, and to move initial value to header
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
* =========================== * ===========================
* std::unordered_map<GLOBALADDR, PTVALUE> * std::unordered_map<GLOBALADDR, PTVALUE>
* where * where
* GLOBALADDR | 27 bits | unsigned int | side, octant, type, phimod2, module, roi, * GLOBALADDR | 27 bits | uint32_t | side, octant, type, phimod2, module, roi,
* | DR(0...0x1f for -15...15)<<4 & DPhi(0...0xf for -7...7) * | DR(0...0x1f for -15...15)<<4 & DPhi(0...0xf for -7...7)
* PTVALUE | 3 bits | unsigned char | pT value (0x0 and 0x7 is no cand.) * PTVALUE | 3 bits | uint8_t | pT value (0x0 and 0x7 is no cand.)
* *
* for GLOBALADDR * for GLOBALADDR
* | 29 |28|27|26|25|24|23| 22 |21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| * | 29 |28|27|26|25|24|23| 22 |21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
...@@ -26,6 +26,76 @@ ...@@ -26,6 +26,76 @@
* where side = 0x0 (A-side), 0x1 (C-side). * where side = 0x0 (A-side), 0x1 (C-side).
* octant = 0x(0...7) * octant = 0x(0...7)
* type = 0x0 (HH), 0x1 (HL), 0x2 (LH), 0x3 (LL): HL means 3-station-wire and 2-station-strip. * type = 0x0 (HH), 0x1 (HL), 0x2 (LH), 0x3 (LL): HL means 3-station-wire and 2-station-strip.
*
* Bit information of Run-2 EIFI-LUT
* =================================
* a) Applied pT in SSC (m_flagpt_eifi)
* std::unordered_map<ADDR, PTMASK>
* where
* ADDR | 12 bits | uint16_t | side, trigger sector, and SSC
* PTMASK | 3 bits | uint8_t | bit mask for applied pT for SSC
*
* b) Applied RoI in SSC (m_flagroi_eifi)
* std::unordered_map<ADDR, ROIMASK>
* where
* ADDR | 12 bits | uint16_t | side, trigger sector, and SSC
* ROIMASK | 8 bits | uint8_t | bit mask for applied RoI in SSC
*
* for ADDR
* | 11 |10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* |side| Trig. Sector | SSC |
* where side = 0x0 (A-side), 0x1 (C-side).
* trig. sector = 0x(0...2f)
* SSC = 0x(0...12)
*
* c) Trigger bit for each input (m_trigbit_eifi)
* std::unordered_map<INPUTADDR, TRIGBIT>
* where TRIGBIT is:
* | EI || FI |
* | Strip | Wire || Strip | Wire |
* | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 || 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
* | <--L phi S--> | <--L eta S--> || <--L phi S--> | <--L eta S-->|
* where each sensor consists of 4 bits information.
*
* for INPUTADDR
* | 13 |12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* |side| Trig. Sector | SSC |Input|
* where side = 0x0 (A-side), 0x1 (C-side).
* trig. sector = 0x(0...2f)
* SSC = 0x(0...12)
* Input = 0x(0...3)
*
* Contents of Run-2 Tile-CW LUT
* =============================
* a) Applied pT in SSC (m_flagpt_tile)
* std::unordered_map<ADDR, PTMASK>
* where
* ADDR | 12 bits | uint16_t | side, trigger sector, and SSC
* PTMASK | 3 bits | uint8_t | bit mask for applied pT for SSC
*
* b) Applied RoI in SSC (m_flagroi_tile)
* std::unordered_map<ADDR, ROIMASK>
* where
* ADDR | 12 bits | uint16_t | side, trigger sector, and SSC
* ROIMASK | 8 bits | uint8_t | bit mask for applied RoI in SSC
*
* c) Trigger bit for each input (m_trigbit_tile)
* std::unordered_map<ADDR, TRIGBIT>
* where TRIGBIT is:
* | Module D (Tile=3) || Module C (Tile=2) || Module B (Tile=1) || Module A (Tile=0) |
* | 15 | 14 | 13 | 12 || 11 | 10 | 9 | 8 || 7 | 6 | 5 | 4 || 3 | 2 | 1 | 0 |
* | 0 | LH | D56| D6 || 0 | LH | D56| D6 || 0 | LH | D56 | D6 || 0 | LH | D56 | D6 |
* for each Module:
* [1:0] hit with cell information: D6=0x1, D56=0x3
* [2] Low/High threshold: 1 = H, 0=L
* e.g.) 0x7 = D5+D6 energy exceeds the high threshold
*
* for ADDR
* | 11 |10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
* |side| Trig. Sector | SSC |
* where side = 0x0 (A-side), 0x1 (C-side).
* trig. sector = 0x(0...2f)
* SSC = 0x(0...12)
*/ */
class TGCTriggerData class TGCTriggerData
...@@ -76,6 +146,16 @@ class TGCTriggerData ...@@ -76,6 +146,16 @@ class TGCTriggerData
static constexpr uint8_t DPHI_HIGH_RANGE = 7; static constexpr uint8_t DPHI_HIGH_RANGE = 7;
/// Range of DPhi in the BW coincidence window for 2-station /// Range of DPhi in the BW coincidence window for 2-station
static constexpr uint8_t DPHI_LOW_RANGE = 3; static constexpr uint8_t DPHI_LOW_RANGE = 3;
/// Mask for trigger sector for the (EIFI/TILE) ADDR
static constexpr uint8_t SECTOR_MASK = 0x3f;
/// Mask for SSC for the (EIFI/TILE) ADDR
static constexpr uint8_t SSC_MASK = 0x1f;
/// Bit position of the side bit in the (EIFI/TILE) ADDR
static constexpr uint8_t ADDR_SIDE_SHIFT = 11;
/// Bit position of the trigger sector bit in the (EIFI/TILE) ADDR
static constexpr uint8_t ADDR_SECTOR_SHIFT = 5;
/// Special bit shift for the EIFI Trigger bit
static constexpr uint8_t EIFI_TRIGBIT_SHIFT = 2;
enum {CW_BW=0, CW_EIFI=1, CW_TILE=2, CW_NUM=3}; enum {CW_BW=0, CW_EIFI=1, CW_TILE=2, CW_NUM=3};
enum {N_PT_THRESH=6, enum {N_PT_THRESH=6,
...@@ -94,12 +174,8 @@ class TGCTriggerData ...@@ -94,12 +174,8 @@ class TGCTriggerData
TGCTriggerData(); TGCTriggerData();
virtual ~TGCTriggerData(); virtual ~TGCTriggerData();
std::string getData(int cwtype, std::string file) const; std::string getType(int cwtype) const;
std::string getData(int cwtype, int channel) const; bool isActive(int cwtype) const;
std::string getFile(int cwtype, int channel) const;
std::string getVersion(int cwtype, int channel = 0) const;
std::string getType(int cwtype, int channel = 0) const;
bool isActive(int cwtype, int channel = 0) const;
int8_t getTYPE(const int16_t lDR, const int16_t hDR, const int16_t lDPhi, const int16_t hDPhi) const; int8_t getTYPE(const int16_t lDR, const int16_t hDR, const int16_t lDPhi, const int16_t hDPhi) const;
...@@ -111,57 +187,29 @@ class TGCTriggerData ...@@ -111,57 +187,29 @@ class TGCTriggerData
unsigned short getTrigMaskTile(int ssc, int sectorId, int side) const; unsigned short getTrigMaskTile(int ssc, int sectorId, int side) const;
unsigned char getFlagPtTile(int ssc, int sectorId, int side) const; unsigned char getFlagPtTile(int ssc, int sectorId, int side) const;
unsigned char getFlagRoiTile(int ssc, int sectorId, int side) const; uint8_t getFlagRoiTile(int ssc, int sectorId, int side) const;
private: private:
std::map<std::string, std::string> m_datamap[CW_NUM]; std::string m_type[CW_NUM];
std::vector<std::string> m_data[CW_NUM]; bool m_active[CW_NUM];
std::vector<std::string> m_file[CW_NUM];
std::vector<std::string> m_version[CW_NUM];
std::vector<std::string> m_type[CW_NUM];
std::vector<bool> m_active[CW_NUM];
/// Run-2 BW-CW LUT map /// Run-2 BW-CW LUT map
std::unordered_map<uint32_t, uint8_t> m_ptmap_bw; std::unordered_map<uint32_t, uint8_t> m_ptmap_bw;
/** Bit information of Run-2 EIFI-LUT // Run-2 EIFI-CW LUT map
* ================================= std::unordered_map<uint16_t, uint8_t> m_flagpt_eifi;
* bits for each input std::unordered_map<uint16_t, uint8_t> m_flagroi_eifi;
* | EI || FI | std::unordered_map<uint16_t, uint16_t> m_trigbit_eifi;
* | Strip | Wire || Strip | Wire |
* | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 || 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
* | <--L phi S--> | <--L eta S--> || <--L phi S--> | <--L eta S-->|
* where each sensor consists of 4 bits information.
*
* Note: Only if fullCW option is true, the different db file per side is read.
* Therefore, the contents are stored by std::vector of side index (A=0, C=1).
*/
std::vector<unsigned short> m_trigbit_eifi[N_ENDCAP_SECTOR][N_ENDCAP_SSC][N_EIFI_INPUT];
std::vector<unsigned char> m_flagpt_eifi[N_ENDCAP_SECTOR][N_ENDCAP_SSC]; //< bits for applied pT (N_PT_THRESH)
std::vector<unsigned char> m_flagroi_eifi[N_ENDCAP_SECTOR][N_ENDCAP_SSC]; //< bits for applied RoI in SSC (N_ROI_IN_SSC)
/** Bit information of Run-2 Tile-LUT
* =================================
* bits for each input
* | Module D (Tile=3) || Module C (Tile=2) || Module B (Tile=1) || Module A (Tile=0) |
* | 15 | 14 | 13 | 12 || 11 | 10 | 9 | 8 || 7 | 6 | 5 | 4 || 3 | 2 | 1 | 0 |
* | 0 | LH | D56| D6 || 0 | LH | D56| D6 || 0 | LH | D56 | D6 || 0 | LH | D56 | D6 |
* for each Module:
* [1:0] hit with cell information: D6=0x1, D56=0x3
* [2] Low/High threshold: 1 = H, 0=L
* e.g.) 0x7 = D5+D6 energy exceeds the high threshold
*
* Note: One db file consists of whole sector information as a fullCW.
*/
unsigned short m_trigbit_tile[N_ENDCAP_SSC][N_ENDCAP_SECTOR][N_SIDE];
unsigned char m_flagpt_tile[N_ENDCAP_SSC][N_ENDCAP_SECTOR][N_SIDE]; //< bits for applied pT (N_PT_THRESH)
unsigned char m_flagroi_tile[N_ENDCAP_SSC][N_ENDCAP_SECTOR][N_SIDE]; //< bits for applied RoI in SSC (N_ROI_IN_SSC)
//Run-2 Tile-CW LUT map
std::unordered_map<uint16_t, uint8_t> m_flagpt_tile;
std::unordered_map<uint16_t, uint8_t> m_flagroi_tile;
std::unordered_map<uint16_t, uint16_t> m_trigbit_tile;
}; };
CLASS_DEF(TGCTriggerData, 72345188, 2) CLASS_DEF(TGCTriggerData, 72345188, 3)
#include "AthenaKernel/CondCont.h" #include "AthenaKernel/CondCont.h"
CLASS_DEF(CondCont<TGCTriggerData>, 96649668, 2) CLASS_DEF(CondCont<TGCTriggerData>, 96649668, 3)
#endif // TGCTRIGGERDATA_H #endif // TGCTRIGGERDATA_H
...@@ -22,20 +22,16 @@ class TGCTriggerDbAlg: public AthAlgorithm ...@@ -22,20 +22,16 @@ class TGCTriggerDbAlg: public AthAlgorithm
virtual StatusCode finalize() override; virtual StatusCode finalize() override;
private: private:
void loadParameters(TGCTriggerData* writeCdo, void fillReadMapBw(TGCTriggerData* writeCdo, const CondAttrListCollection* readKey);
const CondAttrListCollection* readKey, void fillTrigBitEifi(TGCTriggerData* writeCdo, const CondAttrListCollection* readKey);
int cw_type); void fillTrigBitTile(TGCTriggerData* writeCdo, const CondAttrListCollection* readKey);
void fillReadMapBw(TGCTriggerData* writeCdo); SG::ReadCondHandleKey<CondAttrListCollection> m_readKey_bw{this, "ReadKeyBw", "/TGC/TRIGGER/CW_BW", "SG key for CW-BW"};
void fillTrigBitEifi(TGCTriggerData* writeCdo); SG::ReadCondHandleKey<CondAttrListCollection> m_readKey_eifi{this, "ReadKeyEifi", "/TGC/TRIGGER/CW_EIFI", "SG key for CW-EIFI"};
void fillTrigBitTile(TGCTriggerData* writeCdo); SG::ReadCondHandleKey<CondAttrListCollection> m_readKey_tile{this, "ReadKeyTile", "/TGC/TRIGGER/CW_TILE", "SG key for CW-TILE"};
SG::WriteCondHandleKey<TGCTriggerData> m_writeKey{this, "WriteKey", "TGCTriggerData", "SG Key of TGCTrigger LUTs"};
SG::ReadCondHandleKey<CondAttrListCollection> m_readKey_bw;
SG::ReadCondHandleKey<CondAttrListCollection> m_readKey_eifi;
SG::ReadCondHandleKey<CondAttrListCollection> m_readKey_tile;
SG::WriteCondHandleKey<TGCTriggerData> m_writeKey;
ServiceHandle<ICondSvc> m_condSvc;
ServiceHandle<ICondSvc> m_condSvc;
}; };
#endif #endif
......
...@@ -11,36 +11,14 @@ TGCTriggerData::TGCTriggerData() ...@@ -11,36 +11,14 @@ TGCTriggerData::TGCTriggerData()
TGCTriggerData::~TGCTriggerData() TGCTriggerData::~TGCTriggerData()
{} {}
std::string TGCTriggerData::getData(int cwtype, std::string file) const { std::string TGCTriggerData::getType(int cwtype) const
auto itr = m_datamap[cwtype].find(file); {
if (itr == m_datamap[cwtype].end()) { return m_type[cwtype];
return "";
}
return itr->second;
}
std::string TGCTriggerData::getData(int cwtype, int channel) const {
return m_data[cwtype][channel];
}
std::string TGCTriggerData::getFile(int cwtype, int channel) const {
return m_file[cwtype][channel];
}
std::string TGCTriggerData::getVersion(int cwtype, int channel) const {
return m_version[cwtype][channel];
}
std::string TGCTriggerData::getType(int cwtype, int channel) const {
return m_type[cwtype][channel];
} }
bool TGCTriggerData::isActive(int cwtype) const
bool TGCTriggerData::isActive(int cwtype, int channel) const { {
return m_active[cwtype][channel]; return m_active[cwtype];
} }
int8_t TGCTriggerData::getTYPE(const int16_t lDR, const int16_t hDR, const int16_t lDPhi, const int16_t hDPhi) const int8_t TGCTriggerData::getTYPE(const int16_t lDR, const int16_t hDR, const int16_t lDPhi, const int16_t hDPhi) const
...@@ -64,33 +42,65 @@ uint8_t TGCTriggerData::getBigWheelPt(const uint32_t addr) const ...@@ -64,33 +42,65 @@ uint8_t TGCTriggerData::getBigWheelPt(const uint32_t addr) const
unsigned short TGCTriggerData::getTrigBitEifi(int side, int slot, int ssc, int sectorId) const unsigned short TGCTriggerData::getTrigBitEifi(int side, int slot, int ssc, int sectorId) const
{ {
if(m_active[CW_EIFI][0] == false) return 0; // not required EIFI coincidence. int sideindex = (m_type[CW_EIFI] != "full") ? 0 : side;
int sideindex = (this->getType(CW_EIFI) != "full") ? 0 : side; uint16_t addr = ((sideindex & SIDE_MASK)<<ADDR_SIDE_SHIFT) +
return m_trigbit_eifi[sectorId][ssc][slot][sideindex]; ((sectorId & SECTOR_MASK)<<ADDR_SECTOR_SHIFT) +
(ssc & SSC_MASK);
addr = (addr<<EIFI_TRIGBIT_SHIFT) + slot;
std::unordered_map<uint16_t, uint16_t>::const_iterator it = m_trigbit_eifi.find(addr);
if(it == m_trigbit_eifi.end()) return 0x0; // undefined sector (or active=0)
else return it->second;
} }
unsigned char TGCTriggerData::getFlagPtEifi(int side, int ssc, int sectorId) const unsigned char TGCTriggerData::getFlagPtEifi(int side, int ssc, int sectorId) const
{ {
if(m_active[CW_EIFI][0] == false) return 0; // not required EIFI coincidence. int sideindex = (m_type[CW_EIFI] != "full") ? 0 : side;
int sideindex = (this->getType(CW_EIFI) != "full") ? 0 : side; uint16_t addr = ((sideindex & SIDE_MASK)<<ADDR_SIDE_SHIFT) +
return m_flagpt_eifi[sectorId][ssc][sideindex]; ((sectorId & SECTOR_MASK)<<ADDR_SECTOR_SHIFT) +
(ssc & SSC_MASK);
std::unordered_map<uint16_t, uint8_t>::const_iterator it = m_flagpt_eifi.find(addr);
if(it == m_flagpt_eifi.end()) return 0x0; // undefined sector (or active=0)
else return it->second;
} }
unsigned char TGCTriggerData::getFlagRoiEifi(int side, int ssc, int sectorId) const unsigned char TGCTriggerData::getFlagRoiEifi(int side, int ssc, int sectorId) const
{ {
if(m_active[CW_EIFI][0] == false) return 0; // not required EIFI coincidence. int sideindex = (m_type[CW_EIFI] != "full") ? 0 : side;
int sideindex = (this->getType(CW_EIFI) != "full") ? 0 : side; uint16_t addr = ((sideindex & SIDE_MASK)<<ADDR_SIDE_SHIFT) +
return m_flagroi_eifi[sectorId][ssc][sideindex]; ((sectorId & SECTOR_MASK)<<ADDR_SECTOR_SHIFT) +
(ssc & SSC_MASK);
std::unordered_map<uint16_t, uint8_t>::const_iterator it = m_flagroi_eifi.find(addr);
if(it == m_flagroi_eifi.end()) return 0x0; // undefined sector (or active=0)
else return it->second;
} }
unsigned short TGCTriggerData::getTrigMaskTile(int ssc, int sectorId, int side) const { uint16_t TGCTriggerData::getTrigMaskTile(int ssc, int sectorId, int side) const
return m_trigbit_tile[ssc][sectorId][side]; {
uint16_t addr = ((side & SIDE_MASK)<<ADDR_SIDE_SHIFT) +
((sectorId & SECTOR_MASK)<<ADDR_SECTOR_SHIFT) +
(ssc & SSC_MASK);
std::unordered_map<uint16_t, uint16_t>::const_iterator it = m_trigbit_tile.find(addr);
if(it == m_trigbit_tile.end()) return 0x0; // undefined sector (or active=0)
else return it->second;
} }
unsigned char TGCTriggerData::getFlagPtTile(int ssc, int sectorId, int side) const { uint8_t TGCTriggerData::getFlagPtTile(int ssc, int sectorId, int side) const
return m_flagpt_tile[ssc][sectorId][side]; {
uint16_t addr = ((side & SIDE_MASK)<<ADDR_SIDE_SHIFT) +
((sectorId & SECTOR_MASK)<<ADDR_SECTOR_SHIFT) +
(ssc & SSC_MASK);
std::unordered_map<uint16_t, uint8_t>::const_iterator it = m_flagpt_tile.find(addr);
if(it == m_flagpt_tile.end()) return 0x0; // undefined sector (or active=0)
else return it->second;
} }
unsigned char TGCTriggerData::getFlagRoiTile(int ssc, int sectorId, int side) const { uint8_t TGCTriggerData::getFlagRoiTile(int ssc, int sectorId, int side) const
return m_flagroi_tile[ssc][sectorId][side]; {
uint16_t addr = ((side & SIDE_MASK)<<ADDR_SIDE_SHIFT) +
((sectorId & SECTOR_MASK)<<ADDR_SECTOR_SHIFT) +
(ssc & SSC_MASK);
std::unordered_map<uint16_t, uint8_t>::const_iterator it = m_flagroi_tile.find(addr);
if(it == m_flagroi_tile.end()) return 0x0; // undefined sector (or active=0)
else return it->second;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment