HcalL1TriggerObjects

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
#ifndef HcalL1TriggerObjects_h
#define HcalL1TriggerObjects_h

#include "CondFormats/Serialization/interface/Serializable.h"

#include <cstring>
#include <string>

#include "CondFormats/HcalObjects/interface/HcalL1TriggerObject.h"
#include "CondFormats/HcalObjects/interface/HcalCondObjectContainer.h"

#include "FWCore/Utilities/interface/Exception.h"

class HcalL1TriggerObjects : public HcalCondObjectContainer<HcalL1TriggerObject> {
public:
#ifndef HCAL_COND_SUPPRESS_DEFAULT
  HcalL1TriggerObjects() : HcalCondObjectContainer<HcalL1TriggerObject>(nullptr) {}
#endif
  HcalL1TriggerObjects(const HcalTopology* topo) : HcalCondObjectContainer<HcalL1TriggerObject>(topo) {}

  //fill the chars and read them
  void setTagString(std::string const& fTag) {
    std::size_t maxCharacters = charArraySize - 1;
    if (fTag.size() > maxCharacters) {
      throw cms::Exception("HcalL1TriggerObjects::setTagString: string exceeds array size");
    }
    strncpy(mTag, fTag.c_str(), maxCharacters);
    mTag[maxCharacters] = '\0';
  }

  void setAlgoString(std::string const& fAlgo) {
    std::size_t maxCharacters = charArraySize - 1;
    if (fAlgo.size() > maxCharacters) {
      throw cms::Exception("HcalL1TriggerObjects::setAlgoString: string exceeds array size");
    }
    strncpy(mAlgo, fAlgo.c_str(), maxCharacters);
    mAlgo[maxCharacters] = '\0';
  }

  std::string getTagString() const { return mTag; }
  std::string getAlgoString() const { return mAlgo; }
  std::string myname() const override { return "HcalL1TriggerObjects"; }

private:
  static constexpr std::size_t charArraySize = 128;
  char mTag[charArraySize];
  char mAlgo[charArraySize];

  COND_SERIALIZABLE;
};
#endif