@@ -453,10 +453,11 @@ class BcSelectionModule
453453 return ; // don't do anything in case configuration reported not ok
454454
455455 int run = bcs.iteratorAt (0 ).runNumber ();
456- // map from GlobalBC to BcId needed to find triggerBc
457- std::map<uint64_t , int32_t > mapGlobalBCtoBcId;
456+ // sorted vector from GlobalBC to BcId needed to find triggerBc
457+ std::vector<std::pair<uint64_t , int32_t >> vecGlobalBCtoBcId;
458+ vecGlobalBCtoBcId.reserve (bcs.size ());
458459 for (const auto & bc : bcs) {
459- mapGlobalBCtoBcId[ bc.globalBC ()] = bc.globalIndex ();
460+ vecGlobalBCtoBcId. emplace_back ( bc.globalBC (), bc.globalIndex () );
460461 }
461462
462463 int triggerBcShift = bcselOpts.confTriggerBcShift ;
@@ -482,7 +483,10 @@ class BcSelectionModule
482483
483484 uint32_t alias{0 };
484485 // workaround for pp2022 (trigger info is shifted by -294 bcs)
485- int32_t triggerBcId = mapGlobalBCtoBcId[bc.globalBC () + triggerBcShift];
486+ uint64_t triggerBC = bc.globalBC () + triggerBcShift;
487+ auto it = std::lower_bound (vecGlobalBCtoBcId.begin (), vecGlobalBCtoBcId.end (), triggerBC,
488+ [](const std::pair<uint64_t , int32_t >& p, uint64_t val) { return p.first < val; });
489+ int32_t triggerBcId = (it != vecGlobalBCtoBcId.end () && it->first == triggerBC) ? it->second : 0 ;
486490 if (triggerBcId && aliases) {
487491 auto triggerBc = bcs.iteratorAt (triggerBcId);
488492 uint64_t triggerMask = triggerBc.triggerMask ();
0 commit comments