EcalSrFlag

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 8; -*-

#ifndef ECALSRFLAG
#define ECALSRFLAG

#include "DataFormats/DetId/interface/DetId.h"

/** Base class for Selective Readout Flag (SR flag or SRF).
*/
class EcalSrFlag {
public:
  /** SRP flag for suppression of every channel of the readout
   * unit.
   */
  static const int SRF_SUPPRESS = 0;
  /** SRP flag for zero suppression with level 1.
   */
  static const int SRF_ZS1 = 1;
  /** SRP flag for zero suppression with level 2.
   */
  static const int SRF_ZS2 = 2;
  /** SRP flag for full readout of the readout unit.
   */
  static const int SRF_FULL = 3;
  /** Mask for the 'forced' bit which is set when the decision was
   * forced by an error condition or by configuration.
   * <P>E.g., a force full readout flag has value SRF_FORCED_MASK|SRF_FULL
   */
  static const int SRF_FORCED_MASK = 0x4;

public:
  /** Destructor
   */
  virtual ~EcalSrFlag() {}

  /** Gets the Det Id the flag is associated to.
   * @return the det id of the readout unit (a barrel TT or a SC).
   */
  virtual const DetId& id() const = 0;

  /** SR flag value. See SRF_XXX constants.
   * @return the flag value
   */
  int value() const { return flag_; }

  /** Set the SR flag value. See SRF_XXX constants.
   * @param flag new flag value. Must be between 0 and 7.
   */
  void setValue(const int& flag) { flag_ = (unsigned char)flag; }

  /** Cast to int: same as value().
   * @return the SR flag value
   */
  operator int() const { return flag_; }

  /** Return a human readable flag name from its integer value.
   * @param flag the flag value
   * @return the human readable string (which can contain space).
   */
  static std::string flagName(const int& flag) { return (flag == (flag & 0x7)) ? srfNames[flag] : "Invalid"; }

  /** Return a human readable flag name from the flag value.
   * @return the human readable string (which can contain space).
   */
  std::string flagName() const { return flagName(flag_); }

protected:
  /** The SRP flag.
   */
  unsigned char flag_;

private:
  /** Human readable flag value names
   */
  static const char* const srfNames[];
};

#endif  //ECALSRFLAG not defined