CMS 3D CMS Logo

scaleGains.cc

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 
00009 
00010 int main (int argn, char* argv []) {
00011   if (argn < 3) {
00012     std::cerr << "Use: " << argv[0] << " <gains to scale (.txt)> <result (.txt)> <scale factor>" << std::endl;
00013     return 1;
00014   }
00015   std::ifstream inStream (argv[1]);
00016   std::ofstream outStream (argv[2]);
00017   double scale = atof (argv[3]);
00018   HcalGains gainsIn;
00019   HcalDbASCIIIO::getObject (inStream, &gainsIn);
00020   HcalGains gainsOut;
00021   std::vector<DetId> channels = gainsIn.getAllChannels ();
00022   for (unsigned i = 0; i < channels.size(); i++) {
00023     DetId id = channels[i];
00024     HcalGain item(id, gainsIn.getValues(id)->getValue(0) * scale, gainsIn.getValues(id)->getValue(1) * scale, 
00025                   gainsIn.getValues(id)->getValue(2) * scale, gainsIn.getValues(id)->getValue(3) * scale);
00026     gainsOut.addValues(item);
00027   }
00028   HcalDbASCIIIO::dumpObject (outStream, gainsOut);
00029   return 0;
00030 }
00031 

Generated on Tue Jun 9 17:26:53 2009 for CMSSW by  doxygen 1.5.4