41 {
44
45
46 const std::vector<std::shared_ptr<TrigConf::L1Threshold> > & thresholds =
m_l1menu->thresholds(
"MU");
47 int nThresholds = thresholds.size();
49
50
51
53 {
54
57 {
58
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;
69 int roiID = sectorData->roi(icand);
70 if (roiID < 0) continue;
71
72
74
75
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;
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;
96 }
97
98
99
100
101
102 daq_word |= (sectorData->roi(icand) & ROI_MASK) << LVL1::MuCTPIBits::RUN3_ROI_SHIFT;
103
104
105 daq_word |= (
thresh & LVL1::MuCTPIBits::RUN3_CAND_PT_MASK) << LVL1::MuCTPIBits::RUN3_CAND_PT_SHIFT;
106
107
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
122 daq_word |= (sectorData->veto(icand) & 0x1) << LVL1::MuCTPIBits::RUN3_CAND_VETO_SHIFT;
123
124
125 daq_word |= (sectorData->is2candidatesInSector() & LVL1::MuCTPIBits::CAND_OVERFLOW_MASK) << LVL1::MuCTPIBits::RUN3_CAND_OVERFLOW_SHIFT;
126
127
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
134 daq_word |= 1u << 31;
135
136
139 results.daq_data.push_back(DAQData(daq_word, decisions));
140
141
142
143
144
145
146 if (sectorData->veto(icand)) continue;
147
148
149 if (
decisions.size() != thresholds.size())
return "Threshold vector different size than decision vector";
150
151
152
153 for (
unsigned ithresh=0;ithresh<
decisions.size();ithresh++)
154 {
155
156 if (decisions[ithresh].first != thresholds[ithresh]) return "Invalid threshold ordering";
157 if (decisions[ithresh].second)
158 {
160 }
161 }
162 }
163 }
164 }
165 }
166
167
168
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())) {
176 continue;
177 }
179 unsigned nbits = triggerline.
endbit() - triggerline.startbit() + 1;
180 lastPos = std::max(lastPos,triggerline.endbit());
181
182 unsigned int maxMult = pow2.at(nbits)-1;
184
185 full_ctp_word |= (mult << triggerline.startbit());
186 }
187
188
189 const std::bitset<256> u32i_mask = 0xffffffff;
190 unsigned n32_ints = lastPos/32 + 1;
191
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
bool hasLine(const std::string &lineName) const
const TrigConf::TriggerLine & triggerLine(const std::string &lineName) const
unsigned int endbit() const
std::vector< int > multiplicities(const std::string &chain)