Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:51

0001 #ifndef DataFormats_Common_HLTPathStatus_h
0002 #define DataFormats_Common_HLTPathStatus_h
0003 
0004 /** \class edm::HLTPathStatus
0005  *
0006  *  The status of a single HLT trigger (single trigger path consisting
0007  *  of modules on the path).  Initially, the status is Ready (meaning
0008  *  that this trigger path has not run yet for this event).  If all
0009  *  modules on the path pass (accept) the event, then the state is
0010  *  Pass. If any module on the path fails (rejects) the event, then
0011  *  the state of the whole trigger path is Fail. If any module on the
0012  *  path throws an unhandled error, then the trigger state is
0013  *  Exception.  For the latter two cases, the Fw skips further
0014  *  processing of modules along this path, ie, path processing is
0015  *  aborted.
0016  *
0017  *  The index of the module on the path, 0 to n-1 for a path with n
0018  *  modules issuing the decision for the path is recorded.  For
0019  *  accepted events, this is simply the index of the last module on
0020  *  the path, ie, n-1.
0021  *
0022  *  Note that n is limited, due to packing, to at most 2^(16-2)=16384.
0023  *
0024  *  \author Martin Grunewald
0025  *
0026  */
0027 
0028 #include "DataFormats/Common/interface/HLTenums.h"
0029 #include <cassert>
0030 #include <cstdint>
0031 
0032 namespace edm {
0033   class HLTPathStatus {
0034   private:
0035     /// packed status of trigger path [unsigned char is too small]
0036     uint16_t status_;
0037     // bits 0- 1 (0-    3): HLT state
0038     // bits 2-16 (0-16383): index of module on path making path decision
0039 
0040   public:
0041     /// constructor
0042     HLTPathStatus(const hlt::HLTState state = hlt::Ready, const unsigned int index = 0) : status_(index * 4 + state) {
0043       assert(((int)state) < 4);
0044       assert(index < 16384);
0045     }
0046 
0047     /// get state of path
0048     hlt::HLTState state() const { return (static_cast<hlt::HLTState>(status_ % 4)); }
0049     /// get index of module giving the status of this path
0050     /// Nota Bene: if a Path or EndPath is empty (that is, it does not contain any ED module),
0051     /// index will be 0, even if there is no "0th module" responsible for the status of the path
0052     unsigned int index() const { return (static_cast<unsigned int>(status_ / 4)); }
0053     /// reset this path
0054     void reset() { status_ = 0; }
0055 
0056     /// was this path run?
0057     bool wasrun() const { return (state() != hlt::Ready); }
0058     /// has this path accepted the event?
0059     bool accept() const { return (state() == hlt::Pass); }
0060     /// has this path encountered an error (exception)?
0061     bool error() const { return (state() == hlt::Exception); }
0062   };
0063 }  // namespace edm
0064 
0065 #endif  // DataFormats_Common_HLTPathStatus_h