10 #include "CondCore/IOVService/interface/IOV.h"
11 #include "CondTools/Hcal/interface/HcalDbTool.h"
12 #include "CondTools/Hcal/interface/HcalDbOnline.h"
17 typedef std::pair<IOVRun,IOVRun> IntervalOV;
19 std::vector <IntervalOV> allIOV (
const cond::IOV& fIOV) {
20 std::vector <IntervalOV>
result;
22 for (IOVCollection::const_iterator iovi = fIOV.iov.begin (); iovi != fIOV.iov.end (); iovi++) {
23 IOVRun iovMax = iovi->first;
24 result.push_back (std::make_pair (iovMin, iovMax));
31 return fParam.find (
':') != std::string::npos;
35 return fParam.find (
'@') != std::string::npos &&
36 fParam.find (
"cms_val_lb") == std::string::npos;
47 void parse (
int nArgs,
char* fArgs []);
50 std::vector<std::string>
arguments ()
const;
57 std::vector <std::string>
mArgs;
58 std::map <std::string, std::string>
mParsed;
59 std::map <std::string, std::string>
mComments;
64 std::cout <<
"Tool to manipulate by IOV of Hcal Calibrations" << std::endl;
65 std::cout <<
" feedback -> ratnikov@fnal.gov" << std::endl;
67 sprintf (buffer,
" %s <what> <options> <parameters>\n", args.
command ().c_str());
69 std::cout <<
" where <what> is: \n tag\n iov" << std::endl;
74 std::vector<std::string> allTags;
76 HcalDbTool poolDb (fDb, fVerbose);
77 allTags = poolDb.metadataAllTags ();
78 std::cout <<
"Tags available in CMS POOL DB instance: " << fDb << std::endl;
83 std::cout <<
"Tags available in HCAL master DB instance: " << fDb << std::endl;
85 for (
unsigned i = 0;
i < allTags.size();
i++) {
91 std::vector <IntervalOV> allIOVs;
93 HcalDbTool poolDb (fDb, fVerbose);
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;
100 std::cerr <<
"printRuns-> can not find IOV for tag " << fTag << std::endl;
105 allIOVs = onlineDb.
getIOVs (fTag);
107 for (
unsigned i = 0;
i < allIOVs.size();
i++) {
108 std::cout <<
"[ " << allIOVs[
i].first <<
" ... " << allIOVs[
i].second <<
" )" << std::endl;
115 args.
defineParameter (
"-db",
"DB connection string, POOL format, or online format");
120 args.
parse (argn, argv);
122 std::vector<std::string> arguments = args.
arguments ();
124 if (arguments.size () < 1 || args.
optionIsSet (
"-help")) {
138 else if (what ==
"iov") {
141 std::cout <<
"Program has completed successfully" << std::endl;
158 if (nArgs <= 0)
return;
161 while (++iarg < nArgs) {
170 std::cerr <<
"ERROR: Parameter " <<
arg <<
" has no value specified. Ignore parameter." << std::endl;
186 sprintf (buffer,
" %-8s <value> : %s", (
mParameters [i]).c_str(), comment.c_str());
190 for (
unsigned i = 0; i <
mOptions.size (); i++) {
191 std::map<std::string, std::string>::const_iterator it =
mComments.find (
mOptions [i]);
193 sprintf (buffer,
" %-8s : %s", (
mOptions [i]).c_str(), comment.c_str());
void defineOption(const std::string &fOption, const std::string &fComment="")
std::map< std::string, std::string > mComments
std::vector< std::string > arguments() const
std::vector< std::string > mOptions
std::map< IOVRun, std::string > IOVCollection
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::string > mParameters
std::vector< IntervalOV > getIOVs(const std::string &fTag)
std::vector< std::string > mArgs
void printOptionsHelp() const
void parse(int nArgs, char *fArgs[])
Gather conditions data from online DB.
bool dbFile(const std::string fParam)
std::vector< std::string > metadataAllTags()
void printHelp(const Args &args)
std::string command() const
HcalDbTool::IOVRun IOVRun
std::map< std::string, std::string > mParsed
void defineParameter(const std::string &fParameter, const std::string &fComment="")
bool onlineFile(const std::string fParam)
bool optionIsSet(const std::string &fOption) const
std::string getParameter(const std::string &fKey)