From c28113d0e414ba22960a6e6ac1bf6615bb9e58dc Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 31 Oct 2023 16:07:32 +0000
Subject: [PATCH] DecodedDataFromMCRichHits: Set SignalEvent history flag
 correctly

---
 .../src/component/DecodedDataFromMCRichHits.cpp            | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Rich/RichFutureMCUtils/src/component/DecodedDataFromMCRichHits.cpp b/Rich/RichFutureMCUtils/src/component/DecodedDataFromMCRichHits.cpp
index ed2302b9e44..b2586edf26c 100644
--- a/Rich/RichFutureMCUtils/src/component/DecodedDataFromMCRichHits.cpp
+++ b/Rich/RichFutureMCUtils/src/component/DecodedDataFromMCRichHits.cpp
@@ -85,6 +85,11 @@ namespace Rich::Future::MC {
       // Get the location of the container of an MC hit in the TES
       auto hitLocation = [&]( const auto* obj ) { return ( obj ? objectLocation( obj->parent() ) : "Not Contained" ); };
 
+      // Is hit in the main event ?
+      auto inMainEvent = [&]( const auto* mchit ) {
+        return ( hitLocation( mchit ) == ( "/Event/" + LHCb::MCRichHitLocation::Default ) );
+      };
+
       // Get hit time from MC hit, including offsets
       auto getTime = [&]( const auto* mchit ) {
         if ( !mchit ) { return 0.0; }
@@ -197,7 +202,7 @@ namespace Rich::Future::MC {
           summary->setRichSmartID( id );
           summary->setMCParticle( hit.first->mcParticle() );
           auto history = hit.first->mcRichDigitHistoryCode();
-          history.setSignalEvent( true ); // normally done by Boole for signal event only
+          history.setSignalEvent( inMainEvent( hit.first ) );
           summary->setHistory( history );
           summaries.add( summary.release() );
         }
-- 
GitLab