Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:07

0001 #ifndef DQM_HcalCommon_Flag_h
0002 #define DQM_HcalCommon_Flag_h
0003 
0004 #include "DQM/HcalCommon/interface/HcalCommonHeaders.h"
0005 
0006 namespace hcaldqm {
0007   namespace flag {
0008     //
0009     //  State Definition. In the increasing order of worsiness.
0010     //  States(as flags) can be added
0011     //  s1 + s2 = max(s1,s2) - that allows to set the worse of the 2
0012     //
0013     enum State {
0014       fNONE = 0,         // No State - can't have... not used....
0015       fNCDAQ = 1,        // not @cDAQ
0016       fNA = 2,           // Not Applicable
0017       fGOOD = 3,         // GOOD
0018       fPROBLEMATIC = 4,  // problem
0019       fBAD = 5,          // bad
0020       fRESERVED = 6,     // reserved
0021       nState = 7
0022     };
0023 
0024     struct Flag {
0025       Flag() : _name("SOMEFLAG"), _state(fNA) {}
0026       Flag(std::string const &name, State s = fNA) : _name(name), _state(s) {}
0027       Flag(Flag const &f) : _name(f._name), _state(f._state) {}
0028 
0029       //
0030       //    add 2 flags
0031       //
0032       Flag operator+(Flag const &f) {
0033         return Flag(_name != f._name ? "SOMEFLAG" : _name, (State)(std::max(_state, f._state)));
0034       }
0035 
0036       //
0037       //    add 2 flags and save
0038       //
0039       Flag &operator+=(Flag const &f) {
0040         _state = (State)(std::max(_state, f._state));
0041         return *this;
0042       }
0043 
0044       //
0045       //    compare 2 flags
0046       //
0047       bool operator==(Flag const &f) { return (_state == f._state && _name == f._name); }
0048 
0049       //
0050       //    Assignment
0051       //
0052       Flag &operator=(Flag const &f) {
0053         _name = f._name;
0054         _state = f._state;
0055         return *this;
0056       }
0057 
0058       //    reset the state to NA
0059       void reset() { _state = fNA; }
0060 
0061       std::string _name;
0062       State _state;
0063     };
0064   }  // namespace flag
0065 }  // namespace hcaldqm
0066 
0067 #endif