diff --git a/Rich/RichFutureMCUtils/src/component/DecodedDataFromMCRichHits.cpp b/Rich/RichFutureMCUtils/src/component/DecodedDataFromMCRichHits.cpp index b2586edf26c32bd193a2149cc0c50de0b53b075d..d66b3851be49f2eebfd09c69102c2c2e25907bcf 100644 --- a/Rich/RichFutureMCUtils/src/component/DecodedDataFromMCRichHits.cpp +++ b/Rich/RichFutureMCUtils/src/component/DecodedDataFromMCRichHits.cpp @@ -159,9 +159,6 @@ namespace Rich::Future::MC { // Should never fail but just in case... if ( hits.empty() ) { continue; } - // Apply random inefficiency for each RICH - if ( m_randZeroOne.shoot() > m_detEff[id.rich()] ) { continue; } - // temporary copy of SmartID auto newID = id; @@ -179,21 +176,49 @@ namespace Rich::Future::MC { } #endif - // Add best time for this ID - if ( m_includeTimeInfo ) { - // attempt to select the 'best' time for this ID ... - const auto* mch = &hits.front(); - for ( const auto& hit : hits ) { - if ( hit.first->isSignal() ) { - mch = &hit; - break; + // Are we allowing more than one decoded hit per channel ? + if ( !m_allowMultiHits ) { + // 'Normal' mode. Only allow a single decoded hit per channel + + // Apply random inefficiency for each RICH + if ( m_randZeroOne.shoot() > m_detEff[id.rich()] ) { continue; } + + // Add best time for this ID + if ( m_includeTimeInfo ) { + // attempt to select the 'best' time for this ID ... + const auto* mch = &hits.front(); + if ( hits.size() > 1 ) { + for ( const auto& hit : hits ) { + if ( hit.first->isSignal() ) { + mch = &hit; + break; + } + } } + newID.setTime( mch->second ); } - newID.setTime( mch->second ); - } - // Add (dd4hep corrected) ID to decoded list - ids.emplace_back( newID ); + // Add (dd4hep corrected) ID to decoded list + ids.emplace_back( newID ); + + } else { + // Allow more than one hit per channel, one per MC hit + // Useful for granularity studies. + + // loop over all MC hits + for ( const auto& hit : hits ) { + + // Apply random inefficiency for each RICH + if ( m_randZeroOne.shoot() > m_detEff[id.rich()] ) { continue; } + + // Clone channel ID before adding time + auto idWithT = newID; + idWithT.setTime( hit.second ); + + // Add to decoded list + ids.emplace_back( idWithT ); + } + } // Form MC summaries for each MCHit for ( const auto& hit : hits ) { @@ -257,6 +282,9 @@ namespace Rich::Future::MC { /// Include spillover events Gaudi::Property<bool> m_enableSpillover{this, "EnableSpillover", true}; + /// Allow multiple hits per channel + Gaudi::Property<bool> m_allowMultiHits{this, "AllowMultipleHits", false}; + /// Time window shift for each RICH Gaudi::Property<DetectorArray<double>> m_timeShift{ this, "TimeCalib", {0., 40.}, "Global time shift for each RICH, to get both to same calibrated point"};