CMS 3D CMS Logo

Classes | Functions

/data/refman/pasoursint/CMSSW_5_3_3/src/CondTools/Hcal/bin/hcalIovTool.cc File Reference

#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include "CondCore/IOVService/interface/IOV.h"
#include "CondTools/Hcal/interface/HcalDbTool.h"
#include "CondTools/Hcal/interface/HcalDbOnline.h"

Go to the source code of this file.

Classes

class  Args

Functions

int main (int argn, char *argv[])
void printHelp (const Args &args)
void printRuns (const std::string &fDb, const std::string fTag, bool fVerbose)
void printTags (const std::string &fDb, bool fVerbose)

Function Documentation

int main ( int  argn,
char *  argv[] 
)

Definition at line 112 of file hcalIovTool.cc.

References harvestRelVal::args, Args::arguments(), gather_cfg::cout, EcalCondDB::db, Args::defineOption(), Args::defineParameter(), Args::getParameter(), Args::optionIsSet(), Args::parse(), printHelp(), printRuns(), printTags(), and GlobalPosition_Frontier_DevDB_cff::tag.

                                   {

  Args args;
  args.defineParameter ("-db", "DB connection string, POOL format, or online format");
  args.defineParameter ("-tag", "tag specifyer");
  args.defineOption ("-help", "this help");
  args.defineOption ("-verbose", "this help");
  
  args.parse (argn, argv);
  
  std::vector<std::string> arguments = args.arguments ();

  if (arguments.size () < 1 || args.optionIsSet ("-help")) {
    printHelp (args);
    return -1;
  }

  std::string db = args.getParameter ("-db");
  std::string tag = args.getParameter ("-tag");
  bool verbose = args.optionIsSet ("-verbose");

  std::string what = arguments [0];

  if (what == "tag") {
    printTags (db, verbose);
  }
  else if (what == "iov") {
    printRuns (db, tag, verbose);
  }
  std::cout << "Program has completed successfully" << std::endl;
  return 0;
}
void printHelp ( const Args args)

Definition at line 62 of file hcalIovTool.cc.

References Args::command(), gather_cfg::cout, and Args::printOptionsHelp().

                                  {
  char buffer [1024];
  std::cout << "Tool to manipulate by IOV of Hcal Calibrations" << std::endl;
  std::cout << "    feedback -> ratnikov@fnal.gov" << std::endl;
  std::cout << "Use:" << std::endl;
  sprintf (buffer, " %s <what> <options> <parameters>\n", args.command ().c_str());
  std::cout << buffer;
  std::cout << "  where <what> is: \n    tag\n    iov" << std::endl;
  args.printOptionsHelp ();
}
void printRuns ( const std::string &  fDb,
const std::string  fTag,
bool  fVerbose 
)

Definition at line 90 of file hcalIovTool.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, dbFile(), HcalDbOnline::getIOVs(), i, o2o::iov, and onlineFile().

Referenced by main().

                                                                           {
  std::vector <IntervalOV> allIOVs;
  if (dbFile (fDb)) {
    HcalDbTool poolDb (fDb, fVerbose);
    cond::IOV iov;
    if (poolDb.getObject (&iov, fTag)) {
      allIOVs = allIOV (iov);
      std::cout << "IOVs available for tag " << fTag << " in CMS POOL DB instance: " << fDb << std::endl;
    }
    else {
      std::cerr << "printRuns-> can not find IOV for tag " << fTag << std::endl;
    }
  }
  if (onlineFile (fDb)) {
    HcalDbOnline onlineDb (fDb, fVerbose);
    allIOVs = onlineDb.getIOVs (fTag);
  }
  for (unsigned i = 0; i < allIOVs.size(); i++) {
    std::cout << "[ " << allIOVs[i].first << " ... " << allIOVs[i].second << " )" << std::endl;
  }
}
void printTags ( const std::string &  fDb,
bool  fVerbose 
)

Definition at line 73 of file hcalIovTool.cc.

References gather_cfg::cout, dbFile(), i, HcalDbOnline::metadataAllTags(), and onlineFile().

Referenced by main().

                                                     {
  std::vector<std::string> allTags;
  if (dbFile (fDb)) {
    HcalDbTool poolDb (fDb, fVerbose);
    allTags = poolDb.metadataAllTags ();
    std::cout << "Tags available in CMS POOL DB instance: " << fDb << std::endl;
  }
  if (onlineFile (fDb)) {
    HcalDbOnline onlineDb (fDb, fVerbose);
    allTags = onlineDb.metadataAllTags ();
    std::cout << "Tags available in HCAL master DB instance: " << fDb << std::endl;
  }
  for (unsigned i = 0; i < allTags.size(); i++) {
    std::cout << allTags[i] << std::endl;
  }
}