CMS 3D CMS Logo

Classes | Functions

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQM/SiStripHistoricInfoClient/bin/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/AutoLibraryLoader.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.

{
  std::vector<std::string> nameVector;
  std::string concatValues="";
  boost::split(nameVector,line, boost::is_any_of(",@"));
  int time=0;   
  for (unsigned int i=0;i<nameVector.size();i++)
  {
    if (time==1)
    {   
      concatValues+=","+nameVector[i];
      time++;
    }
    else if (time==2)
    {
      concatValues+=nameVector[i];
      time=0;
    }
    else
    {
      time++;
    }
        
                
  }
  return concatValues;
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 239 of file WebTrackingHDQMInspector.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, AutoLibraryLoader::enable(), and runInspector().

{
  // load framework libraries
  gSystem->Load( "libFWCoreFWLite" );
  AutoLibraryLoader::enable();

  if (argc < 9) {
    std::cerr << argv[0] << " [Database] [TagName] [Password] [WhiteListFile] [SelectedTrends] [FirstRun] [LastRun] [CondList]" << std::endl;
  return 1;
  }

  std::cout << "Creating trends for range:  " << argv[6] << " " << argv[7] << " for tag: " << argv[1] << std::endl;
  runInspector( argv[1], argv[2], argv[3], argv[4], argv[5], atoi(argv[6]), atoi(argv[7]), argv[8] );
  return 0;
}
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, first, plotData::firstRun, i, getHLTprescales::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().

{
  // IMPORTANT SETTINGS:
  // string siStripTracker = "268435456";
  // string condition = siStripTracker+"@Chi2oNDF_GenTk@entries > 100";  // Use for collision data
  string condition = "";  // Use for collision data
  string blackList = "";
  // -------------------

  HDQMInspectorConfigTracking trackingConfig;
  // Select quantities you want the integral of
  vector<string> ItemsForIntegration;
  ItemsForIntegration.push_back("Chi2oNDF_GenTk_entries");
  ItemsForIntegration.push_back("NumberOfTracks_GenTk_entries");
  trackingConfig.computeIntegralList(ItemsForIntegration);
  // Create the functor
  DQMHistoryCreateTrend makeTrend(&trackingConfig);

  // Database and output configuration
  makeTrend.setDB(dbName,tagName,"/afs/cern.ch/cms/DB/conddb");
  // makeTrend.setDB(dbName,tagName,"cms_dqm_31x_offline", Password,"");
  makeTrend.setDebug(1);
  makeTrend.setDoStat(1);
  makeTrend.setSkip99s(true);
  makeTrend.setBlackList(blackList);
  makeTrend.setWhiteListFromFile(whiteListFile);

  // Definition of trends
  typedef DQMHistoryTrendsConfig Trend;
  vector<Trend> config;



  std::string trendsFileName(selectedTrends);
  std::ifstream trendsFile;
  trendsFile.open(trendsFileName.c_str());
  if( !trendsFile ) {
    std::cout << "Error: trends configuration file: " << trendsFileName << " not found" << std::endl;
    exit(1);
  }

  //Creating condition string
  if ( CondList != "" ){
    std::ifstream condFile;
    condFile.open(CondList.c_str());
    if ( condFile ){
      //Read the file
      bool first = true;
      while (!condFile.eof()){
        std::string line;
        getline(condFile, line);
        if ( line != ""){
          if (!first)
            condition+= " && ";
          else 
            first = false;
          condition+= line;
        }
      }
      cout << condition << endl; 
    }
    else
      std::cout << "Warning: File " << CondList << " not found : conditions will not be used" << std::endl; 
  }

  
  
  std::string configLine;

  typedef std::map<std::string,plotData> trendsMap;
  //map for holding the super imposed plots
  std::map<std::string,plotData> superImposedtrendsMap;
  //vector for holding the normal plots
  std::vector<plotData> trendsVector;
  //iterator for Map
  typedef std::map<std::string,plotData>::iterator trendsMapIter;


  while( !trendsFile.eof() ) 
  {
    std::string line;
    getline(trendsFile, line);
    if( line != "" ) 
    {
      std::vector<std::string> strs;
      boost::split(strs, line, boost::is_any_of(" "));
        
                
     if( strs.size() == 8 ) 
     {
       //Tracker name                   
       std::string index=strs[4];       
       plotData plot(line);     
       if (index=="0")
         trendsVector.push_back(plot);
       else
       {
         pair<trendsMapIter, bool> insertResult = superImposedtrendsMap.insert(std::make_pair(index,plot));
         if(!insertResult.second) 
         {
           std::string newName=strs[0];
           superImposedtrendsMap[index].names += "," + newName;
         }
       }                
     }//if
     else 
     {
       std::cout << "Warning: trend configuration line: " << line << " is not formatted correctly. It will be skipped." << std::endl;
     }//else
        
    } //if
  } //while

  //creating super imposed plots
  for(map<std::string,plotData>::const_iterator it = superImposedtrendsMap.begin(); it != superImposedtrendsMap.end(); ++it)
  {
    plotData plot=it->second;
    if (plot.maxY<plot.minY)
    {
      plot.minY=0;              
      plot.maxY=100;
    }
    //pushing back the superimposed plots into the vector 
    config.push_back(Trend(plot.names, plot.names+".gif",plot.logY, condition, plot.names, plot.firstRun,plot.lastRun,0,plot.minY,plot.maxY));
  }  
  //creating normal plots 
  for (unsigned int i=0; i<trendsVector.size();i++)
  {
    plotData plot=trendsVector[i];
    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);
    config.push_back(Trend(plot.names, plot.names+".gif",plot.logY, condition, plot.names, plot.firstRun,plot.lastRun,0,plot.minY,plot.maxY));
  }    

  cout << "Test Web: Trends created. " << endl;
  // Creation of trend
  for_each(config.begin(), config.end(), makeTrend);
  cout << "Test Web: Trends maded" << endl;
  // Close the output file
  makeTrend.closeFile();
}