Skip to content
Snippets Groups Projects

Draft: Example of 'binding' tools to conditions and/or event data and/or other tools

Closed Gerhard Raven requested to merge exp-bound-tool into master
Compare and
3 files
+ 148
139
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -8,19 +8,9 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#ifndef MCEVENT_MCTRACKGEOMCRITERIA_H
#define MCEVENT_MCTRACKGEOMCRITERIA_H 1
// Event
#pragma once
#include "Event/MCTrackInfo.h"
// boost
#include <boost/function.hpp>
// stl
#include <map>
#include <string>
#include <utility>
#include <vector>
namespace LHCb {
@@ -32,52 +22,18 @@ namespace LHCb::MC {
class MCTrackGeomCriteria final {
public:
using Criteria = boost::function<bool( MCTrackInfo&, const LHCb::MCParticle* )>;
using Criterium = bool ( MCTrackInfo::* )( const LHCb::MCParticle* ) const;
/** Constructor from vector of Criteria */
MCTrackGeomCriteria( std::vector<Criteria> criteria );
MCTrackGeomCriteria( std::vector<Criterium> criteria ) : m_criteria( std::move( criteria ) ) {}
/** Constructor from vector of strings */
MCTrackGeomCriteria( const std::vector<std::string>& criteria );
/** fulfils Criteria or not */
bool accepted( MCTrackInfo& info, const LHCb::MCParticle* particle ) const;
class FunctionMap final {
public:
/// map to enum
Criteria toType( const std::string& aName ) const;
friend class MCTrackGeomCriteria;
private:
/// constructer
FunctionMap();
FunctionMap( const FunctionMap& rhs ) { m_mapping = rhs.m_mapping; }
typedef std::map<std::string, const Criteria> funMap;
mutable funMap m_mapping;
};
FunctionMap& theMap() {
static FunctionMap sMap;
return sMap;
}
bool accepted( MCTrackInfo const& info, const LHCb::MCParticle* particle ) const;
private:
std::vector<Criteria> m_criteria;
std::vector<Criterium> m_criteria;
};
} // namespace LHCb::MC
inline LHCb::MC::MCTrackGeomCriteria::MCTrackGeomCriteria( std::vector<MCTrackGeomCriteria::Criteria> criteria )
: m_criteria( std::move( criteria ) ) {}
inline LHCb::MC::MCTrackGeomCriteria::Criteria
LHCb::MC::MCTrackGeomCriteria::FunctionMap::toType( const std::string& aName ) const {
// map to enum
const auto iter = m_mapping.find( aName );
return ( iter != m_mapping.end() ? iter->second : Criteria() );
}
#endif
Loading