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

RichMCOpticalPhotonUtils: New accessor for MC photons associated to a given MCParticle

parent 702f97a3
No related branches found
No related tags found
1 merge request!4337Misc. improvements to support RICH 4D Reco
......@@ -15,6 +15,8 @@
#include "Kernel/RichSmartID.h"
// Event model
#include "Event/MCParticle.h"
#include "Event/MCRichHit.h"
#include "Event/MCRichOpticalPhoton.h"
// Rich Utils
......@@ -61,31 +63,46 @@ namespace Rich::Future::MC::Relations {
// Get the list of all MC photons associated to the hits
auto mcPhots = mcOpticalPhotons( hits );
// filter out those not linked to mcPs
const auto it = std::remove_if( mcPhots.begin(), mcPhots.end(), //
[&mcPs]( auto&& phot ) {
// Get the MCParticle associated to this photon
const auto mcP =
( phot && phot->mcRichHit() ? phot->mcRichHit()->mcParticle() : nullptr );
// if MCP not in supplied list return true to erase
return ( !mcP || std::find( mcPs.begin(), mcPs.end(), mcP ) == mcPs.end() );
} );
const auto it = //
std::remove_if( mcPhots.begin(), mcPhots.end(), //
[&mcPs]( auto&& phot ) {
// Get the MCParticle associated to this photon
const auto mcH = ( phot ? phot->mcRichHit() : nullptr );
const auto mcP = ( mcH ? mcH->mcParticle() : nullptr );
// if MCP not in supplied list return true to erase
return ( !mcP || std::find( mcPs.begin(), mcPs.end(), mcP ) == mcPs.end() );
} );
// remove the entries selected for deletion
mcPhots.erase( it, mcPhots.end() );
// return
return mcPhots;
}
/// Get MCRichOpticalPhotons for a given MCParticle
const auto& mcOpticalPhotons( const LHCb::MCParticle* mcP ) const {
// Null entry for when missing
static LHCb::MCRichOpticalPhoton::ConstVector missing;
// Do we have this MCP in the map
const auto mcOPs = m_mcpToPhots.find( mcP );
// return
return ( mcOPs != m_mcpToPhots.end() ? mcOPs->second : missing );
}
private:
// types
/// Type for mapping from MCRichHit to MCRichOpticalPhoton
using MCRichHitToOpPhot = Rich::Map<const LHCb::MCRichHit*, const LHCb::MCRichOpticalPhoton*>;
/// Type for mapping MCParticle to MCRichOpticalPhotons
using MCPartToOpPhots = Rich::Map<const LHCb::MCParticle*, LHCb::MCRichOpticalPhoton::ConstVector>;
private:
// cached data
/// Mapping of hits to photons
MCRichHitToOpPhot m_hitToPhot;
/// Mapping of MCParticles to photons
MCPartToOpPhots m_mcpToPhots;
};
} // namespace Rich::Future::MC::Relations
......@@ -9,15 +9,23 @@
* or submit itself to any jurisdiction. *
\*****************************************************************************/
// local
#include "RichFutureMCUtils/RichMCOpticalPhotonUtils.h"
using namespace Rich::Future::MC::Relations;
MCOpticalPhotonUtils::MCOpticalPhotonUtils( const LHCb::MCRichOpticalPhotons& mcphotons ) {
// loop over mc photons
for ( const auto mcphot : mcphotons ) {
// save hit -> phot link
if ( mcphot && mcphot->mcRichHit() ) { m_hitToPhot[mcphot->mcRichHit()] = mcphot; }
if ( mcphot ) {
const auto mcH = mcphot->mcRichHit();
if ( mcH ) {
m_hitToPhot[mcH] = mcphot;
const auto mcP = mcH->mcParticle();
if ( mcP ) {
auto& phots = m_mcpToPhots[mcP];
if ( phots.empty() ) { phots.reserve( 40 ); }
phots.push_back( mcphot );
}
}
}
}
}
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