28   return StatusCode::SUCCESS;
 
   42       ATH_MSG_ERROR(
"Could not get background BCM RDO container " << bkgContainer.
name() << 
" from store " << bkgContainer.
store());
 
   43       return StatusCode::FAILURE;
 
   45     bkgContainerPtr = bkgContainer.
cptr();
 
   47     ATH_MSG_DEBUG(
"Found background BCM RDO container " << bkgContainer.
name() << 
" in store " << bkgContainer.
store());
 
   51   if (!signalContainer.
isValid()) {
 
   52     ATH_MSG_ERROR(
"Could not get signal BCM RDO container " << signalContainer.
name() << 
" from store " << signalContainer.
store());
 
   53     return StatusCode::FAILURE;
 
   55   ATH_MSG_DEBUG(
"Found signal BCM RDO container " << signalContainer.
name() << 
" in store " << signalContainer.
store());
 
   59   ATH_CHECK(outputContainer.
record(std::make_unique<BCM_RDO_Container>()));
 
   60   if (!outputContainer.
isValid()) {
 
   61     ATH_MSG_ERROR(
"Could not record output BCM RDO container " << outputContainer.
name() << 
" to store " << outputContainer.
store());
 
   62     return StatusCode::FAILURE;
 
   64   ATH_MSG_DEBUG(
"Recorded output BCM RDO container " << outputContainer.
name() << 
" in store " << outputContainer.
store());
 
   69   return StatusCode::SUCCESS;
 
   81       std::unique_ptr<BCM_RDO_Collection> outputColl = std::make_unique<BCM_RDO_Collection>();
 
   86       outputContainer->
push_back(outputColl.release());
 
   89     return StatusCode::SUCCESS;
 
   92   std::unordered_map<unsigned int, const BCM_RDO_Collection *> bkgChannelMap;
 
   94     bkgChannelMap.emplace(bkgColl->getChannel(), bkgColl);
 
   99     auto it = bkgChannelMap.find(sigColl->getChannel());
 
  100     if (
it == bkgChannelMap.end()) {
 
  101       ATH_MSG_ERROR (
"No BCM background collection with channel " << sigColl->getChannel());
 
  102       return StatusCode::FAILURE;
 
  106     bkgChannelMap.erase(
it);
 
  107     std::unique_ptr<BCM_RDO_Collection> outputColl = std::make_unique<BCM_RDO_Collection>();
 
  108     outputColl->
setChannel(sigColl->getChannel());
 
  110     constexpr 
size_t mcSize{1}; 
 
  113       if (sigColl->size() != mcSize) {
 
  115         return StatusCode::FAILURE;
 
  119       size_t collectionSize = bkgColl->
size();
 
  120       if (collectionSize != sigColl->size() && collectionSize != mcSize) {
 
  121         ATH_MSG_ERROR (
"BCM signal and background collection size mismatch");
 
  122         return StatusCode::FAILURE;
 
  126     int currentBCID = ctx.eventID().bunch_crossing_id();
 
  128       if (
m_dataOverlay.value() && bkgRDO->getBCID() != currentBCID) {
 
  136       if (bkgRDO->getChannel() == sigRDO->
getChannel()) {
 
  137         std::unique_ptr<BCM_RawData> mergedRDO = 
mergeChannel(bkgRDO, sigRDO);
 
  138         if (mergedRDO != 
nullptr) {
 
  139           outputColl->
push_back(mergedRDO.release());
 
  142           return StatusCode::FAILURE;
 
  145         ATH_MSG_ERROR (
"BCM signal and background channel mismatch");
 
  146         return StatusCode::FAILURE;
 
  150     outputContainer->
push_back(outputColl.release());
 
  153   return StatusCode::SUCCESS;
 
  161     return std::make_unique<BCM_RawData>(signalRDO->
getWord1(), signalRDO->
getWord2());
 
  163     return std::make_unique<BCM_RawData>(bkgRDO->
getWord1(), bkgRDO->
getWord2());
 
  175   std::vector<std::unique_ptr<BCM_Pulse>> merged_pulses;
 
  177   if (bkg_w1 > 0) merged_pulses.push_back(std::make_unique<BCM_Pulse>(bkg_p1,bkg_w1));
 
  178   if (bkg_w2 > 0) merged_pulses.push_back(std::make_unique<BCM_Pulse>(bkg_p2,bkg_w2));
 
  179   if (sig_w1 > 0) merged_pulses.push_back(std::make_unique<BCM_Pulse>(sig_p1,sig_w1));
 
  180   if (sig_w2 > 0) merged_pulses.push_back(std::make_unique<BCM_Pulse>(sig_p2,sig_w2));
 
  183   std::sort(merged_pulses.begin(), merged_pulses.end(), 
compare);
 
  186   for (
int i{}; 
i < std::ssize(merged_pulses)-1; 
i++) {
 
  189     BCM_Pulse *later = merged_pulses.at(
i+1).get();
 
  191     if ( (early->
p + early->
w - 1) >= later->
p ) {
 
  192       early->
w = later->
p - early->
p + later->
w;      
 
  193       merged_pulses.erase(merged_pulses.begin()+
i+1, 
 
  194                           merged_pulses.begin()+
i+2); 
 
  199   unsigned int merged_p1;
 
  200   unsigned int merged_w1;
 
  201   unsigned int merged_p2;
 
  202   unsigned int merged_w2;
 
  204   if (!merged_pulses.empty()) {
 
  205     merged_p1 = merged_pulses.at(0)->p;
 
  206     merged_w1 = merged_pulses.at(0)->w;
 
  212   if (merged_pulses.size() > 1) {
 
  213     merged_p2 = merged_pulses.at(1)->p;
 
  214     merged_w2 = merged_pulses.at(1)->w;
 
  221   return std::make_unique<BCM_RawData>(bkgRDO->
getChannel(),
 
  222                                        merged_p1, merged_w1,
 
  223                                        merged_p2, merged_w2,
 
  232   constexpr 
double fullPulseWidth{15.};      
 
  235   constexpr 
double slopeUpFraction{1./3.};   
 
  238   constexpr 
double slopeDownFraction{2./3.}; 
 
  242   for (
size_t i = 0; 
i < merged_pulses.size(); 
i++) {
 
  243     BCM_Pulse* pulse_1 = merged_pulses.at(
i).get();
 
  245     for (
size_t j = 0; j < 
i; j++) {
 
  246       BCM_Pulse* pulse_2 = merged_pulses.at(j).get();
 
  247       auto[early,later] = 
timeOrder(pulse_1, pulse_2);
 
  249       int below_thr_later = fullPulseWidth - later->w;
 
  250       int below_thr_early = fullPulseWidth - early->w;
 
  251       double slope_up = 1./slopeUpFraction;
 
  252       double slope_down = 1./slopeDownFraction;
 
  253       if (below_thr_later != 0) slope_up /= below_thr_later;
 
  254       if (below_thr_early != 0) slope_down /= below_thr_early;
 
  256       int bin_min = early->p + early->w;
 
  257       int bin_max = later->p;
 
  260       for (
int bin_iter=bin_min; bin_iter < bin_max; bin_iter++) {
 
  261         if (slope_up*(bin_iter - bin_max) - slope_down*(bin_iter - bin_min) > -1) {
 
  266       for (
int bin_iter=bin_max-1; bin_iter >= bin_min; bin_iter--) {
 
  267         if (slope_up*(bin_iter - bin_max) - slope_down*(bin_iter - bin_min) > -1) {
 
  283   if (pulse2->
p > pulse1->
p) 
return std::pair(pulse1,pulse2);
 
  284   else return std::pair(pulse2,pulse1);
 
  289                          const std::unique_ptr<BCM_Pulse>& 
b)