#include <stdlib.h>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include "CondFormats/HcalObjects/interface/HcalPedestals.h"
#include "CondFormats/HcalObjects/interface/HcalPedestalWidths.h"
#include "CondTools/Hcal/interface/HcalDbOnline.h"
#include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
#include "CalibCalorimetry/HcalAlgos/interface/HcalPedestalAnalysis.h"
Go to the source code of this file.
Classes | |
class | Args |
Functions | |
int | main (int argn, char *argv[]) |
int main | ( | int | argn, |
char * | argv[] | ||
) |
Definition at line 92 of file HcalPedestalValidator.cc.
References harvestRelVal::args, Args::arguments(), benchmark_cfg::cerr, Args::defineOption(), Args::defineParameter(), getObject(), Args::getParameter(), HcalPedestalAnalysis::HcalPedVal(), Args::optionIsSet(), Args::parse(), and Args::printOptionsHelp().
{ // CORAL required variables to be set, even if not needed const char* foo1 = "CORAL_AUTH_USER=blaaah"; const char* foo2 = "CORAL_AUTH_PASSWORD=blaaah"; if (!::getenv("CORAL_AUTH_USER")) ::putenv(const_cast<char*>(foo1)); if (!::getenv("CORAL_AUTH_PASSWORD")) ::putenv(const_cast<char*>(foo2)); Args args; args.defineParameter ("-p", "raw pedestals"); args.defineParameter ("-w", "raw widths"); args.defineParameter ("-run", "current run number <0>"); args.defineParameter ("-ptag", "raw pedestal tag <NULL>"); args.defineParameter ("-wtag", "raw width tag <ptag>"); args.defineParameter ("-pref", "reference pedestals"); args.defineParameter ("-wref", "reference widths"); args.defineParameter ("-ptagref", "reference pedestal tag <NULL>"); args.defineParameter ("-wtagref", "reference width tag <ptagref>"); args.defineParameter ("-pval", "validated pedestals"); args.defineParameter ("-wval", "validated widths"); args.defineOption ("-help", "this help"); args.parse (argn, argv); std::vector<std::string> arguments = args.arguments (); if (args.optionIsSet ("-help")) { args.printOptionsHelp (); return -1; } // read parameters from command line std::string RawPedSource = args.getParameter("-p"); std::string RawPedWidSource = args.getParameter("-w"); std::string RawPedTag = args.getParameter("-ptag").empty() ? "" : args.getParameter("-ptag"); std::string RawPedWidTag = args.getParameter("-wtag").empty() ? RawPedTag : args.getParameter("-wtag"); int RawPedRun = args.getParameter("-run").empty() ? 0 : (int)strtoll (args.getParameter("-run").c_str(),0,0); int RawPedWidRun = RawPedRun; std::string RefPedSource = args.getParameter("-pref"); std::string RefPedWidSource = args.getParameter("-wref"); std::string RefPedTag = args.getParameter("-ptagref").empty() ? "" : args.getParameter("-ptagref"); std::string RefPedWidTag = args.getParameter("-wtagref").empty() ? RefPedTag : args.getParameter("-wtagref"); int RefPedRun = RawPedRun; int RefPedWidRun = RefPedRun; std::string outputPedDest = args.getParameter("-pval"); std::string outputPedWidDest = args.getParameter("-wval"); std::string outputPedTag = ""; std::string outputPedWidTag = ""; int outputPedRun = RawPedRun; int outputPedWidRun = outputPedRun; // get reference objects HcalPedestals* RefPeds = 0; RefPeds = new HcalPedestals (); if (!getObject (RefPeds, RefPedSource, RefPedTag, RefPedRun)) { std::cerr << "HcalPedestalValidator-> Failed to get reference Pedestals" << std::endl; return 1; } HcalPedestalWidths* RefPedWids = 0; RefPedWids = new HcalPedestalWidths (); if (!getObject (RefPedWids, RefPedWidSource, RefPedWidTag, RefPedWidRun)) { std::cerr << "HcalPedestalValidator-> Failed to get reference PedestalWidths" << std::endl; return 2; } // get input raw objects HcalPedestals* RawPeds = 0; RawPeds = new HcalPedestals (); if (!getObject (RawPeds, RawPedSource, RawPedTag, RawPedRun)) { std::cerr << "HcalPedestalValidator-> Failed to get raw Pedestals" << std::endl; return 3; } HcalPedestalWidths* RawPedWids = 0; RawPedWids = new HcalPedestalWidths (); if (!getObject (RawPedWids, RawPedWidSource, RawPedWidTag, RawPedWidRun)) { std::cerr << "HcalPedestalValidator-> Failed to get raw PedestalWidths" << std::endl; return 4; } // make output objects HcalPedestals* outputPeds = 0; outputPeds = new HcalPedestals (); HcalPedestalWidths* outputPedWids = 0; outputPedWids = new HcalPedestalWidths (); // run algorithm int nstat[4]={2500,2500,2500,2500}; int Flag=HcalPedestalAnalysis::HcalPedVal(nstat,RefPeds,RefPedWids,RawPeds,RawPedWids,outputPeds,outputPedWids); delete RefPeds; delete RefPedWids; delete RawPeds; delete RawPedWids; // store new objects if necessary if (Flag%100000>0) { if (outputPeds) { if (!putObject (&outputPeds, outputPedDest, outputPedTag, outputPedRun)) { std::cerr << "HcalPedestalAnalyzer-> Failed to put output Pedestals" << std::endl; return 5; } } if (outputPedWids) { if (!putObject (&outputPedWids, outputPedWidDest, outputPedWidTag, outputPedWidRun)) { std::cerr << "HcalPedestalAnalyzer-> Failed to put output PedestalWidths" << std::endl; return 6; } } } delete outputPeds; delete outputPedWids; return 0; }