Skip to content

Commit

Permalink
Merge pull request #10951 from wmtan/TriggerResultsBasedEventSelector…
Browse files Browse the repository at this point in the history
…Cleanup

Thread Safety: Remove unneeded state from TriggerResultsBasedEventSelector
  • Loading branch information
cmsbuild committed Aug 30, 2015
2 parents 6efd44f + 4ca2385 commit fc6792e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 178 deletions.
63 changes: 11 additions & 52 deletions FWCore/Framework/interface/TriggerResultsBasedEventSelector.h
Expand Up @@ -18,91 +18,50 @@
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Utilities/interface/InputTag.h"

namespace edm
{
namespace edm {
class ModuleCallingContext;

namespace detail
{
namespace detail {
typedef edm::Handle<edm::TriggerResults> handle_t;

class NamedEventSelector
{
class NamedEventSelector {
public:
NamedEventSelector(std::string const& n, EventSelector const& s) :
inputTag_("TriggerResults", "", n),
eventSelector_(s),
product_()
inputTag_("TriggerResults", "", n),
eventSelector_(s)
{ }

void fill(EventPrincipal const& e, ModuleCallingContext const* mcc);

bool match()
{
return eventSelector_.acceptEvent(*product_);
bool match(TriggerResults const& product) {
return eventSelector_.acceptEvent(product);
}

handle_t product() const
{
return product_;
InputTag const& inputTag() const {
return inputTag_;
}

void clear()
{
product_ = handle_t();
}

private:
InputTag inputTag_;
EventSelector eventSelector_;
handle_t product_;
};

class TriggerResultsBasedEventSelector
{
class TriggerResultsBasedEventSelector {
public:
TriggerResultsBasedEventSelector();
typedef detail::handle_t handle_t;
typedef std::vector<NamedEventSelector> selectors_t;
typedef selectors_t::size_type size_type;
typedef std::pair<std::string, std::string> parsed_path_spec_t;

void setupDefault(std::vector<std::string> const& triggernames);

void setup(std::vector<parsed_path_spec_t> const& path_specs,
std::vector<std::string> const& triggernames,
const std::string& process_name);

bool wantEvent(EventPrincipal const& e, ModuleCallingContext const*);

// Clear the cache
void clear();

private:
typedef selectors_t::iterator iter;

// Get all TriggerResults objects for the process names we're
// interested in.
size_type fill(EventPrincipal const& ev, ModuleCallingContext const*);

bool fillDone_;
size_type numberFound_;
selectors_t selectors_;
};

class TRBESSentry {
public:
TRBESSentry(detail::TriggerResultsBasedEventSelector& prods) : p(prods) {}
~TRBESSentry() {
p.clear();
}
private:
detail::TriggerResultsBasedEventSelector& p;

TRBESSentry(TRBESSentry const&) = delete;
TRBESSentry& operator=(TRBESSentry const&) = delete;
};


/** Handles the final initialization of the TriggerResutsBasedEventSelector
\return true if all events will be selected
Expand Down
2 changes: 0 additions & 2 deletions FWCore/Framework/src/OutputModule.cc
Expand Up @@ -215,8 +215,6 @@ namespace edm {
bool OutputModule::prePrefetchSelection(StreamID id, EventPrincipal const& ep, ModuleCallingContext const* mcc) {

auto& s = selectors_[id.value()];
detail::TRBESSentry products_sentry(s);

return wantAllEvents_ or s.wantEvent(ep,mcc);
}

Expand Down
3 changes: 0 additions & 3 deletions FWCore/Framework/src/SubProcess.cc
Expand Up @@ -296,9 +296,6 @@ namespace edm {
SubProcess::doEvent(EventPrincipal const& ep) {
ServiceRegistry::Operate operate(serviceToken_);
/* BEGIN relevant bits from OutputModule::doEvent */
detail::TRBESSentry products_sentry(selectors_);


if(!wantAllEvents_) {
// use module description and const_cast unless interface to
// event is changed to just take a const EventPrincipal
Expand Down

0 comments on commit fc6792e

Please sign in to comment.