17 return fParam ==
"defaults";
20 bool asciiFile (
const std::string fParam) {
21 return fParam.find (
':') == std::string::npos && std::string (fParam, fParam.length () - 4) ==
".txt";
24 bool xmlFile (
const std::string fParam) {
25 return fParam.find (
':') == std::string::npos && std::string (fParam, fParam.length () - 4) ==
".xml";
28 bool dbFile (
const std::string fParam) {
29 return fParam.find (
':') != std::string::npos;
32 bool masterDb (
const std::string fParam) {
33 return fParam.find (
'@') != std::string::npos;
37 bool getObject (
T* fObject,
const std::string& fDb,
const std::string& fTag,
int fRun) {
38 if (!fObject)
return false;
39 if (fDb.empty ())
return false;
41 std::ifstream stream (fDb.c_str ());
45 else if (masterDb (fDb)) {
46 std::cout <<
"HcalPedestalValidator-> Use input: MasterDB " << fDb << std::endl;
48 return masterDb.getObject (fObject, fTag, fRun);
56 bool putObject (
T** fObject,
const std::string& fDb,
const std::string& fTag,
int fRun) {
57 if (!fObject || !*fObject)
return false;
58 if (fDb.empty ())
return false;
60 std::ofstream stream (fDb.c_str ());
75 void defineOption (
const std::string& fOption,
const std::string& fComment =
"");
76 void defineParameter (
const std::string& fParameter,
const std::string& fComment =
"");
77 void parse (
int nArgs,
char* fArgs []);
80 std::vector<std::string>
arguments ()
const;
81 bool optionIsSet (
const std::string& fOption)
const;
87 std::vector <std::string>
mArgs;
88 std::map <std::string, std::string>
mParsed;
95 const char* foo1 =
"CORAL_AUTH_USER=blaaah";
96 const char* foo2 =
"CORAL_AUTH_PASSWORD=blaaah";
97 if (!::getenv(
"CORAL_AUTH_USER")) ::putenv(const_cast<char*>(foo1));
98 if (!::getenv(
"CORAL_AUTH_PASSWORD")) ::putenv(const_cast<char*>(foo2));
114 args.
parse (argn, argv);
115 std::vector<std::string> arguments = args.
arguments ();
127 int RawPedWidRun = RawPedRun;
129 std::string RefPedWidSource = args.
getParameter(
"-wref");
132 int RefPedRun = RawPedRun;
133 int RefPedWidRun = RefPedRun;
135 std::string outputPedWidDest = args.
getParameter(
"-wval");
136 std::string outputPedTag =
"";
137 std::string outputPedWidTag =
"";
138 int outputPedRun = RawPedRun;
139 int outputPedWidRun = outputPedRun;
144 if (!
getObject (RefPeds, RefPedSource, RefPedTag, RefPedRun)) {
145 std::cerr <<
"HcalPedestalValidator-> Failed to get reference Pedestals" << std::endl;
150 if (!
getObject (RefPedWids, RefPedWidSource, RefPedWidTag, RefPedWidRun)) {
151 std::cerr <<
"HcalPedestalValidator-> Failed to get reference PedestalWidths" << std::endl;
158 if (!
getObject (RawPeds, RawPedSource, RawPedTag, RawPedRun)) {
159 std::cerr <<
"HcalPedestalValidator-> Failed to get raw Pedestals" << std::endl;
164 if (!
getObject (RawPedWids, RawPedWidSource, RawPedWidTag, RawPedWidRun)) {
165 std::cerr <<
"HcalPedestalValidator-> Failed to get raw PedestalWidths" << std::endl;
176 int nstat[4]={2500,2500,2500,2500};
188 if (!putObject (&outputPeds, outputPedDest, outputPedTag, outputPedRun)) {
189 std::cerr <<
"HcalPedestalAnalyzer-> Failed to put output Pedestals" << std::endl;
194 if (!putObject (&outputPedWids, outputPedWidDest, outputPedWidTag, outputPedWidRun)) {
195 std::cerr <<
"HcalPedestalAnalyzer-> Failed to put output PedestalWidths" << std::endl;
201 delete outputPedWids;
217 if (nArgs <= 0)
return;
220 while (++iarg < nArgs) {
221 std::string
arg (fArgs [iarg]);
222 if (arg [0] !=
'-')
mArgs.push_back (arg);
229 std::cerr <<
"ERROR: Parameter " << arg <<
" has no value specified. Ignore parameter." << std::endl;
245 sprintf (buffer,
" %-8s <value> : %s", (
mParameters [i]).c_str(), comment.c_str());
250 std::map<std::string, std::string>::const_iterator it =
mComments.find (
mOptions [
i]);
252 sprintf (buffer,
" %-8s : %s", (
mOptions [i]).c_str(), comment.c_str());
void defineOption(const std::string &fOption, const std::string &fComment="")
TObject * getObject(TDirectory *fDir, const std::vector< std::string > &fObjectName)
std::map< std::string, std::string > mComments
bool defaultsFile(const std::string fParam)
std::vector< std::string > arguments() const
std::vector< std::string > mOptions
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
int main(int argc, char **argv)
std::vector< std::string > mParameters
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::string command() const
bool xmlFile(const std::string fParam)
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
bool asciiFile(const std::string fParam)
std::map< std::string, std::string > mParsed
static int HcalPedVal(int nstat[4], const HcalPedestals *fRefPedestals, const HcalPedestalWidths *fRefPedestalWidths, HcalPedestals *fRawPedestals, HcalPedestalWidths *fRawPedestalWidths, HcalPedestals *fValPedestals, HcalPedestalWidths *fValPedestalWidths)
void defineParameter(const std::string &fParameter, const std::string &fComment="")
bool optionIsSet(const std::string &fOption) const
std::string getParameter(const std::string &fKey)