Skip to content
Snippets Groups Projects
Commit d9e05676 authored by Christopher Rob Jones's avatar Christopher Rob Jones
Browse files

DecodedDataFromMCRichHits: Also create MCRichDigitSummarys when decoding from MCRichHits

parent 9b513daa
No related branches found
No related tags found
1 merge request!4255DecodedDataFromMCRichHits: Also create MCRichDigitSummarys when decoding from MCRichHits
Pipeline #6114902 passed
......@@ -20,15 +20,18 @@
#include "RichUtils/RichSmartIDSorter.h"
// Event Model
#include "Event/MCRichDigitSummary.h"
#include "Event/MCRichHit.h"
#include <map>
#include <memory>
#include <tuple>
namespace Rich::Future::MC {
namespace {
/// Output data
using OutData = Rich::Future::DAQ::DecodedData;
using OutData = std::tuple<Rich::Future::DAQ::DecodedData, LHCb::MCRichDigitSummarys>;
} // namespace
using namespace Rich::Future::DAQ;
......@@ -41,17 +44,18 @@ namespace Rich::Future::MC {
* @date 2016-12-07
*/
class DecodedDataFromMCRichHits final
: public LHCb::Algorithm::Transformer<OutData( LHCb::MCRichHits const& ),
Gaudi::Functional::Traits::BaseClass_t<AlgBase<>>> {
: public LHCb::Algorithm::MultiTransformer<OutData( LHCb::MCRichHits const& ),
Gaudi::Functional::Traits::BaseClass_t<AlgBase<>>> {
public:
/// Standard constructor
DecodedDataFromMCRichHits( const std::string& name, ISvcLocator* pSvcLocator )
: Transformer( name, pSvcLocator,
// inputs
{KeyValue{"MCRichHitsLocation", LHCb::MCRichHitLocation::Default}},
// output
{KeyValue{"DecodedDataLocation", DecodedDataLocation::Default}} ) {
: MultiTransformer( name, pSvcLocator,
// inputs
{KeyValue{"MCRichHitsLocation", LHCb::MCRichHitLocation::Default}},
// output
{KeyValue{"DecodedDataLocation", DecodedDataLocation::Default},
KeyValue{"DigitSummaryLocation", LHCb::MCRichDigitSummaryLocation::Default}} ) {
// setProperty( "OutputLevel", MSG::VERBOSE ).ignore();
}
......@@ -59,6 +63,10 @@ namespace Rich::Future::MC {
/// Algorithm execution via transform
OutData operator()( LHCb::MCRichHits const& mchits ) const override {
OutData out_data;
auto& decoded_data = std::get<Rich::Future::DAQ::DecodedData>( out_data );
auto& summaries = std::get<LHCb::MCRichDigitSummarys>( out_data );
// Collect all the hits in the same pixel
std::map<LHCb::RichSmartID, std::vector<LHCb::MCRichHit*>> hitsPerPix;
for ( const auto mchit : mchits ) {
......@@ -95,8 +103,13 @@ namespace Rich::Future::MC {
// Form list of unique IDs
LHCb::RichSmartID::Vector ids;
ids.reserve( mchits.size() );
summaries.reserve( mchits.size() );
for ( const auto& [id, hits] : hitsPerPix ) {
// temporary copy of SmartID
auto newID = id;
// Add best time for this ID
if ( m_includeTimeInfo ) {
// attempt to select the 'best' time for this ID ...
if ( !hits.empty() ) { // should never fail ...
......@@ -110,15 +123,29 @@ namespace Rich::Future::MC {
newID.setTime( hitTime );
}
}
// Add ID to decoded list
ids.emplace_back( newID );
// Form MC summaries for each MCHit
for ( const auto hit : hits ) {
auto summary = std::make_unique<LHCb::MCRichDigitSummary>();
summary->setRichSmartID( id ); // Use version without time
summary->setMCParticle( hit->mcParticle() );
summary->setHistory( hit->mcRichDigitHistoryCode() );
summaries.add( summary.release() );
}
}
// Sort
SmartIDSorter::sortByRegion( ids );
for ( const auto id : ids ) { ri_debug( id, endmsg ); }
// create, fill, and return decoded data structure
return OutData( ids );
// fill decoded data structure
decoded_data.addSmartIDs( ids );
// return
return out_data;
}
private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment