File indexing completed on 2024-04-06 12:03:10
0001
0002
0003
0004 #include <stdlib.h>
0005 #include <vector>
0006 #include <map>
0007 #include <string>
0008 #include <sstream>
0009 #include <fstream>
0010
0011 #include "CondCore/IOVService/interface/IOV.h"
0012 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0013 #include "CondFormats/HcalObjects/interface/HcalPedestals.h"
0014 #include "CondFormats/HcalObjects/interface/HcalPedestalWidths.h"
0015 #include "CondTools/Hcal/interface/HcalDbTool.h"
0016 #include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
0017
0018 typedef HcalDbTool::IOVRun IOVRun;
0019 typedef std::map<IOVRun,std::string> IOVCollection;
0020
0021 int main () {
0022 std::string tag_pedestals = "HCAL_PEDESTALS_TB06_V2";
0023 std::string tag_pedestalws = "HCAL_PEDESTAL_WIDTHS_TB06_V2";
0024 std::string dbcon = "oracle://cmsr/CMS_ECALHCAL_H2_COND";
0025 ::setenv ("POOL_CATALOG", "relationalcatalog_oracle://cmsr/CMS_ECALHCAL_H2_COND", 1);
0026
0027 HcalDbTool db (dbcon);
0028
0029 cond::IOV iov;
0030 if (db.getObject (&iov, tag_pedestals)) {
0031 for (IOVCollection::const_iterator iovi = iov.iov.begin (); iovi != iov.iov.end (); iovi++) {
0032 IOVRun iovMax = iovi->first;
0033 std::cout << "Extracting pedestals for run " << iovMax << "..." << std::endl;
0034 HcalPedestals peds;
0035 if (db.getObject (&peds, tag_pedestals, iovMax)) {
0036 std::ostringstream filename;
0037 filename << tag_pedestals << "_" << iovMax << ".txt";
0038 std::ofstream outStream (filename.str().c_str());
0039 HcalDbASCIIIO::dumpObject (outStream, peds);
0040 }
0041 else {
0042 std::cerr << "printRuns-> can not find pedestals for tag " << tag_pedestals << " run " << iovMax << std::endl;
0043 }
0044 HcalPedestalWidths pedws;
0045 if (db.getObject (&pedws, tag_pedestalws, iovMax)) {
0046 std::ostringstream filename;
0047 filename << tag_pedestalws << "_" << iovMax << ".txt";
0048 std::ofstream outStream (filename.str().c_str());
0049 HcalDbASCIIIO::dumpObject (outStream, pedws);
0050 }
0051 else {
0052 std::cerr << "printRuns-> can not find pedestals for tag " << tag_pedestals << " run " << iovMax << std::endl;
0053 }
0054 }
0055 }
0056 else {
0057 std::cerr << "printRuns-> can not find IOV for tag " << tag_pedestals << std::endl;
0058 }
0059 return 0;
0060 }