CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
jsoncollector::FastMonitor Class Reference

#include <FastMonitor.h>

Public Member Functions

 FastMonitor (const std::vector< JsonMonitorable * > &monitorableVariables, std::string defPath)
 
void outputFullHistoDataPoint (std::string path)
 
void snap (bool outputCSVFile, std::string path)
 
virtual ~FastMonitor ()
 

Private Member Functions

JsonMonitorablegetVarForName (string name) const
 

Private Attributes

std::vector< string > accumulatedCSV_
 
std::string defPath_
 
DataPointDefinition dpd_
 
std::vector< JsonMonitorable * > monitorableVars_
 
std::vector< JsonMonitorable * > monitoredVars_
 
bool snappedOnce_
 

Detailed Description

Definition at line 17 of file FastMonitor.h.

Constructor & Destructor Documentation

FastMonitor::FastMonitor ( const std::vector< JsonMonitorable * > &  monitorableVariables,
std::string  defPath 
)

Definition at line 25 of file FastMonitor.cc.

References defPath_, dpd_, jsoncollector::ObjectMerger::getDataPointDefinitionFor(), jsoncollector::DataPointDefinition::getLegend(), getVarForName(), i, jsoncollector::DataPointDefinition::isPopulated(), and monitoredVars_.

26  :
27  snappedOnce_(false), monitorableVars_(monitorableVariables),
28  defPath_(defPath) {
29 
31  if (dpd_.isPopulated()) {
32  for (unsigned int i = 0; i < dpd_.getLegend().size(); i++) {
33  string toBeMonitored = dpd_.getLegend()[i].getName();
34  monitoredVars_.push_back(getVarForName(toBeMonitored));
35  }
36  }
37 }
int i
Definition: DBlmapReader.cc:9
JsonMonitorable * getVarForName(string name) const
Definition: FastMonitor.cc:99
std::vector< JsonMonitorable * > monitorableVars_
Definition: FastMonitor.h:35
DataPointDefinition dpd_
Definition: FastMonitor.h:34
std::vector< JsonMonitorable * > monitoredVars_
Definition: FastMonitor.h:36
static bool getDataPointDefinitionFor(std::string defFilePath, DataPointDefinition &def)
std::vector< LegendItem > getLegend() const
FastMonitor::~FastMonitor ( )
virtual

Definition at line 39 of file FastMonitor.cc.

39  {
40 }

Member Function Documentation

JsonMonitorable * FastMonitor::getVarForName ( string  name) const
private

Definition at line 99 of file FastMonitor.cc.

References i, and monitorableVars_.

Referenced by FastMonitor().

99  {
100  for (unsigned int i = 0; i < monitorableVars_.size(); i++)
101  if (name.compare(monitorableVars_[i]->getName()) == 0)
102  return monitorableVars_[i];
103  return 0;
104 }
int i
Definition: DBlmapReader.cc:9
std::vector< JsonMonitorable * > monitorableVars_
Definition: FastMonitor.h:35
void FastMonitor::outputFullHistoDataPoint ( std::string  path)

Definition at line 65 of file FastMonitor.cc.

References accumulatedCSV_, gather_cfg::cout, jsoncollector::ObjectMerger::csvToJson(), defPath_, dpd_, jsoncollector::Utils::getHostAndPID(), i, jsoncollector::ObjectMerger::merge(), lumiQueryAPI::msg, jsoncollector::JSONSerializer::serialize(), jsoncollector::DataPoint::setSource(), snappedOnce_, and jsoncollector::FileIO::writeStringToFile().

65  {
66  if (accumulatedCSV_.size() > 0) {
67  std::cout << "accumulatedCSV_.size()=" << accumulatedCSV_.size() << std::endl;
68  assert(accumulatedCSV_.size()<100);
69  vector<DataPoint*> dpToMerge;
70 
71  for (unsigned int i = 0; i < accumulatedCSV_.size(); i++) {
72  string currentCSV = accumulatedCSV_[i];
73  DataPoint* currentDP = ObjectMerger::csvToJson(currentCSV, &dpd_,
74  defPath_);
75  string hpid;
77  currentDP->setSource(hpid);
78  dpToMerge.push_back(currentDP);
79  }
80 
81  string outputJSONAsString;
82  string msg;
83 
84  DataPoint* mergedDP = ObjectMerger::merge(dpToMerge, msg, true);
85  mergedDP->setSource(dpToMerge[0]->getSource());
86 
87  for (unsigned int i = 0; i < dpToMerge.size(); i++)
88  delete dpToMerge[i];
89 
90  JSONSerializer::serialize(mergedDP, outputJSONAsString);
91  FileIO::writeStringToFile(path, outputJSONAsString);
92 
93  accumulatedCSV_.clear();
94  snappedOnce_ = false;
95 
96  }
97 }
int i
Definition: DBlmapReader.cc:9
static void writeStringToFile(std::string &filename, std::string &content)
Definition: FileIO.cc:26
static void getHostAndPID(std::string &sHPid)
Definition: Utils.cc:43
static bool serialize(JsonSerializable *pObj, std::string &output)
DataPointDefinition dpd_
Definition: FastMonitor.h:34
static DataPoint * csvToJson(std::string &olCSV, DataPointDefinition *dpd, std::string defPath)
static DataPoint * merge(const std::vector< DataPoint * > &objectsToMerge, std::string &outcomeMessage, bool onlyHistos)
Definition: ObjectMerger.cc:23
void setSource(std::string source)
Definition: DataPoint.h:44
std::vector< string > accumulatedCSV_
Definition: FastMonitor.h:37
tuple cout
Definition: gather_cfg.py:121
void FastMonitor::snap ( bool  outputCSVFile,
std::string  path 
)

Definition at line 42 of file FastMonitor.cc.

References accumulatedCSV_, defPath_, i, monitoredVars_, dbtoconf::out, download_sqlite_cfg::outputFile, and estimatePileup_makeJSON::trunc.

42  {
43  std::stringstream ss;
44  for (unsigned int i = 0; i < monitoredVars_.size(); i++) {
45  if (i == monitoredVars_.size() - 1) {
46  ss << monitoredVars_[i]->toString();
47  break;
48  }
49  ss << monitoredVars_[i]->toString() << ",";
50  }
51 
52  if (outputCSVFile) {
53  ofstream outputFile;
54  outputFile.open(path.c_str(), fstream::out | fstream::trunc);
55  outputFile << defPath_ << endl;
56  outputFile << ss.str();
57  outputFile << endl;
58  outputFile.close();
59  }
60 
61  string inputStringCSV = ss.str();
62  accumulatedCSV_.push_back(inputStringCSV);
63 }
int i
Definition: DBlmapReader.cc:9
std::vector< JsonMonitorable * > monitoredVars_
Definition: FastMonitor.h:36
tuple out
Definition: dbtoconf.py:99
std::vector< string > accumulatedCSV_
Definition: FastMonitor.h:37

Member Data Documentation

std::vector<string> jsoncollector::FastMonitor::accumulatedCSV_
private

Definition at line 37 of file FastMonitor.h.

Referenced by outputFullHistoDataPoint(), and snap().

std::string jsoncollector::FastMonitor::defPath_
private

Definition at line 38 of file FastMonitor.h.

Referenced by FastMonitor(), outputFullHistoDataPoint(), and snap().

DataPointDefinition jsoncollector::FastMonitor::dpd_
private

Definition at line 34 of file FastMonitor.h.

Referenced by FastMonitor(), and outputFullHistoDataPoint().

std::vector<JsonMonitorable*> jsoncollector::FastMonitor::monitorableVars_
private

Definition at line 35 of file FastMonitor.h.

Referenced by getVarForName().

std::vector<JsonMonitorable*> jsoncollector::FastMonitor::monitoredVars_
private

Definition at line 36 of file FastMonitor.h.

Referenced by FastMonitor(), and snap().

bool jsoncollector::FastMonitor::snappedOnce_
private

Definition at line 33 of file FastMonitor.h.

Referenced by outputFullHistoDataPoint().