CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
WebTrackingHDQMInspector.cc File Reference
#include "DQMServices/Diagnostic/interface/HDQMInspector.h"
#include "DQM/SiStripHistoricInfoClient/interface/HDQMInspectorConfigTracking.h"
#include "DQMServices/Diagnostic/interface/DQMHistoryTrendsConfig.h"
#include "DQMServices/Diagnostic/interface/DQMHistoryCreateTrend.h"
#include <string>
#include <fstream>
#include <map>
#include <boost/algorithm/string.hpp>
#include <vector>
#include <sstream>
#include <iostream>
#include "FWCore/FWLite/interface/FWLiteEnabler.h"
#include <TROOT.h>
#include <TFile.h>
#include <TSystem.h>

Go to the source code of this file.

Classes

struct  plotData
 

Functions

std::string concatNames (const string &line)
 
int main (int argc, char *argv[])
 
void runInspector (const string &dbName, const string &tagName, const string &Password, const string &whiteListFile, const string &selectedTrends, const int Start, const int End, const string &CondList="")
 

Function Documentation

std::string concatNames ( const string &  line)

Definition at line 68 of file WebTrackingHDQMInspector.cc.

References i, split, AlCaHLTBitMon_QueryRunRegistry::string, and cond::rpcobgas::time.

69 {
70  std::vector<std::string> nameVector;
71  std::string concatValues="";
72  boost::split(nameVector,line, boost::is_any_of(",@"));
73  int time=0;
74  for (unsigned int i=0;i<nameVector.size();i++)
75  {
76  if (time==1)
77  {
78  concatValues+=","+nameVector[i];
79  time++;
80  }
81  else if (time==2)
82  {
83  concatValues+=nameVector[i];
84  time=0;
85  }
86  else
87  {
88  time++;
89  }
90 
91 
92  }
93  return concatValues;
94 }
int i
Definition: DBlmapReader.cc:9
double split
Definition: MVATrainer.cc:139
int main ( int  argc,
char *  argv[] 
)

Definition at line 239 of file WebTrackingHDQMInspector.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, gather_cfg::cout, FWLiteEnabler::enable(), and runInspector().

240 {
241  // load framework libraries
242  gSystem->Load( "libFWCoreFWLite" );
244 
245  if (argc < 9) {
246  std::cerr << argv[0] << " [Database] [TagName] [Password] [WhiteListFile] [SelectedTrends] [FirstRun] [LastRun] [CondList]" << std::endl;
247  return 1;
248  }
249 
250  std::cout << "Creating trends for range: " << argv[6] << " " << argv[7] << " for tag: " << argv[1] << std::endl;
251  runInspector( argv[1], argv[2], argv[3], argv[4], argv[5], atoi(argv[6]), atoi(argv[7]), argv[8] );
252  return 0;
253 }
static void enable()
enable automatic library loading
tuple argc
Definition: dir2webdir.py:38
void runInspector(const string &dbName, const string &tagName, const string &Password, const string &whiteListFile, const string &selectedTrends, const int Start, const int End, const string &CondList="")
tuple cout
Definition: gather_cfg.py:121
void runInspector ( const string &  dbName,
const string &  tagName,
const string &  Password,
const string &  whiteListFile,
const string &  selectedTrends,
const int  Start,
const int  End,
const string &  CondList = "" 
)

Definition at line 96 of file WebTrackingHDQMInspector.cc.

References DQMHistoryCreateTrend::closeFile(), HDQMInspectorConfigBase::computeIntegralList(), HDQMDatabaseProducer::config, gather_cfg::cout, cmsRelvalreport::exit, plotBeamSpotDB::first, plotData::firstRun, i, cmsHarvester::index, plotData::lastRun, geometryCSVtoXML::line, plotData::logY, plotData::maxY, plotData::minY, plotData::names, plotResiduals::plot(), DQMHistoryCreateTrend::setBlackList(), DQMHistoryCreateTrend::setDB(), DQMHistoryCreateTrend::setDebug(), DQMHistoryCreateTrend::setDoStat(), DQMHistoryCreateTrend::setSkip99s(), DQMHistoryCreateTrend::setWhiteListFromFile(), split, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by main().

97 {
98  // IMPORTANT SETTINGS:
99  // string siStripTracker = "268435456";
100  // string condition = siStripTracker+"@Chi2oNDF_GenTk@entries > 100"; // Use for collision data
101  string condition = ""; // Use for collision data
102  string blackList = "";
103  // -------------------
104 
105  HDQMInspectorConfigTracking trackingConfig;
106  // Select quantities you want the integral of
107  vector<string> ItemsForIntegration;
108  ItemsForIntegration.push_back("Chi2oNDF_GenTk_entries");
109  ItemsForIntegration.push_back("NumberOfTracks_GenTk_entries");
110  trackingConfig.computeIntegralList(ItemsForIntegration);
111  // Create the functor
112  DQMHistoryCreateTrend makeTrend(&trackingConfig);
113 
114  // Database and output configuration
115  makeTrend.setDB(dbName,tagName,"/afs/cern.ch/cms/DB/conddb");
116  // makeTrend.setDB(dbName,tagName,"cms_dqm_31x_offline", Password,"");
117  makeTrend.setDebug(1);
118  makeTrend.setDoStat(1);
119  makeTrend.setSkip99s(true);
120  makeTrend.setBlackList(blackList);
121  makeTrend.setWhiteListFromFile(whiteListFile);
122 
123  // Definition of trends
124  typedef DQMHistoryTrendsConfig Trend;
125  vector<Trend> config;
126 
127 
128 
129  std::string trendsFileName(selectedTrends);
130  std::ifstream trendsFile;
131  trendsFile.open(trendsFileName.c_str());
132  if( !trendsFile ) {
133  std::cout << "Error: trends configuration file: " << trendsFileName << " not found" << std::endl;
134  exit(1);
135  }
136 
137  //Creating condition string
138  if ( CondList != "" ){
139  std::ifstream condFile;
140  condFile.open(CondList.c_str());
141  if ( condFile ){
142  //Read the file
143  bool first = true;
144  while (!condFile.eof()){
146  getline(condFile, line);
147  if ( line != ""){
148  if (!first)
149  condition+= " && ";
150  else
151  first = false;
152  condition+= line;
153  }
154  }
155  cout << condition << endl;
156  }
157  else
158  std::cout << "Warning: File " << CondList << " not found : conditions will not be used" << std::endl;
159  }
160 
161 
162 
163  std::string configLine;
164 
165  typedef std::map<std::string,plotData> trendsMap;
166  //map for holding the super imposed plots
167  std::map<std::string,plotData> superImposedtrendsMap;
168  //vector for holding the normal plots
169  std::vector<plotData> trendsVector;
170  //iterator for Map
171  typedef std::map<std::string,plotData>::iterator trendsMapIter;
172 
173 
174  while( !trendsFile.eof() )
175  {
177  getline(trendsFile, line);
178  if( line != "" )
179  {
180  std::vector<std::string> strs;
181  boost::split(strs, line, boost::is_any_of(" "));
182 
183 
184  if( strs.size() == 8 )
185  {
186  //Tracker name
187  std::string index=strs[4];
188  plotData plot(line);
189  if (index=="0")
190  trendsVector.push_back(plot);
191  else
192  {
193  pair<trendsMapIter, bool> insertResult = superImposedtrendsMap.insert(std::make_pair(index,plot));
194  if(!insertResult.second)
195  {
196  std::string newName=strs[0];
197  superImposedtrendsMap[index].names += "," + newName;
198  }
199  }
200  }//if
201  else
202  {
203  std::cout << "Warning: trend configuration line: " << line << " is not formatted correctly. It will be skipped." << std::endl;
204  }//else
205 
206  } //if
207  } //while
208 
209  //creating super imposed plots
210  for(map<std::string,plotData>::const_iterator it = superImposedtrendsMap.begin(); it != superImposedtrendsMap.end(); ++it)
211  {
212  plotData plot=it->second;
213  if (plot.maxY<plot.minY)
214  {
215  plot.minY=0;
216  plot.maxY=100;
217  }
218  //pushing back the superimposed plots into the vector
219  config.push_back(Trend(plot.names, plot.names+".gif",plot.logY, condition, plot.names, plot.firstRun,plot.lastRun,0,plot.minY,plot.maxY));
220  }
221  //creating normal plots
222  for (unsigned int i=0; i<trendsVector.size();i++)
223  {
224  plotData plot=trendsVector[i];
225  printf("New Trend:\n%s %d %d %d %d %f %f\n",plot.names.c_str(),plot.logY, plot.firstRun,plot.lastRun,0,plot.minY,plot.maxY);
226  config.push_back(Trend(plot.names, plot.names+".gif",plot.logY, condition, plot.names, plot.firstRun,plot.lastRun,0,plot.minY,plot.maxY));
227  }
228 
229  cout << "Test Web: Trends created. " << endl;
230  // Creation of trend
231  for_each(config.begin(), config.end(), makeTrend);
232  cout << "Test Web: Trends maded" << endl;
233  // Close the output file
234  makeTrend.closeFile();
235 }
int i
Definition: DBlmapReader.cc:9
string dbName
Definition: EcalCondDB.py:76
virtual bool computeIntegralList(const std::vector< std::string > &computeIntegralVector)
fills the list of names of quantities for which a summation over the runs is required ...
tuple cout
Definition: gather_cfg.py:121
double split
Definition: MVATrainer.cc:139