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 
9 
10 
11 int main (int argn, char* argv []) {
12  if (argn < 3) {
13  std::cerr << "Use: " << argv[0] << " <gains to scale (.txt)> <result (.txt)> <scale factor>" << std::endl;
14  return 1;
15  }
17 
18  std::ifstream inStream (argv[1]);
19  std::ofstream outStream (argv[2]);
20  double scale = atof (argv[3]);
21  HcalGains gainsIn(&topo);;
22  HcalDbASCIIIO::getObject (inStream, &gainsIn);
23  HcalGains gainsOut(&topo);;
24  std::vector<DetId> channels = gainsIn.getAllChannels ();
25  for (unsigned i = 0; i < channels.size(); i++) {
26  DetId id = channels[i];
27  HcalGain item(id, gainsIn.getValues(id)->getValue(0) * scale, gainsIn.getValues(id)->getValue(1) * scale,
28  gainsIn.getValues(id)->getValue(2) * scale, gainsIn.getValues(id)->getValue(3) * scale);
29  gainsOut.addValues(item);
30  }
31  HcalDbASCIIIO::dumpObject (outStream, gainsOut);
32  return 0;
33 }
34 
int i
Definition: DBlmapReader.cc:9
const Item * getValues(DetId fId, bool throwOnFail=true) const
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:22
int main(int argc, char **argv)
std::vector< DetId > getAllChannels() const
Definition: DetId.h:18
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
bool addValues(const Item &myItem)