Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:02

0001 #ifndef Framework_EventSelector_h
0002 #define Framework_EventSelector_h
0003 
0004 /*
0005   Author: Jim Kowalkowski 01-02-06
0006 
0007  */
0008 
0009 // Change Log
0010 //
0011 // 1 - Mark Fischler Feb 6, 2008
0012 //  Internals for implementation of glob-style wildcard selection
0013 //  In particular, !xyz* requires the vector nonveto_bits_
0014 //  nonveto_bits_ is designed to also accomodate an AND of triggers
0015 //      selection criterion, if that is wanted at some future date.
0016 
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "DataFormats/Common/interface/HLTPathStatus.h"
0019 #include "DataFormats/Common/interface/TriggerResults.h"
0020 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0021 
0022 #include <memory>
0023 
0024 #include <vector>
0025 #include <string>
0026 
0027 namespace edm {
0028   // possible return codes for the testSelectionOverlap
0029   // method defined below.
0030   namespace evtSel {
0031     enum OverlapResult { InvalidSelection = 0, NoOverlap = 1, PartialOverlap = 2, ExactMatch = 3 };
0032   }
0033 
0034   class ParameterSetDescription;
0035   class EventSelector {
0036   public:
0037     typedef std::vector<std::string> Strings;
0038 
0039     EventSelector(Strings const& pathspecs, Strings const& names);
0040 
0041     explicit EventSelector(Strings const& pathspecs);
0042 
0043     bool wantAll() const { return accept_all_; }
0044     bool acceptEvent(TriggerResults const&);
0045     bool acceptEvent(unsigned char const*, int) const;
0046 
0047     // 29-Jan-2008, KAB - added methods for testing and using
0048     // trigger selections (pathspecs).
0049     static bool selectionIsValid(Strings const& pathspec, Strings const& fullPathList);
0050     static evtSel::OverlapResult testSelectionOverlap(Strings const& pathspec1,
0051                                                       Strings const& pathspec2,
0052                                                       Strings const& fullPathList);
0053     std::shared_ptr<TriggerResults> maskTriggerResults(TriggerResults const& inputResults);
0054     static std::vector<std::string> getEventSelectionVString(edm::ParameterSet const& pset);
0055 
0056     static void fillDescription(ParameterSetDescription& desc);
0057 
0058   private:
0059     struct BitInfo {
0060       BitInfo(unsigned int pos, bool state) : pos_(pos), accept_state_(state) {}
0061       BitInfo() : pos_(), accept_state_() {}
0062 
0063       unsigned int pos_;
0064       bool accept_state_;
0065     };
0066 
0067     // These three data members never change after being initialized.
0068     Strings const pathspecs_;
0069     bool const results_from_current_process_;
0070     bool const accept_all_;
0071 
0072     typedef std::vector<BitInfo> Bits;
0073 
0074     Bits absolute_acceptors_;               // change 3
0075     Bits conditional_acceptors_;            // change 3
0076     Bits exception_acceptors_;              // change 3
0077     std::vector<Bits> all_must_fail_;       // change 1
0078     std::vector<Bits> all_must_fail_noex_;  // change 3
0079 
0080     ParameterSetID psetID_;
0081 
0082     int nPathNames_;
0083 
0084     // private member functions
0085 
0086     Strings initPathSpecs(Strings const& pathSpecs);
0087 
0088     bool initAcceptAll();
0089 
0090     void initPathNames(Strings const& pathNames);
0091 
0092     bool acceptTriggerPath(HLTPathStatus const&, BitInfo const&) const;
0093 
0094     bool acceptOneBit(Bits const& b, HLTGlobalStatus const& tr, hlt::HLTState const& s = hlt::Ready) const;
0095     bool acceptAllBits(Bits const& b, HLTGlobalStatus const& tr) const;
0096 
0097     bool containsExceptions(HLTGlobalStatus const& tr) const;
0098 
0099     bool selectionDecision(HLTGlobalStatus const& tr) const;
0100 
0101     static std::string glob2reg(std::string const& s);
0102     static std::vector<Strings::const_iterator> matching_triggers(Strings const& trigs, std::string const& s);
0103 
0104     static bool identical(std::vector<bool> const& a, std::vector<bool> const& b);
0105     static bool identical(EventSelector const& a, EventSelector const& b, unsigned int N);
0106     static std::vector<bool> expandDecisionList(Bits const& b, bool PassOrFail, unsigned int n);
0107     static bool overlapping(std::vector<bool> const& a, std::vector<bool> const& b);
0108     static bool subset(std::vector<bool> const& a, std::vector<bool> const& b);
0109     static std::vector<bool> combine(std::vector<bool> const& a, std::vector<bool> const& b);
0110   };
0111 }  // namespace edm
0112 
0113 #endif