Go to the documentation of this file.00001 #include <stdlib.h>
00002 #include <iostream>
00003 #include <fstream>
00004 #include <vector>
00005
00006 #include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
00007 #include "CondFormats/HcalObjects/interface/HcalGains.h"
00008 #include "CondFormats/HcalObjects/interface/HcalRespCorrs.h"
00009
00010
00011 int main (int argn, char* argv []) {
00012 if (argn < 3) {
00013 std::cerr << "Use: " << argv[0] << " <gains to scale (.txt)> <result (.txt)> <respcorr (.txt)>" << std::endl;
00014 return 1;
00015 }
00016 std::ifstream inStream (argv[1]);
00017 std::ofstream outStream (argv[2]);
00018 std::ifstream inCorr (argv[3]);
00019 HcalGains gainsIn;
00020 HcalDbASCIIIO::getObject (inStream, &gainsIn);
00021 HcalRespCorrs corrsIn;
00022 HcalDbASCIIIO::getObject (inCorr, &corrsIn);
00023
00024 HcalGains gainsOut;
00025 std::vector<DetId> channels = gainsIn.getAllChannels ();
00026 for (unsigned i = 0; i < channels.size(); i++) {
00027 DetId id = channels[i];
00028 float scale = 1.;
00029 if (corrsIn.exists(id)) scale = corrsIn.getValues(id)->getValue();
00030 HcalGain item(id, gainsIn.getValues(id)->getValue(0) * scale, gainsIn.getValues(id)->getValue(1) * scale,
00031 gainsIn.getValues(id)->getValue(2) * scale, gainsIn.getValues(id)->getValue(3) * scale);
00032 gainsOut.addValues(item);
00033 }
00034 HcalDbASCIIIO::dumpObject (outStream, gainsOut);
00035 return 0;
00036 }
00037