File indexing completed on 2024-04-06 12:12:06
0001 #ifndef FWCore_Framework_TriggerResultsBasedEventSelector_h
0002 #define FWCore_Framework_TriggerResultsBasedEventSelector_h
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <string>
0012 #include <utility>
0013 #include <vector>
0014 #include <map>
0015
0016 #include "FWCore/Framework/interface/ConsumesCollector.h"
0017 #include "FWCore/Framework/interface/EventPrincipal.h"
0018 #include "FWCore/Framework/interface/EventSelector.h"
0019 #include "DataFormats/Common/interface/Handle.h"
0020 #include "FWCore/Utilities/interface/EDGetToken.h"
0021 #include "FWCore/Utilities/interface/InputTag.h"
0022
0023 namespace edm {
0024 class EventForOutput;
0025 class TriggerResults;
0026
0027 namespace detail {
0028 typedef edm::Handle<edm::TriggerResults> handle_t;
0029
0030 class NamedEventSelector {
0031 public:
0032 NamedEventSelector(std::string const& n, EventSelector const& s, ConsumesCollector&& iC)
0033 : inputTag_("TriggerResults", "", n), token_(iC.consumes<TriggerResults>(inputTag_)), eventSelector_(s) {}
0034
0035 bool match(TriggerResults const& product) { return eventSelector_.acceptEvent(product); }
0036
0037 InputTag const& inputTag() const { return inputTag_; }
0038
0039 EDGetTokenT<TriggerResults> const& token() const { return token_; }
0040
0041 private:
0042 InputTag inputTag_;
0043 EDGetTokenT<TriggerResults> token_;
0044 EventSelector eventSelector_;
0045 };
0046
0047 class TriggerResultsBasedEventSelector {
0048 public:
0049 TriggerResultsBasedEventSelector();
0050 typedef detail::handle_t handle_t;
0051 typedef std::vector<NamedEventSelector> selectors_t;
0052 typedef std::pair<std::string, std::string> parsed_path_spec_t;
0053
0054 void setupDefault();
0055
0056 void setup(std::vector<parsed_path_spec_t> const& path_specs,
0057 std::vector<std::string> const& triggernames,
0058 std::string const& process_name,
0059 ConsumesCollector&& iC);
0060
0061 bool wantEvent(EventForOutput const& e);
0062
0063 unsigned int numberOfTokens() const { return selectors_.size(); }
0064 EDGetToken token(unsigned int index) const { return selectors_[index].token(); }
0065
0066 private:
0067 selectors_t selectors_;
0068 bool wantAllEvents_;
0069 };
0070
0071
0072
0073
0074 bool configureEventSelector(edm::ParameterSet const& iPSet,
0075 std::string const& iProcessName,
0076 std::vector<std::string> const& iAllTriggerNames,
0077 edm::detail::TriggerResultsBasedEventSelector& oSelector,
0078 ConsumesCollector&& iC);
0079
0080
0081
0082 ParameterSetID registerProperSelectionInfo(
0083 edm::ParameterSet const& iInitial,
0084 std::string const& iLabel,
0085 std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
0086 bool anyProductProduced);
0087
0088 }
0089 }
0090
0091 #endif