CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes
jsoncollector::DataPointDefinition Class Reference

#include <DataPointDefinition.h>

Inheritance diagram for jsoncollector::DataPointDefinition:
jsoncollector::JsonSerializable

Public Member Functions

void addLegendItem (std::string const &name, std::string const &type, std::string const &operation)
 
 DataPointDefinition ()
 
void deserialize (Json::Value &root) override
 
std::string & getDefFilePath ()
 
std::vector< std::string > const & getNames ()
 
OperationType getOperationFor (unsigned int index)
 
std::vector< std::string > const & getOperations ()
 
bool isPopulated () const
 
void serialize (Json::Value &root) const override
 
void setDefaultGroup (std::string const &group)
 
 ~DataPointDefinition () override
 
- Public Member Functions inherited from jsoncollector::JsonSerializable
virtual ~JsonSerializable ()
 

Static Public Member Functions

static bool getDataPointDefinitionFor (std::string &defFilePath, DataPointDefinition *dpd, const std::string *defaultGroup=nullptr)
 

Static Public Attributes

static const std::string ADLER32 = "adler32"
 
static const std::string AVG = "avg"
 
static const std::string BINARYOR = "binaryOr"
 
static const std::string CAT = "cat"
 
static const std::string DATA = "data"
 
static const std::string HISTO = "histo"
 
static const std::string LEGEND = "legend"
 
static const std::string MERGE = "merge"
 
static const std::string OPERATION = "operation"
 
static const std::string PARAM_NAME = "name"
 
static const std::string SAME = "same"
 
static const std::string SUM = "sum"
 
static const std::string TYPE = "type"
 

Private Attributes

std::string defaultGroup_
 
std::string defFilePath_
 
std::vector< std::string > opNames_
 
std::vector< std::string > typeNames_
 
std::vector< std::string > varNames_
 

Detailed Description

Definition at line 20 of file DataPointDefinition.h.

Constructor & Destructor Documentation

◆ DataPointDefinition()

jsoncollector::DataPointDefinition::DataPointDefinition ( )
inline

Definition at line 22 of file DataPointDefinition.h.

22 {}

◆ ~DataPointDefinition()

jsoncollector::DataPointDefinition::~DataPointDefinition ( )
inlineoverride

Definition at line 27 of file DataPointDefinition.h.

27 {}

Member Function Documentation

◆ addLegendItem()

void DataPointDefinition::addLegendItem ( std::string const &  name,
std::string const &  type,
std::string const &  operation 
)

Definition at line 93 of file DataPointDefinition.cc.

95  {
96  varNames_.push_back(name);
97  typeNames_.push_back(type);
98  opNames_.push_back(operation);
99 }

References Skims_PA_cff::name, opNames_, typeNames_, and varNames_.

Referenced by evf::EvFOutputJSONWriter::EvFOutputJSONWriter(), and RawEventFileWriterForBU::RawEventFileWriterForBU().

◆ deserialize()

void DataPointDefinition::deserialize ( Json::Value root)
overridevirtual

JSON deserialization procedure for this class

Implements jsoncollector::JsonSerializable.

Definition at line 61 of file DataPointDefinition.cc.

61  {
62  if (root.get(defaultGroup_, "").isArray()) {
63  unsigned int size = root.get(defaultGroup_, "").size();
64  for (unsigned int i = 0; i < size; i++) {
65  varNames_.push_back(root.get(defaultGroup_, "")[i].get(PARAM_NAME, "").asString());
66  opNames_.push_back(root.get(defaultGroup_, "")[i].get(OPERATION, "").asString());
67  typeNames_.push_back(root.get(defaultGroup_, "")[i].get(TYPE, "").asString());
68  }
69  }
70 }

References defaultGroup_, mps_fire::i, OPERATION, opNames_, PARAM_NAME, findQualityFiles::size, TYPE, typeNames_, and varNames_.

◆ getDataPointDefinitionFor()

bool DataPointDefinition::getDataPointDefinitionFor ( std::string &  defFilePath,
DataPointDefinition dpd,
const std::string *  defaultGroup = nullptr 
)
static

Loads a DataPointDefinition from a specified reference

Definition at line 32 of file DataPointDefinition.cc.

34  {
35  std::string dpdString;
36  bool readOK = FileIO::readStringFromFile(defFilePath, dpdString);
37  // data point definition is missing!
38  if (!readOK) {
39  edm::LogWarning("DataPointDefinition") << "Cannot read from JSON definition path -: " << defFilePath;
40  return false;
41  }
42  if (!defaultGroup)
43  dpd->setDefaultGroup(LEGEND);
44  else
45  dpd->setDefaultGroup(*defaultGroup);
46  JSONSerializer::deserialize(dpd, dpdString);
47  return true;
48 }

References jsoncollector::JSONSerializer::deserialize(), LEGEND, jsoncollector::FileIO::readStringFromFile(), setDefaultGroup(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by jsoncollector::FastMonitor::addFastPathDefinition(), and jsoncollector::FastMonitor::FastMonitor().

◆ getDefFilePath()

std::string& jsoncollector::DataPointDefinition::getDefFilePath ( )
inline

Definition at line 60 of file DataPointDefinition.h.

60 { return defFilePath_; }

References defFilePath_.

◆ getNames()

std::vector<std::string> const& jsoncollector::DataPointDefinition::getNames ( )
inline

Returns a LegendItem object ref at the specified index

Definition at line 44 of file DataPointDefinition.h.

44 { return varNames_; }

References varNames_.

Referenced by jsoncollector::FastMonitor::commit(), evf::EvFDaqDirector::getNFilesFromEoLS(), evf::EvFDaqDirector::grabNextJsonFile(), and evf::EvFDaqDirector::grabNextJsonFileAndUnlock().

◆ getOperationFor()

OperationType DataPointDefinition::getOperationFor ( unsigned int  index)

Definition at line 78 of file DataPointDefinition.cc.

78  {
79  OperationType opType = OPUNKNOWN;
81  opType = OPSUM;
83  opType = OPAVG;
85  opType = OPSAME;
87  opType = OPHISTO;
89  opType = OPCAT;
90  return opType;
91 }

References AVG, CAT, HISTO, jsoncollector::OPAVG, jsoncollector::OPCAT, jsoncollector::OPHISTO, opNames_, jsoncollector::OPSAME, jsoncollector::OPSUM, jsoncollector::OPUNKNOWN, SAME, and SUM.

Referenced by jsoncollector::FastMonitor::commit().

◆ getOperations()

std::vector<std::string> const& jsoncollector::DataPointDefinition::getOperations ( )
inline

Definition at line 45 of file DataPointDefinition.h.

45 { return opNames_; }

References opNames_.

◆ isPopulated()

bool DataPointDefinition::isPopulated ( ) const

Returns true if the legend_ has elements

Definition at line 72 of file DataPointDefinition.cc.

72  {
73  if (!varNames_.empty())
74  return true;
75  return false;
76 }

References varNames_.

◆ serialize()

void DataPointDefinition::serialize ( Json::Value root) const
overridevirtual

JSON serialization procedure for this class

Implements jsoncollector::JsonSerializable.

Definition at line 50 of file DataPointDefinition.cc.

50  {
51  for (unsigned int i = 0; i < varNames_.size(); i++) {
52  Json::Value currentDef;
53  currentDef[PARAM_NAME] = varNames_[i];
54  currentDef[OPERATION] = opNames_[i];
55  if (!typeNames_[i].empty()) //only if it was found
56  currentDef[TYPE] = typeNames_[i];
57  root[defaultGroup_].append(currentDef);
58  }
59 }

References defaultGroup_, relativeConstraints::empty, mps_fire::i, OPERATION, opNames_, PARAM_NAME, TYPE, typeNames_, and varNames_.

◆ setDefaultGroup()

void jsoncollector::DataPointDefinition::setDefaultGroup ( std::string const &  group)
inline

Member Data Documentation

◆ ADLER32

const std::string DataPointDefinition::ADLER32 = "adler32"
static

◆ AVG

const std::string DataPointDefinition::AVG = "avg"
static

Definition at line 65 of file DataPointDefinition.h.

Referenced by getOperationFor().

◆ BINARYOR

const std::string DataPointDefinition::BINARYOR = "binaryOr"
static

◆ CAT

const std::string DataPointDefinition::CAT = "cat"
static

◆ DATA

const std::string DataPointDefinition::DATA = "data"
static

Definition at line 75 of file DataPointDefinition.h.

◆ defaultGroup_

std::string jsoncollector::DataPointDefinition::defaultGroup_
private

Definition at line 85 of file DataPointDefinition.h.

Referenced by deserialize(), serialize(), and setDefaultGroup().

◆ defFilePath_

std::string jsoncollector::DataPointDefinition::defFilePath_
private

Definition at line 84 of file DataPointDefinition.h.

Referenced by getDefFilePath().

◆ HISTO

const std::string DataPointDefinition::HISTO = "histo"
static

Definition at line 67 of file DataPointDefinition.h.

Referenced by getOperationFor().

◆ LEGEND

const std::string DataPointDefinition::LEGEND = "legend"
static

Definition at line 74 of file DataPointDefinition.h.

Referenced by getDataPointDefinitionFor().

◆ MERGE

const std::string DataPointDefinition::MERGE = "merge"
static

◆ OPERATION

const std::string DataPointDefinition::OPERATION = "operation"
static

Definition at line 77 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

◆ opNames_

std::vector<std::string> jsoncollector::DataPointDefinition::opNames_
private

◆ PARAM_NAME

const std::string DataPointDefinition::PARAM_NAME = "name"
static

Definition at line 76 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

◆ SAME

const std::string DataPointDefinition::SAME = "same"
static

◆ SUM

const std::string DataPointDefinition::SUM = "sum"
static

◆ TYPE

const std::string DataPointDefinition::TYPE = "type"
static

Definition at line 78 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

◆ typeNames_

std::vector<std::string> jsoncollector::DataPointDefinition::typeNames_
private

Definition at line 82 of file DataPointDefinition.h.

Referenced by addLegendItem(), deserialize(), and serialize().

◆ varNames_

std::vector<std::string> jsoncollector::DataPointDefinition::varNames_
private

Definition at line 81 of file DataPointDefinition.h.

Referenced by addLegendItem(), deserialize(), getNames(), isPopulated(), and serialize().

jsoncollector::OPSUM
Definition: JsonMonitorable.h:22
mps_fire.i
i
Definition: mps_fire.py:428
jsoncollector::DataPointDefinition::defaultGroup_
std::string defaultGroup_
Definition: DataPointDefinition.h:85
jsoncollector::DataPointDefinition::setDefaultGroup
void setDefaultGroup(std::string const &group)
Definition: DataPointDefinition.h:54
jsoncollector::DataPointDefinition::AVG
static const std::string AVG
Definition: DataPointDefinition.h:65
jsoncollector::DataPointDefinition::typeNames_
std::vector< std::string > typeNames_
Definition: DataPointDefinition.h:82
jsoncollector::DataPointDefinition::defFilePath_
std::string defFilePath_
Definition: DataPointDefinition.h:84
jsoncollector::OperationType
OperationType
Definition: JsonMonitorable.h:22
jsoncollector::DataPointDefinition::TYPE
static const std::string TYPE
Definition: DataPointDefinition.h:78
jsoncollector::OPUNKNOWN
Definition: JsonMonitorable.h:22
jsoncollector::DataPointDefinition::PARAM_NAME
static const std::string PARAM_NAME
Definition: DataPointDefinition.h:76
jsoncollector::FileIO::readStringFromFile
static bool readStringFromFile(std::string const &filename, std::string &content)
Definition: FileIO.cc:28
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
jsoncollector::OPSAME
Definition: JsonMonitorable.h:22
jsoncollector::DataPointDefinition::SUM
static const std::string SUM
Definition: DataPointDefinition.h:64
jsoncollector::DataPointDefinition::CAT
static const std::string CAT
Definition: DataPointDefinition.h:68
jsoncollector::OPCAT
Definition: JsonMonitorable.h:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
jsoncollector::DataPointDefinition::opNames_
std::vector< std::string > opNames_
Definition: DataPointDefinition.h:83
jsoncollector::DataPointDefinition::HISTO
static const std::string HISTO
Definition: DataPointDefinition.h:67
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
jsoncollector::DataPointDefinition::OPERATION
static const std::string OPERATION
Definition: DataPointDefinition.h:77
jsoncollector::DataPointDefinition::SAME
static const std::string SAME
Definition: DataPointDefinition.h:66
jsoncollector::DataPointDefinition::varNames_
std::vector< std::string > varNames_
Definition: DataPointDefinition.h:81
root
Definition: RooFitFunction.h:10
jsoncollector::OPAVG
Definition: JsonMonitorable.h:22
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
jsoncollector::DataPointDefinition::LEGEND
static const std::string LEGEND
Definition: DataPointDefinition.h:74
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
jsoncollector::OPHISTO
Definition: JsonMonitorable.h:22
jsoncollector::JSONSerializer::deserialize
static bool deserialize(JsonSerializable *pObj, std::string &input)
Definition: JSONSerializer.cc:26
Json::Value
Represents a JSON value.
Definition: value.h:99
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
watchdog.group
group
Definition: watchdog.py:82