CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
HcalPedestalValidator.cc File Reference
#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"
#include "Geometry/CaloTopology/interface/HcalTopology.h"

Go to the source code of this file.

Classes

class  Args
 

Functions

int main (int argn, char *argv[])
 

Function Documentation

int main ( int  argn,
char *  argv[] 
)

Definition at line 93 of file HcalPedestalValidator.cc.

References harvestRelVal::args, Args::arguments(), dtNoiseDBValidation_cfg::cerr, Args::defineOption(), Args::defineParameter(), getObject(), Args::getParameter(), HcalPedestalAnalysis::HcalPedVal(), HcalTopologyMode::LHC, Args::optionIsSet(), Args::parse(), Args::printOptionsHelp(), and AlCaHLTBitMon_QueryRunRegistry::string.

93  {
94 
95 // CORAL required variables to be set, even if not needed
96  const char* foo1 = "CORAL_AUTH_USER=blaaah";
97  const char* foo2 = "CORAL_AUTH_PASSWORD=blaaah";
98  if (!::getenv("CORAL_AUTH_USER")) ::putenv(const_cast<char*>(foo1));
99  if (!::getenv("CORAL_AUTH_PASSWORD")) ::putenv(const_cast<char*>(foo2));
100 
101  Args args;
102  args.defineParameter ("-p", "raw pedestals");
103  args.defineParameter ("-w", "raw widths");
104  args.defineParameter ("-run", "current run number <0>");
105  args.defineParameter ("-ptag", "raw pedestal tag <NULL>");
106  args.defineParameter ("-wtag", "raw width tag <ptag>");
107  args.defineParameter ("-pref", "reference pedestals");
108  args.defineParameter ("-wref", "reference widths");
109  args.defineParameter ("-ptagref", "reference pedestal tag <NULL>");
110  args.defineParameter ("-wtagref", "reference width tag <ptagref>");
111  args.defineParameter ("-pval", "validated pedestals");
112  args.defineParameter ("-wval", "validated widths");
113  args.defineOption ("-help", "this help");
114 
115  args.parse (argn, argv);
116  std::vector<std::string> arguments = args.arguments ();
117  if (args.optionIsSet ("-help")) {
118  args.printOptionsHelp ();
119  return -1;
120  }
121 
122 // read parameters from command line
123  std::string RawPedSource = args.getParameter("-p");
124  std::string RawPedWidSource = args.getParameter("-w");
125  std::string RawPedTag = args.getParameter("-ptag").empty() ? "" : args.getParameter("-ptag");
126  std::string RawPedWidTag = args.getParameter("-wtag").empty() ? RawPedTag : args.getParameter("-wtag");
127  int RawPedRun = args.getParameter("-run").empty() ? 0 : (int)strtoll (args.getParameter("-run").c_str(),0,0);
128  int RawPedWidRun = RawPedRun;
129  std::string RefPedSource = args.getParameter("-pref");
130  std::string RefPedWidSource = args.getParameter("-wref");
131  std::string RefPedTag = args.getParameter("-ptagref").empty() ? "" : args.getParameter("-ptagref");
132  std::string RefPedWidTag = args.getParameter("-wtagref").empty() ? RefPedTag : args.getParameter("-wtagref");
133  int RefPedRun = RawPedRun;
134  int RefPedWidRun = RefPedRun;
135  std::string outputPedDest = args.getParameter("-pval");
136  std::string outputPedWidDest = args.getParameter("-wval");
137  std::string outputPedTag = "";
138  std::string outputPedWidTag = "";
139  int outputPedRun = RawPedRun;
140  int outputPedWidRun = outputPedRun;
141 
142  // need to know how to make proper topology in the future.
144 
145 // get reference objects
146  HcalPedestals* RefPeds = 0;
147  RefPeds = new HcalPedestals (&topo);
148  if (!getObject (RefPeds, RefPedSource, RefPedTag, RefPedRun)) {
149  std::cerr << "HcalPedestalValidator-> Failed to get reference Pedestals" << std::endl;
150  return 1;
151  }
152  HcalPedestalWidths* RefPedWids = 0;
153  RefPedWids = new HcalPedestalWidths (&topo);
154  if (!getObject (RefPedWids, RefPedWidSource, RefPedWidTag, RefPedWidRun)) {
155  std::cerr << "HcalPedestalValidator-> Failed to get reference PedestalWidths" << std::endl;
156  return 2;
157  }
158 
159 // get input raw objects
160  HcalPedestals* RawPeds = 0;
161  RawPeds = new HcalPedestals (&topo);
162  if (!getObject (RawPeds, RawPedSource, RawPedTag, RawPedRun)) {
163  std::cerr << "HcalPedestalValidator-> Failed to get raw Pedestals" << std::endl;
164  return 3;
165  }
166  HcalPedestalWidths* RawPedWids = 0;
167  RawPedWids = new HcalPedestalWidths (&topo);
168  if (!getObject (RawPedWids, RawPedWidSource, RawPedWidTag, RawPedWidRun)) {
169  std::cerr << "HcalPedestalValidator-> Failed to get raw PedestalWidths" << std::endl;
170  return 4;
171  }
172 
173 // make output objects
174  HcalPedestals* outputPeds = 0;
175  outputPeds = new HcalPedestals (&topo);
176  HcalPedestalWidths* outputPedWids = 0;
177  outputPedWids = new HcalPedestalWidths (&topo);
178 
179 // run algorithm
180  int nstat[4]={2500,2500,2500,2500};
181  int Flag=HcalPedestalAnalysis::HcalPedVal(nstat,RefPeds,RefPedWids,RawPeds,RawPedWids,outputPeds,outputPedWids);
182 
183  delete RefPeds;
184  delete RefPedWids;
185  delete RawPeds;
186  delete RawPedWids;
187 
188 
189 // store new objects if necessary
190  if (Flag%100000>0) {
191  if (outputPeds) {
192  if (!putObject (&outputPeds, outputPedDest, outputPedTag, outputPedRun)) {
193  std::cerr << "HcalPedestalAnalyzer-> Failed to put output Pedestals" << std::endl;
194  return 5;
195  }
196  }
197  if (outputPedWids) {
198  if (!putObject (&outputPedWids, outputPedWidDest, outputPedWidTag, outputPedWidRun)) {
199  std::cerr << "HcalPedestalAnalyzer-> Failed to put output PedestalWidths" << std::endl;
200  return 6;
201  }
202  }
203  }
204  delete outputPeds;
205  delete outputPedWids;
206 
207 return 0;
208 }
void defineOption(const std::string &fOption, const std::string &fComment="")
TObject * getObject(TDirectory *fDir, const std::vector< std::string > &fObjectName)
Definition: compareHists.cc:44
std::vector< std::string > arguments() const
void printOptionsHelp() const
void parse(int nArgs, char *fArgs[])
dictionary args
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)