CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/Common/interface/HLTGlobalStatus.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Common_HLTGlobalStatus_h
00002 #define DataFormats_Common_HLTGlobalStatus_h
00003 
00020 #include "DataFormats/Common/interface/HLTenums.h"
00021 #include "DataFormats/Common/interface/HLTPathStatus.h"
00022 
00023 #include <vector>
00024 #include <ostream>
00025 
00026 namespace edm
00027 {
00028   class HLTGlobalStatus {
00029 
00030   private:
00031 
00033     std::vector<HLTPathStatus> paths_;
00034 
00035   public:
00036 
00038     HLTGlobalStatus(const unsigned int n=0) : paths_(n) {}
00039 
00041     unsigned int size() const { return paths_.size(); }
00042 
00044     void reset() {
00045       const unsigned int n(size());
00046       for (unsigned int i = 0; i != n; ++i) paths_[i].reset();
00047     }
00048 
00049     // global "state" variables calculated on the fly!
00050 
00052     bool wasrun() const {return State(0);}
00054     bool accept() const {return State(1);}
00056     bool  error() const {return State(2);}
00057 
00058     // get hold of individual elements, using safe indexing with "at" which throws!
00059 
00060     const HLTPathStatus& at (const unsigned int i)   const { return paths_.at(i); }
00061           HLTPathStatus& at (const unsigned int i)         { return paths_.at(i); }
00062     const HLTPathStatus& operator[](const unsigned int i) const { return paths_.at(i); }
00063           HLTPathStatus& operator[](const unsigned int i)       { return paths_.at(i); }
00064 
00066     bool wasrun(const unsigned int i) const { return at(i).wasrun(); }
00068     bool accept(const unsigned int i) const { return at(i).accept(); }
00070     bool  error(const unsigned int i) const { return at(i).error() ; }
00071 
00073     hlt::HLTState state(const unsigned int i) const { return at(i).state(); }
00075     unsigned int  index(const unsigned int i) const { return at(i).index(); }
00077     void reset(const unsigned int i) { at(i).reset(); }
00079     void swap(HLTGlobalStatus& other) { paths_.swap(other.paths_); }
00081     HLTGlobalStatus& operator=(HLTGlobalStatus const& rhs) {
00082       HLTGlobalStatus temp(rhs);
00083       this->swap(temp);
00084       return *this;
00085     }
00086 
00087   private:
00088 
00090     bool State(unsigned int icase) const {
00091       bool flags[3] = {false, false, false};
00092       const unsigned int n(size());
00093       for (unsigned int i = 0; i != n; ++i) {
00094         const hlt::HLTState s(state(i));
00095         if (s!=hlt::Ready) {
00096           flags[0]=true;       // at least one trigger was run
00097           if (s==hlt::Pass) {
00098             flags[1]=true;     // at least one trigger accepted
00099           } else if (s==hlt::Exception) {
00100             flags[2]=true;     // at least one trigger with error
00101           }
00102         }
00103       }
00104       return flags[icase];
00105     }
00106 
00107   };
00108 
00110   inline
00111   void
00112   swap(HLTGlobalStatus& lhs, HLTGlobalStatus& rhs) {
00113     lhs.swap(rhs);
00114   }
00115 
00117   inline std::ostream& operator <<(std::ostream& ost, const HLTGlobalStatus& hlt) {
00118     std::vector<std::string> text(4); text[0]="n"; text[1]="1"; text[2]="0"; text[3]="e";
00119     const unsigned int n(hlt.size());
00120     for (unsigned int i = 0; i != n; ++i) ost << text.at(hlt.state(i));
00121     return ost;
00122   }
00123 
00124 }
00125 
00126 // The standard allows us to specialize std::swap for non-templates.
00127 // This ensures that HLTGlobalStatus::swap() will be used in algorithms.
00128 
00129 namespace std {
00130   template <> inline void swap(edm::HLTGlobalStatus& lhs, edm::HLTGlobalStatus& rhs) {
00131     lhs.swap(rhs);
00132   }
00133 }
00134 
00135 #endif // DataFormats_Common_HLTGlobalStatus_h
00136 
00137 
00138 
00139