Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:46:42

0001 #ifndef FWCore_Common_TriggerResultsByName_h
0002 #define FWCore_Common_TriggerResultsByName_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Common
0006 // Class  :     TriggerResultsByName
0007 //
0008 /**\class TriggerResultsByName TriggerResultsByName.h FWCore/Common/interface/TriggerResultsByName.h
0009 
0010  Description: Class which provides methods to access trigger results
0011 
0012  Usage:
0013     This class is intended to make it convenient and easy to
0014  get the trigger results from each event starting with the name
0015  of a trigger path.  One obtains an object of this class from
0016  the event using the Event::triggerResultsByName function.
0017  One can use this class for code which needs to work in both
0018  the full and the light (i.e. FWLite) frameworks.
0019 
0020     Once the user has an object of this class, the user can use
0021  the accessors below to get the trigger results for a trigger in
0022  one step, instead of first using the TriggerNames class to get
0023  the index and then using the index and the TriggerResults class
0024  to get the result.
0025 
0026     While the most common use of this class will be to get the
0027  results of the triggers from the HLT process, this class can
0028  also be used to get the results of the paths of any process
0029  used to create the input file.
0030 */
0031 //
0032 // Original Author:  W. David Dagenhart
0033 //         Created:  11 December 2009
0034 //
0035 
0036 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0037 #include "DataFormats/Common/interface/HLTenums.h"
0038 
0039 #include <string>
0040 #include <vector>
0041 
0042 namespace edm {
0043 
0044   class TriggerResults;
0045   class TriggerNames;
0046   class HLTPathStatus;
0047 
0048   class TriggerResultsByName {
0049   public:
0050     TriggerResultsByName(TriggerResults const* triggerResults, TriggerNames const* triggerNames);
0051 
0052     bool isValid() const;
0053 
0054     ParameterSetID const& parameterSetID() const;
0055 
0056     // Was at least one path run?
0057     bool wasrun() const;
0058 
0059     // Has at least one path accepted the event?
0060     bool accept() const;
0061 
0062     // Has any path encountered an error (exception)
0063     bool error() const;
0064 
0065     HLTPathStatus const& at(std::string const& pathName) const;
0066     HLTPathStatus const& at(unsigned i) const;
0067 
0068     HLTPathStatus const& operator[](std::string const& pathName) const;
0069     HLTPathStatus const& operator[](unsigned i) const;
0070 
0071     // Was ith path run?
0072     bool wasrun(std::string const& pathName) const;
0073     bool wasrun(unsigned i) const;
0074 
0075     // Has ith path accepted the event
0076     bool accept(std::string const& pathName) const;
0077     bool accept(unsigned i) const;
0078 
0079     // Has ith path encountered an error (exception)?
0080     bool error(std::string const& pathName) const;
0081     bool error(unsigned i) const;
0082 
0083     // Get status of ith path
0084     hlt::HLTState state(std::string const& pathName) const;
0085     hlt::HLTState state(unsigned i) const;
0086 
0087     // Get index (slot position) of module giving the decision of the ith path
0088     unsigned index(std::string const& pathName) const;
0089     unsigned index(unsigned i) const;
0090 
0091     std::vector<std::string> const& triggerNames() const;
0092 
0093     // Throws if the number is out of range.
0094     std::string const& triggerName(unsigned i) const;
0095 
0096     // If the input name is not known, this returns a value
0097     // equal to the size.
0098     unsigned triggerIndex(std::string const& pathName) const;
0099 
0100     // The number of trigger names.
0101     std::vector<std::string>::size_type size() const;
0102 
0103   private:
0104     unsigned getAndCheckIndex(std::string const& pathName) const;
0105 
0106     void throwTriggerResultsMissing() const;
0107     void throwTriggerNamesMissing() const;
0108 
0109     TriggerResults const* triggerResults_;
0110     TriggerNames const* triggerNames_;
0111   };
0112 }  // namespace edm
0113 #endif