ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1MUCTPIPHASE1::TriggerProcessor Class Reference

#include <TriggerProcessor.h>

Collaboration diagram for LVL1MUCTPIPHASE1::TriggerProcessor:

Public Member Functions

 TriggerProcessor ()=default
void setMenu (const TrigConf::L1Menu *l1menu)
void setTrigTool (LVL1::TrigThresholdDecisionTool &tool)
LVL1MUONIF::Lvl1MuCTPIInputPhase1 mergeInputs (const std::vector< const LVL1MUONIF::Lvl1MuCTPIInputPhase1 * > &inputs) const
std::string computeMultiplicities (LVL1MUONIF::Lvl1MuCTPIInputPhase1 &mergedInputs, int bcid, MUCTPIResults &results) const

Private Attributes

const TrigConf::L1Menum_l1menu {nullptr}
LVL1::TrigThresholdDecisionToolm_trigThresholdDecisionTool {nullptr}

Detailed Description

Definition at line 27 of file TriggerProcessor.h.

Constructor & Destructor Documentation

◆ TriggerProcessor()

LVL1MUCTPIPHASE1::TriggerProcessor::TriggerProcessor ( )
default

Member Function Documentation

◆ computeMultiplicities()

std::string LVL1MUCTPIPHASE1::TriggerProcessor::computeMultiplicities ( LVL1MUONIF::Lvl1MuCTPIInputPhase1 & mergedInputs,
int bcid,
MUCTPIResults & results ) const

Definition at line 40 of file TriggerProcessor.cxx.

41 {
42 results.ctp_words.clear();
43 results.daq_data.clear();
44
45 //initialize the vector to hold the threshold multiplicities
46 const std::vector<std::shared_ptr<TrigConf::L1Threshold> > & thresholds = m_l1menu->thresholds("MU");
47 int nThresholds = thresholds.size();
48 std::vector<unsigned int> multiplicities(nThresholds,0);
49
50
51 // Barrel + EC + Fwd
52 for (size_t isys=0;isys<LVL1MUONIF::Lvl1MuCTPIInputPhase1::numberOfSystems();isys++)
53 {
54 // Sectors per system
56 for (size_t isec=0;isec<LVL1MUONIF::Lvl1MuCTPIInputPhase1::numberOfSector(system);isec++)
57 {
58 // A+C sides
59 for (size_t isub=0;isub<2;isub++)
60 {
61 std::shared_ptr<LVL1MUONIF::Lvl1MuSectorLogicDataPhase1> sectorData = mergedInputs.getSectorLogicDataPtr(isys, isub, isec, bcid);
62 if (!sectorData) continue;
63
64 const unsigned int& ncand_max = LVL1MUONIF::NCAND[isys];
65 for (unsigned int icand=0;icand<ncand_max;icand++)
66 {
67 int thresh = sectorData->pt(icand);
68 if (thresh == -1) continue; // no candidate
69 int roiID = sectorData->roi(icand);
70 if (roiID < 0) continue;
71
72 // Build the DAQ word
73 uint32_t daq_word=0;
74
75 // Some definitions that are different between subsystems
76 uint32_t ROI_MASK=0;
77 uint32_t SECTOR_MASK = 0;
78 uint32_t SUBSYS_MASK = 0x3;
79 uint32_t SUBSYS_ID = 0; // default for barrel
80 if (isys == 0)
81 {
82 ROI_MASK = LVL1::MuCTPIBits::BARREL_ROI_MASK;
83 SECTOR_MASK = LVL1::MuCTPIBits::BARREL_SECTORID_MASK;
84 }
85 else if (isys == 1)
86 {
87 ROI_MASK = LVL1::MuCTPIBits::ENDCAP_ROI_MASK;
88 SECTOR_MASK = LVL1::MuCTPIBits::ENDCAP_SECTORID_MASK;
89 SUBSYS_ID = 2; // not a typo!
90 }
91 else if (isys == 2)
92 {
93 ROI_MASK = LVL1::MuCTPIBits::FORWARD_ROI_MASK;
94 SECTOR_MASK = LVL1::MuCTPIBits::FORWARD_SECTORID_MASK;
95 SUBSYS_ID = 1; // not a typo!
96 }
97
98 //General formula for each subword:
99 //daq_word |= (subword & LVL1::MuCTPIBits::MASK) << LVL1::MuCTPIBits::SHIFT
100
101 //ROI word
102 daq_word |= (sectorData->roi(icand) & ROI_MASK) << LVL1::MuCTPIBits::RUN3_ROI_SHIFT;
103
104 //PT word
105 daq_word |= (thresh & LVL1::MuCTPIBits::RUN3_CAND_PT_MASK) << LVL1::MuCTPIBits::RUN3_CAND_PT_SHIFT;
106
107 //CANDIDIATE FLAGS
108 if (isys == 0)
109 {
110 daq_word |= (sectorData->ovl(icand) & LVL1::MuCTPIBits::RUN3_CAND_WORD_CANDFLAGS_BA_PHIOVERLAP_MASK) << LVL1::MuCTPIBits::RUN3_CAND_WORD_CANDFLAGS_BA_PHIOVERLAP_SHIFT;
111 daq_word |= (sectorData->is2candidates(icand) & LVL1::MuCTPIBits::ROI_OVERFLOW_MASK) << LVL1::MuCTPIBits::RUN3_ROI_OVERFLOW_SHIFT;
112 }
113 else
114 {
115 daq_word |= (sectorData->charge(icand) & 0x1) << LVL1::MuCTPIBits::RUN3_CAND_TGC_CHARGE_SIGN_SHIFT;
116 daq_word |= (sectorData->bw2or3(icand) & 0x1) << LVL1::MuCTPIBits::RUN3_CAND_TGC_BW2OR3_SHIFT;
117 daq_word |= (sectorData->innercoin(icand) & 0x1) << LVL1::MuCTPIBits::RUN3_CAND_TGC_INNERCOIN_SHIFT;
118 daq_word |= (sectorData->goodmf(icand) & 0x1) << LVL1::MuCTPIBits::RUN3_CAND_TGC_GOODMF_SHIFT;
119 }
120
121 //CANDIDATE VETO FLAG
122 daq_word |= (sectorData->veto(icand) & 0x1) << LVL1::MuCTPIBits::RUN3_CAND_VETO_SHIFT;
123
124 //SECTOR FLAGS
125 daq_word |= (sectorData->is2candidatesInSector() & LVL1::MuCTPIBits::CAND_OVERFLOW_MASK) << LVL1::MuCTPIBits::RUN3_CAND_OVERFLOW_SHIFT;
126
127 //SECTOR ADDRESS
128 daq_word |= (isub & LVL1::MuCTPIBits::SECTOR_HEMISPHERE_MASK) << LVL1::MuCTPIBits::RUN3_CAND_SECTOR_ADDRESS_SHIFT;
129 daq_word |= (isec & SECTOR_MASK) << LVL1::MuCTPIBits::RUN3_CAND_SECTORID_SHIFT;
130 daq_word |= (SUBSYS_ID & SUBSYS_MASK) << LVL1::MuCTPIBits::RUN3_SUBSYS_ADDRESS_SHIFT;
131
132
133 // Add extra bit in front to flag that this is a RUN3 RoI
134 daq_word |= 1u << 31;
135
136 //find the trigger decisions
137 std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool> > decisions = m_trigThresholdDecisionTool->getThresholdDecisions(
138 daq_word, m_l1menu->thresholds("MU"), m_l1menu->thrExtraInfo().MU());
139 results.daq_data.push_back(DAQData(daq_word, decisions));
140
141 //
142 // Perform multiplicity counting
143 //
144
145 //if this candidate has been flagged as overlapping, stop here and don't count it in the multiplicity
146 if (sectorData->veto(icand)) continue;
147
148 //basic check that the size vectors are equal
149 if (decisions.size() != thresholds.size()) return "Threshold vector different size than decision vector";
150
151 //loop over each muon threshold passed and see if this candidate satisfies it.
152 //if so, increment the multiplicity of this threshold
153 for (unsigned ithresh=0;ithresh<decisions.size();ithresh++)
154 {
155 //check that the pointers are ordered correctly
156 if (decisions[ithresh].first != thresholds[ithresh]) return "Invalid threshold ordering";
157 if (decisions[ithresh].second)
158 {
159 ++multiplicities[ithresh];
160 }
161 }
162 } // N Cand
163 } // N Subsys
164 } // N Sectors
165 } // N Systems
166
167 //build the CTP words with bitset:
168 //first build the bitset that contains the full word
169 const TrigConf::L1Connector & optConn = m_l1menu->connector("MuCTPiOpt0");
170
171 std::bitset<256> full_ctp_word = 0;
172 unsigned int lastPos = 0;
173 for (int i=0;i<nThresholds;i++)
174 {
175 if(!optConn.hasLine(thresholds[i]->name())) { // not all thresholds are on the multiplicity output line
176 continue;
177 }
178 auto & triggerline = optConn.triggerLine(thresholds[i]->name());
179 unsigned nbits = triggerline.endbit() - triggerline.startbit() + 1;
180 lastPos = std::max(lastPos,triggerline.endbit()); // keep track of highest bit
181
182 unsigned int maxMult = pow2.at(nbits)-1; // multiplicity caped at 2**nbits-1
183 std::bitset<256> mult = ( multiplicities[i]>maxMult ? maxMult : multiplicities[i] ); // needs to be a bitset<256> in order to shift it by more than 32
184
185 full_ctp_word |= (mult << triggerline.startbit());
186 }
187
188 // now divide up into a vector of 32-bit unsigned ints
189 const std::bitset<256> u32i_mask = 0xffffffff;
190 unsigned n32_ints = lastPos/32 + 1;
191 // if (lastPos % 32 != 0) n32_ints += 1;
192 for (unsigned i=0;i<n32_ints;i++)
193 {
194 unsigned int word = static_cast<unsigned int>((full_ctp_word & u32i_mask).to_ulong());
195 results.ctp_words.push_back(word);
196 full_ctp_word >>= 32;
197 }
198
199 return "";
200 }
const TrigConf::L1Menu * m_l1menu
LVL1::TrigThresholdDecisionTool * m_trigThresholdDecisionTool
static size_t numberOfSector(MuonSystem system)
std::shared_ptr< Lvl1MuSectorLogicDataPhase1 > getSectorLogicDataPtr(size_t systemAddress, size_t subSystemAddress, size_t sectorAddress, int bcid=0) const
bool hasLine(const std::string &lineName) const
const TrigConf::TriggerLine & triggerLine(const std::string &lineName) const
unsigned int endbit() const
Definition L1Connector.h:29
std::vector< int > multiplicities(const std::string &chain)
setEventNumber uint32_t

◆ mergeInputs()

LVL1MUONIF::Lvl1MuCTPIInputPhase1 LVL1MUCTPIPHASE1::TriggerProcessor::mergeInputs ( const std::vector< const LVL1MUONIF::Lvl1MuCTPIInputPhase1 * > & inputs) const

Definition at line 32 of file TriggerProcessor.cxx.

33 {
34 LVL1MUONIF::Lvl1MuCTPIInputPhase1 mergedInputs;
35 int nrInputs = inputs.size();
36 for (int i=0;i<nrInputs;i++) mergedInputs.merge(*inputs[i]);
37 return mergedInputs;
38 }
void merge(const Lvl1MuCTPIInputPhase1 &another)
Merge SectorLogic data of another object into this data of a system (Barrel, Endcap or Forward) is no...

◆ setMenu()

void LVL1MUCTPIPHASE1::TriggerProcessor::setMenu ( const TrigConf::L1Menu * l1menu)

Definition at line 27 of file TriggerProcessor.cxx.

28 {
30 }

◆ setTrigTool()

void LVL1MUCTPIPHASE1::TriggerProcessor::setTrigTool ( LVL1::TrigThresholdDecisionTool & tool)
inline

Member Data Documentation

◆ m_l1menu

const TrigConf::L1Menu* LVL1MUCTPIPHASE1::TriggerProcessor::m_l1menu {nullptr}
private

Definition at line 44 of file TriggerProcessor.h.

44{nullptr};

◆ m_trigThresholdDecisionTool

LVL1::TrigThresholdDecisionTool* LVL1MUCTPIPHASE1::TriggerProcessor::m_trigThresholdDecisionTool {nullptr}
private

Definition at line 45 of file TriggerProcessor.h.

45{nullptr};

The documentation for this class was generated from the following files: