CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
scaleGains.cc
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <iostream>
3 #include <fstream>
4 #include <vector>
5 
8 
9 
10 int main (int argn, char* argv []) {
11  if (argn < 3) {
12  std::cerr << "Use: " << argv[0] << " <gains to scale (.txt)> <result (.txt)> <scale factor>" << std::endl;
13  return 1;
14  }
15  std::ifstream inStream (argv[1]);
16  std::ofstream outStream (argv[2]);
17  double scale = atof (argv[3]);
18  HcalGains gainsIn;
19  HcalDbASCIIIO::getObject (inStream, &gainsIn);
20  HcalGains gainsOut;
21  std::vector<DetId> channels = gainsIn.getAllChannels ();
22  for (unsigned i = 0; i < channels.size(); i++) {
23  DetId id = channels[i];
24  HcalGain item(id, gainsIn.getValues(id)->getValue(0) * scale, gainsIn.getValues(id)->getValue(1) * scale,
25  gainsIn.getValues(id)->getValue(2) * scale, gainsIn.getValues(id)->getValue(3) * scale);
26  gainsOut.addValues(item);
27  }
28  HcalDbASCIIIO::dumpObject (outStream, gainsOut);
29  return 0;
30 }
31 
int i
Definition: DBlmapReader.cc:9
bool addValues(const Item &myItem, bool h2mode_=false)
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:20
int main(int argc, char **argv)
std::vector< DetId > getAllChannels() const
Definition: DetId.h:20
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
const Item * getValues(DetId fId) const