CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataPointDefinition.cc
Go to the documentation of this file.
1 /*
2  * DataPointDefinition.cc
3  *
4  * Created on: Sep 24, 2012
5  * Author: aspataru
6  */
7 
13 
14 using namespace jsoncollector;
15 
24 
30 
31 //static member implementation
34  const std::string* defaultGroup) {
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 }
49 
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 }
60 
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 }
71 
73  if (!varNames_.empty())
74  return true;
75  return false;
76 }
77 
79  OperationType opType = OPUNKNOWN;
81  opType = OPSUM;
83  opType = OPAVG;
85  opType = OPSAME;
87  opType = OPHISTO;
89  opType = OPCAT;
90  return opType;
91 }
92 
94  std::string const& type,
95  std::string const& operation) {
96  varNames_.push_back(name);
97  typeNames_.push_back(type);
98  opNames_.push_back(operation);
99 }
jsoncollector::OPSUM
Definition: JsonMonitorable.h:22
jsoncollector::DataPointDefinition::addLegendItem
void addLegendItem(std::string const &name, std::string const &type, std::string const &operation)
Definition: DataPointDefinition.cc:93
mps_fire.i
i
Definition: mps_fire.py:355
jsoncollector::DataPointDefinition::defaultGroup_
std::string defaultGroup_
Definition: DataPointDefinition.h:85
MessageLogger.h
jsoncollector::DataPointDefinition::setDefaultGroup
void setDefaultGroup(std::string const &group)
Definition: DataPointDefinition.h:54
jsoncollector::DataPointDefinition::deserialize
void deserialize(Json::Value &root) override
Definition: DataPointDefinition.cc:61
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::isPopulated
bool isPopulated() const
Definition: DataPointDefinition.cc:72
jsoncollector::OperationType
OperationType
Definition: JsonMonitorable.h:22
JsonMonitorable.h
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
jsoncollector::DataPointDefinition::MERGE
static const std::string MERGE
Definition: DataPointDefinition.h:69
FileIO.h
jsoncollector::OPSAME
Definition: JsonMonitorable.h:22
jsoncollector::DataPointDefinition::SUM
static const std::string SUM
Definition: DataPointDefinition.h:64
jsoncollector::DataPointDefinition::getDataPointDefinitionFor
static bool getDataPointDefinitionFor(std::string &defFilePath, DataPointDefinition *dpd, const std::string *defaultGroup=nullptr)
Definition: DataPointDefinition.cc:32
jsoncollector::DataPointDefinition::getOperationFor
OperationType getOperationFor(unsigned int index)
Definition: DataPointDefinition.cc:78
jsoncollector::DataPointDefinition::serialize
void serialize(Json::Value &root) const override
Definition: DataPointDefinition.cc:50
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
edm::LogWarning
Definition: MessageLogger.h:141
jsoncollector::DataPointDefinition::BINARYOR
static const std::string BINARYOR
Definition: DataPointDefinition.h:70
jsoncollector::DataPointDefinition::opNames_
std::vector< std::string > opNames_
Definition: DataPointDefinition.h:83
jsoncollector::DataPointDefinition::HISTO
static const std::string HISTO
Definition: DataPointDefinition.h:67
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
JSONSerializer.h
jsoncollector::OPAVG
Definition: JsonMonitorable.h:22
jsoncollector
Definition: DataPoint.h:26
jsoncollector::DataPointDefinition
Definition: DataPointDefinition.h:20
DataPointDefinition.h
type
type
Definition: HCALResponse.h:21
jsoncollector::DataPointDefinition::ADLER32
static const std::string ADLER32
Definition: DataPointDefinition.h:71
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
jsoncollector::DataPointDefinition::DATA
static const std::string DATA
Definition: DataPointDefinition.h:75
Json::Value
Represents a JSON value.
Definition: value.h:99
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443