10 #include "DataFormats/Common/interface/Timestamp.h"
11 #include "CondCore/IOVService/interface/IOV.h"
12 #include "CondTools/Hcal/interface/HcalDbTool.h"
25 typedef HcalDbTool::IOVRun IOVRun;
26 typedef std::map<IOVRun,std::string> IOVCollection;
27 typedef std::pair<IOVRun,IOVRun> IntervalOV;
35 void parse (
int nArgs,
char* fArgs []);
38 std::vector<std::string>
arguments ()
const;
45 std::vector <std::string>
mArgs;
46 std::map <std::string, std::string>
mParsed;
47 std::map <std::string, std::string>
mComments;
52 std::cout <<
"Initialize POOL DB with dummy HCAL data" << std::endl;
53 std::cout <<
" feedback -> ratnikov@fnal.gov" << std::endl;
55 sprintf (buffer,
" %s <parameters>\n", args.command ().c_str());
57 args.printOptionsHelp ();
61 HcalDbTool
db (inputdb, verbose);
62 if (inputdb.find (
"sqlite") != std::string::npos) {
63 unsigned pos = inputdb.find (
':');
64 if (pos != std::string::npos) {
72 std::cout <<
"initDb-> initializing metadata" << std::endl;
73 db.metadataSetTag (
"dummy_tag",
"dummy_token");
75 std::cout <<
"initDb-> initializing pedestals" << std::endl;
77 db.putObject (peds,
"dummy_pedestals", 1);
78 std::cout <<
"initDb-> initializing pedestal widths" << std::endl;
80 db.putObject (pedws,
"dummy_pedestalwidths", 1);
81 std::cout <<
"initDb-> initializing gains" << std::endl;
83 db.putObject (gains,
"dummy_gains", 1);
84 std::cout <<
"initDb-> initializing gain widths" << std::endl;
86 db.putObject (gainws,
"dummy_gainwidths", 1);
87 std::cout <<
"initDb-> initializing qie" << std::endl;
89 db.putObject (qie,
"dummy_qie", 1);
90 std::cout <<
"initDb-> initializing electronics map" << std::endl;
92 db.putObject (map,
"dummy_map", 1);
93 std::cout <<
"initDb-> initializing channel quality" << std::endl;
95 db.putObject (quality,
"dummy_quality", 1);
103 args.defineParameter (
"-db",
"DB connection string, POOL format, i.e. oracle://devdb10/CMS_COND_HCAL");
104 args.defineOption (
"-help",
"this help");
105 args.defineOption (
"-verbose",
"verbose");
107 args.parse (argn, argv);
109 std::vector<std::string>
arguments = args.arguments ();
111 if (args.getParameter (
"-db").empty() || args.optionIsSet (
"-help")) {
117 bool verbose = args.optionIsSet (
"-verbose");
119 initDb (inputdb, verbose);
126 mOptions.push_back (fOption);
127 mComments [fOption] = fComment;
131 mParameters.push_back (fParameter);
132 mComments [fParameter] = fComment;
136 if (nArgs <= 0)
return;
139 while (++iarg < nArgs) {
141 if (arg [0] !=
'-') mArgs.push_back (arg);
143 if (
std::find (mOptions.begin(), mOptions.end (),
arg) != mOptions.end ()) {
146 if (
std::find (mParameters.begin(), mParameters.end (),
arg) != mParameters.end ()) {
148 std::cerr <<
"ERROR: Parameter " << arg <<
" has no value specified. Ignore parameter." << std::endl;
161 for (
unsigned i = 0;
i < mParameters.size ();
i++) {
162 std::map<std::string, std::string>::const_iterator it = mComments.find (mParameters [
i]);
163 std::string comment = it != mComments.end () ? it->second :
"uncommented";
164 sprintf (buffer,
" %-8s <value> : %s", (mParameters [i]).c_str(), comment.c_str());
168 for (
unsigned i = 0;
i < mOptions.size ();
i++) {
169 std::map<std::string, std::string>::const_iterator it = mComments.find (mOptions [
i]);
170 std::string comment = it != mComments.end () ? it->second :
"uncommented";
171 sprintf (buffer,
" %-8s : %s", (mOptions [i]).c_str(), comment.c_str());
177 int ipos = mProgramName.rfind (
'/');
184 return mParsed.find (fOption) != mParsed.end ();
188 if (optionIsSet (fKey))
return mParsed [fKey];
vector< string > parse(string line, const string &delimiter)
void defineOption(const std::string &fOption, const std::string &fComment="")
std::map< std::string, std::string > mParsed
std::vector< std::string > mParameters
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::string > mArgs
std::vector< std::string > mOptions
void printOptionsHelp() const
void printHelp(const Args &args)
void defineParameter(const std::string &fParameter, const std::string &fComment="")
bool optionIsSet(const std::string &fOption) const
std::map< std::string, std::string > mComments
std::string getParameter(const std::string &fKey)