139 {
140
141
142 SG::WriteHandle<xAOD::TrigCompositeContainer> wh_trigComposite(
m_trigCompositeKey, ctx);
143 ATH_CHECK(wh_trigComposite.record(std::make_unique<xAOD::TrigCompositeContainer>(), std::make_unique<xAOD::TrigCompositeAuxContainer>()));
144 auto trigCompCont = wh_trigComposite.ptr();
145
146 SG::WriteDecorHandle<xAOD::TrigCompositeContainer, int> trigCompL1A(
m_l1AKey, ctx);
147 SG::WriteDecorHandle<xAOD::TrigCompositeContainer, int> trigCompOther(
m_otherTypeKey, ctx);
148 SG::WriteDecorHandle<xAOD::TrigCompositeContainer, int> trigCompBeforeAfter(
m_beforeAfterKey, ctx);
149 SG::WriteDecorHandle<xAOD::TrigCompositeContainer, int> trigCompPass(
m_passKey, ctx);
150 SG::WriteDecorHandle<xAOD::TrigCompositeContainer, int> trigCompOtherBefore(
m_otherTypeBeforeKey, ctx);
151 SG::WriteDecorHandle<xAOD::TrigCompositeContainer, int> trigCompOtherAfter(
m_otherTypeAfterKey, ctx);
152 SG::WriteDecorHandle<xAOD::TrigCompositeContainer, int> trigCompBeforeOffset(
m_beforeOffsetKey, ctx);
153 SG::WriteDecorHandle<xAOD::TrigCompositeContainer, int> trigCompAfterOffset(
m_afterOffsetKey, ctx);
154
155
156 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFragments;
157 std::vector<uint32_t> roblist;
158
159 roblist.push_back(0x770000);
162 std::ostringstream
os;
163 for(auto rob : roblist){
165 }
167 <<
" ROBs requested/retrieved:" <<
os.str());
168 }
169 if (robFragments.size()<1){
171 return StatusCode::SUCCESS;
172 }
173 const eformat::ROBFragment<const uint32_t*>* rbf = robFragments[0];
174
175
176
177
178 const int l1a_idx = static_cast<int>(CTPfragment::lvl1AcceptBunch(rbf));
179
180 const int nBC = 2 * l1a_idx + 1;
181 const int mid = l1a_idx;
182
183
184 std::vector<std::vector<uint32_t>> tbpWords(nBC), tapWords(nBC);
185 for (
int i = 0;
i < nBC; ++
i) {
186 const unsigned k =
static_cast<unsigned>(
i);
187 tbpWords[
i] = CTPfragment::triggerDecisionBeforePrescales(rbf, k);
188 tapWords[
i] = CTPfragment::triggerDecisionAfterPrescales (rbf, k);
189 }
190
191
192 auto firedFromWords = [&](
const std::vector<uint32_t>&
w,
193 const std::vector<uint32_t>&
mask) -> uint8_t {
194 const std::size_t nw = std::min(
w.size(),
mask.size());
196 for (std::size_t iw = 0; iw < nw; ++iw) on |= static_cast<uint8_t>((w[iw] & mask[iw]) != 0u);
197 return on;
198 };
199
200
201 std::vector<uint8_t> firedbc(nBC,0), firedbc_ele(nBC,0), firedbc_mu(nBC,0), firedbc_jet(nBC,0);
202 for (
int i = 0;
i < nBC; ++
i) {
203 firedbc [
i] = firedFromWords(tbpWords[i],
m_bitmasks);
207 }
208
209
211 firedbc[mid] = firedbc_ele[mid] = firedbc_mu[mid] = firedbc_jet[mid] = 1;
212 }
213
214
215 auto collect_ids_from_words = [
this](
const std::vector<uint32_t>&
words) {
216 std::vector<int>
ids;
217 const std::size_t nw = std::min(
words.size(), this->m_bitmasks.size());
218 ids.reserve(32u * nw);
219 for (std::size_t iw = 0; iw < nw; ++iw) {
221 if (!w) continue;
222 const unsigned base =
static_cast<unsigned>(iw * 32u);
223 for (
unsigned b = 0;
b < 32; ++
b)
if (w & (1u << b))
ids.emplace_back(
static_cast<int>(
base + b));
224 }
226 };
227
228 std::vector<int> vDeltaBC_all_TBP, vCtpId_all_TBP, vDeltaBC_all_TAP, vCtpId_all_TAP;
229 vDeltaBC_all_TBP.reserve(64); vCtpId_all_TBP.reserve(64);
230 vDeltaBC_all_TAP.reserve(64); vCtpId_all_TAP.reserve(64);
231
232 for (
int i = 0;
i < nBC; ++
i) {
233 const int delta =
i - mid;
234 {
235 const auto ids = collect_ids_from_words(tbpWords[i]);
236 vDeltaBC_all_TBP.insert(vDeltaBC_all_TBP.end(),
ids.size(), delta);
237 vCtpId_all_TBP.insert (vCtpId_all_TBP.end(),
ids.begin(),
ids.end());
238 }
239 {
240 const auto ids = collect_ids_from_words(tapWords[i]);
241 vDeltaBC_all_TAP.insert(vDeltaBC_all_TAP.end(),
ids.size(), delta);
242 vCtpId_all_TAP.insert (vCtpId_all_TAP.end(),
ids.begin(),
ids.end());
243 }
244 }
245
246
247 int isPassed = 0;
248 int beforeafterflag = 0;
249 int offset_before = 0, offset_after = 0;
250 for (
int d = 1;
d <= l1a_idx; ++
d) {
251 if (firedbc[mid] && firedbc[mid - d] && offset_before == 0) { offset_before =
d; isPassed = 1; }
252 if (firedbc[mid] && firedbc[mid + d] && offset_after == 0) { offset_after =
d; isPassed = 1; }
253 if (offset_before && offset_after) break;
254 }
255
256
258 if (firedbc_ele[idx] && !firedbc_mu[idx] && !firedbc_jet[idx]) return 1;
259 else if (firedbc_mu [idx] && !firedbc_ele[idx] && !firedbc_jet[idx]) return 2;
260 else if (firedbc_jet[idx] && !firedbc_ele[idx] && !firedbc_mu[idx]) return 3;
261 else if (firedbc_ele[idx] && firedbc_mu[idx] && !firedbc_jet[idx]) return 4;
262 else if (firedbc_ele[idx] && firedbc_jet[idx] && !firedbc_mu[idx]) return 5;
263 else if (firedbc_mu [idx] && firedbc_jet[idx] && !firedbc_ele[idx]) return 6;
264 else if (firedbc_ele[idx] && firedbc_mu[idx] && firedbc_jet[idx]) return 7;
265 return 0;
266 };
267
269 int other_type_before = (offset_before > 0) ?
classify(mid - offset_before) : 0;
270 int other_type_after = (offset_after > 0) ?
classify(mid + offset_after ) : 0;
271
272
273 if (offset_before > 0 && offset_after > 0) {
274 if (offset_before < offset_after) beforeafterflag = -offset_before;
275 else if (offset_after < offset_before) beforeafterflag = +offset_after;
276 else beforeafterflag = +offset_after;
277 } else if (offset_before > 0) {
278 beforeafterflag = -offset_before;
279 } else if (offset_after > 0) {
280 beforeafterflag = +offset_after;
281 }
282
283 int other_type = 0;
284 if (beforeafterflag < 0) other_type = other_type_before;
285 else if (beforeafterflag > 0) other_type = other_type_after;
286
287
288 if (isPassed) {
290 trigCompCont->push_back(trigComp);
291 trigComp->setName("mistimemon_L1Dec");
292
293 trigCompL1A (*trigComp) = l1a_type;
294 trigCompOther (*trigComp) = other_type;
295 trigCompBeforeAfter (*trigComp) = beforeafterflag;
296 trigCompPass (*trigComp) = isPassed;
297 trigCompOtherBefore (*trigComp) = other_type_before;
298 trigCompOtherAfter (*trigComp) = other_type_after;
299 trigCompBeforeOffset(*trigComp) = offset_before;
300 trigCompAfterOffset (*trigComp) = offset_after;
301 }
302
303
304 auto mon_l1a = Monitored::Scalar<int>("l1Accept", l1a_type);
305 auto mon_otherType = Monitored::Scalar<int>("otherType", other_type);
306 auto mon_beforeAfter = Monitored::Scalar<int>("BeforeAfterFlag", beforeafterflag);
307 auto monitorIt = Monitored::Group(
m_monTool, mon_l1a, mon_otherType, mon_beforeAfter);
308
309 if (offset_before > 0 && offset_after > 0) {
310 auto mon_offsetBefore = Monitored::Scalar<int>("BeforeOffset", offset_before);
311 auto mon_offsetAfter = Monitored::Scalar<int>("AfterOffset", offset_after);
312 auto mon_otherBefore = Monitored::Scalar<int>("OtherTypeBefore", other_type_before);
313 auto mon_otherAfter = Monitored::Scalar<int>("OtherTypeAfter", other_type_after);
314 auto gBoth = Monitored::Group(
m_monTool, mon_offsetBefore, mon_offsetAfter, mon_otherBefore, mon_otherAfter);
315 (void)gBoth;
316 } else if (offset_before > 0) {
317 auto mon_offsetBefore = Monitored::Scalar<int>("BeforeOffset", offset_before);
318 auto mon_otherBefore = Monitored::Scalar<int>("OtherTypeBefore", other_type_before);
319 auto gB = Monitored::Group(
m_monTool, mon_offsetBefore, mon_otherBefore);
320 (void)gB;
321 } else if (offset_after > 0) {
322 auto mon_offsetAfter = Monitored::Scalar<int>("AfterOffset", offset_after);
323 auto mon_otherAfter = Monitored::Scalar<int>("OtherTypeAfter", other_type_after);
324 auto gA = Monitored::Group(
m_monTool, mon_offsetAfter, mon_otherAfter);
325 (void)gA;
326 }
327
328
333 auto gMaps = Monitored::Group(
m_monTool, mon_dbc_all_tbp, mon_id_all_tbp,
334 mon_dbc_all_tap, mon_id_all_tap);
335 (void)gMaps;
336
337
338 const auto ids0_tbp = collect_ids_from_words(tbpWords[mid]);
339 const auto ids0_tap = collect_ids_from_words(tapWords[mid]);
340
341 auto fill_pair_map = [&](int deltaSel, bool useTAP,
342 const char* varX, const char* varY) {
343 const int kN = mid + deltaSel;
344 if (kN < 0 || kN >= nBC) return;
345
346 const auto &idsN = useTAP ? collect_ids_from_words(tapWords[kN])
347 : collect_ids_from_words(tbpWords[kN]);
348 const auto& ids0 = useTAP ? ids0_tap : ids0_tbp;
349
350 if (ids0.empty() || idsN.empty()) return;
351
352 std::vector<int> vId0; vId0.reserve(ids0.size() * idsN.size());
353 std::vector<int> vIdN; vIdN.reserve(vId0.capacity());
354 for (
int id0 : ids0)
for (
int idN : idsN) { vId0.emplace_back(id0); vIdN.emplace_back(idN); }
355
358 auto g = Monitored::Group(
m_monTool, mon_x, mon_y);
359 (void)g;
360 };
361
362
363 fill_pair_map(+2, false, "CTPID0tbp_p2", "CTPIDtbp_p2");
364 fill_pair_map(-2, false, "CTPID0tbp_m2", "CTPIDtbp_m2");
365 fill_pair_map(+1, false, "CTPID0tbp_p1", "CTPIDtbp_p1");
366 fill_pair_map(-1, false, "CTPID0tbp_m1", "CTPIDtbp_m1");
367
368
369 fill_pair_map(+2, true , "CTPID0tap_p2", "CTPIDtap_p2");
370 fill_pair_map(-2, true , "CTPID0tap_m2", "CTPIDtap_m2");
371 fill_pair_map(+1, true , "CTPID0tap_p1", "CTPIDtap_p1");
372 fill_pair_map(-1, true , "CTPID0tap_m1", "CTPIDtap_m1");
373
374 return StatusCode::SUCCESS;
375}
#define ATH_CHECK
Evaluate an expression and check for errors.
bool msgLvl(const MSG::Level lvl) const
SG::WriteDecorHandleKey< xAOD::TrigCompositeContainer > m_otherTypeBeforeKey
SG::WriteDecorHandleKey< xAOD::TrigCompositeContainer > m_otherTypeKey
SG::WriteDecorHandleKey< xAOD::TrigCompositeContainer > m_beforeOffsetKey
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_trigCompositeKey
std::vector< uint32_t > m_bitmasks
Gaudi::Property< bool > m_currentBCincl
std::vector< uint32_t > m_bitmasks_ele
SG::WriteDecorHandleKey< xAOD::TrigCompositeContainer > m_otherTypeAfterKey
SG::WriteDecorHandleKey< xAOD::TrigCompositeContainer > m_afterOffsetKey
std::vector< uint32_t > m_bitmasks_jets
ToolHandle< GenericMonitoringTool > m_monTool
ServiceHandle< IROBDataProviderSvc > m_robDataProviderSvc
std::vector< uint32_t > m_bitmasks_mu
SG::WriteDecorHandleKey< xAOD::TrigCompositeContainer > m_l1AKey
SG::WriteDecorHandleKey< xAOD::TrigCompositeContainer > m_beforeAfterKey
SG::WriteDecorHandleKey< xAOD::TrigCompositeContainer > m_passKey
void classify(ToolHandle< IMCTruthClassifier > &m_classif, const xAOD::TruthParticle *theParticle, unsigned int &particleOutCome, unsigned int &result, int &hadron_pdg, unsigned int &particleType, unsigned int &particleOrigin)
for(size_t i=0;i< m_blockFillers.size();i++)
Fill one block.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.