CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
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 createfilelist::args, Args::arguments(), gather_cfg::cout, EcalCondDB::db, Args::defineOption(), Args::defineParameter(), Args::getParameter(), Args::optionIsSet(), Args::parse(), printHelp(), printRuns(), printTags(), AlCaHLTBitMon_QueryRunRegistry::string, and GlobalPosition_Frontier_DevDB_cff::tag.

112  {
113 
114  Args args;
115  args.defineParameter ("-db", "DB connection string, POOL format, or online format");
116  args.defineParameter ("-tag", "tag specifyer");
117  args.defineOption ("-help", "this help");
118  args.defineOption ("-verbose", "this help");
119 
120  args.parse (argn, argv);
121 
122  std::vector<std::string> arguments = args.arguments ();
123 
124  if (arguments.size () < 1 || args.optionIsSet ("-help")) {
125  printHelp (args);
126  return -1;
127  }
128 
129  std::string db = args.getParameter ("-db");
130  std::string tag = args.getParameter ("-tag");
131  bool verbose = args.optionIsSet ("-verbose");
132 
133  std::string what = arguments [0];
134 
135  if (what == "tag") {
136  printTags (db, verbose);
137  }
138  else if (what == "iov") {
139  printRuns (db, tag, verbose);
140  }
141  std::cout << "Program has completed successfully" << std::endl;
142  return 0;
143 }
void defineOption(const std::string &fOption, const std::string &fComment="")
void printTags(const std::string &fDb, bool fVerbose)
Definition: hcalIovTool.cc:73
std::vector< std::string > arguments() const
tuple db
Definition: EcalCondDB.py:151
void printRuns(const std::string &fDb, const std::string fTag, bool fVerbose)
Definition: hcalIovTool.cc:90
void parse(int nArgs, char *fArgs[])
void printHelp(const Args &args)
tuple cout
Definition: gather_cfg.py:145
void defineParameter(const std::string &fParameter, const std::string &fComment="")
bool optionIsSet(const std::string &fOption) const
std::string getParameter(const std::string &fKey)
void printHelp ( const Args args)

Definition at line 62 of file hcalIovTool.cc.

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

62  {
63  char buffer [1024];
64  std::cout << "Tool to manipulate by IOV of Hcal Calibrations" << std::endl;
65  std::cout << " feedback -> ratnikov@fnal.gov" << std::endl;
66  std::cout << "Use:" << std::endl;
67  sprintf (buffer, " %s <what> <options> <parameters>\n", args.command ().c_str());
68  std::cout << buffer;
69  std::cout << " where <what> is: \n tag\n iov" << std::endl;
70  args.printOptionsHelp ();
71 }
void printOptionsHelp() const
std::string command() const
tuple cout
Definition: gather_cfg.py:145
void printRuns ( const std::string &  fDb,
const std::string  fTag,
bool  fVerbose 
)

Definition at line 90 of file hcalIovTool.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, gather_cfg::cout, HcalDbOnline::getIOVs(), i, and o2o::iov.

Referenced by main().

90  {
91  std::vector <IntervalOV> allIOVs;
92  if (dbFile (fDb)) {
93  HcalDbTool poolDb (fDb, fVerbose);
94  cond::IOV iov;
95  if (poolDb.getObject (&iov, fTag)) {
96  allIOVs = allIOV (iov);
97  std::cout << "IOVs available for tag " << fTag << " in CMS POOL DB instance: " << fDb << std::endl;
98  }
99  else {
100  std::cerr << "printRuns-> can not find IOV for tag " << fTag << std::endl;
101  }
102  }
103  if (onlineFile (fDb)) {
104  HcalDbOnline onlineDb (fDb, fVerbose);
105  allIOVs = onlineDb.getIOVs (fTag);
106  }
107  for (unsigned i = 0; i < allIOVs.size(); i++) {
108  std::cout << "[ " << allIOVs[i].first << " ... " << allIOVs[i].second << " )" << std::endl;
109  }
110 }
int i
Definition: DBlmapReader.cc:9
tuple iov
Definition: o2o.py:307
Gather conditions data from online DB.
Definition: HcalDbOnline.h:34
tuple cout
Definition: gather_cfg.py:145
void printTags ( const std::string &  fDb,
bool  fVerbose 
)

Definition at line 73 of file hcalIovTool.cc.

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

Referenced by main().

73  {
74  std::vector<std::string> allTags;
75  if (dbFile (fDb)) {
76  HcalDbTool poolDb (fDb, fVerbose);
77  allTags = poolDb.metadataAllTags ();
78  std::cout << "Tags available in CMS POOL DB instance: " << fDb << std::endl;
79  }
80  if (onlineFile (fDb)) {
81  HcalDbOnline onlineDb (fDb, fVerbose);
82  allTags = onlineDb.metadataAllTags ();
83  std::cout << "Tags available in HCAL master DB instance: " << fDb << std::endl;
84  }
85  for (unsigned i = 0; i < allTags.size(); i++) {
86  std::cout << allTags[i] << std::endl;
87  }
88 }
int i
Definition: DBlmapReader.cc:9
Gather conditions data from online DB.
Definition: HcalDbOnline.h:34
tuple cout
Definition: gather_cfg.py:145